Beispiel #1
0
        /// <summary>
        /// 根据ResourceID得到流程
        /// </summary>
        /// <param name="resourceID"></param>
        /// <returns></returns>
        public static WfProcessCollection GetProcessByResourceID(string resourceID)
        {
            resourceID.NullCheck <WfRuntimeException>("resourceID");

            WfProcessCollection processes = new WfProcessCollection();

            foreach (KeyValuePair <string, IWfProcess> kp in WfProcessContextCache.Instance)
            {
                if (string.Compare(kp.Value.ResourceID, resourceID, true) == 0)
                {
                    processes.Add(kp.Value);
                    break;
                }
            }

            WfProcessCollection persistedProcesses = null;

            PerformanceMonitorHelper.GetDefaultMonitor().WriteExecutionDuration(string.Format("LoadProcessByResourceID({0})", resourceID), () =>
                                                                                persistedProcesses = WorkflowSettings.GetConfig().GetPersistManager().LoadProcessByResourceID(resourceID)
                                                                                );

            persistedProcesses.ForEach(p =>
            {
                if (processes.ContainsKey(p.ID) == false)
                {
                    processes.Add(p);
                }

                WfProcessContextCache.Instance[p.ID] = p;
            });

            return(processes);
        }
Beispiel #2
0
        /// <summary>
        /// 内部启动分支流程
        /// </summary>
        /// <param name="branchTransferParams">分支流程启动参数</param>
        /// <param name="addToOwnerBranches"></param>
        /// <returns></returns>
        internal WfProcessCollection InternalStartupBranchProcesses(WfBranchProcessTransferParams branchTransferParams, bool addToOwnerBranches)
        {
            WfProcessCollection processes = null;

            if (CanStartBranchProcessFromTemplate(branchTransferParams.Template))
            {
                IWfBranchProcessGroup group = this.BranchProcessGroups[branchTransferParams.Template.Key];

                //以模版Key为分支流程实例的分组标准
                if (group == null)
                {
                    group = new WfBranchProcessGroup(this, branchTransferParams.Template);
                    this.BranchProcessGroups.Add(group);
                }

                WfRuntime.ProcessContext.FirePrepareBranchProcessParams(group, branchTransferParams.BranchParams);

                ProcessProgress.Current.MaxStep += branchTransferParams.BranchParams.Count;
                ProcessProgress.Current.Response();

                //根据模板内的分支流程参数,逐一启动具体流程
                for (int i = 0; i < branchTransferParams.BranchParams.Count; i++)
                {
                    //processes = StartupBranchProcess(branchTransferParams, group, group.BranchProcessStatistics.MaxSequence++);
                    processes = StartupBranchProcess(branchTransferParams, group, i);

                    processes.ForEach(p =>
                    {
                        if (addToOwnerBranches)
                        {
                            if (group.Branches.Contains(p) == false)
                            {
                                group.Branches.Add(p);
                            }
                        }

                        WfRuntime.ProcessContext.FireAfterStartupBranchProcess(p);
                    });

                    ProcessProgress.Current.MaxStep = Math.Max(ProcessProgress.Current.MaxStep, ProcessProgress.Current.CurrentStep + processes.Count);
                    ProcessProgress.Current.IncrementBy(processes.Count);
                    ProcessProgress.Current.Response();
                }

                WfRuntime.ProcessContext.AffectedProcesses.AddOrReplace(this.Process);
            }

            if (processes == null)
            {
                processes = new WfProcessCollection();
            }

            return(processes);
        }