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 NoticeOfLeaveActivity() { IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee(); IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; WfUserResourceDescriptor userResDesp = GetUserResDespInstance(); nextActivityDesp.LeaveEventReceivers.Add(userResDesp); WfTransferParams tp = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.approver2); process.MoveTo(tp); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); process.MoveTo(new WfTransferParams(process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity)); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); string actKey = process.CurrentActivity.Descriptor.FromTransitions[0].FromActivity.Key; Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(userResDesp.User.ID, process.Activities[1].ID, TaskStatus.Yue)); }
public void CancelDelegationTest() { WfDelegation delegation = PrepareDelegation(); WfDelegationAdapter.Instance.Update(delegation); try { IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee(); IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; WfTransferParams tp = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.approver1); process.MoveTo(tp); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); process.CancelProcess(false); //取消 WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); Assert.AreEqual(2, ProcessTestHelper.GetActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Yue).Count, "应该产生两条待阅"); } finally { WfDelegationAdapter.Instance.Delete(delegation); //清理委托 } }
public void MovetoDelegationTest() { WfDelegation delegation = PrepareDelegation(); WfDelegationAdapter.Instance.Update(delegation); //添加委托 try { //创建流程 IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee(); IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; WfTransferParams tp = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.approver1); process.MoveTo(tp); //流转 WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); Assert.IsTrue((ProcessTestHelper.GetActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban).Count) >= 2, "至少有两个待办事项。或许其它人也会去为当前人指定相应的委托人"); } finally { WfDelegationAdapter.Instance.Delete(delegation); //清理委托 } }
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); }
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, "重新加载后验证资源中的人员是否是之前活动的操作人"); }
public void SimpleProcessPersistRepeatTest() { IWfProcess process = WfProcessTestCommon.StartupSimpleProcessWithAssignee(); //process.DefaultTaskTitle = "测试保存的流程"; WfRuntime.PersistWorkflows(); IWfProcess loadedProcess = WfRuntime.GetProcessByProcessID(process.ID); IWfProcess loadedProcess2 = WfRuntime.GetProcessByActivityID(process.Activities[0].ID); Assert.AreEqual(loadedProcess, loadedProcess2); int n = loadedProcess.Activities.Count; for (int i = 0; i < n; i++) { if (loadedProcess.Activities[i].Descriptor != loadedProcess.Descriptor.InitialActivity) { WfTransferParams transferPara = new WfTransferParams(loadedProcess.Activities[i].Descriptor); loadedProcess.MoveTo(transferPara); WfRuntime.PersistWorkflows(); } loadedProcess = WfRuntime.GetProcessByActivityID(loadedProcess.Activities[i].ID); } IWfProcess OnceAgainloadedProcess = WfRuntime.GetProcessByProcessID(process.ID); Assert.AreEqual(OnceAgainloadedProcess.ID, process.ID); }
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)); }
public void BranchProcessPersistTest() { 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]; AssertBranchProcessesInfo(group, tp.BranchTransferParams[0].Template.BranchProcessKey); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); group = process.CurrentActivity.BranchProcessGroups[0]; AssertBranchProcessesInfo(group, tp.BranchTransferParams[0].Template.BranchProcessKey); string subProcessID = process.CurrentActivity.BranchProcessGroups[0].Branches[0].ID; WfRuntime.ClearCache(); //构造子流程,反向查找主流程信息 IWfProcess subProcess = WfRuntime.GetProcessByProcessID(subProcessID); AssertBranchProcessesInfo(subProcess.EntryInfo.OwnerActivity.BranchProcessGroups[0], tp.BranchTransferParams[0].Template.BranchProcessKey); }
public void SimpleProcessPersistTest() { IWfProcess process = WfProcessTestCommon.StartupSimpleProcessWithAssignee(); //process.DefaultTaskTitle = "测试保存的流程"; ProcessTestHelper.OutputExecutionTime(() => WfRuntime.PersistWorkflows(), "保存简单流程"); try { IWfProcess loadedProcess = WfRuntime.GetProcessByProcessID(process.ID); Assert.AreEqual(process.ID, loadedProcess.ID); Assert.AreEqual(process.Status, loadedProcess.Status); Assert.AreEqual(DataLoadingType.External, loadedProcess.LoadingType); WfTransferParams transferParams = new WfTransferParams(process.Descriptor.CompletedActivity); transferParams.Assignees.Add(new WfAssignee((IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object)); transferParams.Assignees.Add(new WfAssignee((IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object)); loadedProcess.MoveTo(transferParams); WfRuntime.PersistWorkflows(); Assert.AreEqual(process.ID, loadedProcess.ID); Assert.AreEqual(WfProcessStatus.Completed, loadedProcess.Status); Assert.AreEqual(DataLoadingType.External, loadedProcess.LoadingType); } finally { //WfRuntime.DeleteProcessByProcessID(process.ID); } }
private static IWfProcess StartNewProcess(IWfProcessDescriptor processDesp, IWfProcess originalProcess, string newResourceID, IUser processCreator, IOrganization department) { WfProcessStartupParams wp = new WfProcessStartupParams(processDesp); IWfProcess process = WfRuntime.StartWorkflow(typeof(OAWfProcess), wp); process.OwnerDepartment = department; WfTransferParams tParams = new WfTransferParams(wp.Descriptor.InitialActivity); tParams.Operator = DeluxeIdentity.CurrentUser; tParams.Receivers.Add(processCreator); process.MoveTo(tParams); process.Context["ApplicationName"] = originalProcess.Context["ApplicationName"]; process.Context["ProgramName"] = originalProcess.Context["ProgramName"]; ((OAWfProcess)process).ResourceID = newResourceID; process.Context[WfVariableDefine.ProcessDraftDepartmentNameVariableName] = WfVariableDefine.GetProcessDraftDepartmentName(originalProcess); process.Context[WfVariableDefine.ProcessDraftUserIDVariableName] = WfVariableDefine.GetProcessDraftUserID(originalProcess); process.Context[WfVariableDefine.ProcessDraftUserNameVariableName] = WfVariableDefine.GetProcessDraftUserName(originalProcess); return(process); }
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 SimpleProcessMoveTest() { IWfProcess process = WfProcessTestCommon.StartupSimpleProcess(); WfTransferParams transferParams = new WfTransferParams(process.Descriptor.CompletedActivity); process.MoveTo(transferParams); Assert.IsTrue(process.InitialActivity.Status == WfActivityStatus.Completed); Assert.IsTrue(process.Status == WfProcessStatus.Completed); Assert.IsTrue(process.CompletedActivity.Status == WfActivityStatus.Completed); }
/// <summary> /// 流转到默认的下一个活动 /// </summary> /// <param name="process"></param> /// <returns></returns> public static IWfActivity MoveToNextDefaultActivity(IWfProcess process) { IWfTransitionDescriptor transition = process.CurrentActivity.Descriptor.ToTransitions.GetAllCanTransitTransitions(true).FirstOrDefault(); Assert.IsNotNull(transition, string.Format("活动{0}没有能够使用的出线", process.CurrentActivity.Descriptor.Key)); WfTransferParams transferParams = new WfTransferParams(transition.ToActivity); process.MoveTo(transferParams); return(process.CurrentActivity); }
public void ProcessTaskAccomplishedOfResourceTest() { IUser user = (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object; IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee(); ((WfProcess)process).ResourceID = UuidHelper.NewUuidString(); IWfActivityDescriptor actDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; WfTransferParams tp = new WfTransferParams(actDesp); tp.Assignees.Add(user); process.MoveTo(tp); //设置 同一人 WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); actDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; tp = ProcessTestHelper.GetInstanceOfWfTransferParams(actDesp, OguObject.approver2); process.MoveTo(tp); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); actDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; tp = new WfTransferParams(actDesp); tp.Assignees.Add(user); //设置 同一人 WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); actDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; tp = ProcessTestHelper.GetInstanceOfWfTransferParams(actDesp, OguObject.approver2); process.MoveTo(tp); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); Assert.AreEqual(1, ProcessTestHelper.GetResourceUserTasksAccomplished(process.ResourceID, user.ID), "如果ResourceID相同,且流转过同一个人两次,他只会剩下一个已办"); }
public void SimpleProcessRuntimeSerializeTest() { IWfProcess process = WfProcessTestCommon.StartupSimpleProcess(); if (process.Activities != null) { foreach (var activity in process.Activities) { if (activity.Descriptor != process.Descriptor.InitialActivity) { Assert.IsTrue(activity.Status == WfActivityStatus.NotRunning); WfTransferParams transferPara = new WfTransferParams(activity.Descriptor); process.MoveTo(transferPara); } } } XElementFormatter formatter = new XElementFormatter(); XElement root = formatter.Serialize(process); Console.WriteLine(root.ToString()); IWfProcess clonedProcess = (IWfProcess)formatter.Deserialize(root); Assert.IsTrue(clonedProcess.Status == WfProcessStatus.Completed); for (int i = 0; i < clonedProcess.Activities.Count; i++) { Assert.IsTrue(clonedProcess.Activities[i].Status == WfActivityStatus.Completed); if (i < clonedProcess.Activities.Count - 1) { Assert.AreEqual(clonedProcess.Activities[i].Descriptor.ToTransitions[0], clonedProcess.Activities[i + 1].Descriptor.FromTransitions[0]); } } Assert.IsNotNull(clonedProcess.Descriptor.Activities[process.Descriptor.InitialActivity.Key], "验证反序列化后集合字典的完整性"); XElement reRoot = formatter.Serialize(clonedProcess); //31000是否允许被撤回默认值不同true false Assert.AreEqual(root.ToString(), reRoot.ToString()); IWfProcess reClonedProcess = (IWfProcess)formatter.Deserialize(reRoot); Assert.AreEqual(clonedProcess.ToString(), reClonedProcess.ToString()); }
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); }
public void AllApprovalProcessScheduleRootTest() { 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(process.ID, normalActivity.Instance.BranchProcessGroups[0].Branches[0].ScheduleRootProcess.ID); Assert.AreEqual(normalActivity.Instance.ID, normalActivity.Instance.BranchProcessGroups[0].Branches[0].InitialActivity.ScheduleRootActivity.ID); }
public void CancelSubProcessTest() { IWfProcess process = GetProcessInstanceWithBranchProcessRunning(WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete); IWfProcess branchProcess = process.CurrentActivity.BranchProcessGroups[0].Branches[0]; CancelProcess(branchProcess, false); IWfProcess branchProcess2 = process.CurrentActivity.BranchProcessGroups[0].Branches[1]; CancelProcess(branchProcess2, false); process = WfRuntime.GetProcessByProcessID(process.ID); process.MoveTo(new WfTransferParams(process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity)); Assert.AreEqual(WfActivityStatus.Completed, process.Activities[1].Status); }
public void WfActivityAssigneesResourceTest() { IWfProcess process = GetProcessInstanceWithAssigneesResource(); Assert.AreEqual(process.CurrentActivity.Assignees[0].User.ID, process.CurrentActivity.Descriptor.Resources.ToUsers()[0].ID); IWfActivityDescriptor actDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; WfTransferParams par = new WfTransferParams(actDesp); par.Assignees.Add(actDesp.FromTransitions[0].FromActivity.Resources.ToUsers()[0]); process.MoveTo(par); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban)); }
protected override void OnModifyWorkflow(WfExecutorDataContext dataContext) { this.TargetActivity.Process.Committed = true; IWfProcess process = this.TargetActivity.Process; IWfActivity activity = process.ElapsedActivities.FindActivityByDescriptorKey(TargetActivity.Descriptor.Key); activity.NullCheck("targetActivity"); WfRuntime.ProcessContext.BeginChangeActivityChangingContext(); try { WfRuntime.ProcessContext.ActivityChangingContext.CreatorInstanceID = process.CurrentActivity.ID; process.CurrentActivity.CopyMainStreamActivities(process.CurrentActivity, TargetActivity, process.CurrentActivity.Descriptor.GetAssociatedActivity().Instance, null, WfControlOperationType.Return); if (process.CurrentActivity.Descriptor.ToTransitions.Count == 0) { throw new ApplicationException(string.Format("退回时,不能找到当前活动({0})的出线", process.CurrentActivity.Descriptor.Key)); } IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; WfTransferParams tp = new WfTransferParams(nextActivityDesp); IWfActivity act = process.Activities.FindActivityByDescriptorKey(nextActivityDesp.Key); if (act.Assignees.Count > 0) { tp.Assignees.CopyFrom(act.Assignees); } else { tp.Assignees.CopyFrom(activity.Assignees); } process.MoveTo(tp); } finally { WfRuntime.ProcessContext.RestoreChangeActivityChangingContext(); } }
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"); }
public void ProcessAssigneesTest() { IWfProcess process = WfProcessTestCommon.StartupSimpleProcessDescriptorWithTransitionCondition(); IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; WfTransferParams transferParams = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.requestor); process.MoveTo(transferParams); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); Assert.IsTrue(process.CurrentActivity.Assignees.Count > 0); //WfProcessCurrentInfoCollection coll = WfProcessCurrentInfoAdapter.Instance.Load(true, process.ID); //Assert.AreEqual(process.CurrentActivity.Assignees.Count, coll[0].Assignees.Count); //Assert.AreEqual(process.CurrentActivity.Assignees[0].User.Name, coll[0].Assignees[0].User.Name); }
public void EnterActivityTest() { WfServiceOperationDefinition enterSvcDef = new WfServiceInvokerFactory().SvcOpDef; WfServiceOperationDefinition leaveSvcDef = new WfServiceInvokerFactory().SvcOpDef; enterSvcDef.AddressDef.RequestMethod = WfServiceRequestMethod.Get; enterSvcDef.OperationName = "SayHelloWorld"; enterSvcDef.RtnXmlStoreParamName = "EnterServiceRtnXml"; leaveSvcDef.AddressDef.RequestMethod = WfServiceRequestMethod.Get; leaveSvcDef.OperationName = "Add"; leaveSvcDef.RtnXmlStoreParamName = "LeaveServiceRtnXml"; leaveSvcDef.Params.Add(new WfServiceOperationParameter() { Name = "a", Type = WfSvcOperationParameterType.Int, Value = 50 }); leaveSvcDef.Params.Add(new WfServiceOperationParameter() { Name = "b", Type = WfSvcOperationParameterType.Int, Value = 5 }); IWfProcess process = WfProcessTestCommon.StartupProcessWithServiceDefinition(enterSvcDef, leaveSvcDef); Console.WriteLine("进入起始活动点"); Console.WriteLine(process.ApplicationRuntimeParameters[enterSvcDef.RtnXmlStoreParamName]); Console.WriteLine(process.ApplicationRuntimeParameters[leaveSvcDef.RtnXmlStoreParamName]); IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; WfTransferParams tp = ProcessTestHelper.GetInstanceOfWfTransferParams(nextActivityDesp, OguObject.approver2); process.MoveTo(tp); Console.WriteLine("离开起始活动点"); Console.WriteLine(process.ApplicationRuntimeParameters[enterSvcDef.RtnXmlStoreParamName]); Console.WriteLine(process.ApplicationRuntimeParameters[leaveSvcDef.RtnXmlStoreParamName]); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); }
public void TransitionConditionTest() { TestContext.Properties["Amount"] = 7500; WfRuntime.ProcessContext.EvaluateTransitionCondition += new Expression.CalculateUserFunction(ProcessContext_EvaluateTransition); IWfProcess process = WfProcessTestCommon.StartupSimpleProcessDescriptorWithTransitionCondition(); WfTransferParams transferParams = new WfTransferParams(process.Descriptor.InitialActivity.ToTransitions[0].ToActivity); process.MoveTo(transferParams); WfTransitionDescriptorCollection transitions = process.CurrentActivity.Descriptor.ToTransitions.GetAllCanTransitTransitions(); Assert.AreEqual(1, transitions.Count); Console.WriteLine(((IWfForwardTransitionDescriptor)transitions[0]).Condition.Expression); Assert.AreEqual("Amount >= 5000", ((IWfForwardTransitionDescriptor)transitions[0]).Condition.Expression); }
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 BranchProcessUserTasksTest() { //启支流程及其子流程 IWfProcess process = WfProcessTestCommon.StartupSimpleProcessWithAssignee(); WfTransferParams tp = ProcessTestHelper.GetInstanceOfWfTransferParams(process, WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete); process.MoveTo(tp); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); IWfBranchProcessGroup group = process.CurrentActivity.BranchProcessGroups[0]; AssertBranchProcessesInfo(group, tp.BranchTransferParams[0].Template.BranchProcessKey); UserTaskCollection currentActTasks = UserTaskAdapter.Instance.LoadUserTasks(builder => { builder.LogicOperator = Data.Builder.LogicOperatorDefine.Or; foreach (IWfProcess subProcess in group.Branches) { builder.AppendItem("ACTIVITY_ID", subProcess.CurrentActivity.ID); } }); foreach (IWfProcess subProcess in group.Branches) { bool containsTask = false; group.Branches.ForEach(p => { containsTask = currentActTasks.Exists(u => u.ActivityID == p.CurrentActivity.ID); Assert.IsTrue(containsTask); }); } }
public void ActivitiesTrackTest() { IWfProcess process = WfProcessTestCommon.StartupSimpleProcess(); for (int i = 0; i < process.Activities.Count; i++) { if (process.Activities[i].Descriptor != process.Descriptor.InitialActivity) { WfTransferParams transferPara = new WfTransferParams(process.Activities[i].Descriptor); process.MoveTo(transferPara); } } int k = process.ElapsedActivities.Count; string[] keys = new string[] { "Initial", "NormalActivity", "Completed" }; for (int j = 0; j < process.ElapsedActivities.Count; j++) { Assert.AreEqual(process.ElapsedActivities[j].Descriptor.Key, process.ElapsedActivities[j].Descriptor.Key, keys[j]); } }
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); }
/// <summary> /// 流转到默认的下一个活动 /// </summary> /// <param name="process"></param> /// <returns></returns> public static IWfActivity MoveToNextDefaultActivity(IWfProcess process) { IWfTransitionDescriptor transition = process.CurrentActivity.Descriptor.ToTransitions.GetAllCanTransitTransitions(true).FirstOrDefault(); Assert.IsNotNull(transition, string.Format("活动{0}没有能够使用的出线", process.CurrentActivity.Descriptor.Key)); WfTransferParams transferParams = new WfTransferParams(transition.ToActivity); process.MoveTo(transferParams); return process.CurrentActivity; }