private bool SaveWorkFlowInstance(string WfStatus, DateTime?SumitTime, string WfInstanceId) { bool result = false; WorkFlowInstance workFlowInstance = null; try { workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); bool isEdit = false; if (workFlowInstance == null) { workFlowInstance = new WorkFlowInstance(); workFlowInstance.InstanceId = Guid.NewGuid().ToString(); workFlowInstance.CreateAtTime = DateTime.Now; workFlowInstance.AppId = "10105"; workFlowInstance.CreateDeptCode = CurrentEmployee.DepartCode; workFlowInstance.CreateDeptName = CurrentEmployee.DepartName; workFlowInstance.CreateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.CreateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.FormTitle = PaymentApplication_Common.GetErpFormTitle(this); _BPMContext.ProcID = workFlowInstance.InstanceId; } else { isEdit = true; workFlowInstance.UpdateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.UpdateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.AppId = "10105"; } workFlowInstance.FormId = FormId; workFlowInstance.WfStatus = WfStatus; if (SumitTime != null) { workFlowInstance.SumitTime = SumitTime; } if (WfInstanceId != "") { workFlowInstance.WfInstanceId = WfInstanceId; } if (!isEdit) { result = wf_WorkFlowInstance.AddWorkFlowInstance(workFlowInstance); } else { result = wf_WorkFlowInstance.UpdateWorkFlowInstance(workFlowInstance); } FlowRelated1.ProcId = workFlowInstance.InstanceId; Countersign1.ProcId = workFlowInstance.InstanceId; Countersign1.SaveData(true);//会签数据保存 } catch (Exception ex) { throw ex; } return(result); }
/// <summary> /// 设置流程参数 /// </summary> /// <returns></returns> private NameValueCollection SetWFParams() { //存储过程的四个参数 string startDeptId = ddlDepartName.SelectedItem.Value; //部门【条件1】 string startDeptName = ddlDepartName.SelectedItem.Text; //定义合同类型的取值 // string erpFormType = HttpContext.Current.Request["erpFormType"]; //根据formTitle中的第七位取两位得到合同类型【条件2】 string type = PaymentApplication_Common.GetErpFormTitle(this).Substring(5, 2); //得到金额amount,需要先判断改单子是打开拟稿的还是新打开的,根据ID来判断是哪一类【条件3】 string amounts = null; //用info和_BPMContext.ProcID是否为空来判断是打开的拟稿还是新打开的有什么区别 //如果为null或者为空时,则为新打开的页面,新打开页面的amount值 if (_BPMContext.ProcID == null || _BPMContext.ProcID == "") { amounts = HttpContext.Current.Request["amount"]; } //如果不为null,则为打开的拟稿 else { PaymentApplicationInfo info = PaymentApplication.GetPaymentApplicationInfo(FormId); amounts = info.Amount; } //是否在计划内【条件4】 string isInPlan = cblIsInPan.SelectedItem.Value; NameValueCollection dataFields = new NameValueCollection(); Department deptInfo = new Pkurg.PWorld.Services.DepartmentService().GetByDepartCode(startDeptId); string CompanyCode = BPMHelp.GetCompanyCodeByDeptID(StartDeptId); StringBuilder firstFieldBuilder = new StringBuilder(); foreach (ListItem item in cbRelatonUsers.Items) { if (item.Selected) { firstFieldBuilder.AppendFormat("K2:Founder\\{0},", item.Value); } } string firstField = firstFieldBuilder.ToString().Trim(','); dataFields.Add("RelatedPersonnel", !string.IsNullOrEmpty(firstField) ? firstField : "noapprovers"); bool flag = true;//标记datafields内的变量是否均赋值 //验证部分步骤的审批人是否尚未配置 if (string.IsNullOrEmpty(GetRoleUsers(deptInfo.DepartCode, "部门负责人"))) { flag = false; Alert(Page, "发起部门负责人尚未配置!"); } List <string> countersigns = Countersign1.Result.Split(',').ToList(); foreach (var item in countersigns) { if (!string.IsNullOrEmpty(item)) { if (string.IsNullOrEmpty(GetRoleUsers(item, "部门负责人"))) { flag = false; Alert(Page, item + "会签部门负责人尚未配置!"); } } } string financialManagementDepartmentCode = BPMHelp.GetDeptIDByOtherIDAndName(deptInfo.DepartCode, "财务管理部"); if (string.IsNullOrEmpty(financialManagementDepartmentCode)) { flag = false; Alert(Page, "财务管理部尚未设置!"); } else { string financialManagementDepartmentInfoManager = GetRoleUsers(financialManagementDepartmentCode, "部门负责人"); if (string.IsNullOrEmpty(financialManagementDepartmentInfoManager)) { flag = false; Alert(Page, "财务管理部门负责人尚未配置!"); } //else //{ // if (string.IsNullOrEmpty(GetRoleUsers(financialManagementDepartmentInfo.DepartCode, "主管副总裁"))) // { // flag = false; // Alert(Page, "财务管理部门主管副总裁尚未配置!"); // } //} } if (string.IsNullOrEmpty(GetRoleUsers(CompanyCode, "总裁"))) { flag = false; Alert(Page, "公司总裁尚未配置!"); } if (string.IsNullOrEmpty(GetRoleUsers(PKURGICode, "总裁"))) { flag = false; Alert(Page, "集团总裁尚未配置!"); } StringBuilder leaders = new StringBuilder(); StringBuilder Viceleaders = new StringBuilder(); StringBuilder deptsofGroup = new StringBuilder(); StringBuilder leaderofgroup = new StringBuilder(); StringBuilder AssistantPresident = new StringBuilder(); StringBuilder VicePresident = new StringBuilder(); countersigns.Add(startDeptId); foreach (var item in countersigns) { string leadersTmp = GetRoleUsers(item, "主管助理总裁"); if (!leaders.ToString().Contains(leadersTmp)) { leaders.AppendFormat("{0},", leadersTmp); } string ViceleadersTmp = GetRoleUsers(item, "主管副总裁"); if (!Viceleaders.ToString().Contains(ViceleadersTmp)) { Viceleaders.AppendFormat("{0},", ViceleadersTmp); } string deptsofGroupTmp = GetRoleDepts(item, "集团主管部门"); if (!deptsofGroup.ToString().Contains(deptsofGroupTmp)) { deptsofGroup.AppendFormat("{0},", deptsofGroupTmp); } } //集团审批人员 if (cblisoverCotract.Checked) { foreach (var item in deptsofGroup.ToString().Trim(',').Split(',')) { string leaderofgroupTmp = GetRoleUsers(item, "部门负责人"); if (!leaderofgroup.ToString().Contains(leaderofgroupTmp)) { leaderofgroup.AppendFormat("{0},", leaderofgroupTmp); } string AssistantPresidentTmp = GetRoleUsers(item, "主管助理总裁"); if (!AssistantPresident.ToString().Contains(AssistantPresidentTmp)) { AssistantPresident.AppendFormat("{0},", AssistantPresidentTmp); } string VicePresidentTmp = GetRoleUsers(item, "主管副总裁"); if (!VicePresident.ToString().Contains(VicePresidentTmp)) { VicePresident.AppendFormat("{0},", VicePresidentTmp); } } dataFields.Add("CEOGroup", FilterDataField2(GetRoleUsers(PKURGICode, "总裁"))); dataFields.Add("VicePresident", FilterDataField2(VicePresident)); dataFields.Add("AssistantPresident", FilterDataField2(AssistantPresident)); dataFields.Add("leadersofgroup", FilterDataField2(leaderofgroup)); } if (cbChairman.Checked) { dataFields.Add("chairman", FilterDataField2(GetRoleUsers(CompanyCode, "董事长"))); } else { dataFields.Add("chairman", "noapprovers"); } string CQCompanyCode = "S374"; string CPDeptCode = "S366-S976-S219"; string JSDeptCode = "S366-S976-S782"; string SCKFDeptCode = "S366-S976-S860"; //如果是重庆公司或者是北京北大资源物业公司,则进行判断 if (StartDeptId.Contains(CQCompanyCode) || StartDeptId.Contains(CPDeptCode) || StartDeptId.Contains(JSDeptCode) || StartDeptId.Contains(SCKFDeptCode)) { //判断“分管副总裁”“分管财务副总裁”“总裁”需要审批还是不需要审批 int grade = ERP_PaymentApplication_Grade.GetERP_PaymentApplication_GradeInfo(type, startDeptName, isInPlan, amounts); //如果grade为别的值,则抛出异常 if (grade == -1) { //throw new InvalidDataException("输入的参数不正确!"); grade = 111; } //分管财务副总裁审批 dataFields.Add("financialManagementViceleaders", (grade - (grade / 100 * 100)) / 10 == 1 ? this.FilterDataField2(GetRoleUsers(financialManagementDepartmentCode, "主管副总裁")) : "noapprovers"); //分管副总裁审批【因为总是会审批,所以不需要进行grade的判断】 if ((grade / 100) == 1) { dataFields.Add("Viceleaders", this.FilterDataField2(Viceleaders)); dataFields.Add("leaders", this.FilterDataField2(leaders)); } //总裁审批 dataFields.Add("CEO", (grade - (grade / 100 * 100) - ((grade - grade / 100 * 100) / 10 * 10)) == 1 ? this.FilterDataField2(GetRoleUsers(CompanyCode, "总裁")) : "noapprovers"); } else { //分管财务副总裁审批 dataFields.Add("financialManagementViceleaders", FilterDataField2(GetRoleUsers(financialManagementDepartmentCode, "主管副总裁"))); //分管副总裁审批 dataFields.Add("Viceleaders", this.FilterDataField2(Viceleaders)); dataFields.Add("leaders", this.FilterDataField2(leaders)); //总裁审批 dataFields.Add("CEO", FilterDataField2(GetRoleUsers(CompanyCode, "总裁"))); } dataFields.Add("StandingViceCEO", FilterDataField2(GetRoleUsers(CompanyCode, "常务副总裁"))); dataFields.Add("financialManagement", FilterDataField2(GetRoleUsers(financialManagementDepartmentCode, "部门负责人"))); dataFields.Add("CounterSignUsers", Countersign1.GetCounterSignUsers()); dataFields.Add("DeptManager", GetRoleUsers(deptInfo.DepartCode, "部门负责人")); dataFields.Add("IsOverContract", cblisoverCotract.Checked ? "1" : "0"); dataFields.Add("IsPass", "1"); if (!flag) { dataFields = null; } return(dataFields); }