/// <summary> /// 事件定时 /// </summary> /// <param name="strEventXml">定时所需的XML模版</param> /// <returns></returns> public bool SaveEventTriggerData(string strEventXml) { if (!string.IsNullOrEmpty(strEventXml)) { try { Byte[] b = System.Text.UTF8Encoding.UTF8.GetBytes(strEventXml); XElement xele = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(b))); T_WF_TIMINGTRIGGERACTIVITY trigger = new T_WF_TIMINGTRIGGERACTIVITY(); trigger.COMPANYID = EventXmlAttribute(xele, "CompanyCode"); trigger.SYSTEMCODE = EventXmlAttribute(xele, "SystemCode"); trigger.MODELCODE = EventXmlAttribute(xele, "ModelCode"); trigger.TRIGGERTIME = Convert.ToDateTime(EventXmlAttribute(xele, "TaskStartDate")); trigger.BUSINESSID = EventXmlAttribute(xele, "ApplicationOrderCode"); string ProcessCycle = EventXmlAttribute(xele, "ProcessCycle"); // 0 只触发一次 1 分钟 2小时 3 天 4 月 5年 6周 7未知 switch (ProcessCycle.ToUpper()) { case "YEAR": trigger.TRIGGERROUND = 5; break; case "MONTH": trigger.TRIGGERROUND = 4; break; case "DAY": trigger.TRIGGERROUND = 3; break; case "HOUR": trigger.TRIGGERROUND = 2; break; case "MINUTE": trigger.TRIGGERROUND = 1; break; case "WEEK": trigger.TRIGGERROUND = 6; break; case " ": trigger.TRIGGERROUND = 0; break; case "": trigger.TRIGGERROUND = 0; break; default: trigger.TRIGGERROUND = 100; trigger.REMARK = "未知的触发周期:" + ProcessCycle; break; } trigger.RECEIVERUSERID = EventXmlAttribute(xele, "ReceiveUser"); trigger.RECEIVEROLE = EventXmlAttribute(xele, "ReceiveRole"); trigger.MESSAGEBODY = EventXmlAttribute(xele, "MessageBody"); trigger.WCFURL = EventXmlAttribute(xele, "ProcessWcfUrl"); trigger.FUNCTIONNAME = EventXmlAttribute(xele, "WcfFuncName"); string TriggerType = EventXmlAttribute(xele, "TriggerType"); if (string.IsNullOrEmpty(TriggerType))// { TriggerType = "User"; } trigger.TRIGGERTYPE = TriggerType; string WcfFuncParamter = string.Empty; string MsgLinkUrl = string.Empty; try { WcfFuncParamter = xele.Element("WcfFuncParamter").ToString().Replace("<WcfFuncParamter>", "").Replace("</WcfFuncParamter>", ""); trigger.FUNCTIONPARAMTER = WcfFuncParamter; } catch { } try { MsgLinkUrl = xele.Element("MsgLinkUrl").ToString().Replace("<MsgLinkUrl>", "").Replace("</MsgLinkUrl>", ""); trigger.MESSAGEURL = MsgLinkUrl; } catch { } trigger.PAMETERSPLITCHAR = EventXmlAttribute(xele, "WcfParamSplitChar"); trigger.WCFBINDINGCONTRACT = EventXmlAttribute(xele, "WcfBinding"); trigger.TRIGGERDESCRIPTION = "EventTrigger"; if (trigger.TRIGGERSTART == null) { trigger.TRIGGERSTART = DateTime.Now; } if (trigger.TRIGGEREND == null) { trigger.TRIGGEREND = DateTime.Now.AddYears(60); } if (trigger.TRIGGERMULTIPLE <= 0) { trigger.TRIGGERMULTIPLE = 1; } EngineServicesDAL dal = new EngineServicesDAL(); return dal.AddTimingTrigger(trigger); } catch (Exception e) { string cMessage = "<消息引擎>Message=[" + e.Message + "]" + "<消息引擎>Source=[" + e.Source + "]<消息引擎>StackTrace=[" + e.StackTrace + "]<消息引擎>TargetSite=[" + e.TargetSite + "]"; Tracer.Debug(cMessage); return false; } } else { return false; } }
public void NotesSend(List<ReceiveUserAndContent> List, string SystemCode, string strFormID) { if (List != null) { EngineServicesDAL dal = new EngineServicesDAL(); foreach (ReceiveUserAndContent entity in List) { dal.SendTriggerMsg(entity.ReceiveUser, SystemCode, strFormID, entity.Content); } } }
/// <summary> /// PendingDetailTasksByOrderNodeCodeForMobile /// </summary> /// <param name="orderCode"></param> /// <returns></returns> public T_FLOW_ENGINEMSGLIST PendingDetailTasksByPhone(string orderCode) { EngineServicesDAL dal = new EngineServicesDAL(); try { if (orderCode.IndexOf('_') > 0) { orderCode = orderCode.Substring(orderCode.IndexOf('_') + 1); } return dal.PendingDetailTasksByPhone(orderCode); } catch (Exception ex) { return null; } }
public void ModelMsgClose(string strModelCode, string strReceiveUser) { if (!string.IsNullOrEmpty(strModelCode) && !string.IsNullOrEmpty(strReceiveUser)) { try { EngineServicesDAL dal = new EngineServicesDAL(); //刷新缓存用户是否有新的待办 TaskCache.TaskCacheReflesh(strReceiveUser); dal.ClosedDoTaskStatus(strModelCode, strReceiveUser); } catch (Exception e) { string cMessage = "Message=[" + e.Message + "]" + "<消息引擎>Source=[" + e.Source + "]<消息引擎>StackTrace=[" + e.StackTrace + "]<消息引擎>TargetSite=[" + e.TargetSite + "]" + "\r\n"; Tracer.Debug("ModelMsgClose():" + cMessage); } } }
public void MsgListClose(string strSystemCode, List<ReceiveUserForm> List) { string strMsg = string.Empty; if (List != null && List.Count > 0) { if (!string.IsNullOrEmpty(strSystemCode)) { EngineServicesDAL dal = new EngineServicesDAL(); foreach (ReceiveUserForm user in List) { if (user.FormID != null && user.FormID.Count > 0) { foreach (string strFormID in user.FormID) { try { TaskCache.TaskCacheReflesh(user.ReceiveUser); dal.ClosedDoTaskStatus(strSystemCode, strFormID, user.ReceiveUser); } catch (Exception e) { strMsg = "TaskMsgClose出现异常:SystemCode='" + strSystemCode + "',FormID='" + strFormID + "',ReceiveUser='******',Error='" + e.Message + "'"; } } } } } } else { strMsg = "MsgListClose(批量关闭待办任务) 没有得到关闭列表数据:SystemCode='" + strSystemCode + "'"; } if (!string.IsNullOrEmpty(strMsg)) { Tracer.Debug("MsgListClose" + strMsg); } }
public List<T_FLOW_ENGINENOTES> EngineNotes(string strUserID, string strStatus, int iTop) { EngineServicesDAL dal = new EngineServicesDAL(); try { return dal.GetMsgNodes(strUserID, strStatus, iTop).ToList(); } catch { return null; } }
public T_WF_DOTASK GetDoTaskEntity(string orderID, string receiveUserID) { try { if (string.IsNullOrWhiteSpace(orderID) || string.IsNullOrWhiteSpace(receiveUserID)) { throw new Exception("参数不全!"); } EngineServicesDAL dal = new EngineServicesDAL(); return dal.GetDoTaskEntity(orderID, receiveUserID); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
/// <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(string strAppMsg, string strCompanyID, ref DataTable sourceTable, ref string IsNewFlow, ref string NewFormID, ref string strFormTypes, ref DataRow DRFlowTrigger) { try { EngineServicesDAL dal = new EngineServicesDAL(); 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(SystemCode, ModelCode, null, strCompanyID); if (table != null && table.Rows.Count > 0) { DRFlowTrigger = table.Rows[0]; } } return true; } } catch { return false; } return false; }
private bool EngineExecute(T_WF_DOTASK Entity, string IsTask) { bool result = false; EngineServicesDAL dal = new EngineServicesDAL(); string strAppFieldValue = string.Empty; DataTable sourceTable = Common.FieldStringToDataTable(Entity.APPFIELDVALUE, ref strAppFieldValue);//将业务数据与流程数据转换成DataTable作为替换的源数据 //通过系统代号,模块代号,企业ID,流程状态查到引擎配置内容 DataTable dtFlowTrigger = dal.FlowTriggerTable(Entity.SYSTEMCODE, Entity.MODELCODE, Entity.ORDERSTATUS.ToString(), Entity.COMPANYID); if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0) { #region DataRow[] drs = dtFlowTrigger.Select("ISDEFAULTMSG=1");//发的是默认流程触发条件 if (drs.Count() > 0) { if (IsTask == "1")//新增待办任务 { TaskCache.TaskCacheReflesh(Entity.RECEIVEUSERID); dal.AddDoTask(Entity, drs[0], sourceTable, strAppFieldValue);//新增待办任务 } else if (IsTask == "0")//消息 { dal.AddDoTaskMessage(Entity, drs[0], sourceTable); } } DataRow[] NotDefaultMsg = dtFlowTrigger.Select("ISDEFAULTMSG=0");//非默认消息,需要调用的WCF待办任务 if (NotDefaultMsg != null && NotDefaultMsg.Count() > 0) { foreach (DataRow dr1 in NotDefaultMsg) { string strAppMsg = string.Empty; CallWCFService(dr1, sourceTable, ref strAppMsg);//调用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)) { //通过岗位查找用户,并且取第一个用户为发送消息的对像 PersonnelWS.PersonnelServiceClient HRClient = new PersonnelWS.PersonnelServiceClient(); if (!string.IsNullOrEmpty(dr1["OWNERPOSTID"].ToString())) { string[] Employees = HRClient.GetEmployeeIDsByPostID(dr1["OWNERPOSTID"].ToString()); if (Employees != null && Employees.Count() > 0) { TaskCache.TaskCacheReflesh(NewFormID); dal.AddDoTask(Entity, dr1, sourceTable, Employees[0], NewFormID, strAppFieldValue, string.Concat(dr1["MESSAGEBODY"]), strFormTypes);//发送消息 } } else { result = false; Tracer.Debug("命名空间:SMT.Workflow.Engine.Services.BLL类方法:EngineExecute()引擎调用新流程时没有选定岗位"); } } } catch (Exception ex) { result = false; Tracer.Debug("命名空间:SMT.Workflow.Engine.Services.BLL类方法: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; Tracer.Debug("该单据所对应的引擎系统设置未找到,请先配置该模块引擎消息(审核通过、审核不通过、审核中)" + strMsg); } return result; }
public void TaskDelete(string strSystemCode, string strFormID, string strReceiveID) { EngineServicesDAL dal = new EngineServicesDAL(); if (!string.IsNullOrEmpty(strSystemCode) && !string.IsNullOrEmpty(strFormID)) { TaskCache.TaskCacheReflesh(strReceiveID); dal.DeleteDoTaskStatus(strSystemCode, strFormID, strReceiveID); } }
//kangxf public void TaskMsgClose(string strSystemCode, string strFormID, string strReceiveUser) { if (!string.IsNullOrEmpty(strSystemCode) && !string.IsNullOrEmpty(strFormID) && !string.IsNullOrEmpty(strReceiveUser)) { try { EngineServicesDAL dal = new EngineServicesDAL(); if (strReceiveUser.IndexOf(',') != -1) { string[] users = strReceiveUser.Split(','); foreach (string user in users) { //刷新缓存用户是否有新的待办 TaskCache.TaskCacheReflesh(strReceiveUser); dal.ClosedDoTaskStatus(strSystemCode, strFormID, user); } } else { //刷新缓存用户是否有新的待办 TaskCache.TaskCacheReflesh(strReceiveUser); dal.ClosedDoTaskStatus(strSystemCode, strFormID, strReceiveUser); } } catch (Exception e) { string cMessage = "TaskMsgClose出现异常:SystemCode='" + strSystemCode + "',FormID='" + strFormID + "',ReceiveUser='******',Error='" + e.Message + "'"; Tracer.Debug("TaskMsgClose()" + cMessage); } } }
public void TaskDelete(List<CustomUserMsg> UserAndForm, string strSystemCode) { EngineServicesDAL dal = new EngineServicesDAL(); if (UserAndForm != null && UserAndForm.Count > 0) { foreach (CustomUserMsg user in UserAndForm) { //刷新缓存用户是否有新的待办 //EngineCache.TaskCache.TaskCacheReflesh(user.UserID); TaskCache.TaskCacheReflesh(user.UserID); dal.DeleteDoTaskStatus(strSystemCode, user.FormID, user.UserID); } } }
/// <summary> /// 新增消息(2013-05-06加入新的方法) /// </summary> /// <param name="list">UserID|FromID XML</param> /// <param name="SystemCode">系统代码</param> /// <param name="ModelCode">模块代码</param> public void SendTaskMessage(List<CustomUserMsg> list, string SystemCode, string ModelCode) { try { EngineServicesDAL dal = new EngineServicesDAL(); T_WF_MESSAGEBODYDEFINE MsgBodyDefine = dal.GetMessageBodyDefine(SystemCode, ModelCode, string.Empty, 0).FirstOrDefault(); if (MsgBodyDefine != null) //在默认消息中有定义消息 { //TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks); StringReader strRdr = null; foreach (CustomUserMsg item in list) { strRdr = new StringReader(item.FormID); XDocument xdoc = XDocument.Load(strRdr); string content = MsgBodyDefine.MESSAGEBODY; Regex reg = new Regex("\\{(.*?)\\}", RegexOptions.Singleline | RegexOptions.IgnoreCase); MatchCollection matchs = reg.Matches(content); foreach (var matitem in matchs) { string field = matitem.ToString().Replace("new:", "").Replace("{", "").Replace("}", "").ToUpper(); content = content.Replace(matitem.ToString(), (from ent in xdoc.Descendants("Object").Descendants("Attribute") where ent.Attribute("Name").Value.ToUpper() == field select ent).FirstOrDefault().Attribute("DataValue").Value); } dal.SendTriggerMsg(item.UserID.Split('|')[0], SystemCode, item.UserID.Split('|')[1], content); } //TimeSpan ts2= new TimeSpan(DateTime.Now.Ticks); //TimeSpan ts = ts2.Subtract(ts1).Duration();//计算时间差 strRdr.Dispose(); } else { throw new Exception("没有定义默认消息"); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public bool AddTimingTrigger(T_WF_TIMINGTRIGGERACTIVITY entity) { try { EngineServicesDAL dal = new EngineServicesDAL(); if (string.IsNullOrWhiteSpace(entity.TRIGGERID)) { entity.TRIGGERID = Guid.NewGuid().ToString(); } if (entity.TRIGGERACTIVITYTYPE < 1) { throw new Exception("触发类型必填"); } if (entity.TRIGGERTIME == null) { throw new Exception("触发时间必填"); } if (entity.TRIGGERROUND < 0) { throw new Exception("触发周期必填"); } if (entity.TRIGGERSTART == null) { entity.TRIGGERSTART = DateTime.Now; } if (entity.TRIGGEREND == null) { entity.TRIGGEREND = DateTime.Now.AddYears(60); } if (entity.TRIGGERMULTIPLE <= 0) { entity.TRIGGERMULTIPLE = 1; } return dal.AddTimingTrigger(entity); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
/// <summary> /// 关闭代办 /// </summary> /// <param name="list"></param> /// <param name="strModelCode"></param> /// <param name="strReceiveUser"></param> public void ClosedDoTaskOrderID(List<string> list, string strModelCode, string strReceiveUser) { if (!string.IsNullOrEmpty(strModelCode) && !string.IsNullOrEmpty(strReceiveUser)) { try { EngineServicesDAL dal = new EngineServicesDAL(); //刷新缓存用户是否有新的待办 TaskCache.TaskCacheReflesh(strReceiveUser); foreach (string item in list) { dal.ClosedDoTaskOrderID(item, strModelCode, strReceiveUser); } } catch (Exception e) { string cMessage = "Message=[" + e.Message + "]" + "<消息引擎>Source=[" + e.Source + "]<消息引擎>StackTrace=[" + e.StackTrace + "]<消息引擎>TargetSite=[" + e.TargetSite + "]" + "\r\n"; Tracer.Debug("ClosedDoTaskOrderID():" + cMessage); } } }
public void ApplicationMsgTriggerNew(List<CustomUserMsg> UserAndForm, string companyID, string SystemCode, string ModelCode, string strXml, MsgType msgType) { string strUserAndForm = string.Empty; string cMessage = string.Empty; if (UserAndForm.Count > 0) { try { EngineServicesDAL dal = new EngineServicesDAL(); T_WF_MESSAGEBODYDEFINE MsgBodyDefine = dal.GetMessageBodyDefine(SystemCode, ModelCode, companyID, 0).FirstOrDefault(); if (MsgBodyDefine != null) //在默认消息中有定义消息 { DataTable dtValue = Common.EncrytXmlToDataTable(strXml); string Content = MsgBodyDefine.MESSAGEBODY; string Url = MsgBodyDefine.MESSAGEURL; Content = Content.Replace("new:", ""); Common.ReplaceValue(ref Content, ref Url, dtValue); foreach (CustomUserMsg custom in UserAndForm) { strUserAndForm += "FormID:" + custom.FormID + " ReceiveUserID:" + custom.UserID + "\r\n"; if (MsgType.Task == msgType)//代办任务 { TaskCache.TaskCacheReflesh(custom.UserID); dal.ClosedDoTaskStatus(SystemCode, custom.FormID, custom.UserID); dal.SendTriggerTaskMsg(custom.UserID, SystemCode, ModelCode, custom.FormID, Content, Url, Common.BOObjectEscapeString(strXml), strXml); } else if (MsgType.Msg == msgType) { dal.SendTriggerMsg(custom.UserID, SystemCode, custom.FormID, Content); } } } else { cMessage = "未在消息定义中定义默认数据:ApplicationMsgTriggerNew" + "\r\n" + "SystemCode:" + SystemCode + "\r\n" + "ModelCode:" + ModelCode + "\r\n" + "执行时间:" + DateTime.Now.ToString(); Tracer.Debug("ApplicationMsgTriggerNew()" + cMessage); } } catch (Exception e) { cMessage = "ApplicationMsgTriggerNew出现异常" + "\r\n" + "SystemCode:" + SystemCode + "\r\n" + "ModelCode:" + ModelCode + "\r\n" + "业务数据XML:" + strXml + "\r\n" + "异常信息:" + e.Message + "\r\n" + "异常来源:" + e.Source; Tracer.Debug("ApplicationMsgTriggerNew()" + cMessage); } } cMessage = "ApplicationMsgTriggerNew被执行调用" + "\r\n" + "SystemCode:" + SystemCode + "\r\n" + "ModelCode:" + ModelCode + "\r\n" + "业务数据XML:" + strXml + "\r\n" + "UserAndForm Count:" + UserAndForm.Count + "\r\n" + "UserAndForm:" + strUserAndForm; Tracer.Debug("ApplicationMsgTriggerNew" + cMessage); }
public void DeleteTrigger(string orderID) { try { EngineServicesDAL dal = new EngineServicesDAL(); if (!string.IsNullOrEmpty(orderID)) { dal.DeleteTimingTrigger(orderID); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public void AddDoDask(string companyID, string orderID, string systemCode, string modelCode, string modelName, string strXML, MsgType msgType) { try { Tracer.Debug("传入参数:companyID||" + companyID + "||orderID:" + orderID + "||modelCode:" + modelCode + "||strXML:" + strXML); EngineServicesDAL dal = new EngineServicesDAL(); T_WF_MESSAGEBODYDEFINE MsgBodyDefine = dal.GetMessageBodyDefine(systemCode, modelCode, companyID, 0).FirstOrDefault(); if (MsgBodyDefine == null) { Tracer.Debug("EngineServicesBLL.AddDoDask()没有查询到默认消息:modelCode||" + modelCode + "||systemCode" + systemCode + "||companyID" + companyID); return; } DataTable dtValue = Common.EncrytXmlToDataTable(strXML); string Content = MsgBodyDefine.MESSAGEBODY; string Url = MsgBodyDefine.MESSAGEURL; Tracer.Debug("查询到的URL:" + Url); Content = Content.Replace("new:", ""); Common.ReplaceValue(ref Content, ref Url, dtValue); Tracer.Debug("替换后的URL:" + Url); //T_WF_DOTASK dask = new T_WF_DOTASK(); if (MsgBodyDefine.RECEIVETYPE == 1 && MsgBodyDefine.RECEIVERUSERID != null) { for (int i = 0; i < MsgBodyDefine.RECEIVERUSERID.Split(',').Length; i++) { if (MsgType.Task == msgType)//代办任务 { TaskCache.TaskCacheReflesh(MsgBodyDefine.RECEIVERUSERID.Split(',')[i]); dal.ClosedDoTaskStatus(systemCode, orderID, MsgBodyDefine.RECEIVERUSERID.Split(',')[i]); Tracer.Debug("开始进行保存时的URL:" + Url); dal.SendTriggerTaskMsg(MsgBodyDefine.RECEIVERUSERID.Split(',')[i], systemCode, modelCode, orderID, Content, Url, Common.BOObjectEscapeString(strXML), strXML); } else if (MsgType.Msg == msgType) { dal.SendTriggerMsg(MsgBodyDefine.RECEIVERUSERID.Split(',')[i], systemCode, orderID, Content); } } } else if (MsgBodyDefine.RECEIVETYPE == 0 && MsgBodyDefine.RECEIVEPOSTID != null) { for (int i = 0; i < MsgBodyDefine.RECEIVEPOSTID.Split(',').Length; i++) { PersonnelWS.PersonnelServiceClient HRClient = new PersonnelWS.PersonnelServiceClient(); Tracer.Debug("岗位:" + MsgBodyDefine.RECEIVEPOSTID.Split(',')[i]); if (!string.IsNullOrEmpty(MsgBodyDefine.RECEIVEPOSTID.Split(',')[i])) { string[] Employees = HRClient.GetEmployeeIDsByPostID(MsgBodyDefine.RECEIVEPOSTID.Split(',')[i]); Tracer.Debug("岗位人:" + Employees[0]); if (MsgType.Task == msgType)//代办任务 { TaskCache.TaskCacheReflesh(Employees[0]); dal.ClosedDoTaskStatus(systemCode, orderID, Employees[0]); Tracer.Debug("开始进行保存时的URL:" + Url); dal.SendTriggerTaskMsg(Employees[0], systemCode, modelCode, orderID, Content, Url, Common.BOObjectEscapeString(strXML), strXML); } else if (MsgType.Msg == msgType) { dal.SendTriggerMsg(Employees[0], systemCode, orderID, Content); } } } } } catch (Exception ex) { Tracer.Debug("EngineServicesBLL.AddDoDask()" + ex.Message); } }
/// <summary> /// 流程撤销 /// </summary> /// <param name="strFlowXML"></param> /// <param name="strAppXml"></param> /// <returns></returns> public bool FlowCancel(string strFlowXML, string strAppXml) { 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 { EngineServicesDAL dal = new EngineServicesDAL(); /*解析流程和业务数据XML*/ Byte[] b = System.Text.UTF8Encoding.UTF8.GetBytes(strFlowXML); XElement xele = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(b))); strCompanyID = Common.XMLToAttribute(xele, "COMPANYID"); strSystemCode = string.Empty; strModelCode = Common.XMLToAttribute(xele, "MODELCODE"); strFormID = Common.XMLToAttribute(xele, "FORMID"); strModelName = Common.XMLToAttribute(xele, "ModelName"); strCheckState = Common.XMLToAttribute(xele, "CheckState"); strReceiveID = Common.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 (Common.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 { Tracer.Debug("FlowCancel该单号:" + strFormID + " 中业务数据无法取得EntityKey"); } } string strAppFieldValue = Common.ConbinString(xele) + Common.BOObjectEscapeString(strAppXml); DataTable dtValue = Common.FieldStringToDataTable(strAppFieldValue, ref strAppFieldValue); string content = dal.GetMessageDefineString("FLOWCANCEL"); string strUrl = string.Empty; Common.ReplaceUrl(ref content, ref strUrl, dtValue); dal.DoTaskCancel(strSystemCode, strModelCode, strFormID, strReceiveID, content); if (Config.IsNeedUpdateAudit)//是否执行更新审核状态 { if (!string.IsNullOrEmpty(strSystemCode) && !string.IsNullOrEmpty(strEntityType) && !string.IsNullOrEmpty(strEntityKey)) { UpdateAuditStatus(strSystemCode, strEntityType, strEntityKey, strFormID, strCheckState); } } 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"; Tracer.Debug("FlowCancel流程待办任务撤销异常" + cMessage); return false; } }
/// <summary> /// 引擎直接发消息 /// </summary> /// <param name="UserAndForm"></param> /// <param name="SystemCode"></param> /// <param name="Content"></param> public void ApplicationNotesTrigger(List<CustomUserMsg> UserAndForm, string SystemCode, string Content) { if (UserAndForm.Count > 0) { try { EngineServicesDAL dal = new EngineServicesDAL(); foreach (CustomUserMsg custom in UserAndForm) { dal.SendTriggerMsg(custom.UserID, SystemCode, custom.FormID, Content); } } catch (Exception e) { string cMessage = "ApplicationNotesTrigger出现异常" + "\r\n" + "SystemCode:" + SystemCode + "\r\n" + "Content:" + Content + "\r\n" + "异常信息:" + e.Message + "\r\n" + "异常来源:" + e.Source; Tracer.Debug("ApplicationMsgTrigger" + cMessage); } } }
public Dictionary<string, T_FLOW_ENGINEMSGLIST> GetPendingTaskPrevNext(MsgParms msgParams) { EngineServicesDAL dal = new EngineServicesDAL(); return dal.GetPendingTaskPrevNext(msgParams.MessageId, msgParams.Status, msgParams.UserID); }
/// <summary> /// 发送消息 /// </summary> /// <param name="ReceiveUserID"></param> /// <param name="strFormID"></param> /// <param name="MsgContent"></param> /// <param name="ModelCode"></param> /// <param name="strXml"></param> public void AppMsgTrigger(string ReceiveUserID, string strFormID, string MsgContent, string ModelCode, string strXml, string strNewGuid) { try { EngineServicesDAL dal = new EngineServicesDAL(); string SystemCode = string.Empty; if (!string.IsNullOrEmpty(strXml)) { Byte[] Bo = System.Text.UTF8Encoding.UTF8.GetBytes(strXml); XElement xemeBoObject = XElement.Load(System.Xml.XmlReader.Create(new MemoryStream(Bo))); SystemCode = (from item in xemeBoObject.Descendants("Name") select item).FirstOrDefault().Value; } DataTable dtFlowTrigger = dal.FlowTriggerTable(SystemCode, ModelCode, null, null); if (dtFlowTrigger != null && dtFlowTrigger.Rows.Count > 0) { TaskCache.TaskCacheReflesh(ReceiveUserID); DataTable dtValue = Common.EncrytXmlToDataTable(strXml); string Url = dtFlowTrigger.Rows[0]["applicationurl"] == null ? "" : dtFlowTrigger.Rows[0]["applicationurl"].ToString(); Url = Common.EncyptUrlNeedXMLHeader(Url, strFormID); // MsgTriggerBLL.ReplaceValue(ref Content, ref Url, dtValue); string strApplicationValue = Common.BOObjectEscapeString(strXml); //刷新缓存用户是否有新的待办 //EngineCache.TaskCache.TaskCacheReflesh(ReceiveUserID); dal.SendTriggerTaskMsg(ReceiveUserID, SystemCode, "", strNewGuid, MsgContent, Url, strApplicationValue, string.Empty); } } catch (Exception e) { string cMessage = "AppMsgTrigger出现异常" + "\r\n" + "ModelCode:" + ModelCode + "\r\n" + "strFormID:" + strFormID + "\r\n" + "异常信息:" + e.Message + "\r\n" + "异常来源:" + e.Source; Tracer.Debug("ApplicationMsgTrigger" + cMessage); } }
/// <summary> /// 关闭消息,与定时触发 /// </summary> /// <param name="DaskID"></param> /// <param name="strEventID"></param> public void MsgClose(string DaskID, string strEventID) { EngineServicesDAL dal = new EngineServicesDAL(); if (!string.IsNullOrEmpty(DaskID)) { dal.ClosedDoTaskStatus(DaskID); } if (!string.IsNullOrEmpty(strEventID)) { dal.DeleteTimingTrigger(strEventID); } }
public void CallCustomFlowTrigger(T_FLOW_CUSTOMFLOWDEFINE define) { string strResult = CallWcf(define);//Call 服务 if (!string.IsNullOrEmpty(strResult))//判断是否返回内容 { try { string NewFormID = string.Empty; DataRow DRNewTrigger = null; DataTable sourceTable = new DataTable(); if (ApplicationValueToDataTable(strResult, ref sourceTable, ref NewFormID, ref DRNewTrigger)) { string strUser = SMT.Workflow.Engine.BLL.Utility.ReceiveUser(define.RECEIVEUSER); TaskCache.TaskCacheReflesh(strUser); EngineServicesDAL dal = new EngineServicesDAL(); dal.SendTriggerMsg(sourceTable, NewFormID, define, strUser);//发送消息 } } catch (Exception ex) { string cMessage = "CallCustomFlowTrigger:" + strResult; Tracer.Debug(cMessage + ex.Message); } } }
/// <summary> /// 消息触发 /// </summary> /// <param name="recevieUser">接收人</param> /// <param name="SystemCode">系统代号</param> /// <param name="MsgKey">消息Key</param> /// <param name="ID">业务系统ID</param> /// <param name="strXml">业务数据</param> public void MsgTrigger(string[] recevieUser, string SystemCode, string MsgKey, string ID, string strXml) { if (recevieUser.Length > 0) { try { EngineServicesDAL dal = new EngineServicesDAL(); DataTable dt = dal.GetMessageDefine(MsgKey); DataTable dtValue = Common.EncrytXmlToDataTable(strXml); string Content = dt.Rows[0]["MESSAGEBODY"].ToString(); string Url = dt.Rows[0]["MESSAGEURL"].ToString(); Common.ReplaceValue(ref Content, ref Url, dtValue); foreach (string user in recevieUser) { //刷新缓存用户是否有新的待办 TaskCache.TaskCacheReflesh(user); dal.SendTriggerTaskMsg(user, SystemCode, "", ID, Content, Url, Common.BOObjectEscapeString(strXml), strXml); } } catch (Exception e) { string cMessage = "Message=[" + e.Message + "]" + "<消息引擎>Source=[" + e.Source + "]<消息引擎>StackTrace=[" + e.StackTrace + "]<消息引擎>TargetSite=[" + e.TargetSite + "]" + "\r\n"; Tracer.Debug("MsgTrigger():" + cMessage); } } }
/// <summary> /// 取消事件定时 /// </summary> /// <param name="strApplicationOrderCode">业务系统Guid</param> /// <returns></returns> public bool CancelEventTriggerData(string strApplicationOrderCode) { EngineServicesDAL dal = new EngineServicesDAL(); return dal.DeleteTimingTrigger(strApplicationOrderCode); }
/// <summary> /// 待办任务数据(不带业务数据字段) /// </summary> /// <param name="strMsgID"></param> /// <returns></returns> public T_FLOW_ENGINEMSGLIST PendingDetailTasks(string daskID) { EngineServicesDAL dal = new EngineServicesDAL(); try { return dal.GetEngineMsgDetail(daskID, true); } catch (Exception ex) { return null; } }
public void ClosedDoTaskFromID(string strModelCode, string fromID) { if (!string.IsNullOrEmpty(strModelCode) && !string.IsNullOrEmpty(fromID)) { try { EngineServicesDAL dal = new EngineServicesDAL(); //刷新缓存用户是否有新的待办 DataTable dt = dal.SelectTaskReceiveID(strModelCode, fromID); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { TaskCache.TaskCacheReflesh(dr["RECEIVEUSERID"].ToString()); dal.ClosedDoTaskOrderID(fromID, strModelCode, dr["RECEIVEUSERID"].ToString()); } } } catch (Exception e) { string cMessage = "Message=[" + e.Message + "]" + "<消息引擎>Source=[" + e.Source + "]<消息引擎>StackTrace=[" + e.StackTrace + "]<消息引擎>TargetSite=[" + e.TargetSite + "]" + "\r\n"; Tracer.Debug("ClosedDoTaskFromID():" + cMessage); } } }
/// <summary> /// 待办任务数据(主节) /// </summary> /// <param name="msgParams"></param> /// <returns></returns> public List<T_FLOW_ENGINEMSGLIST> PendingMainTasksParms(MsgParms msgParams) { EngineServicesDAL dal = new EngineServicesDAL(); try { List<T_FLOW_ENGINEMSGLIST> List = dal.GetEngineMainMsgList(msgParams.UserID, msgParams.Status, msgParams.MessageBody, msgParams.Top, msgParams.LastDay).ToList(); return List; } catch { return null; } }
public void AddTask(T_WF_DOTASK dask) { try { EngineServicesDAL dal = new EngineServicesDAL(); if (string.IsNullOrWhiteSpace(dask.DOTASKID)) { dask.DOTASKID = Guid.NewGuid().ToString(); } if (string.IsNullOrWhiteSpace(dask.ORDERID)) { throw new Exception("单据ID不能为空"); } if (string.IsNullOrWhiteSpace(dask.RECEIVEUSERID)) { throw new Exception("接收人ID不能为空"); } TaskCache.TaskCacheReflesh(dask.RECEIVEUSERID); dal.AddTask(dask); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }