public void CancelSerialSubProcessTest()
        {
            IWfProcess process = GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence.Serial, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);

            IWfProcess branchProcess = process.CurrentActivity.BranchProcessGroups[0].Branches[0];

            CheckOperationAndStatusBeforeCancelProcess(branchProcess);

            CancelProcess(branchProcess, false);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            //检查第二个流程是否启动
            branchProcess = process.CurrentActivity.BranchProcessGroups[0].Branches[1];
            Assert.AreEqual(WfProcessStatus.Running, branchProcess.Status);

            ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(process.CurrentActivity, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);

            WfRuntime.PersistWorkflows();

            ProcessTestHelper.ProcessPendingActivity(process.CurrentActivity.ID);

            process       = WfRuntime.GetProcessByProcessID(process.ID);
            branchProcess = process.CurrentActivity.BranchProcessGroups[0].Branches[1];
            Assert.AreEqual(WfProcessStatus.Completed, branchProcess.Status, "第二个子流程的状态");
        }
        public void CancelProcessAndBranchProcessCompleted()
        {
            IWfProcess process = GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete);

            ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(process.CurrentActivity, WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete);
            ProcessTestHelper.ProcessPendingActivity(process.CurrentActivity.ID);

            Assert.AreEqual(WfProcessStatus.Completed, process.CurrentActivity.BranchProcessGroups[0].Branches[0].Status);
            Assert.AreEqual(WfProcessStatus.Running, process.CurrentActivity.BranchProcessGroups[0].Branches[1].Status);

            CancelProcess(process, true);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            CheckOperationAndStatusAfterCancelProcess(process.Activities[1].BranchProcessGroups[0].Branches[0]);
            CheckOperationAndStatusAfterCancelProcess(process.Activities[1].BranchProcessGroups[0].Branches[1]);
        }
        public void WaitAnyoneCompleteOfSerialBranchProcessTest()
        {
            IWfProcess wfProcess = GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence.Serial, WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete);

            CheckProcessRelationOperationAndStatus(wfProcess, false);

            //
            ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(wfProcess.CurrentActivity, WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete);
            ProcessTestHelper.ProcessPendingActivity(wfProcess.CurrentActivity.ID);

            IWfProcess wfProc = WfRuntime.GetProcessByProcessID(wfProcess.ID);

            Assert.AreEqual(WfProcessStatus.Completed, wfProc.CurrentActivity.BranchProcessGroups[0].Branches[0].Status);
            Assert.AreEqual(WfProcessStatus.Running, wfProc.CurrentActivity.BranchProcessGroups[0].Branches[1].Status);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProcess.CurrentActivity.BranchProcessGroups[0].Branches[1].InitialActivity.ID, TaskStatus.Ban));
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProc.CurrentActivity.ID, TaskStatus.Ban));
        }
        public void WaitAllCompleteOfParallelBranchProcessTest()
        {
            IWfProcess wfProcess = GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);

            AssertProcessStatus(wfProcess);

            CheckProcessRelationOperationAndStatus(wfProcess, true);

            //
            ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(wfProcess.CurrentActivity, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);
            ProcessTestHelper.ProcessPendingActivity(wfProcess.CurrentActivity.ID);

            IWfProcess wfProc = WfRuntime.GetProcessByProcessID(wfProcess.ID);

            Assert.AreEqual(WfActivityStatus.Running, wfProc.CurrentActivity.Status);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProc.CurrentActivity.ID, TaskStatus.Ban));
            wfProc.CurrentActivity.BranchProcessGroups[0].Branches.Exists(p => p.Status == WfProcessStatus.Completed);
        }
