public WfControlNextStep(IWfActivity toActivity) { toActivity.NullCheck("toActivity"); this.ActivityDescriptor = toActivity.Descriptor; this._Candidates = toActivity.Candidates.GetSelectedAssignees(); }
public WfControlNextStep(IWfTransitionDescriptor transition, IWfActivity toActivity) { transition.NullCheck("transition"); toActivity.NullCheck("toActivity"); this.ActivityDescriptor = toActivity.Descriptor; this._Candidates = toActivity.Candidates.GetSelectedAssignees();; this.TransitionDescriptor = transition; }
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); }
private void ReplaceResources(WfAssigneeCollection collection) { this.TargetActivity.Descriptor.Resources.Clear(); foreach (IUser user in collection.ToUsers()) { this.TargetActivity.Descriptor.Resources.Add(new WfUserResourceDescriptor(user)); } }
private static void SyncActivityAssigneesUrl(UserTask task, WfAssigneeCollection assignees) { foreach (WfAssignee assignee in assignees) { if (assignee.User != null && string.Compare(assignee.User.ID, task.SendToUserID, true) == 0) { assignee.Url = task.Url; } } }
public WfAssigneeCollection ToAssignees() { OguDataCollection <IUser> users = ToUsers(); WfAssigneeCollection result = new WfAssigneeCollection(); users.ForEach(u => result.Add(u)); return(result); }
//private bool CanTransit(IWfActivity targetActivity) //{ // //广度遍历。。。找最近的目标点。 // bool result = false; // string key= targetActivity.Descriptor.Key; // if (targetActivity.Descriptor.AssociatedActivityKey != null) // key = targetActivity.Descriptor.AssociatedActivityKey; // foreach (var trans in this.Descriptor.ToTransitions) // { // if (trans.ToActivity.Key == key) // { // result = true; // break; // } // } // return result; //} private static IEnumerable <WfResourceDescriptor> GetResources(WfAssigneeCollection wfAssignees) { List <WfResourceDescriptor> list = new List <WfResourceDescriptor>(); foreach (WfAssignee item in wfAssignees) { list.Add(new WfUserResourceDescriptor(item.User)); } return(list); }
/// <summary> /// 过滤出被选择的对象 /// </summary> /// <param name="multiResult">是否允许返回多个结果</param> /// <returns></returns> public WfAssigneeCollection GetSelectedAssignees() { WfAssigneeCollection result = new WfAssigneeCollection(); foreach (WfAssignee assignee in this) { if (assignee.Selected) { result.Add(assignee); } } return(result); }
public WfConsignExecutor(IWfActivity operatorActivity, IWfActivity targetActivity, WfAssigneeCollection assignees, IEnumerable <IUser> consignUsers, IEnumerable <IUser> circulateUsers, WfBranchProcessBlockingType blockingType, WfBranchProcessExecuteSequence sequence) : base(operatorActivity, targetActivity, WfControlOperationType.Consign) { assignees.NullCheck("assignees"); consignUsers.NullCheck("users"); (consignUsers.Count() > 0).FalseThrow <WfRuntimeException>("参与会签的用户数必须大于零"); this.Assignees.CopyFrom(assignees); this.ConsignUsers = consignUsers; this.CirculateUsers = circulateUsers; this.BlockingType = blockingType; this.Sequence = sequence; }
private static List <IUser> GetSecretariesFromCandidates(WfAssigneeCollection candidates) { List <IUser> result = new List <IUser>(); foreach (WfAssignee assignee in candidates) { if (assignee.User != null) { foreach (IUser secretary in assignee.User.Secretaries) { if (result.Exists(u => string.Compare(u.ID, secretary.ID, true) == 0) == false) { result.Add(secretary); } } } } return(result); }
public bool AreSameAssignees(WfAssigneeCollection targetAssignees) { bool result = false; if (targetAssignees != null) { if (this.Count == targetAssignees.Count) { result = true; foreach (WfAssignee targetAssignee in targetAssignees) { if (this.Contains(targetAssignee.User.ID) == false) { result = false; break; } } } } return(result); }
public void GenerateCandidatesFromResources() { WfAssigneeCollection candidates = this.Descriptor.Resources.ToAssignees(); //根据是否允许多个候选人,设置Selected属性 if (this.Descriptor.Properties.GetValue("AllowAssignToMultiUsers", true) == false) { //先查找原来选中的 WfAssignee originalSelected = this.Candidates.Find(a => a.Selected); candidates.ForEach(a => a.Selected = false); WfAssignee matchedSelected = null; if (originalSelected != null) { matchedSelected = candidates.Find(a => string.Compare(a.User.ID, originalSelected.User.ID, true) == 0); } if (matchedSelected != null) { matchedSelected.Selected = true; } else { if (candidates.Count > 0) { candidates[0].Selected = true; } } } this.Candidates.Clear(); this.Candidates.CopyFrom(candidates); this.Candidates.Distinct((a1, a2) => string.Compare(a1.User.ID, a2.User.ID, true) == 0 && a1.AssigneeType == a2.AssigneeType); }
public static IWfProcess StartWorkflow(WfProcessStartupParams startupParams) { startupParams.NullCheck <WfRuntimeException>("startupParams"); WfProcess process = new WfProcess(startupParams.ProcessDescriptor); FillProcessDescriptorProperties(startupParams, process.Descriptor); FillProcessInstanceProperties(startupParams, process); WfProcessContextCache.Instance.Add(process.ID, process); if (process.Creator == null && DeluxePrincipal.IsAuthenticated) { process.Creator = DeluxeIdentity.CurrentUser; } if (process.InitialActivity != null) { if (process.InitialActivity.Descriptor.Properties.GetValue("AutoGenerateCadidates", true)) { process.InitialActivity.GenerateCandidatesFromResources(); WfMatrix matrix = process.GetMatrix(); if (matrix != null) { ((WfActivityBase)process.InitialActivity).GenerateCandidatesFromMatrix(matrix); } } if (startupParams.CheckStartProcessUserPermission) { CheckStartProcessUserPermission(process); } if (startupParams.Assignees.Count == 0) { startupParams.Assignees.CopyFrom(process.InitialActivity.Candidates); } if (process.InitialActivity.Descriptor.Resources.Count == 0) { startupParams.Assignees.ToUsers().ForEach(u => process.InitialActivity.Descriptor.Resources.Add(new WfUserResourceDescriptor(u))); } WfSimulator.WriteSimulationInfo(process, WfSimulationOperationType.Startup); //如果自动启动第一个活动且存在活动点,则流转到第一个点 if (startupParams.AutoStartInitialActivity) { WfAssigneeCollection assignees = startupParams.Assignees; process.InitialActivity.Candidates.Clear(); process.InitialActivity.Candidates.CopyFrom(startupParams.Assignees); IWfActivity originalInitial = process.InitialActivity; WfRuntime.DecorateProcess(process); //修饰流程后,如果起始点发生了变化... if (originalInitial != process.InitialActivity) { assignees = process.InitialActivity.Candidates; } WfTransferParams transferParams = new WfTransferParams(process.InitialActivity.Descriptor); //设置初始节点子流程参数 process.InitialActivity.Descriptor.BranchProcessTemplates.ForEach(branchTemplate => { transferParams.BranchTransferParams.Add(new WfBranchProcessTransferParams(branchTemplate)); }); transferParams.Operator = startupParams.Creator; transferParams.Assignees.CopyFrom(assignees); process.MoveTo(transferParams); WfRuntime.ProcessContext.NormalizeTaskTitles(); } } WfRuntime.ProcessContext.AffectedProcesses.AddOrReplace(process); return(process); }
public WfAddApproverExecutor(IWfActivity operatorActivity, IWfActivity targetActivity, WfAssigneeCollection assignees) : base(operatorActivity, targetActivity, WfControlOperationType.AddApprover) { assignees.NullCheck("assingees"); this.Assignees.CopyFrom(assignees); }
private static bool IsUserInAssignees(string userID, WfAssigneeCollection currentActivityAssignees) { return(currentActivityAssignees.Exists(a => string.Compare(a.User.ID, userID, true) == 0)); }