private WfServiceStartupProcessParams PrepareOneServiceStartupProcessParams(WfBranchProcessTransferParams branchParams, IWfBranchProcessGroup group, int index) { IWfBranchProcessTemplateDescriptor template = branchParams.Template; WfBranchProcessStartupParams branchStartupParams = branchParams.BranchParams[index]; WfServiceStartupProcessParams startupParams = new WfServiceStartupProcessParams(); startupParams.Creator = this.Process.Creator; if (branchStartupParams.Department == null) { startupParams.Department = this.Process.OwnerDepartment; } else { startupParams.Department = branchStartupParams.Department; } startupParams.Assignees = branchStartupParams.Assignees.ToUsers(); if (branchStartupParams.DefaultTaskTitle.IsNullOrEmpty()) { if (startupParams.DefaultTaskTitle.IsNullOrEmpty()) { startupParams.DefaultTaskTitle = this.Process.Descriptor.DefaultTaskTitle; } else { startupParams.DefaultTaskTitle = this.Descriptor.TaskTitle; } } else { startupParams.DefaultTaskTitle = branchStartupParams.DefaultTaskTitle; } if (branchStartupParams.ResourceID.IsNullOrEmpty()) { WfSubProcessResourceMode mode = template.Properties.GetValue("CreateResourceMode", WfSubProcessResourceMode.DependsOnProcess); switch (mode) { //这里的规则是什么? case WfSubProcessResourceMode.DependsOnProcess: startupParams.ResourceID = this.Process.ResourceID; break; case WfSubProcessResourceMode.SameWithRoot: startupParams.ResourceID = this.Process.ResourceID; break; case WfSubProcessResourceMode.NewCreate: startupParams.ResourceID = UuidHelper.NewUuidString(); break; } } else { startupParams.ResourceID = branchStartupParams.ResourceID; } startupParams.OwnerActivityID = this.ID; startupParams.OwnerTemplateKey = template.Key; startupParams.Sequence = index; startupParams.RelativeParams = new Dictionary <object, object>(); foreach (var strpar in branchStartupParams.RelativeParams.AllKeys) { startupParams.RelativeParams.Add(strpar, this.Process.ApplicationRuntimeParameters[branchStartupParams.RelativeParams[strpar]]); } if (!string.IsNullOrEmpty(template.DefaultUrl)) { startupParams.DefaultURL = template.DefaultUrl; } else if (!string.IsNullOrEmpty(this.Descriptor.Url)) { startupParams.DefaultURL = this.Descriptor.Url; } else { startupParams.DefaultURL = this.Process.Descriptor.Url; } //如果是串行执行,且不是第一个流程,则不启动第一个活动,子流程处于未启动状态 if (template.ExecuteSequence == WfBranchProcessExecuteSequence.Serial && index > 0) { startupParams.AutoStartInitialActivity = false; } return(startupParams); }
public static WfClientSubProcessResourceMode ToClientSubProcessResourceMode(this WfSubProcessResourceMode resourceMode) { return((WfClientSubProcessResourceMode)resourceMode); }
private WfProcessStartupParams PrepareOneBranchProcessStartupParams(WfBranchProcessTransferParams branchTransferParams, IWfBranchProcessGroup group, int index) { IWfBranchProcessTemplateDescriptor template = branchTransferParams.Template; WfBranchProcessStartupParams branchStartupParams = branchTransferParams.BranchParams[index]; //准备启动子流程的参数 //先检查有没有预定义好的分支流程 IWfProcessDescriptor subProcessDesp = null; using (WfApplicationParametersContext apContext = WfApplicationParametersContext.CreateContext(branchStartupParams.ApplicationRuntimeParameters)) { subProcessDesp = template.GetBranchProcessDescriptor(); } if (template.DefaultProcessName.IsNotEmpty()) { string runtimeProcessName = this.Process.ApplicationRuntimeParameters.GetMatchedString(template.DefaultProcessName); if (runtimeProcessName.IsNullOrEmpty()) { runtimeProcessName = template.DefaultProcessName; } if (runtimeProcessName.IsNullOrEmpty()) { ((WfProcessDescriptor)subProcessDesp).Name = runtimeProcessName; } if (subProcessDesp.InitialActivity != null && subProcessDesp.InitialActivity.Name.IsNullOrEmpty()) { ((WfActivityDescriptor)subProcessDesp.InitialActivity).Name = runtimeProcessName; } } if (template.DefaultTaskTitle.IsNotEmpty()) { subProcessDesp.DefaultTaskTitle = template.DefaultTaskTitle; } if (template.DefaultUrl.IsNotEmpty()) { subProcessDesp.Url = template.DefaultUrl; } if (subProcessDesp.Url.IsNullOrEmpty()) { subProcessDesp.Url = this.Descriptor.Url.IsNotEmpty() ? this.Descriptor.Url : this.Descriptor.Process.Url; } WfProcessStartupParams startupParams = new WfProcessStartupParams(); startupParams.Creator = this.Operator; if (branchStartupParams.Department == null) { startupParams.Department = this.Process.OwnerDepartment; } else { startupParams.Department = branchStartupParams.Department; } startupParams.Assignees.CopyFrom(branchStartupParams.Assignees); startupParams.ProcessDescriptor = subProcessDesp; if (branchStartupParams.DefaultTaskTitle.IsNullOrEmpty()) { if (startupParams.DefaultTaskTitle.IsNullOrEmpty()) { if (subProcessDesp.DefaultTaskTitle.IsNotEmpty()) { startupParams.DefaultTaskTitle = subProcessDesp.DefaultTaskTitle; } else { startupParams.DefaultTaskTitle = this.Process.Descriptor.DefaultTaskTitle; } } else { startupParams.DefaultTaskTitle = this.Descriptor.TaskTitle; } } else { startupParams.DefaultTaskTitle = branchStartupParams.DefaultTaskTitle; } if (branchStartupParams.ResourceID.IsNullOrEmpty()) { WfSubProcessResourceMode mode = template.Properties.GetValue("CreateResourceMode", WfSubProcessResourceMode.DependsOnProcess); switch (mode) { case WfSubProcessResourceMode.DependsOnProcess: if (subProcessDesp.Properties.GetValue("Independent", false)) { startupParams.ResourceID = UuidHelper.NewUuidString(); } else { startupParams.ResourceID = this.Process.ResourceID; } break; case WfSubProcessResourceMode.SameWithRoot: startupParams.ResourceID = this.Process.ResourceID; break; case WfSubProcessResourceMode.NewCreate: startupParams.ResourceID = UuidHelper.NewUuidString(); break; } } else { startupParams.ResourceID = branchStartupParams.ResourceID; } if (branchStartupParams.RelativeParams.Count == 0) { startupParams.RelativeParams.CopyFrom(this.Process.RelativeParams); } else { startupParams.RelativeParams.CopyFrom(branchStartupParams.RelativeParams); } startupParams.BranchStartupParams = branchStartupParams; startupParams.Group = group; startupParams.OwnerActivityID = this.ID; startupParams.OwnerTemplateKey = template.Key; startupParams.Sequence = index; startupParams.AutoCommit = this.Process.Committed; //子流程的提交属性默认等于主流程的 branchStartupParams.ApplicationRuntimeParameters.ForEach(kp => startupParams.ApplicationRuntimeParameters.Add(kp.Key, kp.Value)); //如果是串行执行,且不是第一个流程,则不启动第一个活动,子流程处于未启动状态 if (template.ExecuteSequence == WfBranchProcessExecuteSequence.Serial && index > 0) { startupParams.AutoStartInitialActivity = false; } return(startupParams); }