/// <summary>
        /// 完成一个工作项
        /// </summary>
        /// <param name="workItemID">工作项ID</param>
        /// <param name="parameters">参数</param>
        public void CompleteWorkItem(string workItemID, IDictionary<string, object> parameters, Func<Participantor> assignParticipant = null)
        {
            WorkItem wi = Persistence.GetWorkItem(workItemID);
            if (wi.CurrentState != (short)WorkItemStatus.WaitExecute && wi.CurrentState != (short)WorkItemStatus.Suspended)
            {
                WFUtil.HandleException(new MessageException()
                {
                    PromptMessage = string.Format("ID={0}的工作项{1}当前状态={2},不能被执行", wi.ID, wi.Name, wi.CurrentState.ToString().Cast<WorkItemStatus>(WorkItemStatus.Executing).GetRemark()),
                    Source = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName
                });

                return;
            }

            wi.CurrentState = (short)WorkItemStatus.Executing;

            using (ITransaction trans = UnitOfWork.BeginTransaction(typeof(ProcessDef)))
            {
                repository.SaveOrUpdate(wi);
                Persistence.UpdateActivityInstStatus(wi.ActivityInstID, ActivityInstStatus.Running);

                trans.Commit();
            }

            ProcessInst processInst = Persistence.GetProcessInst(wi.ProcessInstID);
            ProcessDefine processDefine = Persistence.GetProcessDefine(processInst.ProcessDefID);
            ProcessContext processContext = new ProcessContext()
            {
                ProcessDefine = processDefine,
                ProcessInst = processInst,
                Parameters = parameters
            };

            ProcessRuntime runtime = new ProcessRuntime(engineService, processContext, assignParticipant);
            runtime.Run();
        }
        /// <summary>
        /// 开始启动一个流程
        /// </summary>
        /// <param name="processInstID">流程实例ID</param>
        ///<param name="parameters">启动参数</param>
        public void StartAProcess(string processInstID, IDictionary<string, object> parameters)
        {
            ProcessInst processInst = GetToRunProcessInst(processInstID, WFUtil.User);
            ProcessDefine processDefine = Persistence.GetProcessDefine(processInst.ProcessDefID);
            ProcessContext processContext = new ProcessContext()
            {
                ProcessDefine = processDefine,
                ProcessInst = processInst,
                Parameters = parameters
            };

            ProcessRuntime runtime = new ProcessRuntime(engineService, processContext, null);
            runtime.Run();
        }
 public ProcessRuntime(IEngineService services, ProcessContext context, Func<Participantor> assignParticipant)
 {
     engineService = services;
     Context = context;
     this.assignParticipant = assignParticipant;
 }