Exemple #1
0
        private static IWfProcess GetProcessInstanceWithAssigneesResource()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;
            WfTransferParams      tp = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.approver2);

            process.MoveTo(tp);

            WfRuntime.PersistWorkflows();
            process = WfRuntime.GetProcessByProcessID(process.ID);

            IWfActivityDescriptor actDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;
            WfActivityAssigneesResourceDescriptor actAssResDesp = new WfActivityAssigneesResourceDescriptor();

            actAssResDesp.ActivityKey = actDesp.Key;
            actDesp.Resources.Add(actAssResDesp);

            nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;
            WfTransferParams tpa = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.approver1);

            process.MoveTo(tpa);

            WfRuntime.PersistWorkflows();
            process = WfRuntime.GetProcessByProcessID(process.ID);
            return(process);
        }
        public void CancelProcessInOtherActivityTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            WfRuntime.PersistWorkflows();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;

            WfTransferParams tp = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.requestor);

            process.MoveTo(tp);

            WfRuntime.PersistWorkflows();

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

            Console.WriteLine("Current Activity ID: {0}", process.CurrentActivity.ID);
            Console.WriteLine("User Task Count: {0}", tasks.Count);

            process = CancelProcess(process, false);

            UserTaskCollection userAccomlishedTasks = UserTaskAdapter.Instance.GetUserAccomplishedTasks(UserTaskIDType.ActivityID, UserTaskFieldDefine.All, false, process.CurrentActivity.ID);

            Console.WriteLine("User Accomplished Task Count: {0}", userAccomlishedTasks.Count);

            Assert.AreEqual(tasks.Count, userAccomlishedTasks.Count);
        }
Exemple #3
0
        public void ActivityOperatorResourceTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;
            WfTransferParams      tp = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.approver1);
            IUser requestor          = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;

            tp.Operator = requestor;

            process.MoveTo(tp);

            WfActivityOperatorResourceDescriptor resource = new WfActivityOperatorResourceDescriptor();

            resource.ActivityKey = process.InitialActivity.Descriptor.Key;
            process.CurrentActivity.Descriptor.Resources.Add(resource);
            OguDataCollection <IUser> users = process.CurrentActivity.Descriptor.Resources.ToUsers();

            Assert.IsTrue(users.Count > 0);
            Assert.AreEqual(requestor.ID, users[0].ID, "验证资源中的人员是否是之前活动的操作人");

            WfRuntime.PersistWorkflows();
            process = WfRuntime.GetProcessByProcessID(process.ID);

            users = process.CurrentActivity.Descriptor.Resources.ToUsers();

            Assert.IsTrue(users.Count > 0, "重新加载后资源中应该有人");
            Assert.AreEqual(requestor.ID, users[0].ID, "重新加载后验证资源中的人员是否是之前活动的操作人");
        }
Exemple #4
0
        public void ActivityConditionTest()
        {
            TestContext.Properties["Amount"] = 2500;    //不满足条件
            WfRuntime.ProcessContext.EvaluateActivityCondition += new Expression.CalculateUserFunction(ProcessContext_EvaluateTransition);

            IWfProcess process = WfProcessTestCommon.StartupSimpleProcessDescriptorWithActivityCondition();

            Assert.AreEqual(WfActivityStatus.Running, process.InitialActivity.Status);

            IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;
            WfTransferParams      transferParams   = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.requestor);

            process.MoveTo(transferParams);

            Assert.AreEqual(WfActivityStatus.Completed, process.InitialActivity.Status);

            Assert.AreEqual(WfActivityStatus.Pending, process.CurrentActivity.Status);

            IWfActivity activity = WfRuntime.ProcessContext.OriginalActivity;

            WfRuntime.PersistWorkflows();

            TestContext.Properties["Amount"] = 7500;

            WfPendingActivityInfoCollection pendingActivities = WfPendingActivityInfoAdapter.Instance.Load(builder => builder.AppendItem("ACTIVITY_ID", process.CurrentActivity.ID));

            pendingActivities.ForEach(pai => WfRuntime.ProcessPendingActivity(pai));
        }
Exemple #5
0
        private static void MoveToExecutor(IWfProcess process)
        {
            IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;
            WfTransferParams      pa       = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.approver1);
            WfMoveToExecutor      moveExec = new WfMoveToExecutor(process.CurrentActivity, process.CurrentActivity, pa);

            moveExec.Execute();
        }
