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)); }
private static WfUserResourceDescriptor GetUserResDespInstance() { WfUserResourceDescriptor userResDesp = new WfUserResourceDescriptor(); userResDesp.User = (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object; return(userResDesp); }
protected void Page_Load(object sender, EventArgs e) { WfConverterHelper.RegisterConverters(); var user = new WfUserResourceDescriptor(); //user. var typeName = typeof(WfUserResourceDescriptor).Name; List <object> resTypes = new List <object>() { new { shortType = typeof(WfUserResourceDescriptor).Name, displayName = "用户", imgUrl = ControlResources.UserLogoUrl }, new { shortType = typeof(WfDepartmentResourceDescriptor).Name, displayName = "组织", imgUrl = ControlResources.OULogoUrl }, new { shortType = typeof(WfGroupResourceDescriptor).Name, displayName = "用户组", imgUrl = ControlResources.GroupLogoUrl }, new { shortType = typeof(WfActivityOperatorResourceDescriptor).Name, displayName = "执行人", imgUrl = ControlResources.UserLogoUrl }, new { shortType = typeof(WfActivityAssigneesResourceDescriptor).Name, displayName = "指派人", imgUrl = ControlResources.UserLogoUrl }, new { shortType = typeof(WfRoleResourceDescriptor).Name, displayName = "角色", imgUrl = ControlResources.RoleLogoUrl }, new { shortType = typeof(WfDynamicResourceDescriptor).Name, displayName = "动态角色", imgUrl = ControlResources.RoleLogoUrl }, new { shortType = typeof(WfActivityMatrixResourceDescriptor).Name, displayName = "矩阵角色", imgUrl = ControlResources.RoleLogoUrl }, new { shortType = typeof(WfAURoleResourceDescriptor).Name, displayName = "(AU)架构角色", imgUrl = ControlResources.RoleLogoUrl } }; hiddenResTypesData.Value = JSONSerializerExecute.Serialize(resTypes); WebUtility.RequiredScript(typeof(ClientGrid)); this.CreateResourceTemplate(); }
public override void ClientToServer(WfClientResourceDescriptor client, ref WfResourceDescriptor server) { if (server == null) server = new WfUserResourceDescriptor((IUser)((WfClientUserResourceDescriptor)client).User.ToOguObject()); else ((WfUserResourceDescriptor)server).User = (IUser)((WfClientUserResourceDescriptor)client).User.ToOguObject(); }
protected void Page_Load(object sender, EventArgs e) { WfUserResourceDescriptor wfUserResDesc = new WfUserResourceDescriptor(); hiddenWfUserDescTemplate.Value = JSONSerializerExecute.Serialize(wfUserResDesc); WebUtility.RequiredScript(typeof(ClientGrid)); }
public override void ClientToServer(WfClientResourceDescriptor client, ref WfResourceDescriptor server) { if (server == null) { server = new WfUserResourceDescriptor((IUser)((WfClientUserResourceDescriptor)client).User.ToOguObject()); } else { ((WfUserResourceDescriptor)server).User = (IUser)((WfClientUserResourceDescriptor)client).User.ToOguObject(); } }
private static void FillDynamicActivitySimpleResource(IWfActivityDescriptor actDesp, params IUser[] users) { WfUserResourceDescriptor[] resources = new WfUserResourceDescriptor[users.Length]; for (int i = 0; i < users.Length; i++) { resources[i] = new WfUserResourceDescriptor(users[i]); } FillDynamicActivitySimpleResource(actDesp, resources); }
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 StartWorkflowExecutorTest() { IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object; string procResourceId = GetStartWorkflowResourceID(user); WfProcessCollection processes = WfRuntime.GetProcessByResourceID(procResourceId); Assert.AreEqual(1, processes.Count); Assert.AreEqual(0, processes[0].ElapsedActivities.Count); WfUserResourceDescriptor uDesp = (WfUserResourceDescriptor)processes[0].InitialActivity.Descriptor.Resources[0]; Assert.AreEqual(user.ID, uDesp.User.ID); }
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); }
public void NoticeOfCancelProcess() { IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee(); WfUserResourceDescriptor userResDesp = GetUserResDespInstance(); process.Descriptor.CancelEventReceivers.Add(userResDesp); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); process.CancelProcess(false); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(userResDesp.User.ID, process.CurrentActivity.ID, TaskStatus.Yue)); }
public void WfUserResourceDescriptorConveterTest() { WfConverterHelper.RegisterConverters(); IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object; WfUserResourceDescriptor userDesp = new WfUserResourceDescriptor(user); string result = JSONSerializerExecute.Serialize(userDesp); Console.WriteLine(result); WfUserResourceDescriptor deserializedUserDesp = JSONSerializerExecute.Deserialize <WfUserResourceDescriptor>(result); string reSerialized = JSONSerializerExecute.Serialize(deserializedUserDesp); Assert.AreEqual(result, reSerialized); ResourceConverterTest(userDesp); }
public void NoticeOfAllBranchProcessCompleted() { IWfProcess process = WfProcessTestCommon.StartupProcessWithAssignee(); IWfActivityDescriptor actDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; WfUserResourceDescriptor userResDesp = GetUserResDespInstance(); actDesp.EnterEventReceivers.Add(userResDesp); WfTransferParams tp = ProcessTestHelper.GetInstanceOfWfTransferParams(process, WfBranchProcessExecuteSequence.Parallel, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete); process.MoveTo(tp); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); ProcessTestHelper.CompleteActivityBranchProcessesByBlockingType(process.CurrentActivity, WfBranchProcessBlockingType.WaitAllBranchProcessesComplete); ProcessTestHelper.ProcessPendingActivity(process.CurrentActivity.ID); WfRuntime.PersistWorkflows(); process = WfRuntime.GetProcessByProcessID(process.ID); Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(userResDesp.User.ID, process.Activities[1].ID, TaskStatus.Yue), "节点状态由pending到running后,则被通知人会收到1个待阅"); }
public static WfClientProcess DynamicProcessStartup(WfClientDynamicProcessStartupParameters parameters) { WfProcessDescriptor processDesc = new WfProcessDescriptor(); processDesc.Key = string.IsNullOrEmpty(parameters.ProcessKey) ? UuidHelper.NewUuidString() : parameters.ProcessKey; processDesc.Name = parameters.RuntimeProcessName; processDesc.ApplicationName = "动态流程"; processDesc.ProgramName = "动态流程"; processDesc.DefaultTaskTitle = "${TaskTitle}$"; processDesc.Url = "${TaskUrl}$"; processDesc.DefaultTaskTitle = "${Subject}$"; WfActivityDescriptor initActDesp = new WfActivityDescriptor("Initial", WfActivityType.InitialActivity); initActDesp.Name = parameters.InitialActivityDescriptor.ActivityName; initActDesp.CodeName = "Initial Activity"; initActDesp.Properties.SetValue("AutoSendUserTask", false); initActDesp.Properties.TrySetValue("AllowWithdraw", true); foreach (WfClientUserResourceDescriptorParameters userResourceDescriptor in parameters.InitialActivityDescriptor.UserResourceList) { IUser user = userResourceDescriptor.User; WfUserResourceDescriptor userResourceDesc = new WfUserResourceDescriptor(user); initActDesp.Resources.Add(userResourceDesc); } processDesc.Activities.Add(initActDesp); WfActivityDescriptor completedActDesp = new WfActivityDescriptor("Completed", WfActivityType.CompletedActivity); completedActDesp.Name = "完成"; completedActDesp.CodeName = "Completed Activity"; processDesc.Activities.Add(completedActDesp); for (int j = 0; j < processDesc.Activities.Count - 1; j++) { processDesc.Activities[j].ToTransitions.AddForwardTransition(processDesc.Activities[j + 1]); } WfProcessStartupParams startupParams = new WfProcessStartupParams(); startupParams.ProcessDescriptor = processDesc; startupParams.Creator = DeluxeIdentity.CurrentUser; startupParams.Assignees.Add(DeluxeIdentity.CurrentUser); startupParams.ResourceID = parameters.ResourceID.ToString(); startupParams.AutoCommit = true; startupParams.DefaultTaskTitle = parameters.TaskTitle; startupParams.DefaultUrl = parameters.TaskUrl; startupParams.RuntimeProcessName = parameters.RuntimeProcessName; startupParams.Department = DeluxeIdentity.CurrentUser.Parent; startupParams.RuntimeProcessName = parameters.RuntimeProcessName; //设置工作流运行时参数 SetWorkflowParameters(parameters.ProcessParameters, startupParams.ApplicationRuntimeParameters); //准备执行器 WfStartWorkflowExecutor executor = new WfStartWorkflowExecutor(null, startupParams, null, false); //根据需要设是否自动往下走一步 //调整待办的url和标题 executor.PrepareMoveToTasks += (dataContext, tasks) => { PrepareUserTasks(tasks, null, null, startupParams.ProcessDescriptor.InitialActivity.Name); }; //添加审批意见 executor.AfterSaveApplicationData += (dataContext) => { //根据实际需要添加审批意见 //PrepareStartupOpinions(dataContext, user, "请审批"); }; IWfProcess process = executor.Execute(); return(GetClientProcess(process)); }
protected void btnOK_Click(object sender, EventArgs e) { string returnUrl = Request.QueryString.GetValue("ru", string.Empty); WfProcessDescriptor processDesc = new WfProcessDescriptor(); processDesc.Key = UuidHelper.NewUuidString(); processDesc.Name = "自由流程"; processDesc.ApplicationName = "秘书服务"; processDesc.ProgramName = "部门通知"; processDesc.Url = returnUrl; processDesc.DefaultTaskTitle = "${Subject}$"; WfActivityDescriptor initAct = new WfActivityDescriptor("Initial", WfActivityType.InitialActivity); initAct.Name = "起草"; initAct.CodeName = "Initial Activity"; initAct.Properties.SetValue("AutoSendUserTask", false); initAct.Properties.TrySetValue("AllowWithdraw", true); processDesc.Activities.Add(initAct); foreach (IUser user in processUsers.SelectedOuUserData) { string key = processDesc.FindNotUsedActivityKey(); WfActivityDescriptor normalAct = new WfActivityDescriptor(key, WfActivityType.NormalActivity); normalAct.Name = user.DisplayName; normalAct.CodeName = key; normalAct.Properties.SetValue("AutoAppendSecretary", true); //normalAct.ActivityType = WfActivityType.NormalActivity; WfUserResourceDescriptor userResourceDesc = new WfUserResourceDescriptor(user); normalAct.Resources.Add(userResourceDesc); processDesc.Activities.Add(normalAct); } WfActivityDescriptor completedAct = new WfActivityDescriptor("Completed", WfActivityType.CompletedActivity); completedAct.Name = "完成"; completedAct.CodeName = "Completed Activity"; processDesc.Activities.Add(completedAct); for (int j = 0; j < processDesc.Activities.Count - 1; j++) { processDesc.Activities[j].ToTransitions.AddForwardTransition(processDesc.Activities[j + 1]); } WfProcessStartupParams startupParams = new WfProcessStartupParams(); startupParams.ProcessDescriptor = processDesc; startupParams.Creator = DeluxeIdentity.CurrentUser; startupParams.Assignees.Add(DeluxeIdentity.CurrentUser); startupParams.DefaultTaskTitle = "${Subject}$"; startupParams.RuntimeProcessName = "${Subject}$"; startupParams.ResourceID = UuidHelper.NewUuidString(); startupParams.Department = DeluxeIdentity.CurrentUser.Parent; string relativeParams = Request.QueryString["relativeParams"]; if (relativeParams.IsNotEmpty()) { startupParams.RelativeParams.CopyFrom(UriHelper.GetUriParamsCollection(relativeParams)); } WfStartWorkflowExecutor executor = new WfStartWorkflowExecutor(WfClientContext.Current.OriginalActivity, startupParams); executor.AfterModifyWorkflow += new ExecutorEventHandler(executor_AfterModifyWorkflow); executor.Execute(); IWfProcess process = WfClientContext.Current.OriginalActivity.Process; returnUrl = UriHelper.RemoveUriParams(returnUrl, "relativeParams"); Response.Redirect(string.Format("{0}?resourceID={1}&activityID={2}", returnUrl, process.ResourceID, process.CurrentActivity.ID)); }
public void WfUserResourceDescriptorConveterTest() { WfConverterHelper.RegisterConverters(); IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object; WfUserResourceDescriptor userDesp = new WfUserResourceDescriptor(user); string result = JSONSerializerExecute.Serialize(userDesp); Console.WriteLine(result); WfUserResourceDescriptor deserializedUserDesp = JSONSerializerExecute.Deserialize<WfUserResourceDescriptor>(result); string reSerialized = JSONSerializerExecute.Serialize(deserializedUserDesp); Assert.AreEqual(result, reSerialized); ResourceConverterTest(userDesp); }
private static void FillDynamicActivitySimpleResource(IWfActivityDescriptor actDesp, params IUser[] users) { WfUserResourceDescriptor[] resources = new WfUserResourceDescriptor[users.Length]; for (int i = 0; i < users.Length; i++) resources[i] = new WfUserResourceDescriptor(users[i]); FillDynamicActivitySimpleResource(actDesp, resources); }
public static WfClientProcess Startup(WfClientStartupFreeStepsParameters parameters, string viewUrl) { parameters.NullCheck("parameters"); parameters.Approvers.NullCheck("Approvers"); (parameters.Approvers.Count > 0).FalseThrow("必须包含至少一个以上的审批人"); WfProcessDescriptor processDesc = new WfProcessDescriptor(); processDesc.Key = UuidHelper.NewUuidString(); processDesc.Name = "自由流程"; processDesc.ApplicationName = "秘书服务"; processDesc.ProgramName = "部门通知"; WfActivityDescriptor initActDesp = new WfActivityDescriptor("Initial", WfActivityType.InitialActivity); initActDesp.Name = "起草"; initActDesp.CodeName = "Initial Activity"; initActDesp.Properties.SetValue("AutoSendUserTask", false); initActDesp.Properties.TrySetValue("AllowWithdraw", true); processDesc.Activities.Add(initActDesp); foreach (IUser user in parameters.Approvers) { string key = processDesc.FindNotUsedActivityKey(); WfActivityDescriptor normalActDesp = new WfActivityDescriptor(key, WfActivityType.NormalActivity); normalActDesp.Name = user.DisplayName; normalActDesp.CodeName = key; normalActDesp.Properties.SetValue("AutoAppendSecretary", true); WfUserResourceDescriptor userResourceDesc = new WfUserResourceDescriptor(user); normalActDesp.Resources.Add(userResourceDesc); processDesc.Activities.Add(normalActDesp); } WfActivityDescriptor completedActDesp = new WfActivityDescriptor("Completed", WfActivityType.CompletedActivity); completedActDesp.Name = "完成"; completedActDesp.CodeName = "Completed Activity"; processDesc.Activities.Add(completedActDesp); for (int j = 0; j < processDesc.Activities.Count - 1; j++) { processDesc.Activities[j].ToTransitions.AddForwardTransition(processDesc.Activities[j + 1]); } WfProcessStartupParams startupParams = new WfProcessStartupParams(); startupParams.ProcessDescriptor = processDesc; startupParams.Creator = DeluxeIdentity.CurrentUser; startupParams.Assignees.Add(DeluxeIdentity.CurrentUser); startupParams.DefaultTaskTitle = "${Subject}$"; startupParams.RuntimeProcessName = "${Subject}$"; startupParams.ResourceID = UuidHelper.NewUuidString(); startupParams.Department = DeluxeIdentity.CurrentUser.Parent; startupParams.DefaultUrl = viewUrl; string subject = parameters.Title; if (subject.IsNullOrEmpty()) { subject = "自由审批流程"; } startupParams.ApplicationRuntimeParameters["Subject"] = subject; WfStartWorkflowExecutor executor = new WfStartWorkflowExecutor(null, startupParams, null, true); //添加审批意见 executor.AfterSaveApplicationData += (dataContext) => { PrepareStartupOpinions(dataContext, DeluxeIdentity.CurrentUser, "请审批"); }; IWfProcess process = executor.Execute(); return(GetClientProcess(process)); }
protected void btnOK_Click(object sender, EventArgs e) { string returnUrl = Request.QueryString.GetValue("ru", string.Empty); WfProcessDescriptor processDesc = new WfProcessDescriptor(); processDesc.Key = UuidHelper.NewUuidString(); processDesc.Name = "自由流程"; processDesc.ApplicationName = "秘书服务"; processDesc.ProgramName = "部门通知"; processDesc.Url = returnUrl; processDesc.DefaultTaskTitle = "${Subject}$"; WfActivityDescriptor initAct = new WfActivityDescriptor("Initial", WfActivityType.InitialActivity); initAct.Name = "起草"; initAct.CodeName = "Initial Activity"; initAct.Properties.SetValue("AutoSendUserTask", false); initAct.Properties.TrySetValue("AllowWithdraw", true); processDesc.Activities.Add(initAct); foreach (IUser user in processUsers.SelectedOuUserData) { string key = processDesc.FindNotUsedActivityKey(); WfActivityDescriptor normalAct = new WfActivityDescriptor(key, WfActivityType.NormalActivity); normalAct.Name = user.DisplayName; normalAct.CodeName = key; normalAct.Properties.SetValue("AutoAppendSecretary", true); //normalAct.ActivityType = WfActivityType.NormalActivity; WfUserResourceDescriptor userResourceDesc = new WfUserResourceDescriptor(user); normalAct.Resources.Add(userResourceDesc); processDesc.Activities.Add(normalAct); } WfActivityDescriptor completedAct = new WfActivityDescriptor("Completed", WfActivityType.CompletedActivity); completedAct.Name = "完成"; completedAct.CodeName = "Completed Activity"; processDesc.Activities.Add(completedAct); for (int j = 0; j < processDesc.Activities.Count - 1; j++) { processDesc.Activities[j].ToTransitions.AddForwardTransition(processDesc.Activities[j + 1]); } WfProcessStartupParams startupParams = new WfProcessStartupParams(); startupParams.ProcessDescriptor = processDesc; startupParams.Creator = DeluxeIdentity.CurrentUser; startupParams.Assignees.Add(DeluxeIdentity.CurrentUser); startupParams.DefaultTaskTitle = "${Subject}$"; startupParams.RuntimeProcessName = "${Subject}$"; startupParams.ResourceID = UuidHelper.NewUuidString(); startupParams.Department = DeluxeIdentity.CurrentUser.Parent; string relativeParams = Request.QueryString["relativeParams"]; if (relativeParams.IsNotEmpty()) startupParams.RelativeParams.CopyFrom(UriHelper.GetUriParamsCollection(relativeParams)); WfStartWorkflowExecutor executor = new WfStartWorkflowExecutor(WfClientContext.Current.OriginalActivity, startupParams); executor.AfterModifyWorkflow += new ExecutorEventHandler(executor_AfterModifyWorkflow); executor.Execute(); IWfProcess process = WfClientContext.Current.OriginalActivity.Process; returnUrl = UriHelper.RemoveUriParams(returnUrl, "relativeParams"); Response.Redirect(string.Format("{0}?resourceID={1}&activityID={2}", returnUrl, process.ResourceID, process.CurrentActivity.ID)); }
private static WfUserResourceDescriptor GetUserResDespInstance() { WfUserResourceDescriptor userResDesp = new WfUserResourceDescriptor(); userResDesp.User = (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object; return userResDesp; }