public void ReturnTestWithBranchActivity() { IWfProcessDescriptor desp = WfProcessTestCommon.CreateProcessDescriptor(); desp.InitialActivity.Resources.Add(new WfUserResourceDescriptor((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object)); GetProcDespWithBranchActivities(desp.Activities[1], 2); WfProcessStartupParams startupParams = WfProcessTestCommon.GetInstanceOfWfProcessStartupParams(desp); IWfProcess process = WfRuntime.StartWorkflow(startupParams); ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver1, process); process = WfRuntime.GetProcessByProcessID(process.ID); ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver2, process); process = WfRuntime.GetProcessByProcessID(process.ID); Assert.AreEqual(2, process.ElapsedActivities.Count); WfRuntime.ProcessContext.ActivityChangingContext.CreatorInstanceID = process.CurrentActivity.ID; process.CurrentActivity.CopyMainStreamActivities(process.Activities[1], null, WfControlOperationType.Return); //退件 ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.requestor, process); process = WfRuntime.GetProcessByProcessID(process.ID); Assert.IsTrue(process.CurrentActivity.CreatorInstanceID.IsNotEmpty()); Assert.AreEqual(process.ElapsedActivities[2].ID, process.CurrentActivity.CreatorInstanceID); Assert.AreEqual(10, process.Activities.Count); }
public void MainStreamActivitiesWithConditionActivityPassed() { IWfProcessDescriptor desp = WfProcessTestCommon.CreateProcessDescriptor(); desp.InitialActivity.Resources.Add(new WfUserResourceDescriptor((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object)); IWfActivityDescriptor actDesp = desp.Activities[1]; AddActivitiesDespToSameActivityDesp(actDesp, 2); ToTransitionsDescriptorCollection transDespColl = actDesp.ToTransitions; SetTransitionCondition(transDespColl[0], false, 1); SetTransitionCondition(transDespColl[1], true, 3); WfProcessStartupParams startupParams = WfProcessTestCommon.GetInstanceOfWfProcessStartupParams(desp); IWfProcess process = WfRuntime.StartWorkflow(startupParams); ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver1, process); process = WfRuntime.GetProcessByProcessID(process.ID); ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.approver2, process); process = WfRuntime.GetProcessByProcessID(process.ID); ProcessTestHelper.MoveToAndSaveNextActivityWithDefSelectTranstion(OguObject.requestor, process); process = WfRuntime.GetProcessByProcessID(process.ID); Assert.AreEqual(3, process.ElapsedActivities.Count); WfMainStreamActivityDescriptorCollection coll = process.Descriptor.GetMainStreamActivities(); Assert.AreEqual(process.Activities.Count - 1, coll.Count); Assert.AreEqual(transDespColl[1].ToActivity.Key, coll[2].Activity.Key, "此处为动态添加的活动"); }
private static string GetStartWorkflowResourceID(IUser user) { IWfProcessDescriptor procDesp = WfProcessTestCommon.CreateProcessDescriptor(); WfUserResourceDescriptor userDesp = new WfUserResourceDescriptor(user); procDesp.InitialActivity.Resources.Add(userDesp); WfProcessStartupParams startParams = WfProcessTestCommon.GetInstanceOfWfProcessStartupParams(procDesp); WfStartWorkflowExecutor exec = new WfStartWorkflowExecutor(null, startParams); exec.Execute(); return(startParams.ResourceID); }
public void AddApproverExecutorTest() { //Initial NormalActivity NormalActivity1 NormalActivity2 NormalActivity3 Completed IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object; IWfProcessDescriptor procDesp = WfProcessTestCommon.CreateProcessDescriptor(); WfUserResourceDescriptor userDesp = new WfUserResourceDescriptor(user); procDesp.InitialActivity.Resources.Add(userDesp); WfProcessStartupParams startParams = WfProcessTestCommon.GetInstanceOfWfProcessStartupParams(procDesp); WfStartWorkflowExecutor exec = new WfStartWorkflowExecutor(null, startParams); IWfProcess proc = exec.Execute(); //启动流程 IWfProcess wfp = WfRuntime.GetProcessByProcessID(proc.ID); MoveToExecutor(wfp); //流转一步 ,即第2个节点 IWfProcess p = WfRuntime.GetProcessByProcessID(proc.ID); WfAssigneeCollection assignees = new WfAssigneeCollection(); assignees.Add((IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver1.ToString()].Object); WfAddApproverExecutor addExec = new WfAddApproverExecutor(p.CurrentActivity, p.CurrentActivity, assignees); addExec.Execute(); //加签,即流转到加签点上 IWfProcess process = WfRuntime.GetProcessByProcessID(p.ID); Assert.AreEqual(process.Descriptor.GetMainStreamActivities().Count, process.Activities.Count - 2, "动态添加两个活动,因被加签人要回到加签人"); Assert.AreEqual(2, process.ElapsedActivities.Count); Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban)); Assert.IsTrue(process.CurrentActivity.Descriptor.ToTransitions.Count == 1); Assert.IsNotNull(process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity); IWfProcess wfProcess9 = WfRuntime.GetProcessByProcessID(process.ID); WfWithdrawExecutor withdrawExec = new WfWithdrawExecutor(wfProcess9.CurrentActivity, wfProcess9.CurrentActivity); withdrawExec.Execute(); IWfProcess wfProcess1 = WfRuntime.GetProcessByProcessID(wfProcess9.ID); Assert.AreEqual(wfProcess1.Activities.Count, wfProcess1.Descriptor.GetMainStreamActivities().Count, "此处应该撤回到加签的活动点上,同时被加签的两个点都应该移除"); Assert.AreEqual(1, wfProcess1.ElapsedActivities.Count); Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProcess1.CurrentActivity.ID, TaskStatus.Ban)); Assert.IsTrue(wfProcess1.CurrentActivity.Descriptor.ToTransitions.Count == 1); }