循环审批,很形象当没有得到某种要求时,就一直循环直到满足要求为此。
比如我设备故障要维修时,我们发出一个申请,维修完成我申请人确实,问题是否解决,如还有问题就循环能和维修人员,直到解决为止。
我们来看下工作流设计,同样三个TaskActivity都只用设置TaskCreating和TaskCompleted
我们先来定义三个状态bool
1 2 3 | bool whileStart = true; bool endPassed = true; bool ATOK = false; |
设置whileActivity1循环条件
设置ifElseBranchActivity1判断条件
IT主管审批代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | private void taskActivityIT_TaskCreating(object sender, EquipmentMaintenanceIT.TaskEventArgs e) { e.TaskProperties.AssignedTo = @"i:0#.w|canomo\IT"; e.TaskProperties.Title = "IT设备维修申请"; e.TaskProperties.DueDate = DateTime.Now.AddDays(7.0); e.TaskProperties.ExtendedProperties.Add("状态", "待签批"); } private void taskActivityIT_TaskCompleted(object sender, EquipmentMaintenanceIT.TaskEventArgs e) { bool ITApproval = Convert.ToBoolean(e.TaskProperties.ExtendedProperties["ITApproval"]); if (ITApproval) { //同意... } else { whileStart = false; } } |
处理人员代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | private void taskActivityAT_TaskCreating(object sender, EquipmentMaintenanceIT.TaskEventArgs e) { e.TaskProperties.AssignedTo = @"i:0#.w|canomo\AT"; e.TaskProperties.Title = "处理人员前去处理"; e.TaskProperties.DueDate = DateTime.Now.AddDays(7.0); e.TaskProperties.ExtendedProperties.Add("状态", "待签批"); } private void taskActivityAT_TaskCompleted(object sender, EquipmentMaintenanceIT.TaskEventArgs e) { bool ATApproval = Convert.ToBoolean(e.TaskProperties.ExtendedProperties["ATApproval"]); if (ATApproval) { endPassed = false; whileStart = true; } else { endPassed = true; whileStart = true; } } |
申请人代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | private void taskActivityAR_TaskCreating(object sender, EquipmentMaintenanceIT.TaskEventArgs e) { e.TaskProperties.AssignedTo = this.workflowProperties.Originator; e.TaskProperties.Title = "申请人确认"; e.TaskProperties.DueDate = DateTime.Now.AddDays(7.0); e.TaskProperties.ExtendedProperties.Add("状态", "待签批"); } private void taskActivityAR_TaskCompleted(object sender, EquipmentMaintenanceIT.TaskEventArgs e) { bool ARApproval = Convert.ToBoolean(e.TaskProperties.ExtendedProperties["ARApproval"]); if (!ARApproval) { ATOK = false; endPassed = true; whileStart = true; } else { whileStart = false; } } |