/// <summary> /// 流程咨讯关闭 /// </summary> /// <param name="strSystemCode"></param> /// <param name="strFormID"></param> /// <param name="strReceiveID"></param> public void FlowConsultatiClose(OracleConnection con, string strSystemCode, string strFormID, string strReceiveID) { if (!string.IsNullOrEmpty(strSystemCode) && !string.IsNullOrEmpty(strFormID) && !string.IsNullOrEmpty(strReceiveID)) { try { EnginFlowDAL dal = new EnginFlowDAL(); if (strReceiveID.IndexOf(',') != -1) { string[] users = strReceiveID.Split(','); foreach (string user in users) { //刷新缓存用户是否有新的待办 //EngineCache.TaskCache.TaskCacheReflesh(user); //SMTEngineBLL.CloseMsg(strSystemCode, strFormID, user); dal.CloseConsultati(con, strSystemCode, strFormID, user); } } //SMTEngineBLL.CloseMsg(strSystemCode, strFormID, strReceiveUser); dal.CloseConsultati(con, strSystemCode, strFormID, strReceiveID); } catch (Exception e) { string cMessage = "TaskMsgClose出现异常:SystemCode='" + strSystemCode + "',FormID='" + strFormID + "',ReceiveUser='******',Error='" + e.Message + "'"; LogHelper.WriteLog("TaskMsgClose" + cMessage); } } }
/// <summary> /// 流程待办任务撤销 /// </summary> /// <param name="strFlowXml"></param> /// <param name="strAppXml"></param> /// <returns></returns> public bool FlowCancel(OracleConnection con, string strFlowXml, string strAppXml, ref string ErroMessage) { if (string.IsNullOrEmpty(strFlowXml) && string.IsNullOrEmpty(strAppXml)) { return false; } string strCompanyID = string.Empty;//公司ID string strSystemCode = string.Empty;//系统代号 string strModelCode = string.Empty;//模块代号 string strFormID = string.Empty;//FORMID string strModelName = string.Empty;//模块名称 string strEntityType = string.Empty;//EntityType (表名) string strEntityKey = string.Empty;//EntityKey (主键) string strCheckState = string.Empty;//审核状态 string strReceiveID = string.Empty;//接收人 try { EnginFlowDAL dal = new EnginFlowDAL(); /*解析流程和业务数据XML*/ Byte[] b = System.Text.UTF8Encoding.UTF8.GetBytes(strFlowXml); XElement xele = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(b))); strCompanyID = XMLToAttribute(xele, "COMPANYID"); strSystemCode = string.Empty; strModelCode = XMLToAttribute(xele, "MODELCODE"); strFormID = XMLToAttribute(xele, "FORMID"); strModelName = XMLToAttribute(xele, "ModelName"); strCheckState = XMLToAttribute(xele, "CheckState"); strReceiveID = XMLToAttribute(xele, "APPUSERID"); if (!string.IsNullOrEmpty(strAppXml)) { Byte[] Bo = System.Text.UTF8Encoding.UTF8.GetBytes(strAppXml); XElement xemeBoObject = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(Bo))); strSystemCode = (from item in xemeBoObject.Descendants("Name") select item).FirstOrDefault().Value; try { strEntityType = (from item in xemeBoObject.Descendants("Object") select item).FirstOrDefault().Attribute("Name").Value; strEntityKey = (from item in xemeBoObject.Descendants("Object") select item).FirstOrDefault().Attribute("Key").Value; //有些特殊的模块需要改变接收人 if (CheckModelName(strModelCode) && strCheckState == "2") { strReceiveID = (from item in xemeBoObject.Descendants("Object").Descendants("Attribute") where item.Attribute("Name").Value.ToUpper() == "CREATEUSERID" select item).FirstOrDefault().Attribute("DataValue").Value; } } catch { LogHelper.WriteLog("FlowCancel该单号:" + strFormID + " 中业务数据无法取得EntityKey"); } } string strAppFieldValue = ConbinString(xele) + BOObjectEscapeString(strAppXml); DataTable dtValue = FieldStringToDataTable(strAppFieldValue, ref strAppFieldValue); string content = dal.GetMessageDefine(con, "FLOWCANCEL"); string strUrl = string.Empty; ReplaceUrl(ref content, ref strUrl, dtValue); dal.DoTaskCancel(con, strSystemCode, strModelCode, strFormID, strReceiveID, content); if (Config.IsNeedUpdateAudit)//是否执行更新审核状态 { if (!string.IsNullOrEmpty(strSystemCode) && !string.IsNullOrEmpty(strEntityType) && !string.IsNullOrEmpty(strEntityKey)) { LogHelper.WriteLog("UpdateAuditStatus开始更新...FORMID=" + strFormID + ""); bool bol= UpdateAuditStatus(strSystemCode, strEntityType, strEntityKey, strFormID, strCheckState, ref ErroMessage); LogHelper.WriteLog("UpdateAuditStatus结束更新...FORMID=" + strFormID + ""); if (!bol) { throw new Exception(ErroMessage); //抛出异常终止执行流程 } } } return true; } catch (Exception e) { string cMessage = "流程待办任务撤销异常" + "\r\n" + "SystemCode:" + strSystemCode + "\r\n" + "MODELCODE:" + strModelCode + "\r\n" + "COMPANYID:" + strCompanyID + "\r\n" + "Error:" + e.Message + "\r\n" + "FORMID:" + strFormID + "\r\n" + "流程XML:" + strFlowXml + "\r\n" + "AppXml:" + strAppXml + "\r\n"; LogHelper.WriteLog("FlowCancel流程待办任务撤销异常" + cMessage + ErroMessage); // LogHelper.WriteLog("FlowCancel流程待办任务撤销异常" + cMessage + ErroMessage); return false; } }
/// <summary> /// 流程咨讯 /// </summary> /// <param name="UserAndForm"></param> /// <param name="strTitle"></param> /// <param name="strFlowXML"></param> /// <param name="strAppXml"></param> /// <returns></returns> public bool FlowConsultati(OracleConnection con, List<CustomUserMsg> UserAndForm, string strTitle, string strFlowXML, string strAppXml) { string strCompanyID = string.Empty;//公司ID string strSystemCode = string.Empty;//系统代号 string strModelCode = string.Empty;//模块代号 string strFormID = string.Empty;//FORMID string strModelName = string.Empty;//模块名称 if (UserAndForm.Count > 0) { try { EnginFlowDAL dal = new EnginFlowDAL(); /*解析流程和业务数据XML*/ Byte[] b = System.Text.UTF8Encoding.UTF8.GetBytes(strFlowXML); XElement xele = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(b))); strCompanyID = XMLToAttribute(xele, "COMPANYID"); strSystemCode = string.Empty; strModelCode = XMLToAttribute(xele, "MODELCODE"); strFormID = XMLToAttribute(xele, "FORMID"); strModelName = XMLToAttribute(xele, "ModelName"); if (!string.IsNullOrEmpty(strAppXml)) { Byte[] Bo = System.Text.UTF8Encoding.UTF8.GetBytes(strAppXml); XElement xemeBoObject = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(Bo))); strSystemCode = (from item in xemeBoObject.Descendants("Name") select item).FirstOrDefault().Value; } /*在T_WF_MESSAGEDEFINE 中查找消息内容*/ string content = dal.GetMessageDefine(con, "FLOWCONSULTATI"); string strAppFieldValue = ConbinString(xele) + BOObjectEscapeString(strAppXml); DataTable dtValue = FieldStringToDataTable(strAppFieldValue, ref strAppFieldValue); /*在消息触发规则定义中查找消息链接*/ DataTable dtFlowTrigger = dal.FlowTriggerTable(con, strSystemCode, strModelCode, string.Empty, strCompanyID); if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0) { string Url = dtFlowTrigger.Rows[0]["applicationurl"].ToString(); ReplaceUrl(ref content, ref Url, dtValue); string strContent = string.Empty; foreach (CustomUserMsg custom in UserAndForm) { if (!string.IsNullOrEmpty(strTitle)) { content = strTitle; } //刷新缓存用户是否有新的待办 //EngineCache.TaskCache.TaskCacheReflesh(custom.UserID); dal.FlowConsultatiMsg(con, custom.UserID, strSystemCode, strModelCode, custom.FormID, content, Url, BOObjectEscapeString(strAppXml), strFlowXML, strAppXml); } return true; } else { //未能在触发规则定义中找到一条数据,无法发送咨讯 string cMessage = "未能在触发规则定义中找到一条数据,无法发送咨讯" + "\r\n" + "SystemCode:" + strSystemCode + "\r\n" + "Content:" + content + "\r\n" + "MODELCODE:" + strModelCode + "\r\n" + "COMPANYID:" + strCompanyID + "\r\n" + "FORMID:" + strFormID + "\r\n"; LogHelper.WriteLog("FlowConsultati()流程咨讯" + cMessage); return false; } } catch (Exception e) { string cMessage = "发送咨讯出现异常" + "\r\n" + "SystemCode:" + strSystemCode + "\r\n" + "MODELCODE:" + strModelCode + "\r\n" + "COMPANYID:" + strCompanyID + "\r\n" + "Error:" + e.Message + "\r\n" + "FORMID:" + strFormID + "\r\n"; LogHelper.WriteLog("FlowConsultati()流程咨讯" + cMessage); return false; } } else { string cMessage = "发送咨讯出现错误(没有指定接收人员)" + "\r\n" + "SystemCode:" + strSystemCode + "\r\n" + "MODELCODE:" + strModelCode + "\r\n" + "COMPANYID:" + strCompanyID + "\r\n" + "FORMID:" + strFormID + "\r\n"; LogHelper.WriteLog("FlowConsultati()流程咨讯" + cMessage); return false; } }
private bool EngineExecute(OracleConnection con, T_WF_DOTASK Entity, string IsTask, ref string ErroMessage) { bool result = false; EnginFlowDAL dal = new EnginFlowDAL(); string strAppFieldValue = string.Empty; LogHelper.WriteLog("开始将数据源字段转换成数据表...."); DataTable sourceTable = FieldStringToDataTable(Entity.APPFIELDVALUE, ref strAppFieldValue);//将业务数据与流程数据转换成DataTable作为替换的源数据 LogHelper.WriteLog("结束将数据源字段转换成数据表"); //通过系统代号,模块代号,企业ID,流程状态查到引擎配置内容 LogHelper.WriteLog("开始通过系统代号,模块代号,企业ID,流程状态查到引擎配置内容...."); DataTable dtFlowTrigger = dal.FlowTriggerTable(con, Entity.SYSTEMCODE, Entity.MODELCODE, Entity.ORDERSTATUS.ToString(), Entity.COMPANYID); LogHelper.WriteLog("结束通过系统代号,模块代号,企业ID,流程状态查到引擎配置内容"); if (dtFlowTrigger == null || dtFlowTrigger.Rows.Count == 0) { dtFlowTrigger = dal.FlowTriggerTable(con, Entity.SYSTEMCODE, Entity.MODELCODE, Entity.ORDERSTATUS.ToString()); } LogHelper.WriteLog("数量:" + dtFlowTrigger.Rows.Count.ToString()); if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0) { #region DataRow[] drs = dtFlowTrigger.Select("ISDEFAULTMSG=1");//发的是默认流程触发条件 if (drs.Count() > 0) { ErroMessage+="开始-发的是默认流程触发条件\r\n"; if (IsTask == "1")//新增待办任务 { ErroMessage += "开始-新增待办任务\r\n"; dal.AddDoTask(con, Entity, drs[0], sourceTable, strAppFieldValue);//新增待办任务 ErroMessage += "结束-新增待办任务\r\n"; } else if (IsTask == "0")//消息 { ErroMessage += "开始-新增消息\r\n"; dal.AddDoTaskMessage(con, Entity, drs[0], sourceTable); ErroMessage += "结束-新增消息\r\n"; } ErroMessage += "结束-发的是默认流程触发条件\r\n"; } DataRow[] NotDefaultMsg = dtFlowTrigger.Select("ISDEFAULTMSG=0");//非默认消息,需要调用的WCF待办任务 if (NotDefaultMsg != null && NotDefaultMsg.Count() > 0) { foreach (DataRow dr1 in NotDefaultMsg) { string strAppMsg = string.Empty; ErroMessage += "开始-调用WCF服务\r\n"; CallWCFService(con, dr1, sourceTable, ref strAppMsg, ref ErroMessage);//调用WCF服务 ErroMessage += "结束-调用WCF服务\r\n"; if (!string.IsNullOrEmpty(strAppMsg)) { try { string IsNewFlow = "1"; string NewFormID = string.Empty; string strFormTypes = string.Empty;//表单状态 DataRow DRNewTrigger = null; if (ApplicationValueToDataTable(con, strAppMsg, string.Concat(Entity.COMPANYID), ref sourceTable, ref IsNewFlow, ref NewFormID, ref strFormTypes, ref DRNewTrigger)) { //通过岗位查找用户,并且取第一个用户为发送消息的对像 PersonnelServiceClient HRClient = new PersonnelServiceClient(); if (!string.IsNullOrEmpty(dr1["OWNERPOSTID"].ToString())) { string[] Employees = HRClient.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString()); if (Employees != null && Employees.Count() > 0) { dal.AddDoTask(con, Entity, dr1, sourceTable, Employees[0], NewFormID, strAppFieldValue, string.Concat(dr1["MESSAGEBODY"]), strFormTypes);//发送消息 } } else { string cMessage = "引擎调用新流程时没有选定岗位 SystemCode:" + string.Concat(DRNewTrigger["SYSTEMCODE"]) + " MODELCODE:" + string.Concat(DRNewTrigger["MODELCODE"]) + " NewFormID:" + NewFormID; ErroMessage += cMessage; throw new Exception("命名空间:SMT.FlowWFService.EnginFlowBLL类方法:EngineExecute()引擎调用新流程时没有选定岗位"); } } } catch (Exception ex) { LogHelper.WriteLog(ErroMessage); throw new Exception("命名空间:SMT.FlowWFService.EnginFlowBLL类方法:EngineExecute()" + ex.Message); } } } } result = true; #endregion } else { string strMsg = "系统代号" + Entity.SYSTEMCODE + "\r\n" + "模块代号:" + Entity.MODELCODE + "\r\n" + "触发条件:" + Entity.ORDERSTATUS + "公司ID:" + Entity.COMPANYID + "\r\n" + "单据ID:" + Entity.ORDERID; ErroMessage += "该单据所对应的引擎系统设置未找到,请先配置该模块引擎消息(审核通过、审核不通过、审核中):\r\n" + strMsg; LogHelper.WriteLog(ErroMessage); throw new Exception("该单据所对应的引擎系统设置未找到,请先配置该模块引擎消息(审核通过、审核不通过、审核中)" + strMsg); } return result; }
/// <summary> /// 调用WCF返回数据转换成数据源 /// </summary> /// <param name="strAppMsg">返回数据内容</param> /// <param name="sourceTable">原数据源Table</param> /// <param name="IsNewFlow">是否是新流程</param> /// <param name="DRFlowTrigger">新流程对应的流程定义</param> /// <returns></returns> private bool ApplicationValueToDataTable(OracleConnection con, string strAppMsg, string strCompanyID, ref DataTable sourceTable, ref string IsNewFlow, ref string NewFormID, ref string strFormTypes, ref DataRow DRFlowTrigger) { try { EnginFlowDAL dal = new EnginFlowDAL(); if (sourceTable == null) { sourceTable = new DataTable(); sourceTable.Columns.Add("FieldType", typeof(string)); sourceTable.Columns.Add("ColumnName", typeof(string)); sourceTable.Columns.Add("ColumnValue", typeof(string)); } Byte[] b = System.Text.UTF8Encoding.UTF8.GetBytes(strAppMsg); XElement xele = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(b))); var v = from c in xele.Descendants("Attribute") select c; IsNewFlow = string.Empty; try { //是否是新流程(0:新流程,1:旧流程) IsNewFlow = (from c in xele.Descendants("IsNewFlow") select c).FirstOrDefault().Value; } catch { IsNewFlow = "1"; } try { NewFormID = (from c in xele.Descendants("NewFormID") select c).FirstOrDefault().Value; } catch { } try { strFormTypes = (from c in xele.Descendants("FormTypes") select c).FirstOrDefault().Value; } catch { } if (v.Count() > 0) { string SystemCode = string.Empty; string ModelCode = string.Empty; foreach (var vv in v) { DataRow dr = sourceTable.NewRow(); string Name = vv.Attribute("Name").Value.ToString(); DataRow[] drs = sourceTable.Select("ColumnName='" + Name + "'"); if (drs != null && drs.Length > 0) { foreach (DataRow row in drs) { sourceTable.Rows.Remove(row);//移除相同数据 } } string Value = vv.Attribute("DataValue").Value.ToString(); dr["ColumnName"] = Name; dr["ColumnValue"] = Value; dr["FieldType"] = "sys"; if (IsNewFlow == "0") { switch (Name) { case "SYSTEMCODE": SystemCode = Value; break; case "MODELCODE": ModelCode = Value; break; } } sourceTable.Rows.Add(dr); } //新流程,并且系统代号与模块代号不为空 if (IsNewFlow == "0" && !string.IsNullOrEmpty(SystemCode) && !string.IsNullOrEmpty(ModelCode)) { DataTable table = dal.FlowTriggerTable(con, SystemCode, ModelCode, null, strCompanyID); if (table != null && table.Rows.Count > 0) { DRFlowTrigger = table.Rows[0]; } } return true; } } catch { return false; } return false; }
/// <summary> /// 非默认消息时,自动发起流程 /// </summary> private void AutoCallFlow( EnginFlowDAL dal, T_WF_DOTASK Entity, DataTable dtFlowTrigger, DataTable sourceTable, ref FlowUser sUser,string strAppFieldValue, ref string ErroMessage) { DataRow[] NotDefaultMsg = dtFlowTrigger.Select("ISDEFAULTMSG=0");//非默认消息,需要调用的WCF待办任务 if (NotDefaultMsg != null && NotDefaultMsg.Count() > 0) { #region 非默认消息时,自动发起流程 foreach (DataRow dr1 in NotDefaultMsg) { string strAppMsg = string.Empty; CallWCFService( dr1, sourceTable, ref sUser, ref strAppMsg, ref ErroMessage);//调用WCF服务 if (!string.IsNullOrEmpty(strAppMsg)) { #region 执行自动发起流程结果返回不为空 try { string IsNewFlow = "1"; string NewFormID = string.Empty; string strFormTypes = string.Empty;//表单状态 DataRow DRNewTrigger = null; if (ApplicationValueToDataTable( strAppMsg, string.Concat(Entity.COMPANYID), ref sourceTable, ref IsNewFlow, ref NewFormID, ref strFormTypes, ref DRNewTrigger)) { //通过岗位查找用户,并且取第一个用户为发送消息的对像 //PersonnelServiceClient HRClient = new PersonnelServiceClient(); if (!string.IsNullOrEmpty(dr1["OWNERPOSTID"].ToString())) { if (DRNewTrigger != null) { Tracer.Debug("自动发起流程 消息规则设置中 选定岗位=" + dr1["OWNERPOSTID"].ToString() + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + ":MODELCODE=" + string.Concat(DRNewTrigger["MODELCODE"]) + ";AutoCallFlow() FORMID=" + sUser.FormID); } else { Tracer.Debug("DRNewTrigger=null 自动发起流程的第三方消息规则中没有设置没有消息规则,当前的模块消息规则设置中 选定岗位=" + dr1["OWNERPOSTID"].ToString() + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + ":MODELCODE=null;AutoCallFlow() FORMID=" + sUser.FormID); } List<string> Employees = new List<string>();// HRClient.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString()); using (EmployeeBLL bll = new EmployeeBLL()) { var q = bll.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString()); Employees= q.Count() > 0 ? q.ToList() : null; } if (Employees != null && Employees.Count() > 0) { Entity.SYSTEMCODE = dr1["SYSTEMCODE"].ToString();//解决傅意成遇到的问题(发起员工入职手续的待办,数据库中数据存在问题,系统代号是错误的RM代号,应是HR代号) dal.AddDoTask( Entity, dr1, sourceTable, Employees[0], NewFormID, strAppFieldValue, string.Concat(dr1["MESSAGEBODY"]), strFormTypes);//发送消息 //FlowEngine.TaskCacheReflesh(Employees[0]); } } else { string cMessage = ""; if (DRNewTrigger != null) { cMessage = "SystemCode:" + string.Concat(DRNewTrigger["SYSTEMCODE"]) + " MODELCODE:" + string.Concat(DRNewTrigger["MODELCODE"]) + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + " NewFormID:" + NewFormID; } else { cMessage = "DRNewTrigger=null 消息=" + string.Concat(dr1["MESSAGEBODY"]) + " NewFormID:" + NewFormID; } //string cMessage = "SystemCode:" + string.Concat(DRNewTrigger["SYSTEMCODE"]) + " MODELCODE:" + string.Concat(DRNewTrigger["MODELCODE"]) + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + " NewFormID:" + NewFormID; ErroMessage = cMessage; if (DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_oa_businesstrip" || DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_oa_businessreport" || DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_salaryrecordbatch" || DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_attendancesolutionasign" || DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_attendancesolution" || DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_employeesalaryrecord" || DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_employeeentry" || DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_leftoffice" || DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_oa_travelreimbursement" || DRNewTrigger["MODELCODE"].ToString().ToLower() == "t_hr_leftofficeconfirm" ) {//不需要接收岗位的: //出差申请 T_OA_BUSINESSTRIP //出差报告 T_OA_BUSINESSREPORT //月薪批量审核 T_HR_SALARYRECORDBATCH //考勤方案分配 T_HR_ATTENDANCESOLUTIONASIGN //考勤方案定义 T_HR_ATTENDANCESOLUTION //薪资记录 T_HR_EMPLOYEESALARYRECORD //员工入职 T_HR_EMPLOYEEENTRY //员工离职 T_HR_LEFTOFFICE //离职确认 T_HR_LEFTOFFICECONFIRM //出差报销 T_OA_TRAVELREIMBURSEMENT Tracer.Debug("自动发起流程 消息规则中非默认的设置中 不需要 选定岗位: AutoCallFlow() FORMID=" + sUser.FormID + " " + cMessage); } else { Tracer.Debug("自动发起流程(失败) 消息规则中非默认的设置中没有选定岗位:AutoCallFlow() FORMID=" + sUser.FormID + " " + cMessage); throw new Exception("自动发起流程(失败) 消息规则中非默认的设置中没有选定岗位 \r\n FORMID=" + sUser.FormID); } } } } catch (Exception ex) { Tracer.Debug("自动发起流程(失败):消息规则中非默认的设置中检查选定岗位出错 消息=" + string.Concat(dr1["MESSAGEBODY"]) + " AutoCallFlow() FORMID=" + sUser.FormID + " 异常信息:\r\n" + ex.Message); throw new Exception("自动发起流程(失败):消息规则中非默认的设置中检查选定岗位出错 \r\n FORMID=" + sUser.FormID); } #endregion } else { Tracer.Debug("自动发起流程成功,但返回的结果为空 消息规则设置中 ;选定岗位=" + dr1["OWNERPOSTID"].ToString() + " ;消息=" + string.Concat(dr1["MESSAGEBODY"]) + ";MODELCODE=" + string.Concat(dr1["MODELCODE"]) + ":AutoCallFlow() FORMID=" + sUser.FormID); } } #endregion } }
/// <summary> /// 任务完成后,消息关闭 /// </summary> /// <param name="strSystemCode">系统代码</param> /// <param name="strFormID">单据ID</param> /// <param name="strReceiveID">接收人</param> public void TaskMsgClose( string strSystemCode, string strFormID, string strReceiveID) { if (!string.IsNullOrEmpty(strSystemCode) && !string.IsNullOrEmpty(strFormID) && !string.IsNullOrEmpty(strReceiveID)) { try { EnginFlowDAL dal = new EnginFlowDAL(); if (strReceiveID.IndexOf(',') != -1) { string[] users = strReceiveID.Split(','); foreach (string user in users) { //刷新缓存用户是否有新的待办 暂时没有写入缓存 dal.CloseDoTaskStatus( strSystemCode, strFormID, user); //FlowEngine.TaskCacheReflesh(user); } } else { //刷新缓存用户是否有新的待办 dal.CloseDoTaskStatus( strSystemCode, strFormID, strReceiveID);//关闭待办 //FlowEngine.TaskCacheReflesh(strReceiveID); } } catch (Exception e) { string cMessage = "TaskMsgClose出现异常:SystemCode='" + strSystemCode + "',FormID='" + strFormID + "',ReceiveUser='******',Error='" + e.Message + "'"; Tracer.Debug("TaskMsgClose" + cMessage); } } }
/// <summary> /// 我的单据新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool AddPersonalRecord( SubmitData submitData, string state, FlowUser user, FLOW_FLOWRECORDMASTER_T entity) { try { string SystemCode = string.Empty; string modeCode = string.Empty; string modeName = string.Empty; string strEntityKey = string.Empty; string msgOpen = string.Empty; string strBusiness = submitData.XML; SetFileFromBusinessXml(strBusiness, ref SystemCode, ref modeCode, ref modeName, ref strEntityKey, ref msgOpen); Tracer.Debug("在填写我的单据时候的参数CHECKSTATE:" + state + "||模块名称:" + user.ModelName); T_PF_PERSONALRECORD model = new T_PF_PERSONALRECORD(); model.SYSTYPE = user.SysCode; model.PERSONALRECORDID = Guid.NewGuid().ToString(); model.ISFORWARD = "0"; model.ISVIEW = "0"; switch (state) { case "1": model.MODELCODE = submitData.ModelCode; model.MODELID = submitData.FormID; if (string.IsNullOrWhiteSpace(submitData.SumbitUserID) && string.IsNullOrWhiteSpace(submitData.SumbitCompanyID)) { //预算有这样情况submitData.SumbitUserID为空 model.OWNERCOMPANYID = submitData.ApprovalUser.CompanyID; model.OWNERDEPARTMENTID = submitData.ApprovalUser.DepartmentID; model.OWNERID = submitData.ApprovalUser.UserID; model.OWNERPOSTID = submitData.ApprovalUser.PostID; } else { model.OWNERCOMPANYID = submitData.SumbitCompanyID; model.OWNERDEPARTMENTID = submitData.SumbitDeparmentID; model.OWNERID = submitData.SumbitUserID; model.OWNERPOSTID = submitData.SumbitPostID; } model.MODELDESCRIPTION = string.Format("您{0}的[{1}]正在审核中!", DateTime.Now.ToString("MM月dd日HH:mm"), user.ModelName.Trim()); break; case "2": model.MODELID = submitData.FormID; model.MODELCODE = entity.MODELCODE; model.MODELDESCRIPTION = string.Format("您{0}的[{1}]已经审核通过!", entity.CREATEDATE.Value.ToString("MM月dd日HH:mm"), user.ModelName.Trim()); break; case "3": model.MODELID = submitData.FormID; model.MODELCODE = entity.MODELCODE; model.MODELDESCRIPTION = string.Format("您{0}的[{1}]已经审核不通过!", entity.CREATEDATE.Value.ToString("MM月dd日HH:mm"), user.ModelName.Trim()); break; } model.CHECKSTATE = state; model.CREATEDATE = DateTime.Now; model.CONFIGINFO = msgOpen;// ConvertXML(submitData); if (!string.IsNullOrWhiteSpace(model.CONFIGINFO)) { EnginFlowDAL dal = new EnginFlowDAL(); string recordID = dal.GetExistRecord(model.SYSTYPE, model.MODELCODE, model.MODELID, model.ISFORWARD); if (recordID != "") { return dal.UpdatePersonalRecord(model, recordID); } else { return dal.AddPersonalRecord(model); } } else { Tracer.Debug("在填写我的单据时候获取不到配置FormID:" + submitData.FormID + ""); } return false; } catch (Exception ex) { Tracer.Debug("在填写我的单据时候错误FormID:" + submitData.FormID + "||Exception" + ex.Message); throw new Exception(ex.Message, ex); } }
/// <summary> /// 审核结束时关闭所有的流程资讯在待办中 /// </summary> /// <param name="con"></param> /// <param name="strSystemCode"></param> /// <param name="strFormID"></param> /// <returns></returns> public bool FlowConsultatiCloseAll( string strSystemCode, string strFormID) { if (!string.IsNullOrEmpty(strSystemCode) && !string.IsNullOrEmpty(strFormID)) { try { EnginFlowDAL dal = new EnginFlowDAL(); return dal.CloseAllConsultati( strSystemCode, strFormID); } catch (Exception e) { string cMessage = "CloseAllConsultati出现异常:SystemCode='" + strSystemCode + "',FormID='" + strFormID + "'Error='" + e.Message + "'"; Tracer.Debug("CloseAllConsultati" + cMessage); return false; } } else { return false; } }
private bool SendDotask(string submitUserName, string modeName, string msgOpen, T_WF_DOTASK Entity, string IsTask, ref FlowUser sUser, ref string ErroMessage) { bool result = false; dal = new EnginFlowDAL(); strAppFieldValue = string.Empty; //sUser.TrackingMessage+="开始将数据源字段转换成数据表 FORMID="+sUser.FormID+"r\n"; //将业务数据与流程数据转换成DataTable作为替换的源数据 sourceTable = FieldStringToDataTable(Entity.APPFIELDVALUE, ref strAppFieldValue); //sUser.TrackingMessage += "结束将数据源字段转换成数据表 FORMID=" + sUser.FormID + "r\n"; //通过系统代号,模块代号,企业ID,流程状态查到引擎配置内容 //Tracer.Debug("开始通过系统代号,模块代号,企业ID,流程状态查[消息规则]内容 FORMID=" + sUser.FormID + ""); dtFlowTrigger = dal.FlowTriggerTable(Entity.SYSTEMCODE, Entity.MODELCODE, Entity.ORDERSTATUS.ToString(), Entity.COMPANYID); //Tracer.Debug("结束通过系统代号,模块代号,企业ID,流程状态查[消息规则]内容 FORMID=" + sUser.FormID + ""); if (dtFlowTrigger == null || dtFlowTrigger.Rows.Count == 0) { //sUser.ErrorMsg += "没有找到[消息规则]内容 再次通过全局默认消息继续查找 FORMID=" + sUser.FormID + " 异常信息:" + ErroMessage + "\r\n"; //Tracer.Debug("dtFlowTrigger=null或者dtFlowTrigger.Rows.Count == 0 没有找到[消息规则]内容 再次通过全局默认消息继续查找 FORMID=" + sUser.FormID + ""); dtFlowTrigger = dal.FlowTriggerTable(Entity.SYSTEMCODE, Entity.MODELCODE, Entity.ORDERSTATUS.ToString()); } //if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0) //{ //} //else //{ // //string strMsg = "系统代号:" + Entity.SYSTEMCODE + "\r\n" + // // "模块代号:" + Entity.MODELCODE + "\r\n" + // // "触发条件:" + Entity.ORDERSTATUS + "\r\n" + // // "公司 ID:" + Entity.COMPANYID + "\r\n" + // // "单据 ID:" + Entity.ORDERID; // //ErroMessage = "FORMID=" + sUser.FormID + " 发送待办任务失败, 该单据所对应的[消息规则]设置未找到,请先配置公司[" + sUser.CompayName+ "("+sUser.CompayID+")] 下的模块[ " + sUser.ModelName + " ]的 [消息规则](审核通过、审核不通过、审核中):\r\n" + strMsg; // //sUser.ErrorMsg += "发送待办任务失败 FORMID=" + sUser.FormID + " 异常信息:" + ErroMessage + "\r\n"; // //Tracer.Debug(ErroMessage); // //暂是没有默认消息也可以审核通过 // // throw new Exception("该单据所对应的引擎系统设置未找到,请先配置该模块 " + sUser.ModelName + " 引擎消息(审核通过、审核不通过、审核中)"); //} #region 发送待办任务(不管有没有配置消息规则,都发送待办任务) DataRow[] drs = new DataRow[] { }; if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0) { drs = dtFlowTrigger.Select("ISDEFAULTMSG=1");//不管有没有配置 } //edit by ken 2015-7-17 //if (drs.Count() > 0) //{ //sUser.ErrorMsg += "发现默认流程触发[消息规则]内容 FORMID=" + sUser.FormID + " IsTask:" + IsTask.ToString() + "\r\n"; //Tracer.Debug("FORMID=" + sUser.FormID + " 发现默认流程触发消息规则 IsTask=" + IsTask.ToString()); //if (IsTask == "1")//新增待办任务 //{ dal.AddDoTask(Entity, drs, sourceTable, strAppFieldValue, submitUserName, modeName, msgOpen);//新增待办任务 //FlowEngine.TaskCacheReflesh(Entity.RECEIVEUSERID); //} //else if (IsTask == "0")//消息 //{ //dal.AddDoTaskMessage(Entity, drs[0], sourceTable); //} //} //else //{ // sUser.ErrorMsg += "没有发现默认流程触发(审核通过、审核不通过、审核中)[消息规则]内容 FORMID=" + sUser.FormID + " IsTask:" + IsTask.ToString() + "\r\n"; // Tracer.Debug("FORMID=" + sUser.FormID + " 没有发现默认流程触发(审核通过、审核不通过、审核中)消息规则 "); // //throw new Exception("该单据所对应的默认[消息规则]设置未找到,请先配置该模块 " + sUser.ModelName + " 默认消息规则(审核通过、审核不通过、审核中)"); //} //end edit by ken 2015-7-17 DataRow[] NotDefaultMsg = dtFlowTrigger.Select("ISDEFAULTMSG=0");//非默认消息,需要调用的WCF待办任务 if (NotDefaultMsg != null && NotDefaultMsg.Count() > 0) { //AutoCallFlow( dal,Entity,dtFlowTrigger,sourceTable, ref sUser, strAppFieldValue, ref ErroMessage); #region 非默认消息时,自动发起流程 //foreach (DataRow dr1 in NotDefaultMsg) //{ // string strAppMsg = string.Empty; // CallWCFService( dr1, sourceTable, ref sUser, ref strAppMsg, ref ErroMessage);//调用WCF服务 // if (!string.IsNullOrEmpty(strAppMsg)) // { // try // { // string IsNewFlow = "1"; // string NewFormID = string.Empty; // string strFormTypes = string.Empty;//表单状态 // DataRow DRNewTrigger = null; // if (ApplicationValueToDataTable( strAppMsg, string.Concat(Entity.COMPANYID), ref sourceTable, ref IsNewFlow, ref NewFormID, ref strFormTypes, ref DRNewTrigger)) // { // //通过岗位查找用户,并且取第一个用户为发送消息的对像 // PersonnelServiceClient HRClient = new PersonnelServiceClient(); // if (!string.IsNullOrEmpty(dr1["OWNERPOSTID"].ToString())) // { // string[] Employees = HRClient.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString()); // if (Employees != null && Employees.Count() > 0) // { // dal.AddDoTask( Entity, dr1, sourceTable, Employees[0], NewFormID, strAppFieldValue, string.Concat(dr1["MESSAGEBODY"]), strFormTypes);//发送消息 // } // } // else // { // string cMessage = "引擎调用新流程时没有选定岗位 SystemCode:" + string.Concat(DRNewTrigger["SYSTEMCODE"]) + " MODELCODE:" + string.Concat(DRNewTrigger["MODELCODE"]) + " NewFormID:" + NewFormID; // ErroMessage = cMessage; // throw new Exception("命名空间:SMT.FlowWFService.EnginFlowBLL类方法:EngineExecute()引擎调用新流程时没有选定岗位"); // } // } // } // catch (Exception ex) // { // throw new Exception("命名空间:SMT.FlowWFService.EnginFlowBLL类方法:EngineExecute() FORMID=" + sUser.FormID + "" + ex.Message); // } // } //} #endregion } result = true; #endregion return result; }