Exemple #6
0
        public static void MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject oguObject, IWfProcess process)
        {
            IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions.FindDefaultSelectTransition().ToActivity;
            WfTransferParams      transferParams   = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, oguObject);

            process.MoveTo(transferParams);
            WfRuntime.PersistWorkflows();
        }
        private static IWfProcess GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence sequence, WfBranchProcessBlockingType blockingType)
        {
            IWfProcess       process = WfProcessTestCommon.StartupProcessWithAssignee();
            WfTransferParams tp      = ProcessTestHelper.GetInstanceOfWfTransferParams(process, sequence, blockingType);

            process.MoveTo(tp);

            WfRuntime.PersistWorkflows();

            return(WfRuntime.GetProcessByProcessID(process.ID));
        }
        public void WithdrawAndReplayRunProcessActivityWithBranchProcess()
        {
            IWfProcess process = GetProcessInstance(false);

            string fromActivityId = process.CurrentActivity.ID;

            process.Withdraw(process.Activities[0], true);            //撤回
            WfRuntime.PersistWorkflows();

            CheckOperationAndStatusAfterWithdrawProcess(process.ID, fromActivityId, process.Activities[0].ID);

            process = WfRuntime.GetProcessByProcessID(process.ID);
            WfTransferParams pa = ProcessTestHelper.GetInstanceOfWfTransferParams(process, WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);

            process.MoveTo(pa);

            Assert.AreEqual(4, process.CurrentActivity.BranchProcessGroups[0].Branches.Count, "当前节点的分支流程应为撤回前与当前的,即4");
        }
Exemple #9
0
        public void BranchProcessStartTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupSimpleProcessWithAssignee();

            WfTransferParams tp = ProcessTestHelper.GetInstanceOfWfTransferParams(process, WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete);

            process.MoveTo(tp);

            Assert.AreEqual(1, process.CurrentActivity.BranchProcessGroups.Count);
            IWfBranchProcessGroup group = process.CurrentActivity.BranchProcessGroups[0];

            Assert.AreEqual(tp.BranchTransferParams[0].Template.BranchProcessKey, group.ProcessTemplate.BranchProcessKey);
            Assert.AreEqual(2, group.Branches.Count);
            Assert.AreEqual(tp.BranchTransferParams[0].Template.BranchProcessKey, group.Branches[0].Descriptor.Key);
            Assert.AreEqual(tp.BranchTransferParams[0].Template.BranchProcessKey, group.Branches[1].Descriptor.Key);
            Assert.AreEqual(WfProcessStatus.Running, group.Branches[0].Status);
            Assert.AreEqual(WfProcessStatus.Running, group.Branches[1].Status);

            Assert.AreEqual(OguObjectSettings.GetConfig().Objects["approver1"].Object.ID, group.Branches[0].InitialActivity.Assignees[0].User.ID);
            Assert.AreEqual(OguObjectSettings.GetConfig().Objects["approver2"].Object.ID, group.Branches[1].InitialActivity.Assignees[0].User.ID);
        }
        public void RestoreCanceledProcessTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            WfRuntime.PersistWorkflows();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;

            WfTransferParams tp = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.requestor);

            process.MoveTo(tp);

            WfRuntime.PersistWorkflows();

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

            Console.WriteLine("Current Activity ID: {0}", process.CurrentActivity.ID);
            Console.WriteLine("User Task Count: {0}", beforeCancelTasks.Count);

            process = CancelProcess(process, false);

            process.RestoreProcess();

            WfRuntime.PersistWorkflows();

            process = WfRuntime.GetProcessByProcessID(process.ID);

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

            Console.WriteLine("Restored User Task Count: {0}", afterRestoreTasks.Count);

            Assert.AreEqual(beforeCancelTasks.Count, afterRestoreTasks.Count);

            Assert.AreEqual(WfProcessStatus.Running, process.Status);
            Assert.AreEqual(WfActivityStatus.Running, process.CurrentActivity.Status);
        }
Exemple #11
0
        public void BranchProcessRunTimeTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupSimpleProcessWithAssignee();

            IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;
            WfTransferParams      tp = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.requestor);

            tp.BranchTransferParams.Add(new WfBranchProcessTransferParams(
                                            ProcessTestHelper.CreateConsignTemplate(WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete)));

            for (int i = 0; i < 20; i++)
            {
                IUser obj  = (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object;
                IUser obj2 = (IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object;

                tp.BranchTransferParams[0].BranchParams.Add(obj, obj2);
            }
            int branchProcessNum = tp.BranchTransferParams[0].BranchParams.Count;

            ProcessTestHelper.OutputExecutionTime(() => process.MoveTo(tp), "流转并启动子流程");
            ProcessTestHelper.OutputExecutionTime(() => WfRuntime.PersistWorkflows(), "保存流程状态");
            ProcessTestHelper.OutputExecutionTime(() => WfRuntime.GetProcessByProcessID(process.ID), "重新加载主流程");
        }
        public void RestoreCanceledPendingProcessTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee();

            process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity.Condition.Expression = "1 == 0";

            WfRuntime.PersistWorkflows();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity;

            WfTransferParams tp = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.requestor);

            process.MoveTo(tp);

            Assert.AreEqual(WfActivityStatus.Pending, process.CurrentActivity.Status);

            WfRuntime.PersistWorkflows();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            process.CancelProcess(true);

            WfRuntime.PersistWorkflows();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            process.RestoreProcess();

            WfRuntime.PersistWorkflows();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            Assert.AreEqual(WfProcessStatus.Running, process.Status);
            Assert.AreEqual(WfActivityStatus.Pending, process.CurrentActivity.Status);
        }