//得到组里的用户 public static NameCollection GetTaskUsers(string group) { NameCollection taskUsers = new NameCollection(); List<string> groupUsers = null; groupUsers = WorkFlowUtil.UserListInGroup(group); taskUsers.AddRange(groupUsers.ToArray()); return taskUsers; }
private void StartWorkflowButton_Executing(object sender, CancelEventArgs e) { WorkflowContext context = WorkflowContext.Current; WorkflowDataFields fields = context.DataFields; context.UpdateWorkflowVariable("UploadBillTaskTitle", "Please upload credit card e-statement"); context.UpdateWorkflowVariable("UploadBillTaskFormURL","/_Layouts/CA/WorkFlows/CreditCardClaim/UploadExcelBill.aspx"); var taskUsers = new NameCollection(); List<string> groupUsers = null; groupUsers = WorkFlowUtil.UserListInGroup(WorkflowGroupName.WF_FinanceConfirm); taskUsers.AddRange(groupUsers.ToArray()); ReturnAllApproversSP("TaskUsers", groupUsers.ToArray()); context.UpdateWorkflowVariable("UploadBillTaskUsers", taskUsers); }
void actions_ActionExecuting(object sender, QuickFlow.UI.Controls.ActionEventArgs e) { //SPFieldUserValueCollection col = WorkFlowUtil.GetApproversValue(); //WorkflowContext.Current.DataFields["Approvers"] = col; //添加审批人 AddWorkFlowStepApprovers(WorkflowContext.Current.Task.Step, WorkFlowStep.SupplierReticketingApprovers, WorkFlowStep.SupplierReticketingApproverLoginName); switch (WorkflowContext.Current.Task.Step) { case WorkFlowStep.SupplierReticketingBuyingApprove: WorkflowContext.Current.UpdateWorkflowVariable(WorkFlowStep.SupplierReticketingDepartmentHead, GetDelemanNameCollection(new NameCollection(WorkFlowUtil.GetUserInGroup("wf_BSSHead")), Constants.CAModules.SupplierReTicketingCharge)); break; case WorkFlowStep.SupplierReticketingDepartmentHeadApproval: List<string> strGroupUser = WorkFlowUtil.UserListInGroup("wf_Finance_SR"); NameCollection GroupUsers = new NameCollection(); GroupUsers.AddRange(strGroupUser.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable(WorkFlowStep.SupplierReticketingFinanceTaskUsers, GetDelemanNameCollection(GroupUsers, Constants.CAModules.SupplierReTicketingCharge)); break; } WorkFlowUtil.UpdateWorkflowPath(WorkflowContext.Current); }
private void StartWorkflowButton_Executing(object sender, CancelEventArgs e) { string taskTitle = string.Empty; WorkflowContext context = WorkflowContext.Current; WorkflowDataFields fields = WorkflowContext.Current.DataFields; //Check which button has been clicked var btn = sender as StartWorkflowButton; context.UpdateWorkflowVariable("IsSubmit", true); #region Set users for workflow var manager = new NameCollection(); List<string> groupUsers = WorkFlowUtil.UserListInGroup("wf_IT"); manager.AddRange(groupUsers.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("ApproveTaskUsers", manager); #endregion //Set NextApproveTask title for workflow taskTitle = "DEMO Workflow"; context.UpdateWorkflowVariable("ApproveTaskTitle", taskTitle + "needs approval"); SPQuery query = new SPQuery(); query.Query = @"<OrderBy> <FieldRef Name='ID' Ascending='False' /> </OrderBy>"; fields["Title"] = WorkFlowUtil.CreateWorkFlowNumber("DEMO_"); #region Set page URL for workflow //Set page url var URL = "/_Layouts/CA/WorkFlows/demo/ApproveForm.aspx"; context.UpdateWorkflowVariable("ApproveTaskFormURL", URL); #endregion //"DEMO_" +(int.Parse( SPContext.Current.List.GetItems(query)[0]["ID"].AsString())+1); }
void StartWorkflowButton1_Executing(object sender, System.ComponentModel.CancelEventArgs e) { StartWorkflowButton btnStart = sender as StartWorkflowButton; if (string.Equals(btnStart.Text, "Save", StringComparison.CurrentCultureIgnoreCase)) { WorkflowContext.Current.UpdateWorkflowVariable("IsSave", true); DataForm1.Update(); WorkflowContext.Current.DataFields["Status"] = "NonSubmit"; } else { string msg = DataForm1.Validate(); if (!string.IsNullOrEmpty(msg)) { DisplayMessage(msg); e.Cancel = true; return; } WorkflowContext.Current.DataFields["Status"] = "In Progress"; } NameCollection buyingUsers = new NameCollection(); buyingUsers.Add(DataForm1.BuyingUser); WorkflowContext.Current.UpdateWorkflowVariable("BuyingApproveUsers", buyingUsers); WorkflowContext.Current.UpdateWorkflowVariable("BuyingApproveTaskTitle", DataForm1.Applicant.DisplayName + "'s re-ticketing request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHead", WorkFlowUtil.GetUserInGroup("wf_BSSHead")); List <string> strGroupUser = WorkFlowUtil.UserListInGroup("wf_Finance_SR"); if (strGroupUser.Count == 0) { //Don DisplayMessage("Unable to submit the application. There is no user in wf_Finance_SR group. Please contact IT for further help."); e.Cancel = true; return; } NameCollection GroupUsers = new NameCollection(); GroupUsers.AddRange(strGroupUser.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("FinanceTaskUsers", GroupUsers); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeadTaskTitle", DataForm1.Applicant.DisplayName + "'s re-ticketing request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("FinanceUserTaskTitle", "Please complete re-ticketing request for " + DataForm1.Applicant.DisplayName); this.WorkFlowNumber = CreateWorkFlowNumber(); WorkflowContext.Current.DataFields["WorkflowNumber"] = this.WorkFlowNumber; WorkflowContext.Current.DataFields["BuyingUser"] = DataForm1.BuyingUser; DataForm1.WorkflowNumber = this.WorkFlowNumber; WorkflowContext.Current.DataFields["FileName"] = DataForm1.Submit(); }
/// <summary> /// 更新工作流相关list中字段数据 /// </summary> /// <param name="dpTaskUsers">部门领导</param> private void UpdateWorkFlowDataFields(NameCollection dpTaskUsers) { WorkflowContext.Current.DataFields["Status"] = CAWorkflowStatus.InProgress; WorkflowContext.Current.DataFields["Manager"] = dpTaskUsers.Count > 0 ? dpTaskUsers[0] : ""; var DepartmentManagerTaskUsers = new NameCollection(); var FinanceAnalystTaskUsers = new NameCollection(); var CFOTaskUsers = new NameCollection(); DepartmentManagerTaskUsers.Add(UserProfileUtil.GetDepartmentManager(CurrentEmployee.Department)); List<string> lst = WorkFlowUtil.UserListInGroup("wf_CFO"); CFOTaskUsers.AddRange(lst.ToArray()); lst = WorkFlowUtil.UserListInGroup("wf_FinanceAnalyst_IO"); FinanceAnalystTaskUsers.AddRange(lst.ToArray()); //WorkflowContext.Current.UpdateWorkflowVariable("FinanceAnalystTaskUsers", FinanceAnalystTaskUsers); //WorkflowContext.Current.UpdateWorkflowVariable("CFOTaskUsers", CFOTaskUsers); //WorkflowContext.Current.UpdateWorkflowVariable("DepartmentManagerTaskUsers", DepartmentManagerTaskUsers); System.Text.StringBuilder strStepAndUsers = new System.Text.StringBuilder(); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.InternalOrderMaintenanceDepartmentManagerTask, DepartmentManagerTaskUsers.JoinString(",")); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.InternalOrderMaintenanceCFOTask, CFOTaskUsers.JoinString(",")); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.InternalOrderMaintenanceFinanceAnalystTask, FinanceAnalystTaskUsers.JoinString(",")); WorkflowContext.Current.DataFields["WorkFlowStepsAndUsers"] = strStepAndUsers.ToString(); }
//Return task users object according to special group public static NameCollection GetTaskUsers(string group, string moduleId) { var taskUsers = new NameCollection(); List<string> delemans = null; List<string> groupUsers = null; groupUsers = WorkFlowUtil.UserListInGroup(group); taskUsers.AddRange(groupUsers.ToArray()); delemans = WorkFlowUtil.GetDelemans(groupUsers, moduleId); //if (delemans.Count > 0) //{ // taskUsers.AddRange(delemans.ToArray()); //} foreach (var delegateAccount in delemans) { // Need to check whether the delegate account is valid. if (UserProfileUtil.GetEmployeeEx(delegateAccount) != null) { taskUsers.Add(delegateAccount); } } return taskUsers; }
void StartWorkflowButton1_Executing(object sender, System.ComponentModel.CancelEventArgs e) { bool flag = IsCanSubmit(); if (!flag) { ScriptManager.RegisterStartupScript(this,this.GetType(),"msg", "alert('You do not belong to Buying .');",true); e.Cancel = true; return; } StartWorkflowButton btn = sender as StartWorkflowButton; if (string.Equals(btn.Text, "Save", StringComparison.CurrentCultureIgnoreCase)) { WorkflowContext.Current.UpdateWorkflowVariable("IsSave", true); WorkflowContext.Current.DataFields["Flag"] = "Save"; WorkflowContext.Current.DataFields["RequestStatus"] = "NonSubmit"; } else { WorkflowContext.Current.UpdateWorkflowVariable("IsSave", false); WorkflowContext.Current.DataFields["Flag"] = "Submit"; WorkflowContext.Current.DataFields["RequestStatus"] = "In Progress"; } string strDepartment = DataForm1.Applicant.Department; //string strManager = @"ca\ztao"; //string strDirector = @"ca\ztao"; //string strHead = @"ca\ztao"; //string strBBSTeam = @"ca\ztao"; string strMondial = this.DataForm1.IsMondia; //组开始 //List<string> lst = WorkFlowUtil.UserListInGroup("DivisionManagerGroup"); string Head = WorkFlowUtil.GetEmployeeApproverInDept(DataForm1.Applicant, true, true).UserAccount; NameCollection ManagerUser = new NameCollection(); NameCollection DirectorUser = new NameCollection(); bool isHeadOne = false; bool isHeadTwo = false; if (!string.IsNullOrEmpty(Head)) { isHeadOne = true; ManagerUser.Add(Head); Employee employee = WorkFlowUtil.GetEmployeeApproverInDept(WorkFlowUtil.GetEmployeeApproverInDept(DataForm1.Applicant, true, true), true, false); if (employee != null) { string strhead = employee.UserAccount; if (!string.IsNullOrEmpty(strhead)) { isHeadTwo = true; DirectorUser.Add(strhead); } } } //lst = WorkFlowUtil.UserListInGroup("BuyingDirectorGroup"); //DirectorUser.AddRange(lst.ToArray()); //DirectorUser.Add(strDirector); NameCollection HeadUser = new NameCollection(); List<string> lst = WorkFlowUtil.UserListInGroup("wf_CommercialHead"); HeadUser.AddRange(lst.ToArray()); //HeadUser.Add(strHeader); NameCollection BBSTeamUser = new NameCollection(); lst = WorkFlowUtil.UserListInGroup("wf_BSSTeam"); BBSTeamUser.AddRange(lst.ToArray()); //BBSTeamUser.Add(strBBSTeam); //组结束 WorkflowContext.Current.UpdateWorkflowVariable("Manager", ManagerUser); WorkflowContext.Current.UpdateWorkflowVariable("BuyDirector", DirectorUser); WorkflowContext.Current.UpdateWorkflowVariable("Header", HeadUser); WorkflowContext.Current.UpdateWorkflowVariable("BBSTeamAccount", BBSTeamUser); WorkflowContext.Current.UpdateWorkflowVariable("Mondial", strMondial); WorkflowContext.Current.UpdateWorkflowVariable("isHeadOne", isHeadOne); WorkflowContext.Current.UpdateWorkflowVariable("isHeadTwo", isHeadTwo); //修改TaskTitle WorkflowContext.Current.UpdateWorkflowVariable("ManagerTitle", DataForm1.Applicant.DisplayName + "'s New Trade Supplier Creation request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("DirectorTitle", DataForm1.Applicant.DisplayName + "'s New Trade Supplier Creation request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("HeaderTitle", DataForm1.Applicant.DisplayName + "'s New Trade Supplier Creation request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("BBSTeamTitle", DataForm1.Applicant.DisplayName + "'s New Trade Supplier Creation request needs confirm"); WorkflowContext.Current.UpdateWorkflowVariable("TaskUpdateTitle", "Please complete New Trade Supplier Creation request for " + DataForm1.Applicant.DisplayName); //修改结束 this.WorkFlowNumber = CreateWorkFlowNumber(); WorkflowContext.Current.DataFields["WorkFlowNumber"] = this.WorkFlowNumber; WorkflowContext.Current.DataFields["UserName"] = DataForm1.Applicant.UserAccount; WorkflowContext.Current.DataFields["Supplier"] = DataForm1.Supplier; WorkflowContext.Current.DataFields["SubDivision"] = DataForm1.SubDivision; WorkflowContext.Current.DataFields["IsMondial"] = DataForm1.IsMondia; //WorkflowContext.Current.DataFields["Upload"] = DataForm1.UploadFile; WorkflowContext.Current.DataFields["Status"] = DataForm1.Status; }
private void Actions_ActionExecuting(object sender, ActionEventArgs e) { WorkflowContext context = WorkflowContext.Current; WorkflowDataFields fields = WorkflowContext.Current.DataFields; switch (WorkflowContext.Current.Step) { case "DMMTask": if (e.Action.Equals("Approve", StringComparison.CurrentCultureIgnoreCase)) { NameCollection wf_NTSC_QM = new NameCollection(); List<string> qm = WorkFlowUtil.UserListInGroup(NewProductionUnitCreationConstants.wf_NTSC_QM); wf_NTSC_QM.AddRange(qm.ToArray()); fields["CurrManager"] = qm.ToArray(); context.UpdateWorkflowVariable("NextApproveTaskUsers", GetDelemanNameCollection(wf_NTSC_QM, WorkFlowUtil.GetModuleIdByListName("New Production Unit Creation"))); } else { fields["Status"] = CAWorkflowStatus.Rejected; context.UpdateWorkflowVariable("CompleteTaskTitle", "Please resubmit New Production Unit Creation"); } break; case "QMTask": if (e.Action.Equals("Approve", StringComparison.CurrentCultureIgnoreCase)) { NameCollection wf_NTSC_SCM = new NameCollection(); List<string> scm = WorkFlowUtil.UserListInGroup(NewProductionUnitCreationConstants.wf_NTSC_SCM); wf_NTSC_SCM.AddRange(scm.ToArray()); fields["CurrManager"] = scm.ToArray(); context.UpdateWorkflowVariable("NextApproveTaskUsers", GetDelemanNameCollection(wf_NTSC_SCM, WorkFlowUtil.GetModuleIdByListName("New Production Unit Creation"))); } else { fields["Status"] = CAWorkflowStatus.Rejected; context.UpdateWorkflowVariable("CompleteTaskTitle", "Please resubmit New Production Unit Creation"); } break; case "SCMTask": if (e.Action.Equals("Approve", StringComparison.CurrentCultureIgnoreCase)) { NameCollection wf_NTSC_SCMM = new NameCollection(); List<string> scmm = WorkFlowUtil.UserListInGroup(NewProductionUnitCreationConstants.wf_NTSC_SCMM); wf_NTSC_SCMM.AddRange(scmm.ToArray()); fields["CurrManager"] = scmm.ToArray(); context.UpdateWorkflowVariable("NextApproveTaskUsers", GetDelemanNameCollection(wf_NTSC_SCMM, WorkFlowUtil.GetModuleIdByListName("New Production Unit Creation"))); //string taskTitle = string.Format("{0} {1} {2}'s New Production Unit Creation needs confirm" // , fields["WorkFlowNumber"].AsString() // , fields["SupplierName"].AsString() // , fields["Applicant"].AsString()); string taskTitle = string.Format("{0} {1}'s New Production Unit Creation needs confirm" , fields["WorkFlowNumber"].AsString() , fields["Applicant"].AsString()); context.UpdateWorkflowVariable("NextApproveTaskTitle", taskTitle); } else { fields["Status"] = CAWorkflowStatus.Rejected; context.UpdateWorkflowVariable("CompleteTaskTitle", "Please resubmit New Production Unit Creation"); } break; case "SCMConfirmTask": if (e.Action.Equals("Confirm", StringComparison.CurrentCultureIgnoreCase)) { fields["Status"] = CAWorkflowStatus.Completed; } else { fields["Status"] = CAWorkflowStatus.Rejected; context.UpdateWorkflowVariable("CompleteTaskTitle", "Please resubmit New Production Unit Creation"); } break; } AddWorkFlowStepApprovers(WorkflowContext.Current.Task.Step, "ApproversSPUser", "Approvers"); WorkFlowUtil.UpdateWorkflowPath(WorkflowContext.Current); }
void SaveFormToWf() { WorkflowContext curContext = WorkflowContext.Current; string passTo = DataForm1.PickedBy; //DateTime now = DateTime.Now; WorkflowDataFields fields = WorkflowContext.Current.DataFields; string taskTitle = SPContext.Current.Web.CurrentUser.Name + "'s Store Sampling"; fields["Store Number"] = ((DropDownList)DataForm1.FindControl("ddlStoreNumber")).SelectedValue; //((TextBox)DataForm1.FindControl("txtStoreNumber")).Text; fields["Cost Center"] = string.Empty; fields["Issued to"] = ((DropDownList)DataForm1.FindControl("ddlIssuedTo")).SelectedValue; fields["Actual Quantity"] = ((TextBox)DataForm1.FindControl("txtActualQuantity")).Text; if (!string.IsNullOrEmpty(passTo)) { //fields["Picked by"] = EnsureUser(passTo); //fields["Picked by"] = web.EnsureUser(passTo); //try //{ // fields["Picked by"] = web.SiteUsers[passTo]; //} //catch { //} fields["Picked by"] = web.SiteUsers[passTo]; } fields["Picked Time"] = ((CADateTimeControl)DataForm1.FindControl("CADateTime1")).SelectedDate.ToShortDateString(); DataForm1.WorkflowNumber = CreateWorkflowNumber(); fields["WorkflowNumber"] = DataForm1.WorkflowNumber; fields["FileName"] = DataForm1.Submit(); curContext.UpdateWorkflowVariable("StoreAdminSubmitTitle", "Please complete store sampling"); curContext.UpdateWorkflowVariable("BuyerApproveTitle", taskTitle + " needs confirm"); curContext.UpdateWorkflowVariable("StoreManagerApproveTitle", taskTitle + " needs approval"); curContext.UpdateWorkflowVariable("AreaManagerApproveTitle", taskTitle + " needs approval"); curContext.UpdateWorkflowVariable("BSSHeadGroupApproveTitle", taskTitle + " needs approval"); curContext.UpdateWorkflowVariable("BSSTeamTitle", taskTitle + " needs approval"); curContext.UpdateWorkflowVariable("FinanceGroupConfirmTitle", taskTitle + " needs confirm"); ISharePointService sps = ServiceFactory.GetSharePointService(true, SPContext.Current.Site.RootWeb); SPList stores = sps.GetList("Stores"); QueryField field = new QueryField("Store Number", false); SPListItemCollection coll = sps.Query(stores, field.Equal(fields["Store Number"] + ""), 1); if (coll.Count > 0) { curContext.UpdateWorkflowVariable("StoreManager", new SPFieldLookupValue(coll[0]["Manager"] + "").LookupValue); curContext.UpdateWorkflowVariable("AreaManagerApproveUser", new SPFieldLookupValue(coll[0]["AreaManager"]+"").LookupValue); } else { return; } curContext.UpdateWorkflowVariable("Buyer", passTo); curContext.UpdateWorkflowVariable("BSSHeadGroup", "wf_BSSHead"); NameCollection BBSTeamUser = new NameCollection(); List<string> lst = WorkFlowUtil.UserListInGroup("wf_NSC"); BBSTeamUser.AddRange(lst.ToArray()); curContext.UpdateWorkflowVariable("BSSTeamAccount", BBSTeamUser); curContext.UpdateWorkflowVariable("FinanceGroup", "wf_Finance_SS"); }
void StartWorkflowButton1_Executing(object sender, System.ComponentModel.CancelEventArgs e) { StartWorkflowButton btnStart = sender as StartWorkflowButton; if (string.Equals(btnStart.Text, "Save", StringComparison.CurrentCultureIgnoreCase)) { WorkflowContext.Current.UpdateWorkflowVariable("IsSave", true); DataForm1.Update(); } else { string msg = DataForm1.Validate(); if (!string.IsNullOrEmpty(msg)) { DisplayMessage(msg); e.Cancel = true; return; } Employee approver = WorkFlowUtil.GetEmployeeApprover(DataForm1.Applicant); if (approver == null) { DisplayMessage("Unable to find an approver for the applicant. Please contact IT for further help."); e.Cancel = true; return; } List<string> list = WorkFlowUtil.UserListInGroup("wf_Reception"); if (list.Count > 1) { DisplayMessage("Unable to submit the application. More than one receptionist is defined. Please contact IT for further help."); e.Cancel = true; return; } //验证组里用户是否为空 if(list.Count==0) { DisplayMessage("Unable to submit the application. There is no user in wf_Reception group. Please contact IT for further help."); e.Cancel = true; return; } string deptHead = approver.UserAccount; WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHead", deptHead); NameCollection names = new NameCollection(); if (DataForm1.radiobuttonYes && DataForm1.RadioYes) { names.AddRange(list.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } else if (DataForm1.radiobuttonYes && DataForm1.RadioNo) { if (IsReceptionist(DataForm1.btApplicant1)) { names.AddRange(list.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } else { names.AddRange(list.ToArray()); names.Add(DataForm1.btApplicant1); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "no"; } } else if (DataForm1.radiobuttonYes && DataForm1.RadioDisplay) { names.AddRange(list.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } else if (DataForm1.radiobuttonNO && DataForm1.RadioYes) { if (IsReceptionist(DataForm1.btUser1)) { names.AddRange(list.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } else { names.AddRange(list.ToArray()); names.Add(DataForm1.btUser1); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "no"; } } else if (DataForm1.radiobuttonNO && DataForm1.RadioNo) { if (DataForm1.btUser1.Equals(DataForm1.btApplicant1, StringComparison.CurrentCultureIgnoreCase)) { names.Add(DataForm1.btUser1); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } else { names.Add(DataForm1.btUser1); names.Add(DataForm1.btApplicant1); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "no"; } } else if (DataForm1.radiobuttonNO && DataForm1.RadioDisplay) { names.Add(DataForm1.btUser1); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } //List<string> strGroupUsers = WorkFlowUtil.UserListInGroup("wf_Reception"); //NameCollection names = new NameCollection(); //names.AddRange(strGroupUsers.ToArray()); //WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeadTaskTitle", DataForm1.Applicant.DisplayName + "'s travel request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistTaskTitle", "Please complete travel request for " + DataForm1.Applicant.DisplayName); WorkflowContext.Current.DataFields["Status"] = "InProgress"; } this.WorkFlowNumber = CreateWorkFlowNumber(); WorkflowContext.Current.DataFields["WorkflowNumber"] = this.WorkFlowNumber; WorkflowContext.Current.DataFields["UserName"] = DataForm1.Applicant.UserAccount; WorkflowContext.Current.DataFields["EnglishName"] = DataForm1.Applicant.DisplayName; WorkflowContext.Current.DataFields["Department"] = DataForm1.Applicant.Department; WorkflowContext.Current.DataFields["JobTitle"] = DataForm1.Applicant.Title; WorkflowContext.Current.DataFields["Status"] = "InProgress"; WorkflowContext.Current.DataFields["AirNotes"] = DataForm1.AirNotes; WorkflowContext.Current.DataFields["HotelNotes"] = DataForm1.HotelNotes; bool bol = DataForm1.RadioYes; WorkflowContext.Current.DataFields["RadioYes"] = bol.ToString(); if (DataForm1.radiobuttonNO) { WorkflowContext.Current.DataFields["btUser"] = DataForm1.btUser1; } else { WorkflowContext.Current.DataFields["btUser"] = string.Empty; ; } if (DataForm1.RadioNo) { WorkflowContext.Current.DataFields["btApplicant"] = DataForm1.btApplicant1; } else { WorkflowContext.Current.DataFields["btApplicant"] = string.Empty; ; } }
void actions_ActionExecuting(object sender, QuickFlow.UI.Controls.ActionEventArgs e) { WorkflowContext curContext = WorkflowContext.Current; WorkflowDataFields fields = curContext.DataFields; fields["Status"] = "In Progress"; ISharePointService sps = ServiceFactory.GetSharePointService(true, SPContext.Current.Site.RootWeb); SPList stores = sps.GetList("Stores"); QueryField field = new QueryField("Store Number", false); SPListItemCollection coll = sps.Query(stores, field.Equal(fields["Store Number"] + ""), 1); switch (curContext.Task.Step) { case "BuyerApprove": if (coll.Count > 0) { WorkflowContext.Current.UpdateWorkflowVariable(WorkFlowStep.StoreSamplingStoreManager, GetDelemanNameCollection(new NameCollection(new SPFieldLookupValue(coll[0]["Manager"] + "").LookupValue), Constants.CAModules.StoreSampling)); } //fields["Approvers"] = WorkFlowUtil.GetApproversValue(); AddWorkFlowStepApprovers(WorkflowContext.Current.Task.Step, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApprovers, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApproverLoginName); break; case "StoreManagerApprove": if (coll.Count > 0) { WorkflowContext.Current.UpdateWorkflowVariable(WorkFlowStep.StoreSamplingAreaManagerApproveUser, GetDelemanNameCollection(new NameCollection(new SPFieldLookupValue(coll[0]["AreaManager"] + "").LookupValue), Constants.CAModules.StoreSampling)); } //fields["Approvers"] = WorkFlowUtil.GetApproversValue(); AddWorkFlowStepApprovers(WorkflowContext.Current.Task.Step, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApprovers, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApproverLoginName); break; case "AreaManagerApprove": //fields["Approvers"] = WorkFlowUtil.GetApproversValue(); NameCollection bSSHead = WorkFlowUtil.GetUsersInGroup("wf_BSSHead"); WorkflowContext.Current.UpdateWorkflowVariable(WorkFlowStep.StoreSamplingBSSHeadGroup, GetDelemanNameCollection(bSSHead, Constants.CAModules.StoreSampling)); AddWorkFlowStepApprovers(WorkflowContext.Current.Task.Step, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApprovers, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApproverLoginName); break; case "BSSHeadApprove": //fields["Approvers"] = WorkFlowUtil.GetApproversValue(); NameCollection BBSTeamUser = new NameCollection(); List<string> lst = WorkFlowUtil.UserListInGroup("wf_NSC"); BBSTeamUser.AddRange(lst.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable(WorkFlowStep.StoreSamplingBSSTeamAccount, GetDelemanNameCollection(BBSTeamUser, Constants.CAModules.StoreSampling)); AddWorkFlowStepApprovers(WorkflowContext.Current.Task.Step, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApprovers, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApproverLoginName); break; case "BSSTeamApprove": if(e.Action=="Approve") { if (string.IsNullOrEmpty(((DropDownList)DataForm1.FindControl("ddlCostCenter")).SelectedValue)&&string.IsNullOrEmpty(DataForm1.TextBoxCostCenter)) { e.Cancel = true; ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "alert('Please supply a cost center.');", true); DataForm1.PickedBy = new SPFieldLookupValue(SPContext.Current.ListItem["Picked by"] + "").LookupValue; ((CADateTimeControl)DataForm1.FindControl("CADateTime1")).Enabled = false; return; } if (string.IsNullOrEmpty(((DropDownList)DataForm1.FindControl("ddlCostCenter")).SelectedValue)) { fields["Cost Center"] = DataForm1.TextBoxCostCenter; } else { fields["Cost Center"] = ((DropDownList)DataForm1.FindControl("ddlCostCenter")).SelectedValue; } } //fields["Approvers"] = WorkFlowUtil.GetApproversValue(); NameCollection finance_SS = WorkFlowUtil.GetUsersInGroup("wf_Finance_SS"); WorkflowContext.Current.UpdateWorkflowVariable(WorkFlowStep.StoreSamplingFinanceGroup, GetDelemanNameCollection(finance_SS, Constants.CAModules.StoreSampling)); AddWorkFlowStepApprovers(WorkflowContext.Current.Task.Step, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApprovers, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApproverLoginName); break; case "FinanceConfirm": // if (e.Action == "Approve") if(e.Action=="Confirm") { fields["Status"] = "Completed"; fields["Completed Date"] = System.DateTime.Now.ToShortDateString(); } //fields["Approvers"] = WorkFlowUtil.GetApproversValue(); AddWorkFlowStepApprovers(WorkflowContext.Current.Task.Step, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApprovers, CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingApproverLoginName); break; case "StoreAdminSubmit": if (e.Action.Equals("End", StringComparison.CurrentCultureIgnoreCase)) { WorkflowContext.Current.DataFields["Status"] = "Cancelled"; return; } string msg = DataForm1.Validate(); if (!string.IsNullOrEmpty(msg)) { DisplayMessage(msg); e.Cancel = true; return; } string passTo = DataForm1.PickedBy; fields["Store Number"] = ((DropDownList)DataForm1.FindControl("ddlStoreNumber")).SelectedValue; //((TextBox)DataForm1.FindControl("txtStoreNumber")).Text; fields["Cost Center"] = string.Empty; fields["Issued to"] = ((DropDownList)DataForm1.FindControl("ddlIssuedTo")).SelectedValue; if (!string.IsNullOrEmpty(passTo)) { fields["Picked by"] = EnsureUser(passTo); } //fields["Comments"] = ((TextBox)DataForm1.FindControl("txtComments")).Text; fields["FileName"] = DataForm1.Submit(); //curContext.UpdateWorkflowVariable("Buyer", passTo); WorkflowContext.Current.UpdateWorkflowVariable(CA.WorkFlow.UI.Constants.WorkFlowStep.StoreSamplingBuyer, GetDelemanNameCollection(new NameCollection(passTo), Constants.CAModules.StoreSampling)); break; } WorkFlowUtil.UpdateWorkflowPath(WorkflowContext.Current); }
/// <summary> /// 更新工作流相关list中字段数据 /// </summary> /// <param name="dpTaskUsers">部门领导</param> /// <param name="isSave">是否为保存数据状态</param> private void UpdateWorkFlowDataFields(NameCollection dpTaskUsers, bool isSave) { double lastValue = DataForm1.GetLastValue(WorkflowContext.Current.DataFields["Order Number"].ToString()); WorkflowContext.Current.DataFields["Last Value"] = lastValue; WorkflowContext.Current.DataFields["Status"] = isSave ? CAWorkflowStatus.Pending : CAWorkflowStatus.InProgress; WorkflowContext.Current.DataFields["WorkFlowNumber"] = CreateWorkflowNumber(); WorkflowContext.Current.DataFields["Applicant"] = CurrentEmployee.DisplayName + "(" + CurrentEmployee.UserAccount + ")"; WorkflowContext.Current.DataFields["Department"] = CurrentEmployee.Department; WorkflowContext.Current.DataFields["Manager"] = dpTaskUsers.Count > 0 ? dpTaskUsers[0] : ""; var DepartmentManagerTaskUsers = new NameCollection(); var FinanceAnalystTaskUsers = new NameCollection(); var CFOTaskUsers = new NameCollection(); DepartmentManagerTaskUsers.Add(UserProfileUtil.GetDepartmentManager(CurrentEmployee.Department)); List<string> lst = WorkFlowUtil.UserListInGroup("wf_CFO"); CFOTaskUsers.AddRange(lst.ToArray()); lst = WorkFlowUtil.UserListInGroup("wf_FinanceAnalyst_IO"); FinanceAnalystTaskUsers.AddRange(lst.ToArray()); //WorkflowContext.Current.UpdateWorkflowVariable("FinanceAnalystTaskUsers", FinanceAnalystTaskUsers); //WorkflowContext.Current.UpdateWorkflowVariable("CFOTaskUsers", CFOTaskUsers); //WorkflowContext.Current.UpdateWorkflowVariable("DepartmentManagerTaskUsers", DepartmentManagerTaskUsers); System.Text.StringBuilder strStepAndUsers = new System.Text.StringBuilder(); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.InternalOrderMaintenanceDepartmentManagerTask, DepartmentManagerTaskUsers.JoinString(",")); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.InternalOrderMaintenanceCFOTask, CFOTaskUsers.JoinString(",")); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.InternalOrderMaintenanceFinanceAnalystTask, FinanceAnalystTaskUsers.JoinString(",")); WorkflowContext.Current.DataFields["WorkFlowStepsAndUsers"] = strStepAndUsers.ToString(); }
//Save or Submit private void StartWorkflowButton_Executing(object sender, CancelEventArgs e) { string taskTitle = CurrentEmployee.DisplayName + "'s Non-Trade Supplier Setup & Maintenance "; var manager = UserProfileUtil.GetDepartmentManager(CurrentEmployee.Department); if (manager.IsNullOrWhitespace()) { DisplayMessage("The department manager is not set in the system."); e.Cancel = true; return; } else if (manager.Equals(CurrentEmployee.UserAccount, StringComparison.CurrentCultureIgnoreCase)) { var managerEmp = WorkFlowUtil.GetEmployeeApprover(CurrentEmployee); if (managerEmp == null) { DisplayMessage("The manager is not set in the system."); e.Cancel = true; return; } manager = managerEmp.UserAccount; } //Check which button has been clicked var btn = sender as StartWorkflowButton; if (string.Equals(btn.Text, "Save", StringComparison.CurrentCultureIgnoreCase)) { WorkflowContext.Current.UpdateWorkflowVariable("IsSave", true); WorkflowContext.Current.DataFields["Status"] = CAWorkflowStatus.Pending; } else { if (!this.DataForm1.Validate()) { DisplayMessage(this.DataForm1.msg.IsNotNullOrWhitespace() ? this.DataForm1.msg : "Please fill in all the necessary fields."); e.Cancel = true; return; } this.DataForm1.UpdateValues(); WorkflowContext.Current.UpdateWorkflowVariable("IsSave", false); WorkflowContext.Current.DataFields["Status"] = CAWorkflowStatus.InProgress; //Update varivable.(Payment term less than 30 days required CFO's special approval) WorkflowContext.Current.UpdateWorkflowVariable("PaymentTerm", this.DataForm1.PaymentTerm); } WorkflowContext.Current.DataFields["WorkFlowNumber"] = CreateWorkflowNumber(); WorkflowContext.Current.DataFields["Applicant"] = CurrentEmployee.DisplayName + "(" + CurrentEmployee.UserAccount + ")"; WorkflowContext.Current.DataFields["DepartmentVal"] = CurrentEmployee.Department; #region Set title for workflow //Modify task title WorkflowContext.Current.UpdateWorkflowVariable("CompleteTaskTitle", "please complete Supplier Setup & Maintenance"); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeadTaskTitle", taskTitle + "needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("MDMTaskTitle", taskTitle + "needs confirm"); WorkflowContext.Current.UpdateWorkflowVariable("CFOTaskTitle", taskTitle + "needs approval"); #endregion #region Set users for workflow //Modify task users var DepartmentHeadTaskUsers = new NameCollection(); var MDMTaskUsers = new NameCollection(); var CFOTaskUsers = new NameCollection(); DepartmentHeadTaskUsers.Add(manager); List<string> lst = WorkFlowUtil.UserListInGroup("wf_CFO"); CFOTaskUsers.AddRange(lst.ToArray()); lst = WorkFlowUtil.UserListInGroup("wf_Finance_MDM"); MDMTaskUsers.AddRange(lst.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeadTaskUsers", DepartmentHeadTaskUsers); WorkflowContext.Current.UpdateWorkflowVariable("MDMTaskUsers", MDMTaskUsers); WorkflowContext.Current.UpdateWorkflowVariable("CFOTaskUsers", CFOTaskUsers); #endregion #region Set page URL for workflow //Set page url var editURL = "/_Layouts/CA/WorkFlows/NonTradeSupplierSetupMaintenance/EditForm.aspx"; var approveURL = "/_Layouts/CA/WorkFlows/NonTradeSupplierSetupMaintenance/ApproveForm.aspx"; WorkflowContext.Current.UpdateWorkflowVariable("CompleteTaskFormURL", editURL); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeadTaskFormURL", approveURL); WorkflowContext.Current.UpdateWorkflowVariable("MDMTaskFormURL", approveURL); WorkflowContext.Current.UpdateWorkflowVariable("CFOTaskFormURL", approveURL); #endregion }
void StartWorkflowButton1_Executing(object sender, System.ComponentModel.CancelEventArgs e) { StartWorkflowButton btnStart = sender as StartWorkflowButton; if (string.Equals(btnStart.Text, "Save", StringComparison.CurrentCultureIgnoreCase)) { WorkflowContext.Current.UpdateWorkflowVariable("IsSave", true); DataForm1.Update(); WorkflowContext.Current.DataFields["Status"] = "NonSubmit"; } else { string msg = DataForm1.Validate(); if (!string.IsNullOrEmpty(msg)) { DisplayMessage(msg); e.Cancel = true; return; } WorkflowContext.Current.DataFields["Status"] = "In Progress"; } //WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHead", WorkFlowUtil.GetUserInGroup("wf_BSSHead")); List<string> strGroupUser = WorkFlowUtil.UserListInGroup("wf_Finance_SR"); if (strGroupUser.Count == 0) { //Don DisplayMessage("Unable to submit the application. There is no user in wf_Finance_SR. Please contact IT for further help."); e.Cancel = true; return; } NameCollection GroupUsers = new NameCollection(); GroupUsers.AddRange(strGroupUser.ToArray()); //WorkflowContext.Current.UpdateWorkflowVariable("FinanceTaskUsers", GroupUsers); System.Text.StringBuilder strStepAndUsers = new System.Text.StringBuilder(); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.SupplierReinspectionDepartmentHeadApproval, WorkFlowUtil.GetUserInGroup("wf_BSSHead")); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.SupplierReinspectionFinanceTask, GroupUsers.JoinString(",")); WorkflowContext.Current.DataFields["WorkFlowStepsAndUsers"] = strStepAndUsers.ToString(); WorkflowContext.Current.UpdateWorkflowVariable(CA.WorkFlow.UI.Constants.WorkFlowStep.SupplierReinspectionDepartmentHead, GetDelemanNameCollection(new NameCollection(WorkFlowUtil.GetUserInGroup("wf_BSSHead")), Constants.CAModules.SupplierReInspectionCharge)); WorkflowContext.Current.UpdateWorkflowVariable(CA.WorkFlow.UI.Constants.WorkFlowStep.SupplierReinspectionFinanceTaskUsers, GetDelemanNameCollection(GroupUsers, Constants.CAModules.SupplierReInspectionCharge)); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeadTaskTitle", DataForm1.Applicant.DisplayName + "'s re-inspection request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("FinanceUserTaskTitle", "Please complete re-inspection request for " + DataForm1.Applicant.DisplayName); this.WorkFlowNumber = CreateWorkFlowNumber(); WorkflowContext.Current.DataFields["WorkflowNumber"] = this.WorkFlowNumber; DataForm1.WorkflowNumber = this.WorkFlowNumber; WorkflowContext.Current.DataFields["FileName"] = DataForm1.Submit(); WorkFlowUtil.UpdateWorkflowPath(WorkflowContext.Current); }
/// <summary> /// 更新工作流相关list中字段数据 /// </summary> /// <param name="dpTaskUsers">部门领导</param> /// <param name="isSave">是否为保存数据状态</param> private void UpdateWorkFlowDataFields(NameCollection dpTaskUsers, bool isSave) { WorkflowContext.Current.DataFields["Status"] = isSave ? CAWorkflowStatus.Pending : CAWorkflowStatus.InProgress; WorkflowContext.Current.DataFields["WorkFlowNumber"] = CreateWorkflowNumber(); WorkflowContext.Current.DataFields["Applicant"] = CurrentEmployee.DisplayName + "(" + CurrentEmployee.UserAccount + ")"; WorkflowContext.Current.DataFields["DepartmentVal"] = CurrentEmployee.Department; WorkflowContext.Current.DataFields["Manager"] = dpTaskUsers.Count > 0 ? dpTaskUsers[0] : ""; //Update varivable.(Payment term less than 30 days required CFO's special approval) WorkflowContext.Current.DataFields["PaymentTerm"] = DataForm1.PaymentTerm; var DepartmentHeadTaskUsers = new NameCollection(); var MDMTaskUsers = new NameCollection(); var CFOTaskUsers = new NameCollection(); string department = CurrentEmployee.Department; DepartmentHeadTaskUsers.Add(UserProfileUtil.GetDepartmentManager(department)); List<string> lst = WorkFlowUtil.UserListInGroup("wf_CFO"); CFOTaskUsers.AddRange(lst.ToArray()); lst = WorkFlowUtil.UserListInGroup("wf_Finance_MDM"); MDMTaskUsers.AddRange(lst.ToArray()); //WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeadTaskUsers", DepartmentHeadTaskUsers); //WorkflowContext.Current.UpdateWorkflowVariable("MDMTaskUsers", MDMTaskUsers); //WorkflowContext.Current.UpdateWorkflowVariable("CFOTaskUsers", CFOTaskUsers); System.Text.StringBuilder strStepAndUsers = new System.Text.StringBuilder(); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.SupplierSetupMaintenanceDepartmentHeadTask, DepartmentHeadTaskUsers.JoinString(",")); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.SupplierSetupMaintenanceMDMTask, MDMTaskUsers.JoinString(",")); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.SupplierSetupMaintenanceCFOTask, CFOTaskUsers.JoinString(",")); WorkflowContext.Current.DataFields["WorkFlowStepsAndUsers"] = strStepAndUsers.ToString(); }
void actions_ActionExecuting(object sender, QuickFlow.UI.Controls.ActionEventArgs e) { if (e.Action.Equals("End", StringComparison.CurrentCultureIgnoreCase)) { WorkflowContext.Current.DataFields["Status"] = "Cancelled"; return; } string msg = DataForm1.Validate; if (!string.IsNullOrEmpty(msg)) { DisplayMessage(msg); e.Cancel = true; return; } //组开始 List<string> lst = WorkFlowUtil.UserListInGroup("wf_IT"); if (lst.Count == 0) { //Don DisplayMessage("Unable to submit the application. There is no user in wf_IT group. Please contact IT for further help."); e.Cancel = true; return; } NameCollection ItMemberUser = new NameCollection(); ItMemberUser.AddRange(lst.ToArray()); Employee approver = WorkFlowUtil.GetEmployeeApprover(DataForm1.Applicant); if (approver == null) { //Don DisplayMessage("Unable to find an approver for the applicant. Please contact IT for further help."); e.Cancel = true; return; } NameCollection DepartHeadUser = new NameCollection(); DepartHeadUser.Add(approver.UserAccount); NameCollection ITHeadUser = new NameCollection(); string strHRHeadAccount = UserProfileUtil.GetDepartmentManager("it"); ITHeadUser.Add(strHRHeadAccount); NameCollection CFOUser = new NameCollection(); lst = WorkFlowUtil.UserListInGroup("wf_CFO"); CFOUser.AddRange(lst.ToArray()); //组结束 try { WorkflowContext.Current.UpdateWorkflowVariable("ITMemberAccounts", ItMemberUser); WorkflowContext.Current.UpdateWorkflowVariable("DepartHeaderAccounts", DepartHeadUser); WorkflowContext.Current.UpdateWorkflowVariable("ITHeaderAccounts", ITHeadUser); WorkflowContext.Current.UpdateWorkflowVariable("FOCOAccounts", CFOUser); WorkflowContext.Current.UpdateWorkflowVariable("IsFOCO", false); WorkflowContext.Current.UpdateWorkflowVariable("ITMemberTitle", DataForm1.Applicant.DisplayName + "'s IT request needs confirm"); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeaderTitle", DataForm1.Applicant.DisplayName + "'s IT request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("ITHeaderTitle", DataForm1.Applicant.DisplayName + "'s IT request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("FOCOTitle", DataForm1.Applicant.DisplayName + "s 'IT request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("UpdateTaskTitle", "Please complete IT request for " + DataForm1.Applicant.DisplayName); WorkflowContext.Current.DataFields["Name"] = DataForm1.Name; WorkflowContext.Current.DataFields["Department"] = DataForm1.Department; WorkflowContext.Current.DataFields["FOCOApprove"] = DataForm1.IsFOCO; WorkflowContext.Current.DataFields["ApplyDate"] = DataForm1.ApplyDate; WorkflowContext.Current.DataFields["AppliedUser"] = this.DataForm1.Applicant.UserAccount; WorkflowContext.Current.DataFields["ReasonforRequest"] = this.DataForm1.ReasonforRequest; WorkflowContext.Current.DataFields["Flag"] = "Submit"; WorkflowContext.Current.DataFields["Status"] = "In Progress"; } catch (Exception ex) { throw ex; } }
private void UpdateWorkflow(QuickFlow.UI.Controls.ActionEventArgs e) { Employee approver = WorkFlowUtil.GetEmployeeApprover(DataForm1.Applicant); if (approver == null) { DisplayMessage("Unable to find an approver for the applicant. Please contact IT for further help."); e.Cancel = true; return; } List<string> list = WorkFlowUtil.UserListInGroup("wf_Reception"); if (list.Count > 1) { DisplayMessage("Unable to submit the application. More than one receptionist is defined. Please contact IT for further help."); e.Cancel = true; return; } string deptHead = approver.UserAccount; WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHead", deptHead); NameCollection names = new NameCollection(); if (DataForm1.radiobuttonYes && DataForm1.RadioYes) { names.AddRange(list.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } else if (DataForm1.radiobuttonYes && DataForm1.RadioNo) { if (IsReceptionist(DataForm1.btApplicant1)) { names.AddRange(list.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } else { names.AddRange(list.ToArray()); names.Add(DataForm1.btApplicant1); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "no"; } } else if (DataForm1.radiobuttonYes && DataForm1.RadioDisplay) { names.AddRange(list.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } else if (DataForm1.radiobuttonNO && DataForm1.RadioYes) { if (IsReceptionist(DataForm1.btUser1)) { names.AddRange(list.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } else { names.AddRange(list.ToArray()); names.Add(DataForm1.btUser1); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "no"; } } else if (DataForm1.radiobuttonNO && DataForm1.RadioNo) { if (DataForm1.btUser1.Equals(DataForm1.btApplicant1, StringComparison.CurrentCultureIgnoreCase)) { names.Add(DataForm1.btUser1); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } else { names.Add(DataForm1.btUser1); names.Add(DataForm1.btApplicant1); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "no"; } } else if (DataForm1.radiobuttonNO && DataForm1.RadioDisplay) { names.Add(DataForm1.btUser1); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.DataFields["IsTheSame"] = "yes"; } //List<string> strGroupUsers = WorkFlowUtil.UserListInGroup("wf_Reception"); //NameCollection names = new NameCollection(); //names.AddRange(strGroupUsers.ToArray()); //WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistUsers", names); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeadTaskTitle", DataForm1.Applicant.DisplayName + "'s travel request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("ReceptionistTaskTitle", "Please complete travel request for " + DataForm1.Applicant.DisplayName); WorkflowContext.Current.DataFields["UserName"] = DataForm1.Applicant.UserAccount; WorkflowContext.Current.DataFields["EnglishName"] = DataForm1.Applicant.DisplayName; WorkflowContext.Current.DataFields["Department"] = DataForm1.Applicant.Department; WorkflowContext.Current.DataFields["JobTitle"] = DataForm1.Applicant.Title; WorkflowContext.Current.DataFields["AirNotes"] = DataForm1.AirNotes; WorkflowContext.Current.DataFields["HotelNotes"] = DataForm1.HotelNotes; bool bol = DataForm1.RadioYes; WorkflowContext.Current.DataFields["RadioYes"] = bol.ToString(); if (DataForm1.radiobuttonNO) { WorkflowContext.Current.DataFields["btUser"] = DataForm1.btUser1; } else { WorkflowContext.Current.DataFields["btUser"] = string.Empty; } if (DataForm1.RadioNo) { WorkflowContext.Current.DataFields["btApplicant"] = DataForm1.btApplicant1; } else { WorkflowContext.Current.DataFields["btApplicant"] = string.Empty; } WorkflowContext.Current.DataFields["Status"] = "InProgress"; }
private void TerminateAndStartWFForFinanceGroup() { SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID)) { web.AllowUnsafeUpdates = true; SPList list = web.Lists[WorkflowListName.CreditCardBill]; SPWorkflowAssociation wfAss = list.WorkflowAssociations.GetAssociationByName(WorkflowConfigName.CreditCardBillWorkflow, System.Globalization.CultureInfo.CurrentCulture); SPQuery query = new SPQuery(); query.Query = CreditCardClaimCommon.GetQuery("WorkflowStep", "UploadBillTask"); SPListItemCollection items = list.GetItems(query); if (items.Count > 0) { foreach (SPWorkflow wfItem in items[0].Workflows) { foreach (SPWorkflowTask wfTask in wfItem.Tasks) { wfTask["Status"] = "Canceled"; wfTask.SystemUpdate(); } SPWorkflowManager.CancelWorkflow(wfItem); } WorkflowVariableValues vs = new WorkflowVariableValues(); vs["UploadBillTaskTitle"] = "Please upload credit card e-statement"; vs["UploadBillTaskFormURL"] = "/_Layouts/CA/WorkFlows/CreditCardClaim/UploadExcelBill.aspx"; var taskUsers = new NameCollection(); List<string> groupUsers = null; groupUsers = WorkFlowUtil.UserListInGroup(WorkflowGroupName.WF_FinanceConfirm); taskUsers.AddRange(groupUsers.ToArray()); vs["UploadBillTaskUsers"] = taskUsers; string eventData = SerializeUtil.Serialize(vs); site.WorkflowManager.StartWorkflow(items[0], wfAss, eventData); } web.AllowUnsafeUpdates = false; } } }); }
void StartWorkflowButton1_Executing(object sender, System.ComponentModel.CancelEventArgs e) { StartWorkflowButton btn = sender as StartWorkflowButton; if (string.Equals(btn.Text, "Save", StringComparison.CurrentCultureIgnoreCase)) { WorkflowContext.Current.UpdateWorkflowVariable("IsSave", true); WorkflowContext.Current.DataFields["Flag"] = "Save"; WorkflowContext.Current.DataFields["Status"] = "NonSubmit"; } else { WorkflowContext.Current.UpdateWorkflowVariable("IsSave", false); WorkflowContext.Current.DataFields["Flag"] = "Submit"; WorkflowContext.Current.DataFields["Status"] = "In Progress"; } //string strDepartment = DataForm1.Applicant.Department; //string strConstructionHeader = @"ca\ztao"; //string strConstruction = @"ca\ztao"; //string strDepartmentHeader = @"ca\ztao"; //string strStoreOperationTeam = @"ca\ztao"; //string strCFO = @"ca\ztao"; //组开始 string strConstructionHeadAccount = UserProfileUtil.GetDepartmentManager("Construction"); //List<string> lst = WorkFlowUtil.UserListInGroup("ConstructionHeadGroup"); NameCollection ConstructionHead = new NameCollection(); //ConstructionHead.AddRange(lst.ToArray()); ConstructionHead.Add(strConstructionHeadAccount); //ConstructionHead.Add(@"ca\caix"); NameCollection ConstructionUser = new NameCollection(); List<string> lst = WorkFlowUtil.UserListInGroup("wf_Construction"); ConstructionUser.AddRange(lst.ToArray()); //ConstructionUser.Add(strConstruction); string department = string.Empty; if (DataForm1.Applicant.Department.Contains(';')) department = DataForm1.Applicant.Department.Substring(0, DataForm1.Applicant.Department.IndexOf(';')+1); else department = DataForm1.Applicant.Department; string departmentManager = UserProfileUtil.GetDepartmentManager(department); if (string.IsNullOrEmpty(departmentManager)) { //Don DisplayMessage("Unable to submit the application. There is no department manager defined. Please contact IT for further help."); e.Cancel = true; return; } NameCollection DepartmentHead = new NameCollection(); //lst = WorkFlowUtil.UserListInGroup("DepartmentHeadGroup"); //DepartmentHead.AddRange(lst.ToArray()); //DepartmentHead.Add(strDepartmentHeader); DepartmentHead.Add(departmentManager); NameCollection StoreOperationTeamUser = new NameCollection(); try { //lst = WorkFlowUtil.UserListInGroup("wf_StoreOperationTeam"); //StoreOperationTeamUser.AddRange(lst.ToArray()); //SPListItemCollection coll = GetSPColl("Stores", "Cost Center", DataForm1.CostCenter, 1); //StoreOperationTeamUser.Add(new SPFieldLookupValue(coll[0]["Owner"] + "").LookupValue); string strStoreOperations = UserProfileUtil.GetDepartmentManager("Store Operations"); StoreOperationTeamUser.Add(strStoreOperations); } catch { } //StoreOperationTeamUser.Add(strStoreOperationTeam); NameCollection CFOUser = new NameCollection(); lst = WorkFlowUtil.UserListInGroup("wf_CFO"); CFOUser.AddRange(lst.ToArray()); //CFOUser.Add(strCFO); //组结束 WorkflowContext.Current.UpdateWorkflowVariable("ConstructionHeadAccount", ConstructionHead); WorkflowContext.Current.UpdateWorkflowVariable("ConstructionAccount", ConstructionUser); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeadAccount", DepartmentHead); WorkflowContext.Current.UpdateWorkflowVariable("StoreOperationTeamAccount", StoreOperationTeamUser); WorkflowContext.Current.UpdateWorkflowVariable("CFOAccount", CFOUser); WorkflowContext.Current.UpdateWorkflowVariable("isSameUser", Common.IsSameUser(DepartmentHead, StoreOperationTeamUser, CFOUser)); WorkflowContext.Current.UpdateWorkflowVariable("IsFixedAsset", DataForm1.RequestType == "Capex" ? "FixedAsset" : DataForm1.RequestType); //修改TaskTitle WorkflowContext.Current.UpdateWorkflowVariable("ConstructionHeadTitle", DataForm1.Applicant.DisplayName + "'s construction purchasing request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("ConstructionTitle", DataForm1.Applicant.DisplayName + "'s construction purchasing request needs supplies other information"); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeadTitle", DataForm1.Applicant.DisplayName + "'s construction purchasing request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("StoreOperationTeamTitle", DataForm1.Applicant.DisplayName + "'s construction purchasing request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("CFOTitle", DataForm1.Applicant.DisplayName + "'s construction purchasing request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("UpdateTaskTitle", "Please complete construction purchasing request for " + DataForm1.Applicant.DisplayName); WorkflowContext.Current.UpdateWorkflowVariable("PlacesTheOrderTitle", DataForm1.Applicant.DisplayName + "'s construction purchasing request needs places the order"); WorkflowContext.Current.UpdateWorkflowVariable("OrderHandoverTitle", DataForm1.Applicant.DisplayName + "'s construction purchasing request needs order handover"); //修改结束 this.WorkFlowNumber = CreateWorkFlowNumber(); WorkflowContext.Current.DataFields["WorkFlowNumber"] = this.WorkFlowNumber; WorkflowContext.Current.DataFields["ApplyDept"] = DataForm1.Applicant.Department; WorkflowContext.Current.DataFields["ApplyDate"] = DataForm1.ApplyDate; WorkflowContext.Current.DataFields["ApplyUser"] = this.DataForm1.Applicant.UserAccount; WorkflowContext.Current.DataFields["RequestType"] = this.DataForm1.RequestType; WorkflowContext.Current.DataFields["BudgetApproved"] = this.DataForm1.BudgetApproved; WorkflowContext.Current.DataFields["CurrencyType"] = this.DataForm1.CurrencyType; WorkflowContext.Current.DataFields["CostCenter"] = this.DataForm1.CostCenter; WorkflowContext.Current.DataFields["BudgetValue"] = this.DataForm1.BudgetValue; WorkflowContext.Current.DataFields["ProduceandDeliveryDate"] = this.DataForm1.ProduceandDeliveryDate; WorkflowContext.Current.DataFields["Installation"] = this.DataForm1.Installation; WorkflowContext.Current.DataFields["Freight"] = this.DataForm1.Freight; WorkflowContext.Current.DataFields["Packaging"] = this.DataForm1.Packaging; }
void StartWorkflowButton1_Executing(object sender, System.ComponentModel.CancelEventArgs e) { StartWorkflowButton btn = sender as StartWorkflowButton; if (string.Equals(btn.Text, "Save", StringComparison.CurrentCultureIgnoreCase)) { WorkflowContext.Current.UpdateWorkflowVariable("IsSave", true); WorkflowContext.Current.DataFields["Flag"] = "Save"; WorkflowContext.Current.DataFields["Status"] = "NonSubmit"; } else { string msg = DataForm1.Validate; if (!string.IsNullOrEmpty(msg)) { DisplayMessage(msg); e.Cancel = true; return; } WorkflowContext.Current.UpdateWorkflowVariable("IsSave", false); WorkflowContext.Current.DataFields["Flag"] = "Submit"; WorkflowContext.Current.DataFields["Status"] = "In Progress"; //string strDepartment = DataForm1.Applicant.Department; //string strManager = @"ca\ztao"; //string strDirector = @"ca\ztao"; //string strHeader = @"ca\ztao"; //string strBBSTeam = @"ca\ztao"; //组开始 List<string> lst = WorkFlowUtil.UserListInGroup("wf_IT"); if (lst.Count == 0) { //Don DisplayMessage("Unable to submit the application. There is no user in wf_IT group. Please contact IT for further help."); e.Cancel = true; return; } NameCollection ItMemberUser = new NameCollection(); ItMemberUser.AddRange(lst.ToArray()); //ItMemberUser.Add(strManager); //string department = string.Empty; //if (DataForm1.Department.Contains(';')) // department = DataForm1.Department.Substring(0, DataForm1.Department.IndexOf(';') + 1); //else // department = DataForm1.Department; Employee approver = WorkFlowUtil.GetEmployeeApprover(DataForm1.Applicant); if (approver == null) { //Don DisplayMessage("Unable to find an approver for the applicant. Please contact IT for further help."); e.Cancel = true; return; } NameCollection DepartHeadUser = new NameCollection(); //lst = WorkFlowUtil.UserListInGroup("DepartmentHeadGroup"); //DepartHeadUser.AddRange(lst.ToArray()); DepartHeadUser.Add(approver.UserAccount); NameCollection ITHeadUser = new NameCollection(); string strHRHeadAccount = UserProfileUtil.GetDepartmentManager("it"); //lst = WorkFlowUtil.UserListInGroup("ITHead"); //ITHeadUser.AddRange(lst.ToArray()); ITHeadUser.Add(strHRHeadAccount); NameCollection CFOUser = new NameCollection(); lst = WorkFlowUtil.UserListInGroup("wf_CFO"); CFOUser.AddRange(lst.ToArray()); //FOCOUser.Add(strBBSTeam); //组结束 WorkflowContext.Current.UpdateWorkflowVariable("ITMemberAccounts", ItMemberUser); WorkflowContext.Current.UpdateWorkflowVariable("DepartHeaderAccounts", DepartHeadUser); WorkflowContext.Current.UpdateWorkflowVariable("ITHeaderAccounts", ITHeadUser); WorkflowContext.Current.UpdateWorkflowVariable("FOCOAccounts", CFOUser); WorkflowContext.Current.UpdateWorkflowVariable("IsFOCO", false); } //修改TaskTitle WorkflowContext.Current.UpdateWorkflowVariable("ITMemberTitle", DataForm1.Applicant.DisplayName + "'s IT request needs confirm"); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeaderTitle", DataForm1.Applicant.DisplayName + "'s IT request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("ITHeaderTitle", DataForm1.Applicant.DisplayName + "'s IT request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("FOCOTitle", DataForm1.Applicant.DisplayName + "'s IT request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("UpdateTaskTitle", "Please complete IT request for " + DataForm1.Applicant.DisplayName); //修改结束 this.WorkFlowNumber = CreateWorkFlowNumber(); WorkflowContext.Current.DataFields["WorkFlowNumber"] = this.WorkFlowNumber; WorkflowContext.Current.DataFields["Name"] = DataForm1.Name; WorkflowContext.Current.DataFields["Department"] = DataForm1.Department; WorkflowContext.Current.DataFields["FOCOApprove"] = DataForm1.IsFOCO; WorkflowContext.Current.DataFields["ApplyDate"] = DataForm1.ApplyDate; WorkflowContext.Current.DataFields["AppliedUser"] = this.DataForm1.Applicant.UserAccount; WorkflowContext.Current.DataFields["ReasonforRequest"] = this.DataForm1.ReasonforRequest; }
private void StartWorkflowButton_Executing(object sender, CancelEventArgs e) { string url = Request.UrlReferrer.ToString(); if (!this.DataForm.SubmitStatus) { Response.Write("<script type=\"text/javascript\">alert('You are not in Buying Department .');window.location = '" + url + "';</script>"); Response.End(); e.Cancel = true; return; } WorkflowContext context = WorkflowContext.Current; WorkflowDataFields fields = WorkflowContext.Current.DataFields; var btn = sender as StartWorkflowButton; if (string.Equals(btn.Text, "Save", StringComparison.CurrentCultureIgnoreCase)) { context.UpdateWorkflowVariable("IsSave", true); context.DataFields["Status"] = CAWorkflowStatus.Pending; } else { #region Set users for workflow Employee manager = WorkFlowUtil.GetApproverByLevelPAD(this.DataForm.Applicant); if (null == manager) { Response.Write("<script type=\"text/javascript\">alert('The init error about applicant’s manager in the system.');window.location = '" + url + "';</script>"); Response.End(); e.Cancel = true; return; } NameCollection DMMTask = new NameCollection(); DMMTask.Add(manager.UserAccount); fields["CurrManager"] = manager.UserAccount; NameCollection wf_NTSC_QM = new NameCollection(); //NameCollection wf_NTSC_QAD = new NameCollection(); NameCollection wf_NTSC_SCM = new NameCollection(); NameCollection wf_NTSC_SCMM = new NameCollection(); List<string> qm = WorkFlowUtil.UserListInGroup(NewProductionUnitCreationConstants.wf_NTSC_QM); //List<string> qad = WorkFlowUtil.UserListInGroup(NewProductionUnitCreationConstants.wf_NTSC_QAD); List<string> scm = WorkFlowUtil.UserListInGroup(NewProductionUnitCreationConstants.wf_NTSC_SCM); List<string> scmm = WorkFlowUtil.UserListInGroup(NewProductionUnitCreationConstants.wf_NTSC_SCMM); System.Text.StringBuilder group = new System.Text.StringBuilder(); if (qm.Count == 0) { group.Append(" wf_NTSC_QM "); } //if (qad.Count == 0) //{ // group.Append(" wf_NTSC_QAD "); //} if (scm.Count == 0) { group.Append(" wf_NTSC_SCM "); } if (scmm.Count == 0) { group.Append(" wf_NTSC_SCMM "); } if (scm.Count == 0 || scmm.Count == 0 || qm.Count == 0) { Response.Write("<script type=\"text/javascript\">alert('The init error about WorkflowPerson in the " + group.ToString() + "');window.location = '" + url + "';</script>"); Response.End(); e.Cancel = true; return; } wf_NTSC_QM.AddRange(qm.ToArray()); //wf_NTSC_QAD.AddRange(qad.ToArray()); wf_NTSC_SCM.AddRange(scm.ToArray()); wf_NTSC_SCMM.AddRange(scmm.ToArray()); System.Text.StringBuilder strStepAndUsers = new System.Text.StringBuilder(); strStepAndUsers.AppendFormat("{0}:{1};", "DMMTask", DMMTask.JoinString(",")); strStepAndUsers.AppendFormat("{0}:{1};", "QMTask", wf_NTSC_QM.JoinString(",")); //strStepAndUsers.AppendFormat("{0}:{1};", "QADTask", wf_NTSC_QAD.JoinString(",")); strStepAndUsers.AppendFormat("{0}:{1};", "SCMTask", wf_NTSC_SCM.JoinString(",")); strStepAndUsers.AppendFormat("{0}:{1};", "SCMConfirmTask", wf_NTSC_SCMM.JoinString(",")); fields["WorkFlowStepsAndUsers"] = strStepAndUsers.ToString(); context.UpdateWorkflowVariable("NextApproveTaskUsers", GetDelemanNameCollection(DMMTask, WorkFlowUtil.GetModuleIdByListName("New Production Unit Creation"))); #endregion context.UpdateWorkflowVariable("IsSave", false); context.DataFields["Status"] = CAWorkflowStatus.InProgress; } #region Save the data string workflowNumber = CreateWorkflowNumber(); fields["WorkFlowNumber"] = workflowNumber; fields["Applicant"] = this.DataForm.Applicant.UserAccount; fields["Department"] = this.DataForm.Applicant.Department; fields["ApplicantSPUser"] = NewProductionUnitCreation.EnsureUser(this.DataForm.Applicant.UserAccount); fields["SupplierName"] = this.DataForm.SupplierName; fields["SubDivision"] = this.DataForm.Applicant.Department; fields["SupplierNo"] = this.DataForm.SupplierNo; fields["PUNO"] = this.DataForm.PUNO; fields["ProductionUnitName"] = this.DataForm.ProductionUnitName; fields["IsMondial"] = this.DataForm.IsMondial == "Yes" ? true : false; fields["Reason"] = this.DataForm.Reason; #endregion #region Set title for workflow //string taskTitle = string.Format("{0} {1} {2}'s New Production Unit Creation needs approval" // , workflowNumber // , this.DataForm.SupplierName // , this.DataForm.Applicant.UserAccount); string taskTitle = string.Format("{0} {1}'s New Production Unit Creation needs approval" , workflowNumber , this.DataForm.Applicant.UserAccount); context.UpdateWorkflowVariable("CompleteTaskTitle", "Please complete New Production Unit Creation"); context.UpdateWorkflowVariable("NextApproveTaskTitle", taskTitle); #endregion #region Set page URL for workflow var editURL = "/_Layouts/CA/WorkFlows/NewProductionUnitCreation/EditForm.aspx"; var approveURL = "/_Layouts/CA/WorkFlows/NewProductionUnitCreation/ApproveForm.aspx"; context.UpdateWorkflowVariable("CompleteTaskFormURL", editURL); context.UpdateWorkflowVariable("NextApproveTaskFormURL", approveURL); #endregion SendEmail("Submit"); WorkFlowUtil.UpdateWorkflowPath(WorkflowContext.Current); }
//Save or Submit private void StartWorkflowButton_Executing(object sender, CancelEventArgs e) { string taskTitle = CurrentEmployee.DisplayName + "'s Internal Order Maintenance "; var manager = UserProfileUtil.GetDepartmentManager(CurrentEmployee.Department); if (manager.IsNullOrWhitespace()) { DisplayMessage("The department manager is not set in the system."); e.Cancel = true; return; } else if (manager.Equals(CurrentEmployee.UserAccount, StringComparison.CurrentCultureIgnoreCase)) { var managerEmp = WorkFlowUtil.GetEmployeeApprover(CurrentEmployee); if (managerEmp == null) { DisplayMessage("The manager is not set in the system."); e.Cancel = true; return; } manager = managerEmp.UserAccount; } //Check which button has been clicked var btn = sender as StartWorkflowButton; if (string.Equals(btn.Text, "Save", StringComparison.CurrentCultureIgnoreCase)) { if (!Validate(e)) { return; } WorkflowContext.Current.UpdateWorkflowVariable("IsSave", true); WorkflowContext.Current.DataFields["Status"] = CAWorkflowStatus.Pending; } else { if (!Validate(e)) { return; } double lastValue = this.DataForm1.GetLastValue(WorkflowContext.Current.DataFields["Order Number"] as string); WorkflowContext.Current.DataFields["Last Value"] = lastValue; WorkflowContext.Current.UpdateWorkflowVariable("IsSave", false); WorkflowContext.Current.DataFields["Status"] = CAWorkflowStatus.InProgress; } WorkflowContext.Current.DataFields["WorkFlowNumber"] = CreateWorkflowNumber(); WorkflowContext.Current.DataFields["Applicant"] = CurrentEmployee.DisplayName + "(" + CurrentEmployee.UserAccount + ")"; WorkflowContext.Current.DataFields["Department"] = CurrentEmployee.Department; #region Set title for workflow //Modify task title WorkflowContext.Current.UpdateWorkflowVariable("CompleteTaskTitle", "please complete internal order maintenance"); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentManagerTaskTitle", taskTitle + "needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("CFOTaskTitle", taskTitle + "needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("FinanceAnalystTaskTitle", taskTitle + "needs confirm"); #endregion #region Set users for workflow //Modify task users var DepartmentManagerTaskUsers = new NameCollection(); var FinanceAnalystTaskUsers = new NameCollection(); var CFOTaskUsers = new NameCollection(); DepartmentManagerTaskUsers.Add(manager); List<string> lst = WorkFlowUtil.UserListInGroup("wf_CFO"); CFOTaskUsers.AddRange(lst.ToArray()); lst = WorkFlowUtil.UserListInGroup("wf_FinanceAnalyst_IO"); FinanceAnalystTaskUsers.AddRange(lst.ToArray()); WorkflowContext.Current.UpdateWorkflowVariable("FinanceAnalystTaskUsers", FinanceAnalystTaskUsers); WorkflowContext.Current.UpdateWorkflowVariable("CFOTaskUsers", CFOTaskUsers); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentManagerTaskUsers", DepartmentManagerTaskUsers); #endregion #region Set page URL for workflow //Set page url var editURL = "/_Layouts/CA/WorkFlows/InternalOrderMaintenance/EditForm.aspx"; var approveURL = "/_Layouts/CA/WorkFlows/InternalOrderMaintenance/ApproveForm.aspx"; WorkflowContext.Current.UpdateWorkflowVariable("CompleteTaskFormURL", editURL); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentManagerTaskFormURL", approveURL); WorkflowContext.Current.UpdateWorkflowVariable("CFOTaskFormURL", approveURL); WorkflowContext.Current.UpdateWorkflowVariable("FinanceAnalystTaskFormURL", approveURL); #endregion }
public static NameCollection GetTaskUsersWithoutDeleman(string group, string moduleId) { var taskUsers = new NameCollection(); List<string> groupUsers = null; groupUsers = WorkFlowUtil.UserListInGroup(group); taskUsers.AddRange(groupUsers.ToArray()); return taskUsers; }
void StartWorkflowButton1_Executing(object sender, System.ComponentModel.CancelEventArgs e) { StartWorkflowButton btnStart = sender as StartWorkflowButton; if (string.Equals(btnStart.Text, "Save", StringComparison.CurrentCultureIgnoreCase)) { WorkflowContext.Current.UpdateWorkflowVariable("IsSave", true); } else { WorkflowContext.Current.UpdateWorkflowVariable("IsSave", false); string msg = DataForm1.validateGeneralInfo(); if (!string.IsNullOrEmpty(msg)) { DisplayMessage(msg); e.Cancel = true; return; } WorkflowContext.Current.DataFields["Status"] = "In Progress"; } //long Intamount = Convert.ToInt64(this.DataForm1.amount); float amount = string.IsNullOrEmpty(DataForm1.amount) ? 0 : Convert.ToSingle(DataForm1.amount); //string deptHead = WorkFlowUtil.GetEmployeeApprover(DataForm1.Applicant).UserAccount; //WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHead", deptHead); string strDeptNamemanger = "Construction"; string strDeptNamemangerName = UserProfileUtil.GetDepartmentManager(strDeptNamemanger); //1 //WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHead", strDeptNamemangerName); string CFOName = WorkFlowUtil.GetUserInGroup("wf_CFO"); //2 //WorkflowContext.Current.UpdateWorkflowVariable("CFOApprovalUser", CFOName); //WorkflowContext.Current.UpdateWorkflowVariable("Amount", Intamount); WorkflowContext.Current.UpdateWorkflowVariable("Amount", amount); string CEOName = WorkFlowUtil.GetUserInGroup("wf_CEO"); //3 //WorkflowContext.Current.UpdateWorkflowVariable("CEOApprovalUser", CEOName); List<string> strGroupUser = WorkFlowUtil.UserListInGroup("wf_Finance_BA"); if (strGroupUser.Count == 0) { //Don DisplayMessage("Unable to submit the application. There is no user in wf_Finance_BA group. Please contact IT for further help."); e.Cancel = true; return; } NameCollection GroupUsers = new NameCollection(); GroupUsers.AddRange(strGroupUser.ToArray()); //4 // WorkflowContext.Current.UpdateWorkflowVariable("FinanceTaskUsers", GroupUsers); System.Text.StringBuilder strStepAndUsers = new System.Text.StringBuilder(); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.StoreBudgetConstructionHeadApproval, strDeptNamemangerName); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.StoreBudgetCFOApproval, CFOName); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.StoreBudgetCEOApproval, CEOName); strStepAndUsers.AppendFormat("{0}:{1};", CA.WorkFlow.UI.Constants.WorkFlowStep.StoreBudgetFinanceTask, GroupUsers.JoinString(",")); WorkflowContext.Current.DataFields["WorkFlowStepsAndUsers"] = strStepAndUsers.ToString(); WorkflowContext.Current.UpdateWorkflowVariable(CA.WorkFlow.UI.Constants.WorkFlowStep.StoreBudgetDepartmentHead, GetDelemanNameCollection(new NameCollection(strDeptNamemangerName), Constants.CAModules.NewStoreBudgetApplication)); WorkflowContext.Current.UpdateWorkflowVariable(CA.WorkFlow.UI.Constants.WorkFlowStep.StoreBudgetCFOApprovalUser, GetDelemanNameCollection(new NameCollection(CFOName), Constants.CAModules.NewStoreBudgetApplication)); WorkflowContext.Current.UpdateWorkflowVariable(CA.WorkFlow.UI.Constants.WorkFlowStep.StoreBudgetCEOApprovalUser, GetDelemanNameCollection(new NameCollection(CEOName), Constants.CAModules.NewStoreBudgetApplication)); WorkflowContext.Current.UpdateWorkflowVariable(CA.WorkFlow.UI.Constants.WorkFlowStep.StoreBudgetFinanceTaskUsers, GetDelemanNameCollection(GroupUsers, Constants.CAModules.NewStoreBudgetApplication)); WorkflowContext.Current.UpdateWorkflowVariable("DepartmentHeadTaskTitle", DataForm1.Applicant.DisplayName + "'s New Store Construction Budget request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("CFOApprovalTaskTitle", DataForm1.Applicant.DisplayName + "'s New Store Construction Budget request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("CEOApprovalTaskTitle", DataForm1.Applicant.DisplayName + "'s New Store Construction Budget request needs approval"); WorkflowContext.Current.UpdateWorkflowVariable("FinanceUserTaskTitle", "Please complete New Store Construction Budget request for " + DataForm1.Applicant.DisplayName); this.WorkFlowNumber = CreateWorkFlowNumber(); WorkflowContext.Current.DataFields["WorkflowNumber"] = this.WorkFlowNumber; DataForm1.WorkflowNumber = this.WorkFlowNumber; WorkflowContext.Current.DataFields["FileName"] = DataForm1.Submit(); WorkFlowUtil.UpdateWorkflowPath(WorkflowContext.Current); }