protected override void OnModifyWorkflow(WfExecutorDataContext dataContext) { IWfProcess process = WfRuntime.StartWorkflow(StartupParams); if (this.OperatorActivity == null) { this.OperatorActivity = process.CurrentActivity; } if (this.AutoMoveTo) { if (this.TransferParams == null) { this.TransferParams = WfTransferParams.FromNextDefaultActivity(process); } //如果流转参数中没有下一步的人员,则从下一步活动的候选人中复制 if (this.TransferParams.Assignees.Count == 0) { IWfActivity nextActivity = process.Activities.FindActivityByDescriptorKey(this.TransferParams.NextActivityDescriptor.Key); if (nextActivity != null) { this.TransferParams.Assignees.CopyFrom(nextActivity.Candidates); } } this.TransferParams.FillActivityAndTransitionInfoFromContext(process); WfMoveToExecutor.DoMoveToOperation(process, this.TransferParams); } WfRuntime.ProcessContext.ResetContextByProcess(process); }
public WfMoveToExecutor(IWfActivity operatorActivity, IWfActivity targetActivity, WfTransferParams transferParams) : base(operatorActivity, targetActivity, WfControlOperationType.MoveTo) { transferParams.NullCheck("transferParams"); TransferParams = transferParams; }
public static WfTransferParams FromNextActivity(IWfActivityDescriptor currentActDesp, Func <WfTransitionDescriptorCollection, IWfTransitionDescriptor> predicate) { currentActDesp.NullCheck("actDesp"); predicate.NullCheck("predicate"); WfTransferParams transferParams = null; WfTransitionDescriptorCollection toTransitions = currentActDesp.ToTransitions.GetAllCanTransitTransitions(); //找到匹配的线 IWfTransitionDescriptor transition = predicate(toTransitions); if (transition != null) { transferParams = new WfTransferParams(transition.ToActivity); transferParams.FromTransitionDescriptor = transition; if (transition.ToActivity.Instance != null) { transferParams.Assignees.CopyFrom(transition.ToActivity.Instance.Candidates); } if (DeluxePrincipal.IsAuthenticated) { transferParams.Operator = DeluxeIdentity.CurrentUser; } } (transferParams != null).FalseThrow(Translator.Translate(Define.DefaultCulture, "不能根据活动定义{0}找到符合条件的下一步环节", currentActDesp.Key)); return(transferParams); }
public WfMoveToExecutor(IWfActivity operatorActivity, IWfActivity targetActivity, WfTransferParams transferParams, IEnumerable <Lock> locks) : base(operatorActivity, targetActivity, WfControlOperationType.MoveTo) { transferParams.NullCheck("transferParams"); TransferParams = transferParams; this.Locks = locks; }
/// <summary> /// 根据默认的下一环节生成流转参数 /// </summary> /// <param name="process"></param> /// <returns></returns> public static WfTransferParams FromNextDefaultActivity(IWfProcess process) { process.NullCheck("process"); WfTransferParams transferParams = null; if (process.CurrentActivity != null) { transferParams = FromNextDefaultActivity(process.CurrentActivity.Descriptor); } (transferParams != null).FalseThrow(Translator.Translate(Define.DefaultCulture, "不能根据流程当前活动找到默认的下一步环节")); return(transferParams); }
internal static void DoMoveToOperation(IWfProcess process, WfTransferParams transferParams) { process.Committed = true; WfRuntime.ProcessContext.BeginChangeActivityChangingContext(); try { (transferParams.NextActivityDescriptor != null).FalseThrow("流转参数的目标活动不能为空"); IWfActivity nextActivity = process.Activities.FindActivityByDescriptorKey(transferParams.NextActivityDescriptor.Key); (nextActivity != null).FalseThrow("不能找到Key为{0}的活动", transferParams.NextActivityDescriptor.Key); if (nextActivity.Status != WfActivityStatus.NotRunning) { WfRuntime.ProcessContext.ActivityChangingContext.CreatorInstanceID = process.CurrentActivity.ID; IWfTransitionDescriptor returnTransition = process.CurrentActivity.CopyMainStreamActivities(nextActivity, transferParams.FromTransitionDescriptor, WfControlOperationType.Return); IWfActivity nextCloneActivity = nextActivity; if (returnTransition != null) { transferParams.FromTransitionDescriptor = returnTransition; nextCloneActivity = returnTransition.ToActivity.Instance; } if (nextCloneActivity != null) { transferParams.NextActivityDescriptor = nextCloneActivity.Descriptor; } else { transferParams.NextActivityDescriptor = process.CurrentActivity.Descriptor.ToTransitions.FindDefaultSelectTransition().ToActivity; } IEnumerable <IUser> candidates = null; if (nextActivity != null) { candidates = nextActivity.Candidates.ToUsers(); } if (nextCloneActivity != null) { if (candidates.Count() == 0) { candidates = nextCloneActivity.Candidates.ToUsers(); } if (candidates.Count() == 0) { candidates = nextCloneActivity.Descriptor.Resources.ToUsers(); } } transferParams.Assignees.Add(candidates); } process.MoveTo(transferParams); while ((process.Status == WfProcessStatus.Completed || process.Status == WfProcessStatus.Aborted) && process.EntryInfo != null) { process.EntryInfo.OwnerActivity.Process.ProcessPendingActivity(); process = process.EntryInfo.OwnerActivity.Process; } } finally { WfRuntime.ProcessContext.RestoreChangeActivityChangingContext(); } }
internal static bool PrepareUserOperationLogDescriptionByTransferParams(WfExecutorDataContext dataContext, WfTransferParams transferParams, UserOperationLog log) { bool dealed = false; if (log.RealUser != null && log.OperationDescription.IsNullOrEmpty()) { string transitionName = string.Empty; if (transferParams.FromTransitionDescriptor != null) { transitionName = transferParams.FromTransitionDescriptor.Name; if (transitionName.IsNullOrEmpty()) { transitionName = transferParams.FromTransitionDescriptor.Description; } } if (transitionName.IsNotEmpty()) { log.OperationDescription = string.Format("{0}:{1}->{2}, '{3}' {4:yyyy-MM-dd HH:mm:ss}", log.OperationName, log.RealUser.DisplayName, Translator.Translate(Define.DefaultCulture, transitionName), log.Subject, DateTime.Now); dealed = true; } } return(dealed); }
/// <summary> /// 构造方法 /// </summary> /// <param name="fromActivity"></param> /// <param name="toActivity"></param> /// <param name="transferParams"></param> public WfMoveToEventArgs(IWfActivity fromActivity, IWfActivity toActivity, WfTransferParams transferParams) { this.FromActivity = fromActivity; this.ToActivity = toActivity; this.TransferParams = transferParams; }
public WfStartWorkflowExecutor(IWfActivity operatorActivity, WfProcessStartupParams startupParams, WfTransferParams transferParams, bool autoMoveTo = true) : base(operatorActivity, WfControlOperationType.Startup) { startupParams.NullCheck("startupParams"); this.StartupParams = startupParams; this.TransferParams = transferParams; this._AutoMoveTo = autoMoveTo; }