/// <summary> /// 更新表单数据 /// </summary> /// <param name="action"></param> /// <returns></returns> protected bool UpdateData(ProcessAction action) { try { //Biz_CustomFlow bcf = new Biz_CustomFlow(); CustomFlowBLL bll = new CustomFlowBLL(); CustomFlow cf = CreateCustomFlowObject(); if (action == ProcessAction.SaveDraft || action == ProcessAction.Save) { CustomizeFlowChart cfc = new CustomizeFlowChart(); cf.jqFlowChart = cfc.FlowChartJsonToXml_Approve(this.hfjqFlowChart.Value, TaskPage.ADAccount); cf.ProcessState = K2Utility.ProcessStatus.Draft.ToString(); bll.UpdateCustomFlowByFormId(cf); } if (action == ProcessAction.Approve || action == ProcessAction.Rework || action == ProcessAction.ApproveSave || action == ProcessAction.SubmitDraft) { cf.ProcessState = K2Utility.ProcessStatus.Running.ToString(); if (action == ProcessAction.Rework) { CustomizeFlowChart cfc = new CustomizeFlowChart(); cf.jqFlowChart = cfc.FlowChartJsonToXml_ReSubmit(this.hfjqFlowChart.Value, TaskPage.ADAccount); bll.UpdateCustomFlowByFormId(cf); } bll.UpdateCustomFlowStatusByAttachIds(cf.AttachIds, TaskPage.FormID); //如果是审批,则还需要修改附件表的状态 if (action == ProcessAction.Approve || action == ProcessAction.Rework || action == ProcessAction.SubmitDraft) { bll.UpdateAttachStatusByAttachAttachCodes(cf.AttachIds); } if (action == ProcessAction.Approve && IsEnd) { bll.UpdateCostomFlowStatusByFormId(TaskPage.FormID, K2Utility.ProcessStatus.Finished.ToString()); } } if (action == ProcessAction.Reject) { cf.ProcessState = K2Utility.ProcessStatus.Rejected.ToString(); //bcf.UpdateCustomFlowStatusByAttachIds(cf.AttachIds, TaskPage.FormID); bll.UpdateCostomFlowStatusByFormId(TaskPage.FormID, cf.ProcessState); } return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// 插入表单数据到DB /// </summary> /// <param name="action"></param> /// <returns></returns> private bool InsertData(ProcessAction action) { bool result = false; try { this.FormId.Value = this.lbl_formid.Text = TaskPage.FormID = FormID.SerialsNO("CDF"); TaskPage.ProcessID = ddlProcessType.SelectedValue; this.State.Value = "1"; CustomFlow cf = CreateCustomFlowObject(); //string approveNodeXml = K2.Common.K2Rule.GetApproveNodeXML(ddlProcessType.SelectedValue, "Reimbursement", CreateRequestXml()); //提交申请 //string approveXml = K2.Common.K2Rule.GetApproveXML(approveNodeXml, CreateRequestXml()); //取得最终的xml cf.jqFlowChart = ""; if (action == ProcessAction.SaveDraft || action == ProcessAction.Save) { //cf.jqFlowChart = cfc.FlowChartJsonToXml_Approve(this.hfjqFlowChart.Value, hfEmployeeCode.Value); cf.ProcessState = K2Utility.ProcessStatus.Draft.ToString(); } else if (action == ProcessAction.SubmitCF || action == ProcessAction.SubmitDraft) { cf.ProcessState = K2Utility.ProcessStatus.Running.ToString(); } CustomFlowBLL bll = new CustomFlowBLL(); if (bll.AddCustomFlow(cf)) { if (action == ProcessAction.SubmitCF) { bll.UpdateAttachStatusByAttachAttachCodes(cf.AttachIds); } result = true; } else { result = false; } return(result); } catch (Exception ex) { LogUtil.Log.Error(ex.Message); return(false); //异常和错误信息写入日志表中 } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["ProcInstID"])) { CustomFlowBLL bll = new CustomFlowBLL(); //ViewState["Approval"] = new bll.GetApproveXMLByProcInsID(Request.QueryString["ProcInstID"]); } else if (!string.IsNullOrEmpty(Request.QueryString["SN"])) { string formId = string.Empty; string activityName = string.Empty; string processID = string.Empty; string approveXML = string.Empty; WorkflowHelper.GetProcessInfo(Request.QueryString["SN"], ref formId, ref processID, ref activityName, ref approveXML); ViewState["Approval"] = approveXML; } CustomizeFlowChart cfc = new CustomizeFlowChart(); hfjqFlowChart.Value = cfc.FlowChartXmlToJson(ViewState["Approval"].ToString(), true); } }