private void executor_SaveApplicationData(WfExecutorDataContext dataContext) { //if (dataContext.OperationType == WfControlOperationType.Return) // throw new ApplicationException("调试终止"); if (WfClientContext.Current.OriginalActivity.Process.IsApprovalRootProcess) { AppCommonInfoAdapter.Instance.Update(ViewData.ToAppCommonInfo(ViewData.Data.Subject), "Creator", "DraftDepartmentName"); } if (this.opinionListView.CurrentOpinion != null && dataContext.OperationType != WfControlOperationType.CancelProcess) { GenericOpinionAdapter.Instance.Update(opinionListView.CurrentOpinion); } MaterialAdapter.Instance.SaveDeltaMaterials(attachmentsControl.DeltaMaterials); //如果进入到了维护模式 if (dataContext.CurrentProcess.Status == WfProcessStatus.Maintaining) { foreach (IWfBranchProcessTemplateDescriptor template in WfClientContext.Current.CurrentActivity.Descriptor.BranchProcessTemplates) { DispatchStartBranchProcessTask.SendTask(WfClientContext.Current.CurrentActivity.ID, template, true); } } }
public void DispatchStartBranchProcessTaskTest() { IWfProcessDescriptor processDesp = CreateProcessWithAutoMaintainProperty(); IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp); MoveToExecutor(process); process = WfRuntime.GetProcessByProcessID(process.ID); IWfActivity ownerActivity = process.CurrentActivity; Console.WriteLine("OwnerActivityID: {0}", ownerActivity.ID); //在Template设置资源为一个组织,用于后续分发分支流程的测试 IWfBranchProcessTemplateDescriptor template = ownerActivity.Descriptor.BranchProcessTemplates[0]; IUser userInTemplate = template.Resources.ToUsers().FirstOrDefault(); WfDepartmentResourceDescriptor deptResourceDesp = new WfDepartmentResourceDescriptor(userInTemplate.Parent); template.Resources.Clear(); template.Resources.Add(deptResourceDesp); SysTaskAdapter.Instance.ClearAll(); SysTaskCommon.ExecuteAndAssertTask(DispatchStartBranchProcessTask.SendTask(ownerActivity.ID, template, true)); WfRuntime.ClearCache(); process = WfRuntime.GetProcessByProcessID(process.ID); int startedTaskCount = (int)WfServiceInvoker.InvokeContext["returnValue"]; Console.WriteLine("Started Branch Task Count: {0}", startedTaskCount); Assert.IsTrue(startedTaskCount > 0); int executedTaskCount = SysTaskCommon.ExecuteAllTasks(); Assert.AreEqual(startedTaskCount, executedTaskCount); WfRuntime.ClearCache(); process = WfRuntime.GetProcessByProcessID(process.ID); Assert.AreEqual(WfProcessStatus.Running, process.Status); Assert.IsTrue(process.CurrentActivity.BranchProcessGroups.Count > 0); Assert.AreEqual(startedTaskCount - 1, process.CurrentActivity.BranchProcessGroups[0].Branches.Count); }