public WfControlNextStep(IWfActivity toActivity) { toActivity.NullCheck("toActivity"); this.ActivityDescriptor = toActivity.Descriptor; this._Candidates = toActivity.Candidates.GetSelectedAssignees(); }
/// <summary> /// /// </summary> /// <param name="operatorActivity">操作人所在的Activity,可以为null</param> /// <param name="targetActivity">需要替换人员的目标活动</param> /// <param name="originalAssignee"></param> /// <param name="targetAssignees"></param> public WfReplaceAssigneesExecutor(IWfActivity operatorActivity, IWfActivity targetActivity, IUser originalAssignee, IEnumerable <IUser> targetAssignees) : base(operatorActivity, WfControlOperationType.ReplaceAssignees) { targetActivity.NullCheck("targetActivity"); targetAssignees.NullCheck("targetAssignees"); if (originalAssignee != null) { this._OriginalAssignees.Add(originalAssignee); } else { this._OriginalAssignees.CopyFrom(targetActivity.Assignees.ToUsers()); if (this._OriginalAssignees.Count == 0) { this._OriginalAssignees.CopyFrom(targetActivity.Candidates.ToUsers()); } } this.TargetAssignees = targetAssignees; this.TargetActivity = targetActivity; if (OperatorActivity == null) { OperatorActivity = this.TargetActivity; } }
/// <summary> /// 切换到某个活动,该切换会影响到OriginalActivity、OriginalCurrentActivity以及CurrentActivity属性 /// </summary> /// <param name="originalActivity">原始活动</param> public void ChangeTo(IWfActivity originalActivity) { originalActivity.NullCheck("originalActivity"); this.OriginalActivity = originalActivity; this._OriginalCurrentActivity = originalActivity.Process.CurrentActivity; }
public WfStartBranchProcessExecutor(IWfActivity operatorActivity, IWfActivity ownerActivity, IWfBranchProcessTemplateDescriptor template) : base(operatorActivity, WfControlOperationType.StartBranchProcess) { ownerActivity.NullCheck("ownerActivity"); template.NullCheck("template"); this.OwnerActivity = ownerActivity; this.BranchTransferParams = new WfBranchProcessTransferParams(template); }
public WfControlNextStep(IWfTransitionDescriptor transition, IWfActivity toActivity) { transition.NullCheck("transition"); toActivity.NullCheck("toActivity"); this.ActivityDescriptor = toActivity.Descriptor; this._Candidates = toActivity.Candidates.GetSelectedAssignees();; this.TransitionDescriptor = transition; }
public WfPendingActivityInfo(IWfActivity activity) { activity.NullCheck("activity"); this.ActivityID = activity.ID; this.ProcessID = activity.Process.ID; this.ApplicationName = activity.Descriptor.Process.ApplicationName; this.ProgramName = activity.Descriptor.Process.ProgramName; }
protected WfActivityRelativeExecutorBase(IWfActivity operatorActivity, IWfActivity targetActivity, WfControlOperationType operationType) : base(operatorActivity, operationType) { targetActivity.NullCheck("targetActivity"); TargetActivity = targetActivity; if (OperatorActivity == null) OperatorActivity = targetActivity; }
/// <summary> /// 构造方法 /// </summary> /// <param name="owner"></param> /// <param name="template"></param> public WfBranchProcessGroup(IWfActivity owner, IWfBranchProcessTemplateDescriptor template) { owner.NullCheck("owner"); this.OwnerActivity = owner; this.ProcessTemplate = template; ////从内存中构造时,会走这个构造方法。 //this._BranchProcessStatistics = new WfBranchProcessStatistics(); }
/// <summary> /// 在指定的活动点之后,添加从startActivity与endActivity之间复制出来的 /// </summary> /// <param name="activityToAppend">复制的活动需要添加到哪一个活动之后</param> /// <param name="startActivity">需要复制的活动的起始点</param> /// <param name="endActivity">需要复制的活动的终止点</param> /// <param name="entryTransition"></param> /// <param name="operationType">操作类型</param> /// <returns>返回的第一个Clone活动的出线</returns> public IWfTransitionDescriptor CopyMainStreamActivities(IWfActivity activityToAppend, IWfActivity startActivity, IWfActivity endActivity, IWfTransitionDescriptor entryTransition, WfControlOperationType operationType) { activityToAppend.NullCheck("activityToAppend"); //沈峥注释,和WfMoveToExecutor中,是否按退回线进行的判断进行匹配 ExceptionHelper.TrueThrow(startActivity.Status == WfActivityStatus.NotRunning, "退件时所指定活动必须是已执行过的活动"); //沈峥重构后的实现 return CreateMainStreamActivities(activityToAppend, startActivity, endActivity, entryTransition, operationType); }
//protected override void OnPrepareNotifyTasks(WfExecutorDataContext dataContext) //{ // base.OnPrepareNotifyTasks(dataContext); // if (this.CancelProcess) // { // dataContext.NotifyTasks.Remove(t => // t.ActivityID == dataContext.GetValue("OriginalActivityID", string.Empty) // && t.Status == TaskStatus.Yue // ); // } //} private void InitProperties(IWfActivity operatorActivity, IWfActivity originalActivity, bool cancelAllBranchProcesses, bool cancelProcess) { originalActivity.NullCheck("originalActivity"); (originalActivity.Process.CurrentActivity == originalActivity).FalseThrow("活动(ID={0}, Key={1})不是流程的当前活动,不能撤回", originalActivity.ID, originalActivity.Descriptor.Key); this.OriginalActivity = originalActivity; this.CancelAllBranchProcesses = cancelAllBranchProcesses; this.CancelProcess = cancelProcess; }
/// <summary> /// 在指定的活动点之后,添加从startActivity与endActivity之间复制出来的 /// </summary> /// <param name="activityToAppend">复制的活动需要添加到哪一个活动之后</param> /// <param name="startActivity">需要复制的活动的起始点</param> /// <param name="endActivity">需要复制的活动的终止点</param> /// <param name="entryTransition"></param> /// <param name="operationType">操作类型</param> /// <returns>返回的第一个Clone活动的出线</returns> public IWfTransitionDescriptor CopyMainStreamActivities(IWfActivity activityToAppend, IWfActivity startActivity, IWfActivity endActivity, IWfTransitionDescriptor entryTransition, WfControlOperationType operationType) { activityToAppend.NullCheck("activityToAppend"); //沈峥注释,和WfMoveToExecutor中,是否按退回线进行的判断进行匹配 ExceptionHelper.TrueThrow(startActivity.Status == WfActivityStatus.NotRunning, "退件时所指定活动必须是已执行过的活动"); //沈峥重构后的实现 return(CreateMainStreamActivities(activityToAppend, startActivity, endActivity, entryTransition, operationType)); }
protected WfActivityRelativeExecutorBase(IWfActivity operatorActivity, IWfActivity targetActivity, WfControlOperationType operationType) : base(operatorActivity, operationType) { targetActivity.NullCheck("targetActivity"); TargetActivity = targetActivity; if (OperatorActivity == null) { OperatorActivity = targetActivity; } }
public WfStartBranchProcessExecutor(IWfActivity operatorActivity, IWfActivity ownerActivity, WfBranchProcessTransferParams branchTransferParams) : base(operatorActivity, WfControlOperationType.StartBranchProcess) { ownerActivity.NullCheck("ownerActivity"); branchTransferParams.NullCheck("branchTransferParams"); this.OwnerActivity = ownerActivity; this.BranchTransferParams = branchTransferParams; if (this.OperatorActivity == null) this.OperatorActivity = ownerActivity; }
public WfStartBranchProcessExecutor(IWfActivity operatorActivity, IWfActivity ownerActivity, WfBranchProcessTransferParams branchTransferParams) : base(operatorActivity, WfControlOperationType.StartBranchProcess) { ownerActivity.NullCheck("ownerActivity"); branchTransferParams.NullCheck("branchTransferParams"); this.OwnerActivity = ownerActivity; this.BranchTransferParams = branchTransferParams; if (this.OperatorActivity == null) { this.OperatorActivity = ownerActivity; } }
protected void SetSceneByActivity(IWfActivity activity) { activity.NullCheck("activity"); string scene = activity.Descriptor.InheritedScene; if (scene.IsNullOrEmpty()) { if (SceneInfo != null) scene = SceneInfo.DefaultWorkflowSceneID; } if (scene.IsNotEmpty()) OnSetScene(scene); }
protected override void OnModifyWorkflow(WfExecutorDataContext dataContext) { this.TargetActivity.Process.Committed = true; IWfProcess process = this.TargetActivity.Process; IWfActivity activity = process.ElapsedActivities.FindActivityByDescriptorKey(TargetActivity.Descriptor.Key); activity.NullCheck("targetActivity"); WfRuntime.ProcessContext.BeginChangeActivityChangingContext(); try { WfRuntime.ProcessContext.ActivityChangingContext.CreatorInstanceID = process.CurrentActivity.ID; process.CurrentActivity.CopyMainStreamActivities(process.CurrentActivity, TargetActivity, process.CurrentActivity.Descriptor.GetAssociatedActivity().Instance, null, WfControlOperationType.Return); if (process.CurrentActivity.Descriptor.ToTransitions.Count == 0) { throw new ApplicationException(string.Format("退回时,不能找到当前活动({0})的出线", process.CurrentActivity.Descriptor.Key)); } IWfActivityDescriptor nextActivityDesp = process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity; WfTransferParams tp = new WfTransferParams(nextActivityDesp); IWfActivity act = process.Activities.FindActivityByDescriptorKey(nextActivityDesp.Key); if (act.Assignees.Count > 0) { tp.Assignees.CopyFrom(act.Assignees); } else { tp.Assignees.CopyFrom(activity.Assignees); } process.MoveTo(tp); } finally { WfRuntime.ProcessContext.RestoreChangeActivityChangingContext(); } }
protected void SetSceneByActivity(IWfActivity activity) { activity.NullCheck("activity"); string scene = activity.Descriptor.InheritedScene; if (scene.IsNullOrEmpty()) { if (SceneInfo != null) { scene = SceneInfo.DefaultWorkflowSceneID; } } if (scene.IsNotEmpty()) { OnSetScene(scene); } }
/// <summary> /// /// </summary> /// <param name="operatorActivity">操作人所在的Activity,可以为null</param> /// <param name="targetActivity">需要替换人员的目标活动</param> /// <param name="originalAssignee"></param> /// <param name="targetAssignees"></param> public WfReplaceAssigneesExecutor(IWfActivity operatorActivity, IWfActivity targetActivity, IUser originalAssignee, IEnumerable<IUser> targetAssignees) : base(operatorActivity, WfControlOperationType.ReplaceAssignees) { targetActivity.NullCheck("targetActivity"); targetAssignees.NullCheck("targetAssignees"); if (originalAssignee != null) this._OriginalAssignees.Add(originalAssignee); else { this._OriginalAssignees.CopyFrom(targetActivity.Assignees.ToUsers()); if (this._OriginalAssignees.Count == 0) this._OriginalAssignees.CopyFrom(targetActivity.Candidates.ToUsers()); } this.TargetAssignees = targetAssignees; this.TargetActivity = targetActivity; if (OperatorActivity == null) OperatorActivity = this.TargetActivity; }
public void Withdraw(IWfActivity destinationActivity, bool cancelAllBranchProcesses) { destinationActivity.NullCheck("destinationActivity"); ElapsedActivities.ContainsKey(destinationActivity.ID).FalseThrow<WfRuntimeException>( "不能撤回到活动'{0}',这个Key对应的活动不存在", destinationActivity.Descriptor.Key); WfProcessActionContext actionContext = WfRuntime.ProcessContext; WfProcessActionContextState state = actionContext.SaveDifferentProcessInfo(this); try { actionContext.ResetContextByProcess(this); this.Status = WfProcessStatus.Running; RegisterAndPrepareActions(this.CurrentActivity.BeWithdrawnActions); actionContext.OriginalActivity.CancelBranchProcesses(cancelAllBranchProcesses); ((WfActivityBase)actionContext.OriginalActivity).Status = WfActivityStatus.NotRunning; while (this.ElapsedActivities.Count > 0) { WfActivityBase activity = (WfActivityBase)this.ElapsedActivities[this.ElapsedActivities.Count - 1]; this.ElapsedActivities.RemoveAt(this.ElapsedActivities.Count - 1); if (string.Compare(activity.ID, destinationActivity.ID, true) == 0) { activity.Status = WfActivityStatus.Running; break; } else { activity.CancelBranchProcesses(cancelAllBranchProcesses); activity.Status = WfActivityStatus.NotRunning; } } if (this.CurrentActivity != null) { this.ApplicationRuntimeParameters["PreviousActivityID"] = this.CurrentActivity.ID; this.ApplicationRuntimeParameters["PreviousActivityName"] = GetActivityName(this.CurrentActivity); } this.ApplicationRuntimeParameters["CurrentTransitionName"] = string.Empty; this.CurrentActivity = Activities[destinationActivity.ID]; RegisterAndPrepareActions(this.CurrentActivity.WithdrawActions); WfRuntime.ProcessContext.AffectedProcesses.AddOrReplace(this); RegisterAndPrepareActions(this.WithdrawActions); } finally { actionContext.RestoreSavedProcessInfo(state); } }