Beispiel #1
0
        public void ReplaceAssigneeExecutorTestReplay()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            IWfActivityDescriptor normalActDesp = processDesp.Activities["NormalActivity"];

            IUser originalApprover = (IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver1.ToString()].Object;

            normalActDesp.Resources.Clear();
            normalActDesp.Resources.Add(new WfUserResourceDescriptor(originalApprover));

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            WfProcessTestCommon.MoveToNextDefaultActivityWithExecutor(process);

            process = WfRuntime.GetProcessByProcessID(process.ID);

            IUser newApprover = (IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver2.ToString()].Object;

            WfReplaceAssigneesExecutor executor = new WfReplaceAssigneesExecutor(process.CurrentActivity, process.CurrentActivity, originalApprover, new IUser[] { newApprover });

            executor.Execute();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            UserTaskCollection tasks = UserTaskAdapter.Instance.LoadUserTasks(build => build.AppendItem("ACTIVITY_ID", process.CurrentActivity.ID));

            Assert.AreEqual(1, tasks.Count);
            Assert.AreEqual(newApprover.ID, tasks[0].SendToUserID);
        }
Beispiel #2
0
        public void MainStreamActivitiesWithAmountCondition()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithCondition();

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            process.ApplicationRuntimeParameters["Amount"] = 2500;

            WfMainStreamActivityDescriptorCollection mainActs = process.GetMainStreamActivities(true);

            mainActs.Output("不经过领导的主线活动");

            Assert.IsTrue(mainActs.ContainsKey("NormalActivity"));
            Assert.IsFalse(mainActs.ContainsKey("ManagerActivity"));

            //改变条件
            process.ApplicationRuntimeParameters["Amount"] = 10000;

            mainActs = process.GetMainStreamActivities(true);

            mainActs.Output("经过领导的主线活动");

            Assert.IsTrue(mainActs.ContainsKey("NormalActivity"));
            Assert.IsTrue(mainActs.ContainsKey("ManagerActivity"));
        }
Beispiel #3
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);
        }
Beispiel #4
0
        public void NormalActivityAutoMoveTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            processDesp.Activities["NormalActivity"].Properties.SetValue("AutoMoveTo", true);

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            IWfActivity currentActivity = process.MoveToNextDefaultActivity();

            Console.WriteLine(currentActivity.Descriptor.ActivityType);

            Assert.AreEqual(WfActivityType.CompletedActivity, currentActivity.Descriptor.ActivityType);
        }
Beispiel #5
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);
        }
Beispiel #6
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());
        }