Beispiel #5
0
        public void ConsignExecutorTest()
        {
            IUser  user           = (IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object;
            string procResourceID = GetStartWorkflowResourceID(user);
            string processID      = string.Empty;

            WfProcessCollection processes = WfRuntime.GetProcessByResourceID(procResourceID);

            processID = processes[0].ID;
            MoveToExecutor(processes[0]);
            Assert.AreEqual(1, processes[0].ElapsedActivities.Count);

            processes = WfRuntime.GetProcessByResourceID(procResourceID);
            List <IUser> users;

            ConsignExecutor(processes[0], out users);

            processes = WfRuntime.GetProcessByResourceID(procResourceID);
            Assert.AreEqual(3, processes.Count, "共3个流程,主流程与两个子流程");

            IWfProcess proc = WfRuntime.GetProcessByProcessID(processID);

            Assert.AreEqual(7, proc.Activities.Count);
            string k = proc.CurrentActivity.Descriptor.FromTransitions[0].FromActivity.Key;

            Assert.IsNotNull(proc.Activities.FindActivityByDescriptorKey(k).CreatorInstanceID, "添加会签点的活动确实没值");

            Assert.AreEqual(WfActivityStatus.Pending, proc.CurrentActivity.Status);            //NO
            Assert.AreEqual(users.Count, proc.CurrentActivity.BranchProcessGroups[0].Branches.Count);

            //使子流程完成
            proc = WfRuntime.GetProcessByProcessID(processID);
            ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(proc.CurrentActivity, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);
            WfRuntime.PersistWorkflows();
            ProcessTestHelper.ProcessPendingActivity(proc.CurrentActivity.ID);

            proc = WfRuntime.GetProcessByProcessID(processID);
            Assert.AreEqual(WfActivityStatus.Running, proc.CurrentActivity.Status, "此为添加的会签点");
            Assert.AreEqual(2, proc.CurrentActivity.BranchProcessGroups[0].Branches.Count, "存在两个子流程");
            Assert.AreEqual(2, proc.ElapsedActivities.Count);
            MoveToExecutor(proc);
            Assert.AreEqual(3, proc.ElapsedActivities.Count);
        }
        private static IWfProcess GetProcessInstance(bool movetoCompletedActivity)
        {
            IWfProcess process = GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete);

            process = WfRuntime.GetProcessByProcessID(process.ID);

            if (movetoCompletedActivity)
            {
                //使第二个节点可以正常流转
                ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(process.CurrentActivity, WfBranchProcessBlockingType.WaitAnyoneBranchProcessComplete);
                ProcessTestHelper.ProcessPendingActivity(process.CurrentActivity.ID);

                IWfProcess wfProc = WfRuntime.GetProcessByProcessID(process.ID);

                Assert.AreEqual(WfActivityStatus.Running, wfProc.Activities[1].Status);
                Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProc.CurrentActivity.ID, TaskStatus.Ban));
                Assert.AreEqual(WfProcessStatus.Completed, wfProc.CurrentActivity.BranchProcessGroups[0].Branches[0].Status);
                Assert.AreEqual(WfProcessStatus.Running, wfProc.CurrentActivity.BranchProcessGroups[0].Branches[1].Status);


                //初始节点已完成,从第二个节点开始
                for (int i = 2; i < process.Activities.Count; i++)
                {
                    if (process.Activities[i].Descriptor.ActivityType != WfActivityType.CompletedActivity)
                    {
                        process = WfRuntime.GetProcessByProcessID(process.ID);
                        WfTransferParams transferPara = new WfTransferParams(process.Activities[i].Descriptor);
                        transferPara.Assignees.Add((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object);

                        process.MoveTo(transferPara);
                        WfRuntime.PersistWorkflows();
                    }
                }
            }

            process = WfRuntime.GetProcessByProcessID(process.ID);
            return(process);
        }
Beispiel #7
0
        public void SingleStepWithDrawByDynamicAdd()
        {
            //Initial  NormalActivity  NormalActivity1 NormalActivity2 NormalActivity3 Completed
            IUser  user           = (IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object;
            string procResourceId = GetStartWorkflowResourceID(user);

            WfProcessCollection processes = WfRuntime.GetProcessByResourceID(procResourceId);
            string processId = processes[0].ID;

            MoveToExecutor(processes[0]);
            Assert.AreEqual(1, processes[0].ElapsedActivities.Count);            //initial

            processes = WfRuntime.GetProcessByResourceID(procResourceId);
            List <IUser> users;

            ConsignExecutor(processes[0], out users);

            IWfProcess proc = WfRuntime.GetProcessByProcessID(processId);

            Assert.AreEqual(2, proc.ElapsedActivities.Count);            //NormalActivity
            ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(proc.CurrentActivity, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);
            WfRuntime.PersistWorkflows();
            ProcessTestHelper.ProcessPendingActivity(proc.CurrentActivity.ID);

            proc = WfRuntime.GetProcessByProcessID(processId);
            WfWithdrawExecutor withdrawExec = new WfWithdrawExecutor(proc.CurrentActivity, proc.CurrentActivity);            //"NO"

            withdrawExec.Execute();

            proc = WfRuntime.GetProcessByProcessID(processId);
            Assert.AreEqual(1, proc.ElapsedActivities.Count);
            Assert.AreEqual(proc.Descriptor.GetMainStreamActivities().Count, proc.Activities.Count);
            Assert.AreEqual(proc.ElapsedActivities[0].Descriptor.ToTransitions[0].ToActivity.Key, proc.CurrentActivity.Descriptor.Key);
            Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(proc.CurrentActivity.ID, TaskStatus.Ban));
            Assert.IsTrue(proc.CurrentActivity.Descriptor.ToTransitions.Count == 1);
        }