public void StartBranchProcessExecutorTest() { IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithBranchTemplate(); IWfActivityDescriptor normalActivityDesp = processDesp.Activities["NormalActivity"]; //不自动启动分支流程 normalActivityDesp.Properties.SetValue("AutoStartBranchProcesses", false); IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp); //前进一步,但是没有启动流程 MoveToExecutor(process); process = WfRuntime.GetProcessByProcessID(process.ID); IWfActivity normalActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity"); Assert.AreEqual(0, normalActivity.BranchProcessGroups.Count); WfProcessCollection processes = new WfProcessCollection(); for (int i = 0; i < normalActivity.Descriptor.BranchProcessTemplates.Count; i++) { process = WfRuntime.GetProcessByProcessID(process.ID); normalActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity"); WfStartBranchProcessExecutor executor = new WfStartBranchProcessExecutor(normalActivity, normalActivity, normalActivity.Descriptor.BranchProcessTemplates[i]); executor.Execute(); processes.CopyFrom(executor.StartedProcesses); } process = WfRuntime.GetProcessByProcessID(process.ID); normalActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity"); Console.WriteLine(processes.Count); Assert.AreEqual(2, normalActivity.BranchProcessGroups.Count); //Assert.AreEqual(1, normalActivity.BranchProcessGroups[0].BranchProcessStatistics.Total); //Assert.AreEqual(0, normalActivity.BranchProcessGroups[0].BranchProcessStatistics.Completed); //Assert.AreEqual(0, normalActivity.BranchProcessGroups[0].BranchProcessStatistics.Aborted); Assert.IsTrue(normalActivity.BranchProcessGroups[0].IsBlocking()); //Assert.AreEqual(1, normalActivity.BranchProcessGroups[1].BranchProcessStatistics.Total); //Assert.AreEqual(0, normalActivity.BranchProcessGroups[1].BranchProcessStatistics.Completed); //Assert.AreEqual(0, normalActivity.BranchProcessGroups[1].BranchProcessStatistics.Aborted); Assert.IsTrue(normalActivity.BranchProcessGroups[1].IsBlocking()); Assert.AreEqual(1, normalActivity.BranchProcessGroups[0].Branches.Count); Assert.AreEqual(1, normalActivity.BranchProcessGroups[1].Branches.Count); }
public string[] StartBranchProcesses(string ownerActivityID, WfBranchProcessTransferParams branchTransferParams) { ownerActivityID.CheckStringIsNullOrEmpty("ownerActivityID"); branchTransferParams.NullCheck("branchTransferParams"); IWfProcess process = WfRuntime.GetProcessByActivityID(ownerActivityID); IWfActivity ownerActivity = process.Activities[ownerActivityID]; WfStartBranchProcessExecutor executor = new WfStartBranchProcessExecutor(ownerActivity, ownerActivity, branchTransferParams); executor.Execute(); List <string> startedProcessIDs = new List <string>(); executor.StartedProcesses.ForEach(p => startedProcessIDs.Add(p.ID)); return(startedProcessIDs.ToArray()); }
public void StartBranchProcessAndUnlockExecutorTest() { IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithBranchTemplate(); IWfActivityDescriptor normalActivityDesp = processDesp.Activities["NormalActivity"]; //不自动启动分支流程 normalActivityDesp.Properties.SetValue("AutoStartBranchProcesses", false); IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp); //前进一步,但是没有启动流程 MoveToExecutor(process); process = WfRuntime.GetProcessByProcessID(process.ID); IWfActivity normalActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity"); Assert.AreEqual(0, normalActivity.BranchProcessGroups.Count); process = WfRuntime.GetProcessByProcessID(process.ID); normalActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity"); WfStartBranchProcessExecutor executor = new WfStartBranchProcessExecutor(normalActivity, normalActivity, normalActivity.Descriptor.BranchProcessTemplates[0]); //启动一组分支流程 executor.Execute(); //流转每一条子流程(办结) foreach (IWfProcess subProcess in executor.StartedProcesses) { IWfProcess subProcessInstance = WfRuntime.GetProcessByProcessID(subProcess.ID); MoveToExecutor(subProcessInstance); } process = WfRuntime.GetProcessByProcessID(process.ID); Console.WriteLine(process.CurrentActivity.Descriptor.Key); Assert.IsFalse(process.CurrentActivity.BranchProcessGroups[0].IsBlocking()); }