/// <summary>
        /// 启动。
        /// </summary>
        public void Start(FlowStepInstance flowStepInstance)
        {
            FlowProcessInstance flowProcessInstance = new FlowProcessInstance();
            flowProcessInstance.ProcessInstanceID = flowStepInstance.ProcessInstanceID;
            if (this.flowProcessInstanceEntity.LoadRecord(ref flowProcessInstance))
            {
                #region 流程处理。
                EnumInstanceProcessStatus status = (EnumInstanceProcessStatus)flowProcessInstance.InstanceProcessStatus;
                FlowInstanceRunError err = null;
                switch (status)
                {
                    case EnumInstanceProcessStatus.Run:
                        {
                            try
                            {
                                Process process = Utils.DeSerializerDatabaseFormart<Process>(flowProcessInstance.ProcessSerialization, flowProcessInstance.Verify);
                                if (process == null)
                                    throw new Exception("流程实例反序列化失败。");
                                this.FlowServiceCore(flowProcessInstance, flowStepInstance, process);

                                string strVerify = null;
                                flowProcessInstance.ProcessSerialization = Utils.SerializerDatabaseFormart<Process>(process, out strVerify);
                                if (!string.IsNullOrEmpty(strVerify) && (flowProcessInstance.Verify != strVerify))
                                {
                                    flowProcessInstance.Verify = strVerify;
                                    this.flowProcessInstanceEntity.UpdateRecord(flowProcessInstance);
                                }
                            }
                            catch (Exception e)
                            {
                                flowStepInstance.InstanceStepStatus = (int)EnumInstanceStepStatus.Error;
                                err = new FlowInstanceRunError();
                                err.ErrorID = GUIDEx.New;
                                err.ProcessInstanceID = flowProcessInstance.ProcessInstanceID;
                                err.StepInstanceID = flowStepInstance.StepInstanceID;
                                err.ErrorMessage = e.Message;
                                err.CreateDate = DateTime.Now;
                                this.flowInstanceRunErrorEntity.UpdateRecord(err);

                                flowProcessInstance.InstanceProcessStatus = (int)EnumInstanceProcessStatus.Error;
                                this.flowProcessInstanceEntity.UpdateRecord(flowProcessInstance);
                            }
                        }
                        break;

                    case EnumInstanceProcessStatus.Complete:
                        {
                            flowStepInstance.InstanceStepStatus = (int)EnumInstanceStepStatus.Error;
                            err = new FlowInstanceRunError();
                            err.ErrorID = GUIDEx.New;
                            err.ProcessInstanceID = flowProcessInstance.ProcessInstanceID;
                            err.StepInstanceID = flowStepInstance.StepInstanceID;
                            err.ErrorMessage = "该流程已经完成结束。";
                            err.CreateDate = DateTime.Now;
                            this.flowInstanceRunErrorEntity.UpdateRecord(err);
                        }
                        break;

                    case EnumInstanceProcessStatus.Error:
                        {
                            flowStepInstance.InstanceStepStatus = (int)EnumInstanceStepStatus.Error;
                        }
                        break;

                    case EnumInstanceProcessStatus.Stop:
                        {
                            flowStepInstance.InstanceStepStatus = (int)EnumInstanceStepStatus.Suspended;
                            err = new FlowInstanceRunError();
                            err.ErrorID = GUIDEx.New;
                            err.ProcessInstanceID = flowProcessInstance.ProcessInstanceID;
                            err.StepInstanceID = flowStepInstance.StepInstanceID;
                            err.ErrorMessage = "该流程已经被暂停。";
                            err.CreateDate = DateTime.Now;
                            this.flowInstanceRunErrorEntity.UpdateRecord(err);
                        }
                        break;
                }
                #endregion
            }
            else
                flowStepInstance.InstanceStepStatus = (int)EnumInstanceStepStatus.Suspended;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="flowProcessInstance">流程实例。</param>
        /// <param name="flowStepInstance">步骤实例。</param>
        /// <param name="process">流程定义。</param>
        void FlowServiceCore(FlowProcessInstance flowProcessInstance, FlowStepInstance flowStepInstance, Process process)
        {
            Step step = process.Steps[flowStepInstance.StepID];
            if (step == null)
                throw new Exception(string.Format("流程定义中没有找到步骤[步骤ID:{0}]", flowStepInstance.StepID));
            else if (step.StepType == EnumStepType.Last)//终结步骤。
            {
                flowProcessInstance.EndDate = flowStepInstance.EndDate = DateTime.Now;

                flowStepInstance.InstanceStepStatus = (int)EnumInstanceStepStatus.Complete;
                flowProcessInstance.InstanceProcessStatus = (int)EnumInstanceProcessStatus.Complete;

                this.flowProcessInstanceEntity.UpdateRecord(flowProcessInstance);
                return;
            }
            EnumStepMode stepMode = step.StepMode;
            TransitionCollection transitionCollection = null;
            if (stepMode == EnumStepMode.JoinAND)//与汇聚处理。
            {
                transitionCollection = process.Transitions.FindToStepTransition(step.StepID);
                if (transitionCollection == null || transitionCollection.Count == 0)
                    throw new Exception("流程定义中没有找到变迁规则。");
                bool bResult = true;
                foreach (Transition t in transitionCollection)
                {
                    bResult &= this.CoreConditionsCalculated(process, t, step, flowStepInstance.StepInstanceID, false);
                }
                if (!bResult)
                {
                    flowStepInstance.InstanceStepStatus = (int)EnumInstanceStepStatus.Suspended;
                    return;
                }
            }
            //非与汇聚处理。
            transitionCollection = process.Transitions.FindTransition(step.StepID);
            if (transitionCollection == null || transitionCollection.Count == 0)
                throw new Exception("流程定义中没有找到变迁规则。");
            foreach (Transition t in transitionCollection)
            {
                this.CoreConditionsCalculated(process, t, step, flowStepInstance.StepInstanceID, true);
            }
            flowStepInstance.InstanceStepStatus = (int)EnumInstanceStepStatus.Complete;
        }