protected override WfExecutorBase CreateExecutor() { WfAssigneeCollection wfac = new WfAssigneeCollection(); wfac.Add(this.selectedUsers); return new WfAddApproverExecutor(WfClientContext.Current.OriginalCurrentActivity, WfClientContext.Current.OriginalCurrentActivity, wfac) { AddApproverMode = this.AddApproverMode }; }
private static void ConsignExecutorWithCondition(IWfProcess process, out List <IUser> users) { WfAssigneeCollection assignees = new WfAssigneeCollection(); assignees.Add((IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver1.ToString()].Object); users = new List <IUser>(); users.Add((IUser)OguObjectSettings.GetConfig().Objects[OguObject.requestor.ToString()].Object); users.Add((IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver2.ToString()].Object); WfConsignExecutor exec = new WfConsignExecutor(process.CurrentActivity, process.CurrentActivity, assignees, users, new List <IUser>(), WfBranchProcessBlockingType.WaitAllBranchProcessesComplete, WfBranchProcessExecuteSequence.Parallel); exec.Execute(); }
public WfExecutorBase CreateExecutor() { WfExecutorBase executor = null; switch (this.OperationType) { case WfControlOperationType.MoveTo: executor = new WfMoveToExecutor( WfClientContext.Current.OriginalActivity, WfClientContext.Current.OriginalActivity, ToTransferParams(), WfClientContext.Current.Locks); break; case WfControlOperationType.Consign: { WfAssigneeCollection assignees = new WfAssigneeCollection(); WfAssignee assignee = new WfAssignee(WfClientContext.Current.User); assignees.Add(assignee); executor = new WfConsignExecutor( WfClientContext.Current.OriginalActivity, WfClientContext.Current.OriginalActivity, assignees, this.Assignees.ToUsers(), this.Circulators.ToUsers(), BlockingType, SequenceType); } break; case WfControlOperationType.Return: if (this._RejectMode == WfRejectMode.LikeAddApprover) { executor = new WfAddApproverExecutor(WfClientContext.Current.CurrentActivity, WfClientContext.Current.CurrentActivity.Process.Activities.FindActivityByDescriptorKey(TargetActivityDescriptor.Key)); } else { executor = new WfReturnExecutor(WfClientContext.Current.CurrentActivity, WfClientContext.Current.CurrentActivity.Process.Activities.FindActivityByDescriptorKey(TargetActivityDescriptor.Key)); } break; default: throw new WfRuntimeException(Translator.Translate(Define.DefaultCulture, "不能处理操作类型为{0}", this.OperationType)); } return(executor); }
public void AddApproverExecutorTest() { //Initial NormalActivity NormalActivity1 NormalActivity2 NormalActivity3 Completed IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object; IWfProcessDescriptor procDesp = WfProcessTestCommon.CreateProcessDescriptor(); WfUserResourceDescriptor userDesp = new WfUserResourceDescriptor(user); procDesp.InitialActivity.Resources.Add(userDesp); WfProcessStartupParams startParams = WfProcessTestCommon.GetInstanceOfWfProcessStartupParams(procDesp); WfStartWorkflowExecutor exec = new WfStartWorkflowExecutor(null, startParams); IWfProcess proc = exec.Execute(); //启动流程 IWfProcess wfp = WfRuntime.GetProcessByProcessID(proc.ID); MoveToExecutor(wfp); //流转一步 ,即第2个节点 IWfProcess p = WfRuntime.GetProcessByProcessID(proc.ID); WfAssigneeCollection assignees = new WfAssigneeCollection(); assignees.Add((IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver1.ToString()].Object); WfAddApproverExecutor addExec = new WfAddApproverExecutor(p.CurrentActivity, p.CurrentActivity, assignees); addExec.Execute(); //加签,即流转到加签点上 IWfProcess process = WfRuntime.GetProcessByProcessID(p.ID); Assert.AreEqual(process.Descriptor.GetMainStreamActivities().Count, process.Activities.Count - 2, "动态添加两个活动,因被加签人要回到加签人"); Assert.AreEqual(2, process.ElapsedActivities.Count); Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(process.CurrentActivity.ID, TaskStatus.Ban)); Assert.IsTrue(process.CurrentActivity.Descriptor.ToTransitions.Count == 1); Assert.IsNotNull(process.CurrentActivity.Descriptor.ToTransitions[0].ToActivity); IWfProcess wfProcess9 = WfRuntime.GetProcessByProcessID(process.ID); WfWithdrawExecutor withdrawExec = new WfWithdrawExecutor(wfProcess9.CurrentActivity, wfProcess9.CurrentActivity); withdrawExec.Execute(); IWfProcess wfProcess1 = WfRuntime.GetProcessByProcessID(wfProcess9.ID); Assert.AreEqual(wfProcess1.Activities.Count, wfProcess1.Descriptor.GetMainStreamActivities().Count, "此处应该撤回到加签的活动点上,同时被加签的两个点都应该移除"); Assert.AreEqual(1, wfProcess1.ElapsedActivities.Count); Assert.IsTrue(ProcessTestHelper.ExistsActivityUserTasks(wfProcess1.CurrentActivity.ID, TaskStatus.Ban)); Assert.IsTrue(wfProcess1.CurrentActivity.Descriptor.ToTransitions.Count == 1); }
public void ClientToServer(WfClientAssigneeCollection client, WfAssigneeCollection server) { client.NullCheck("client"); server.NullCheck("server"); server.Clear(); foreach (WfClientAssignee c in client) { WfAssignee s = null; WfClientAssigneeConverter.Instance.ClientToServer(c, ref s); server.Add(s); } }
/// <summary> /// 得到被委托的人员 /// </summary> /// <param name="sourceAssignees"></param> /// <returns></returns> private static WfAssigneeCollection GetDelegatedAssignees(WfAssigneeCollection sourceAssignees, IWfProcess process) { WfAssigneeCollection result = new WfAssigneeCollection(); foreach (WfAssignee sourceAssignee in sourceAssignees) { WfDelegationCollection delegations = WfDelegationSettings.GetConfig().Reader.GetUserActiveDelegations(sourceAssignee.User, process); foreach (WfDelegation delegation in delegations) { OguUser user = new OguUser(delegation.DestinationUserID); user.DisplayName = delegation.DestinationUserName; user.Name = delegation.DestinationUserName; OguUser delegator = new OguUser(delegation.SourceUserID); delegator.DisplayName = delegation.SourceUserName; delegator.Name = delegation.SourceUserName; WfAssignee assignee = new WfAssignee(user); assignee.AssigneeType = WfAssigneeType.Delegated; assignee.Delegator = delegator; result.Add(assignee); } } return result; }
public WfExecutorBase CreateExecutor() { WfExecutorBase executor = null; switch (this.OperationType) { case WfControlOperationType.MoveTo: executor = new WfMoveToExecutor( WfClientContext.Current.OriginalActivity, WfClientContext.Current.OriginalActivity, ToTransferParams(), WfClientContext.Current.Locks); break; case WfControlOperationType.Consign: { WfAssigneeCollection assignees = new WfAssigneeCollection(); WfAssignee assignee = new WfAssignee(WfClientContext.Current.User); assignees.Add(assignee); executor = new WfConsignExecutor( WfClientContext.Current.OriginalActivity, WfClientContext.Current.OriginalActivity, assignees, this.Assignees.ToUsers(), this.Circulators.ToUsers(), BlockingType, SequenceType); } break; case WfControlOperationType.Return: if (this._RejectMode == WfRejectMode.LikeAddApprover) executor = new WfAddApproverExecutor(WfClientContext.Current.CurrentActivity, WfClientContext.Current.CurrentActivity.Process.Activities.FindActivityByDescriptorKey(TargetActivityDescriptor.Key)); else executor = new WfReturnExecutor(WfClientContext.Current.CurrentActivity, WfClientContext.Current.CurrentActivity.Process.Activities.FindActivityByDescriptorKey(TargetActivityDescriptor.Key)); break; default: throw new WfRuntimeException(Translator.Translate(Define.DefaultCulture, "不能处理操作类型为{0}", this.OperationType)); } return executor; }
private void ReplaceAssignees(WfAssigneeCollection collection) { foreach (IUser user in this._OriginalAssignees) collection.Remove(a => string.Compare(a.User.ID, user.ID, true) == 0); collection.Add(this.TargetAssignees); }