/// <summary> /// 添加自定义流程 /// </summary> /// <param name="cf"></param> /// <returns></returns> public bool AddCustomFlow(CustomFlow cf) { try { string sql = "SProc_InsertCustomFlow"; SqlParameter[] parms = { new SqlParameter("@FormId", cf.FormId), new SqlParameter("@ProcessId", cf.ProcessId), new SqlParameter("@SubmitId", cf.SubmitId), new SqlParameter("@Applicant", cf.Applicant), new SqlParameter("@Priority", cf.Priority), new SqlParameter("@Urgent", cf.Urgent), new SqlParameter("@IsEmail", cf.IsEmail), new SqlParameter("@IsSMS", cf.IsSMS), new SqlParameter("@AppReason", cf.AppReason), new SqlParameter("@AttachIds", cf.AttachIds), new SqlParameter("@ApproveXML", cf.jqFlowChart), new SqlParameter("@State", cf.State), new SqlParameter("@Operator", cf.Operator), new SqlParameter("@CreatedBy", cf.CreatedBy), new SqlParameter("@ProcessState", cf.ProcessState), new SqlParameter("@DeptCode", cf.DeptCode) }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, System.Data.CommandType.StoredProcedure, sql, parms); } catch (Exception ex) { DBManager.RecoreErrorProfile(ex, "CustomFlowDAL.AddCustomFlow", DBManager.GetCurrentUserAD()); return(false); } return(true); }
/// <summary> /// 更新自定义流程业务表 /// </summary> /// <param name="cf"></param> /// <returns></returns> public bool UpdateCustomFlowByFormId(CustomFlow cf) { try { string sql = "SProc_UpdateCustomflowByFormID"; SqlParameter[] parms = { new SqlParameter("@FormId", cf.FormId), new SqlParameter("@SubmitId", cf.SubmitId), new SqlParameter("@Applicant", cf.Applicant), new SqlParameter("@Priority", cf.Priority), new SqlParameter("@Urgent", cf.Urgent), new SqlParameter("@IsEmail", cf.IsEmail), new SqlParameter("@IsSMS", cf.IsSMS), new SqlParameter("@BBCategoryCode", cf.BBCategoryCode), new SqlParameter("@BSCategoryCode", cf.BSCategoryCode), new SqlParameter("@AppReason", cf.AppReason), new SqlParameter("@AttachIds", cf.AttachIds), new SqlParameter("@ApproveXML", cf.jqFlowChart), new SqlParameter("@State", cf.State), new SqlParameter("@Operator", cf.Operator), new SqlParameter("@ProcessState", cf.ProcessState), new SqlParameter("@CreatedBy", cf.CreatedBy), new SqlParameter("@AppExplain", cf.AppExplain) }; return(SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, sql, parms) > 0); } catch (Exception ex) { DBManager.RecoreErrorProfile(ex, "CustomFlowDAL.UpdateCustomFlowByFormId", DBManager.GetCurrentUserAD()); return(false); } }
private CustomFlow FillModel(DataTable dt) { List <CustomFlow> l = new List <CustomFlow>(); CustomFlow model = default(CustomFlow); foreach (DataRow dr in dt.Rows) { model = Activator.CreateInstance <CustomFlow>(); foreach (DataColumn dc in dr.Table.Columns) { PropertyInfo pi = model.GetType().GetProperty(dc.ColumnName); if (dr[dc.ColumnName] != DBNull.Value) { object obj = dr[dc.ColumnName]; if (dr[dc.ColumnName].GetType().FullName == "System.Guid") { obj = obj.ToString(); } pi.SetValue(model, obj, null); } else { pi.SetValue(model, null, null); } } l.Add(model); } return(l.Count > 0 ? l[0] : null); }
/// <summary> /// 取得业务数据 /// </summary> /// <param name="FormId"></param> /// <returns></returns> public CustomFlow GetCustomFlowByFormId(string FormId) { DataTable dt = dal.GetCustomFlowByFormId(FormId); CustomFlow cf = new CustomFlow(); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { cf.SubmitDate = Convert.ToDateTime(dr["SubmitDate"]); //申请信息 cf.ApplicantName = dr["CHName"].ToString(); cf.EmployeeId = dr["SubmitId"].ToString(); cf.EmployeeName = dr["CHName"].ToString(); cf.DeptCode = dr["DeptCode"].ToString(); cf.Tel = dr["BlackBerry"].ToString(); cf.Email = dr["Email"].ToString(); cf.State = Convert.ToInt32(dr["State"]); cf.FormId = dr["FormId"].ToString(); cf.CreatedBy = dr["CreatedBy"].ToString(); cf.ProcessId = dr["ProcessId"].ToString(); cf.SubmitId = dr["SubmitId"].ToString(); cf.AppReason = dr["AppReason"].ToString(); cf.ApproveXML = dr["ApproveXML"].ToString(); cf.ProcessId = dr["ProcessId"].ToString(); } } return(cf); }
private void LoadCustomFlowInfo(string FormId) { //DataTable dt = boardFormOP.GetCustomFlowByFormId(FormId); CustomFlow cf = boardFormOP.GetCustomFlowByFormId(FormId); if (cf != null) { //基本信息 this.lbl_formid.Text = FormId; this.lbl_date.Text = cf.SubmitDate.Value.ToString("yyyy-MM-dd"); //申请信息 ApplicantName.Value = cf.EmployeeName; //EmployeeCode.Text = cf.SubmitId; //Tel.Value = cf.Tel; //Email.Value = cf.Email; State.Value = cf.State.Value.ToString(); this.FormId.Value = cf.FormId; CreatedBy.Value = cf.CreatedBy; AppReason.Text = Server.HtmlDecode(cf.AppReason); LoadProcessInfo(); //加载流程信息 LoadDepartmentInfo(cf.SubmitId); //加载部门信息 foreach (ListItem li in ddlProcessType.Items) { if (li.Value.Equals(cf.ProcessId, StringComparison.OrdinalIgnoreCase)) { lbProcessType.Value = li.Text; li.Selected = true; break; } } foreach (ListItem li in ddlDepartment.Items) { if (li.Value.Equals(cf.DeptCode, StringComparison.OrdinalIgnoreCase)) { lbDepartment.Value = li.Text; li.Selected = true; break; } } /*暂时屏蔽---------------*/ //CustomizeFlowChart cfc = new CustomizeFlowChart(); //if (TaskPage.IsViewProcessPage) //{ // TaskPage.ApproveXML = boardFormOP.GetApproveXMLByProcInsID(Request.QueryString["ProcInstID"]); //取得InstanceID //} //if (TaskPage.IsDraftPage) // hfjqFlowChart.Value = cfc.FlowChartXmlToJson(cf.ApproveXML, false); //else if (TaskPage.IsReWorkPage) // hfjqFlowChart.Value = cfc.FlowChartXmlToJson_ReSubmit(cf.ApproveXML, false); //else // hfjqFlowChart.Value = cfc.FlowChartXmlToJson(TaskPage.ApproveXML, false); } }
/// <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); //异常和错误信息写入日志表中 } }
private CustomFlow CreateCustomFlowObject() { CustomFlow cf = new CustomFlow(); cf.Applicant = TaskPage.ADAccount; cf.AppReason = Server.HtmlEncode(AppReason.Text); cf.AppExplain = ""; cf.CreatedBy = TaskPage.ADAccount; cf.FormId = FormId.Value; cf.Priority = Priority.SelectedValue; cf.ProcessId = ddlProcessType.SelectedValue; cf.State = int.Parse(this.State.Value); cf.Urgent = Urgent.SelectedValue; cf.AttachIds = string.Empty; cf.SubmitId = TaskPage.EmployeeID; cf.Operator = TaskPage.ADAccount; //通知方式 cf.IsEmail = cbIsEmail.Checked; cf.IsSMS = cbIsSMS.Checked; cf.DeptCode = ddlDepartment.SelectedValue; return(cf); }
/// <summary> /// 更新自定义流程业务表 /// </summary> /// <param name="cf"></param> /// <returns></returns> public bool UpdateCustomFlowByFormId(CustomFlow cf) { if (string.IsNullOrEmpty(cf.Applicant)) { cf.Applicant = string.Empty; } if (string.IsNullOrEmpty(cf.AppReason)) { cf.AppReason = string.Empty; } if (string.IsNullOrEmpty(cf.AttachIds)) { cf.AttachIds = string.Empty; } if (string.IsNullOrEmpty(cf.BBCategoryCode)) { cf.BBCategoryCode = string.Empty; } if (string.IsNullOrEmpty(cf.BSCategoryCode)) { cf.BSCategoryCode = string.Empty; } if (string.IsNullOrEmpty(cf.CreatedBy)) { cf.CreatedBy = string.Empty; } if (string.IsNullOrEmpty(cf.FormId)) { cf.FormId = string.Empty; } if (string.IsNullOrEmpty(cf.jqFlowChart)) { cf.jqFlowChart = string.Empty; } if (string.IsNullOrEmpty(cf.Operator)) { cf.Operator = string.Empty; } if (string.IsNullOrEmpty(cf.Priority)) { cf.Priority = string.Empty; } if (string.IsNullOrEmpty(cf.ProcessId)) { cf.Priority = string.Empty; } if (string.IsNullOrEmpty(cf.ProcessState)) { cf.ProcessState = string.Empty; } if (string.IsNullOrEmpty(cf.SubmitId)) { cf.SubmitId = string.Empty; } if (string.IsNullOrEmpty(cf.Urgent)) { cf.Urgent = string.Empty; } if (string.IsNullOrEmpty(cf.AppExplain)) { cf.AppExplain = string.Empty; } return(dal.UpdateCustomFlowByFormId(cf)); }