Пример #1
0
        /// <summary>
        /// 启动一个模版(组)下的一组分支流程,在服务模式下,可能返回多个流程。其它情况返回单个流程
        /// </summary>
        /// <param name="branchTransferParams"></param>
        /// <param name="group"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        private WfProcessCollection StartupBranchProcess(WfBranchProcessTransferParams branchTransferParams, IWfBranchProcessGroup group, int index)
        {
            WfProcessCollection processes = null;

            if (branchTransferParams.Template.OperationDefinition == null)
            {
                WfProcessStartupParams startupParams = PrepareOneBranchProcessStartupParams(branchTransferParams, group, index);

                startupParams.CheckStartProcessUserPermission = false;

                processes = new WfProcessCollection();
                processes.Add(WfRuntime.StartWorkflow(startupParams));
            }
            else
            {
                if (WfRuntime.ProcessContext.EnableServiceCall)
                {
                    WfServiceStartupProcessParams startupParams = PrepareOneServiceStartupProcessParams(branchTransferParams, group, index);

                    processes = InvokeBranchProcess(startupParams, branchTransferParams.Template);
                }
                else
                {
                    processes = new WfProcessCollection();
                }
            }

            return(processes);
        }
Пример #2
0
        /// <summary>
        /// 调用外部服务。对方会返回一个或一组流程ID。本函数返回这组ID对应的流程。
        /// </summary>
        /// <param name="startupParams"></param>
        /// <param name="template"></param>
        /// <returns></returns>
        private WfProcessCollection InvokeBranchProcess(WfServiceStartupProcessParams startupParams, IWfBranchProcessTemplateDescriptor template)
        {
            this.Process.ApplicationRuntimeParameters["serviceOP_Paramas"] = startupParams;

            WfServiceInvoker svcInvoker = new WfServiceInvoker(template.OperationDefinition);

            object obj = svcInvoker.Invoke();

            WfProcessCollection processes          = new WfProcessCollection();
            WfBranchProcessTemplateDescriptor temp = template as WfBranchProcessTemplateDescriptor;

            IList array = obj as IList;

            if (array != null)
            {
                IWfProcess process = null;
                foreach (string processID in array)
                {
                    process = WfRuntime.GetProcessByProcessID(processID);
                    processes.Add(process);
                }

                temp.BranchProcessKey = process.Descriptor.Key;
            }
            else
            {
                IWfProcess process = WfRuntime.GetProcessByProcessID(obj.ToString());
                processes.Add(process);
                temp.BranchProcessKey = process.Descriptor.Key;
            }

            return(processes);
        }
Пример #3
0
 public WfProcessStartupParams(WfServiceStartupProcessParams serviceOP_Paramas, string ProcessDespKey)
 {
     this.ProcessDescriptor     = WfProcessDescriptorManager.GetDescriptor(ProcessDespKey);
     this.ProcessDescriptor.Url = serviceOP_Paramas.DefaultURL;
     this.Assignees.Add(serviceOP_Paramas.Assignees);
     this.AutoStartInitialActivity = serviceOP_Paramas.AutoStartInitialActivity;
     this.Creator          = serviceOP_Paramas.Creator;
     this.DefaultTaskTitle = serviceOP_Paramas.DefaultTaskTitle;
     this.Department       = serviceOP_Paramas.Department;
     this.ResourceID       = serviceOP_Paramas.ResourceID;
     this.RelativeID       = serviceOP_Paramas.RelativeID;
     this.RelativeURL      = serviceOP_Paramas.RelativeURL;
     this.OwnerActivityID  = serviceOP_Paramas.OwnerActivityID;
     this.OwnerTemplateKey = serviceOP_Paramas.OwnerTemplateKey;
     this.CheckStartProcessUserPermission = false;
     this.RuntimeProcessName = serviceOP_Paramas.RuntimeProcessName;
     this.AutoCommit         = serviceOP_Paramas.AutoCommit;
     this.DefaultUrl         = serviceOP_Paramas.DefaultUrl;
 }
Пример #4
0
        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);
        }