Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void MoveToWithBranchProcessesExecutorTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithBranchTemplate();

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            IWfActivityDescriptor normalActivity = processDesp.InitialActivity.ToTransitions[0].ToActivity;

            WfTransferParams transferParams0 = new WfTransferParams(normalActivity);

            //初始化后,流转到有分支流程的活动
            process.MoveTo(transferParams0);

            Assert.AreEqual(normalActivity.BranchProcessTemplates.Count, process.CurrentActivity.BranchProcessGroups.Count);
        }
Ejemplo n.º 3
0
        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());
        }