我需要为审批流程建模。之前很简单。两个角色必须批准某件事,然后我们可以继续下一步:
public class Approved
{
public string ApproverRole;
}
var approvals = Subscribe<Approved>();
var vpOfFinance = approvals.Where(e => e.ApproverRole == "Finance VP");
var vpOfSales = approvals.Where(e => e.ApproverRole == "Sales VP");
var approvedByAll = vpOfFinance.Zip(vpOfSales, Tuple.Create);
approvedByAll.Subscribe(_ => SomeInterestingBusinessProcess());
但现在有一个新要求:批准某事所需的角色数量可能会有所不同:
public class ApprovalRequested
{
public string[] Roles;
}
var approvalRequest = Subscribe<ApprovalRequested>().Take(1);
var approvals = Subscribe<Approved>();
var approvedByAll = ???;
approvedByAll.Subscribe(_ => SomeInterestingBusinessProcess());
我觉得我在这里遗漏了一些非常明显的东西......谁能指出我正确的方向?
编辑
澄清一下:批准过程是基于每个项目的。批准到达的顺序是未定义的。我们不在乎一个角色是否多次批准一个项目。