private bool AddApprovalOption(string sn, string action, string opinion, string isSign, string activityName) { string DelegateUserName = ""; string DelegateUserCode = ""; string currentActiveName = activityName; var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), FormID = _BPMContext.ProcInst.FormId, InstanceID = _BPMContext.ProcInst.ProcId, CurrentActiveName = currentActiveName, ApproveResult = action, //审批结果 Opinion = opinion, //用户填写的审批意见 ISSign = isSign, OpinionType = "", CurrentActiveID = "0", DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = _BPMContext.CurrentPWordUser.EmployeeCode, CreateByUserName = _BPMContext.CurrentPWordUser.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = _BPMContext.CurrentPWordUser.EmployeeCode, UpdateByUserName = _BPMContext.CurrentPWordUser.EmployeeName, ApproveAtTime = DateTime.Now, ApproveByUserCode = _BPMContext.CurrentPWordUser.EmployeeCode, ApproveByUserName = _BPMContext.CurrentPWordUser.EmployeeName, FinishedTime = DateTime.Now, ApproveStatus = IsFromPC ? "" : "Mobile" }; bfApproval.AddApprovalRecord(appRecord); wf_WorkFlowInstance.UpdateNowStatus(_BPMContext.ProcInst.WorkflowId, "1", "0", currentActiveName, 0, null, _BPMContext.CurrentUser.PWordUser); return(true); }
/// <summary> /// 通一增加审批意见,不涉及流程引擎 /// </summary> /// <param name="action"></param> /// <param name="opinion"></param> /// <param name="isSign"></param> /// <param name="currentActiveName"></param> private void AddApprovalOption(string action, string opinion, string isSign, string currentActiveName) { string DelegateUserName = ""; string DelegateUserCode = ""; var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), FormID = workFlowInstance.FormId, InstanceID = workFlowInstance.InstanceId, CurrentActiveName = currentActiveName, ApproveResult = action, //审批结果 Opinion = opinion, //用户填写的审批意见 ISSign = isSign, OpinionType = "", DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = _BPMContext.CurrentPWordUser.EmployeeCode, CreateByUserName = _BPMContext.CurrentPWordUser.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = _BPMContext.CurrentPWordUser.EmployeeCode, UpdateByUserName = _BPMContext.CurrentPWordUser.EmployeeName, ApproveAtTime = DateTime.Now, ApproveByUserCode = _BPMContext.CurrentPWordUser.EmployeeCode, ApproveByUserName = _BPMContext.CurrentPWordUser.EmployeeName, FinishedTime = DateTime.Now }; bfApproval.AddApprovalRecord(appRecord); wf_WorkFlowInstance.UpdateNowStatus(workFlowInstance.WfInstanceId, "1", "0", currentActiveName, 0, null, _BPMContext.CurrentUser.PWordUser); }
protected void Submit_Click(object sender, EventArgs e) { string id = ViewState["FormID"].ToString(); string SaveVerification = SaveWFParams(); if (string.IsNullOrEmpty(SaveVerification)) { return; } #region 工作流参数 NameValueCollection dataFields = SetWFParams(); if (dataFields == null) { return; } #endregion InstructionOfPKURGIInfo obj = SaveData(id, "02"); if (obj != null) { //开启流程 WorkflowHelper.CurrentUser = "******" + _BPMContext.CurrentUser.LoginId; AppDict appInfo = new Pkurg.BPM.Services.AppDictService().GetByAppId("3001"); if (appInfo == null) { Alert("提交失败"); return; } int wfInstanceId = 0; //process instance id WorkflowHelper.StartProcess(@"K2Workflow\OA_InstructionOfPKURGI", id, dataFields, ref wfInstanceId); if (wfInstanceId > 0) { if (SaveWorkFlowInstance(obj, "1", DateTime.Now, wfInstanceId.ToString())) { if (Eitems.UpdateStatus(id, "02")) { string Opinion = ""; string ApproveResult = "同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(obj.FormID); var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), FormID = id, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = "拟稿", ISSign = IsSign, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; BFApprovalRecord bfApproval = new BFApprovalRecord(); bfApproval.AddApprovalRecord(appRecord); } ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('提交成功');", true); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true); } } } Alert("提交失败"); }
/// <summary> /// 批准事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Agree_Click(object sender, EventArgs e) { WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormID); bool IsSubmit = true; if (nodeName.Value == "流程审核员审核") { SaveWFParams(); UpdateWFParams(); SaveData(ViewState["FormID"].ToString(), ""); } if (IsSubmit) { if (workFlowInstance != null) { UploadAttachments1.SaveAttachment(FormID); string action = "同意"; bool isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action, "founder\\" + _BPMContext.CurrentUser.LoginId); string Opinion = ""; if (GetApproveOpinion(nodeName.Value) == null || GetApproveOpinion(nodeName.Value) == "") { Opinion = "同意"; } else { Opinion = GetApproveOpinion(nodeName.Value); } string ApproveResult = "同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; if (isSuccess && !(bool)ViewState["IsSubmit"]) { var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), WFTaskID = int.Parse(taskID.Value), FormID = FormID, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = nodeName.Value, ISSign = IsSign, CurrentActiveID = nodeID.Value, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; if (bfApproval.AddApprovalRecord(appRecord)) { ViewState["IsSubmit"] = true; wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee); ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.opener.location.href=window.opener.location.href; ", true); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true); } } } } }
//批准 protected void Save_Click(object sender, EventArgs e) { string id = ViewState["FormID"].ToString(); WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id); if (workFlowInstance != null) { UploadAttachments1.SaveAttachment(id); Countersign1.SaveAndSubmit(); // string action = "同意"; bool isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action); string Opinion = GetApproveOpinion(nodeName.Value); string ApproveResult = "同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; if (isSuccess) { var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), WFTaskID = int.Parse(taskID.Value), FormID = id, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = nodeName.Value, ISSign = IsSign, CurrentActiveID = nodeID.Value, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; if (bfApproval.AddApprovalRecord(appRecord)) { if (WorkflowHelper.GetProcessInstance(int.Parse(workFlowInstance.WfInstanceId)).Status1 == ProcessInstance.Status.Completed) { wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "2", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), DateTime.Now, CurrentEmployee); if (wf_Instruction.UpdateStatus(id, "04", workFlowInstance.WfInstanceId)) { WebCommon.Show(this, Resources.Message.ApplicationReviewSucess); Response.Redirect("~/Workflow/ToDoWorkList.aspx", false); } } else { wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee); if (wf_Instruction.UpdateStatus(id, "03", workFlowInstance.WfInstanceId)) { WebCommon.Show(this, Resources.Message.ApplicationReviewSucess); Response.Redirect("~/Workflow/ToDoWorkList.aspx", false); } } } } } }
public bool CreateNewFormByInstanceIDAndEmployeeCodeWithStoredProcedure(string InstanceID, string EmployeeCode, string sp) { DataProvider dataProvider = new DataProvider(); dataProvider.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["BPMConnectionString"].ConnectionString; BFEmployee bfEmployee = new BFEmployee(); Employee employeeInfo = new Employee(); WF_WorkFlowInstance wFlowInst = new WF_WorkFlowInstance(); BFApprovalRecord bFApprovalRecord = new BFApprovalRecord(); EmployeeAdditional employeeAddition = bfEmployee.GetEmployeeAdditionalById(EmployeeCode); employeeInfo = bfEmployee.GetEmployeeByEmployeeCode(EmployeeCode); string EmployeeName = bfEmployee.GetEmployeeNameByEmployeeCode(EmployeeCode); WorkFlowInstance wFlowInstanceBefore = new WorkFlowInstance(); wFlowInstanceBefore = wFlowInst.GetWorkFlowInstanceById(InstanceID); WorkFlowInstance newWorkFlowInstance = new WorkFlowInstance(); { newWorkFlowInstance.InstanceId = Guid.NewGuid().ToString(); newWorkFlowInstance.AppId = wFlowInstanceBefore.AppId; newWorkFlowInstance.FormId = BPMHelp.GetSerialNumber("SQ_"); newWorkFlowInstance.WfInstanceId = wFlowInstanceBefore.WfInstanceId; newWorkFlowInstance.OrderNo = wFlowInstanceBefore.OrderNo; newWorkFlowInstance.IsDel = 0; newWorkFlowInstance.CreateByUserCode = EmployeeCode; newWorkFlowInstance.CreateByUserName = EmployeeName; newWorkFlowInstance.CreateAtTime = System.DateTime.Now; newWorkFlowInstance.UpdateByUserCode = EmployeeCode; newWorkFlowInstance.UpdateByUserName = EmployeeName; newWorkFlowInstance.UpdateAtTime = wFlowInstanceBefore.UpdateAtTime; newWorkFlowInstance.CreateDeptCode = employeeInfo.DepartCode; newWorkFlowInstance.CreateDeptName = employeeInfo.DepartName; newWorkFlowInstance.WorkItemCode = wFlowInstanceBefore.WorkItemCode; newWorkFlowInstance.WorkItemName = wFlowInstanceBefore.WorkItemName; newWorkFlowInstance.WfTaskId = wFlowInstanceBefore.WfTaskId; newWorkFlowInstance.FinishedTime = null; newWorkFlowInstance.Remark = wFlowInstanceBefore.Remark; newWorkFlowInstance.FormTitle = wFlowInstanceBefore.FormTitle; newWorkFlowInstance.WfStatus = "0"; newWorkFlowInstance.SumitTime = null; newWorkFlowInstance.FormData = wFlowInstanceBefore.FormData; } var newApprovalRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record(); newApprovalRecord.ApprovalID = Guid.NewGuid().ToString(); newApprovalRecord.FormID = newWorkFlowInstance.FormId; newApprovalRecord.InstanceID = newWorkFlowInstance.InstanceId; newApprovalRecord.CreateByUserCode = employeeInfo.EmployeeCode; newApprovalRecord.CreateByUserName = employeeInfo.EmployeeName; newApprovalRecord.CreateAtTime = System.DateTime.Now; newApprovalRecord.ApproveByUserCode = employeeInfo.EmployeeCode; newApprovalRecord.ApproveByUserName = employeeInfo.EmployeeName; newApprovalRecord.UpdateByUserCode = employeeInfo.EmployeeCode; newApprovalRecord.UpdateByUserName = employeeInfo.EmployeeName; newApprovalRecord.UpdateAtTime = wFlowInstanceBefore.UpdateAtTime; newApprovalRecord.CurrentActiveName = "拟稿"; Pkurg.BPM.Entities.FlowRelated relationInfo = new FlowRelated() { FlowId = newWorkFlowInstance.InstanceId, CreatorName = employeeInfo.EmployeeName, CreateTime = System.DateTime.Now, CreatorId = employeeInfo.EmployeeCode, RelatedFlowId = wFlowInstanceBefore.InstanceId, RelatedFlowCreator = wFlowInstanceBefore.CreateByUserName, RelatedFlowEndTime = wFlowInstanceBefore.FinishedTime, RelatedFlowName = wFlowInstanceBefore.FormTitle, }; WF_Relation.AddRelatedFlowInfo(relationInfo); SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@FormID_Before", System.Data.SqlDbType.NVarChar, 100), new SqlParameter("@FormID_New", System.Data.SqlDbType.NVarChar, 100) }; parameters[0].Value = wFlowInstanceBefore.FormId; parameters[1].Value = newWorkFlowInstance.FormId; dataProvider.ExecutedProcedure(sp, parameters); bool isSuccessForInstance = wFlowInst.AddWorkFlowInstance(newWorkFlowInstance); bool isSuccessForApprovalRecord = bFApprovalRecord.AddApprovalRecord(newApprovalRecord); if (isSuccessForInstance && isSuccessForApprovalRecord) { return(true); } else { return(false); } }
//批准 protected void Agree_Click(object sender, EventArgs e) { string id = ViewState["FormID"].ToString(); WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id); if (workFlowInstance != null) { UploadAttachments1.SaveAttachment(id); Countersign1.SaveAndSubmit(); // string action = "同意"; bool isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action); string Opinion = ""; if (GetApproveOpinion(nodeName.Value) == null || GetApproveOpinion(nodeName.Value) == "") { Opinion = "同意"; } else { Opinion = GetApproveOpinion(nodeName.Value); } string ApproveResult = "同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; if (isSuccess && !(bool)ViewState["IsSubmit"]) { var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), WFTaskID = int.Parse(taskID.Value), FormID = id, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = nodeName.Value, ISSign = IsSign, CurrentActiveID = nodeID.Value, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; ViewState["IsSubmit"] = true; if (bfApproval.AddApprovalRecord(appRecord)) { wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee); if (wf_Instruction.UpdateStatus(id, "03", workFlowInstance.WfInstanceId)) { ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.close();", true); } } } Countersign1.SaveAndSubmit(); } }
/// <summary> /// 批准事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Agree_Click(object sender, EventArgs e) { string id = ViewState["FormID"].ToString(); WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id); if (workFlowInstance != null) { UploadAttachments1.SaveAttachment(id); string action = "同意"; string currentName = K2_TaskItem.ActivityInstanceDestination.Name; if (currentName == "招标委员会主任意见" || currentName == "集团招标委员会主任意见") { //如果招标委员会意见是同意,则之前的意见可以忽略,只看招标委员会主任的意见 ChangeResultToAgree(); } bool isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action, "founder\\" + _BPMContext.CurrentUser.LoginId); string optionDefault = "同意"; string Opinion = ""; if (GetApproveOpinion(nodeName.Value) == null || GetApproveOpinion(nodeName.Value) == "") { Opinion = optionDefault; } else { Opinion = GetApproveOpinion(nodeName.Value); } string ApproveResult = "同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; if (isSuccess && !(bool)ViewState["IsSubmit"]) { var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { //???? ApprovalID = Guid.NewGuid().ToString(), WFTaskID = int.Parse(taskID.Value), FormID = id, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = nodeName.Value, ISSign = IsSign, CurrentActiveID = nodeID.Value, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; ViewState["IsSubmit"] = true; if (bfApproval.AddApprovalRecord(appRecord)) { wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee); ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.opener.location.href=window.opener.location.href; ", true); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true); } } } }
protected void Submit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtMaxCost.Text.Trim())) { txtMaxCost.Focus(); Alert(Page, "目标成本限额 不能为空!"); return; } decimal val = 0; bool f = decimal.TryParse(txtMaxCost.Text.Trim(), out val); if (!f) { txtMaxCost.Focus(); Alert(Page, "目标成本限额 不是有效的数值!"); return; } //合同总额已超目标成本限额 if (!string.IsNullOrEmpty(txtTotalPrice.Text.Trim())) { if (Convert.ToDecimal(txtMaxCost.Text.Trim()) < Convert.ToDecimal(txtTotalPrice.Text)) { if (string.IsNullOrEmpty(tbNote.Text.Trim())) { tbNote.Focus(); Alert(Page, "订单合同总额已超目标成本限额,请在“备注”中写明理由!"); return; } } } #region 工作流参数 NameValueCollection dataFields = SetWFParams(); if (dataFields == null) { return; } #endregion int wfInstanceId = 0; //process instance id string id = ViewState["FormID"].ToString(); //会签数据保存 yanghechun //Countersign1.SaveData(true); JC_ElevatorOrderInfo jcInfo = SaveJCElevatorOrder(id, "02"); if (jcInfo != null) { //Countersign1.SaveAndSubmit();//会签数据保存 //开启流程 WorkflowHelper.CurrentUser = "******" + _BPMContext.CurrentUser.LoginId; WorkflowHelper.StartProcess(@"K2Workflow\JC_Lift", id, dataFields, ref wfInstanceId); if (wfInstanceId > 0) { if (SaveWorkFlowInstance(jcInfo, "1", DateTime.Now, wfInstanceId.ToString())) { if (jc.UpdateStatus(id, "02")) { string Opinion = ""; string ApproveResult = "同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(jcInfo.FormID); //通知集采系统 string instanceID = workFlowInstance.InstanceId; string url = "http://" + Request.Url.Authority + "/Workflow/ViewPage/V_JCElevatorOrder.aspx?ID=" + instanceID; try { //和集采的接口 order.SubmitWorkFlow(url, Convert.ToInt16(tbOrderType.Text.ToString()), Convert.ToInt16(tbOrderID.Text.ToString())); } catch { } var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), FormID = id, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = "拟稿", ISSign = IsSign, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; BFApprovalRecord bfApproval = new BFApprovalRecord(); bfApproval.AddApprovalRecord(appRecord); } } } } ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('提交成功');", true); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true); }
protected void Submit_Click(object sender, EventArgs e) { #region 工作流参数 NameValueCollection dataFields = SetWFParams(); if (dataFields == null) { return; } #endregion int wfInstanceId = 0; //process instance id string id = ViewState["FormID"].ToString(); BP_LeaseContractInfo obj = SaveData(id, "02"); if (obj != null) { //开启流程 WorkflowHelper.CurrentUser = "******" + _BPMContext.CurrentUser.LoginId; WorkflowHelper.StartProcess(@"K2Workflow\BP_LeaseContract", id, dataFields, ref wfInstanceId); if (wfInstanceId > 0) { if (SaveWorkFlowInstance(obj, "1", DateTime.Now, wfInstanceId.ToString())) { if (lc.UpdateStatus(id, "02")) { string Opinion = ""; string ApproveResult = "同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(obj.FormID); //通知系统 string instanceID = workFlowInstance.InstanceId; string url = "http://" + Request.Url.Authority + "/Workflow/ViewPage/V_BP_LeaseContract.aspx?ID=" + instanceID; try { ContractClass.SubmitWorkFlow(url, Convert.ToInt16(tbBizType.Text.ToString()), Convert.ToInt16(tbBizID.Text.ToString())); } catch { } var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), FormID = id, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = "拟稿", ISSign = IsSign, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; BFApprovalRecord bfApproval = new BFApprovalRecord(); bfApproval.AddApprovalRecord(appRecord); } } } } ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('提交成功');", true); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true); }
protected void Submit_Click(object sender, EventArgs e) { #region 工作流参数 //get users by role BFEmployee employee = new BFEmployee(); EmployeeAdditional employeeadd = employee.GetEmployeeAdditionalByLoginName("xupc"); Employee em = employee.GetEmployeeByEmployeeCode(employeeadd.EmployeeCode);//get user info //get activity destination users BFPmsUserRoleDepartment bfurd = new BFPmsUserRoleDepartment(); DataTable dtDept = bfurd.GetSelectRoleUser(em.DepartCode, "部门负责人"); DataTable dtCheck = bfurd.GetSelectRoleUser(em.CompanyCode, "流程审核人"); //BFCountersignRoleDepartment CountersignRole= new BFCountersignRoleDepartment(); //DataTable dtContri = CountersignRole.GetSelectCountersignDepartment(em.CompanyCode); DataTable dtlead = bfurd.GetSelectRoleUser(em.DepartCode, "主管总裁"); DataTable dtCEO = bfurd.GetSelectRoleUser(em.CompanyCode, "CEO"); //add datafields NameValueCollection dataFields = new NameValueCollection(); //部门负责人 if (chkDeptManager.Checked) { dataFields.Add("DeptManager", "K2:Founder\\" + dtDept.Rows[0]["LoginName"].ToString()); } else { dataFields.Add("DeptManager", "noapprovers"); } //流程审核人 dataFields.Add("WFM", "K2:Founder\\" + dtCheck.Rows[0]["LoginName"].ToString()); //会签 //dataFields.Add("CounterSignUsers", "K2:Founder\\" + dtContri.Rows[0]["LoginName"].ToString()); //部门主管领导 dataFields.Add("leaders", "K2:Founder\\" + dtlead.Rows[0]["LoginName"].ToString()); //CEO dataFields.Add("CEO", "K2:Founder\\" + dtCEO.Rows[0]["LoginName"].ToString()); //触发新流程 if (cbIsReport.Checked) { dataFields.Add("NewFlow_SP", "wf_usp_CreateNewForm"); } #endregion int wfInstanceId = 0; //process instance id string id = ViewState["FormID"].ToString(); Countersign1.SaveData();//会签数据保存 InstructionOfPkurg instructionOfPkurg = SaveInstructionOfPkurg(id, "02"); if (instructionOfPkurg != null) { UploadAttachments1.SaveAttachment(id); Countersign1.SaveAndSubmit();//会签数据保存 WorkflowHelper.StartProcess(@"K2Workflow\InstructionOfPKURG", id, dataFields, ref wfInstanceId); if (wfInstanceId > 0) { if (SaveWorkFlowInstance(instructionOfPkurg, "1", DateTime.Now, wfInstanceId.ToString())) { if (wf_Instruction.UpdateStatus(id, "02", wfInstanceId.ToString())) { string Opinion = ""; string ApproveResult = "同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(instructionOfPkurg.FormId); var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), FormID = id, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = "拟稿", ISSign = IsSign, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; BFApprovalRecord bfApproval = new BFApprovalRecord(); bfApproval.AddApprovalRecord(appRecord); //WebCommon.Show(this, Resources.Message.SubmitSucess); //Response.Redirect("~/Workflow/ToDoWorkList.aspx", false); } } } } ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('提交成功'); window.close();", true); //WorkflowHelper.ApproveProcess //insert data to business object }
//批准 protected void Agree_Click(object sender, EventArgs e) { string id = ViewState["FormID"].ToString(); WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id); if (workFlowInstance != null) { //修改合同编号 2015-08-05 by yanghechun //2015-8-5 经办人确认生效 //更新合同编号 if (nodeName.Value == "经办人确认生效") { if (txtContract_No.Text.Trim() == "") { Alert(Page, "合同编号不能为空,请输入!"); txtContract_No.Focus(); return; } try { ContractClass contractClass = new ContractClass(); int biz_type = Convert.ToInt16(hf_biz_type.Value); int biz_id = Convert.ToInt16(hf_biz_id.Value); contractClass.UpdateContractNo(biz_type, biz_id, txtContract_No.Text.Trim()); } catch { } } string action = "同意"; bool isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action, "founder\\" + _BPMContext.CurrentUser.LoginId); string Opinion = ""; if (GetApproveOpinion(nodeName.Value) == null || GetApproveOpinion(nodeName.Value) == "") { Opinion = "同意"; } else { Opinion = GetApproveOpinion(nodeName.Value); } string ApproveResult = "同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; if (isSuccess && !(bool)ViewState["IsSubmit"]) { var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), WFTaskID = int.Parse(taskID.Value), FormID = id, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = nodeName.Value, ISSign = IsSign, CurrentActiveID= nodeID.Value, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; if (bfApproval.AddApprovalRecord(appRecord)) { ViewState["IsSubmit"] = true; wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee); ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.opener.location.href=window.opener.location.href; ", true); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true); } } } }