internal IWfActivity InnerMoveTo(WfTransferParamsBase transferParams) { ExceptionHelper.FalseThrow <ArgumentNullException>(transferParams != null, "transferParams"); //如果流程没有启动,且一个点都没有,则自动设为运行状态 if (this.Status == WfProcessStatus.NotRunning && this.Activities.Count == 0) { this.Status = WfProcessStatus.Running; } else if (this.Status == WfProcessStatus.Completed) //如果流程已经结束,那么流程状态应该变为运行状态 { this.Status = WfProcessStatus.Running; } CheckProcessRunningStatus(); CheckActivityMoveToCondition(); IWfActivity activity = null; //生成下一个新的活动点 if (transferParams.NextActivityDescriptor is IWfAnchorActivityDescriptor) { activity = this.Factory.CreateAnchorActivity(this, (WfBranchesTransferParams)transferParams); } else { activity = this.Factory.CreateActivity(this, transferParams.NextActivityDescriptor); } activity.Operator = transferParams.Operator; //当前点与新的活动点连接,并设置好相关指针 if (CurrentActivity != null) { ((WfActivityBase)CurrentActivity).ConnectToNextActivity(activity); ((WfActivityBase)CurrentActivity).Status = WfActivityStatus.Completed; } //加入点集合并设置好新的活动点 Activities.Add(activity); activity.Assignees.CopyFrom(transferParams.Receivers); ///设置的 if (transferParams.FromTransitionDescriptor != null) { activity.Context["FromTransitionDescriptor"] = transferParams.FromTransitionDescriptor.Key; } DoComplete(activity); return(activity); }
/// <summary> /// /// </summary> /// <param name="transferParams"></param> /// <returns></returns> public IWfActivity MoveTo(WfTransferParamsBase transferParams) { lock (this) { IWfActivity activity = InnerMoveTo(transferParams); if (this.CurrentActivity.FromTransition == null) { WorkflowSettings.GetConfig().EnqueueWorkItemExecutor.EnqueueMoveToWorkItem( null, this.CurrentActivity); } else { WorkflowSettings.GetConfig().EnqueueWorkItemExecutor.EnqueueMoveToWorkItem( this.CurrentActivity.FromTransition.FromActivity, this.CurrentActivity); } return(activity); } }