private string AddRuleExtension(MessageRuleByCompany rule, Int32 ID) { string message = ""; DataTable dt; string Query; foreach (MessageRuleExtension ruleExt in rule.RuleExtensions) { Query = ruleExt.Custom2.Replace("__PARAM1", ID.ToString()); IList <Object[]> objList = Factory.DaoMenuOptionExtension().GetReportObject(Query, new List <String>()); //Query //Creado el objeto a desplegar dt = GetDataTableSchema(ruleExt.Custom3.Split(','), "dt0", objList); if (dt == null || dt.Rows.Count == 0) { continue; } message += ruleExt.Custom2; message += ConvertDataTableToHtml(dt, ""); } return(message); }
private void ProcessBusinessAlert(MessageRuleByCompany rule) { //Console.WriteLine("Entre BA"); try { //Si se vencio el next runtime lo ejecute if (rule.NextRunTime != null && rule.NextRunTime > DateTime.Now) { return; } //Sace el data set y guarda el resultado en Message Pool MessagePool msg = new MessagePool { CreationDate = DateTime.Now, CreatedBy = WmsSetupValues.SystemUser }; //Console.WriteLine("Get Message"); msg.Message = GetBusinessAlertMessage(rule); //Console.WriteLine("Message: " + msg.Message); if (string.IsNullOrEmpty(msg.Message)) { return; } msg.Entity = new ClassEntity { ClassEntityID = EntityID.BusinessAlert }; msg.IsHtml = rule.IsHtml; msg.MailFrom = rule.MailFrom; msg.MailTo = rule.MailTo; msg.Subject = rule.Template.Name; msg.AlreadySent = false; msg.Rule = rule; //Save the record. //Console.WriteLine("Saving BA:"); Factory.DaoMessagePool().Save(msg); //Setea el next runtime rule.NextRunTime = DateTime.Now.AddSeconds(rule.FrequencyNumber * rule.FrequencyType); rule.LastUpdate = DateTime.Now; Factory.DaoMessageRuleByCompany().Update(rule); } catch (Exception ex) { Console.WriteLine(ex.Message); ExceptionMngr.WriteEvent(" BusinessAlert:" + rule.RuleName, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Messages); } }
private void ProcessMessageObject(Object obj, Int32 rID, string rCode, MessageRuleByCompany rule, short EntityTypeID) { try { //lista de Mappings IList <LabelMapping> listMap = Factory.DaoLabelMapping().Select( new LabelMapping { LabelType = new DocumentType { DocTypeID = LabelType.Message } }); if (listMap != null && listMap.Count > 0) { MessagePool msg = GenerateMessage(listMap, rule.Template, obj); if (!string.IsNullOrEmpty(rule.Template.DetailQuery)) { msg.Message += AddDocumentDetails(rule, rID, rCode); } //Revisa si hay rule extension que adicionan informacion al mensaje if (rule.RuleExtensions != null && rule.RuleExtensions.Count > 0) { msg.Message += AddRuleExtension(rule, rID); } //Campos Faltantes msg.RecordID = rID; msg.Entity = new ClassEntity { ClassEntityID = EntityTypeID }; msg.IsHtml = rule.IsHtml; msg.MailFrom = rule.MailFrom; msg.MailTo = rule.MailTo; //Si el objeto es un documento de tipo sales Shipment y esta la //Variable de sent notification to customers se va el mail. if (obj.GetType().Equals(typeof(Document))) { msg.MailTo += GetAccountAddress((Document)obj); } msg.AlreadySent = false; msg.Rule = rule; //Save the record. Factory.DaoMessagePool().Save(msg); } } catch { } }
public IList <MessageRuleByCompany> Select(MessageRuleByCompany data) { IList <MessageRuleByCompany> datos = new List <MessageRuleByCompany>(); datos = GetHsql(data).List <MessageRuleByCompany>(); if (!Factory.IsTransactional) { Factory.Commit(); } return(datos); }
private string GetBusinessAlertMessage(MessageRuleByCompany rule) { IList <Object[]> objList = Factory.DaoMenuOptionExtension().GetReportObject(rule.Template.DetailQuery, new List <String>()); //Query //Creado el objeto a desplegar DataTable dt = GetDataTableSchema(rule.Template.DetailColumns.Split(','), "dt0", objList); if (dt == null || dt.Rows.Count == 0) { return(""); } return(ConvertDataTableToHtml(dt, "")); }
/// <summary> /// Cunado la regla aplica sobre documentos /// </summary> /// <param name="rule"></param> private void ProcessDocuments(MessageRuleByCompany rule) { if (string.IsNullOrEmpty(rule.MailTo)) //Sale si no hay a quien enviarle { return; } if (rule.RuleType == 1) { //Created Document pattern = new Document(); pattern.Company = rule.Company; if (!string.IsNullOrEmpty(rule.IntAttrib1)) { pattern.DocType = new DocumentType(); pattern.DocType.DocTypeID = short.Parse(rule.IntAttrib1.Split('=')[1]); } if (!string.IsNullOrEmpty(rule.IntAttrib2)) { pattern.DocStatus = new Status(); pattern.DocStatus.StatusID = short.Parse(rule.IntAttrib2.Split('=')[1]); } //Obteniendo la lista de documentos que coinciden IList <Int32> listObj = Factory.DaoDocument().SelectRulesMessage((Document)pattern, rule); if (listObj == null || listObj.Count == 0) { return; } Document doc = null; foreach (Int32 docID in listObj) { doc = Factory.DaoDocument().SelectById(new Document { DocID = docID }); ProcessMessageObject(doc, docID, doc.DocNumber, rule, EntityID.Document); } } }
public IList <Int32> SelectRulesMessage(Document document, MessageRuleByCompany rule) { string sQuery = ""; sQuery = "select DocID from Trace.Document a left outer join Report.MessagePool m on a.DocID = m.RecordID " + " and m.EntityID = :idx1 and m.RuleID = :rule Where " + " ( a.CreationDate >= :dtm1 or a.ModDate >= :dtm1 ) and m.RecordID is null "; StringBuilder sql = new StringBuilder(sQuery); if (document != null) { Parms = new List <Object[]>(); Parms.Add(new Object[] { "dtm1", DateTime.Today.AddDays(-5) }); //Limita a enviar solo los del dia Parms.Add(new Object[] { "idx1", EntityID.Document }); Parms.Add(new Object[] { "rule", rule.RowID }); //Rule a ejecutar if (document.DocType != null && document.DocType.DocTypeID != 0) { sql.Append(" and a.DocTypeID = :id1 "); Parms.Add(new Object[] { "id1", document.DocType.DocTypeID }); } if (document.DocStatus != null && document.DocStatus.StatusID != 0) { sql.Append(" and a.DocStatusID = :id3 "); Parms.Add(new Object[] { "id3", document.DocStatus.StatusID }); } //sql.Append(" and ( a.DocStatusID != :id2) "); //Parms.Add(new Object[] { "id2", DocStatus.Cancelled }); } sql = new StringBuilder(sql.ToString()); IQuery query = Factory.Session.CreateSQLQuery(sql.ToString()); SetParameters(query); return(query.List <Int32>()); }
public override IQuery GetHsql(object data) { StringBuilder sql = new StringBuilder("select a from MessageRuleByCompany a where "); MessageRuleByCompany option = (MessageRuleByCompany)data; if (option != null) { Parms = new List <Object[]>(); if (option.RowID != 0) { sql.Append(" a.RowID = :id and "); Parms.Add(new Object[] { "id", option.RowID }); } if (option.Template != null && option.Template.RowID != 0) { sql.Append("a.Template.RowID = :id1 and "); Parms.Add(new Object[] { "id1", option.Template.RowID }); } if (option.Company != null && option.Company.CompanyID != 0) { sql.Append("a.Company.CompanyID = :id2 and "); Parms.Add(new Object[] { "id2", option.Company.CompanyID }); } if (option.Entity != null && option.Entity.ClassEntityID != 0) { sql.Append("a.Entity.ClassEntityID = :id12 and "); Parms.Add(new Object[] { "id12", option.Entity.ClassEntityID }); } } sql = new StringBuilder(sql.ToString()); sql.Append("1=1 order by a.RowID asc "); IQuery query = Factory.Session.CreateQuery(sql.ToString()); SetParameters(query); return(query); }
private void ProcessLogErrors(MessageRuleByCompany rule) { if (string.IsNullOrEmpty(rule.MailTo)) //Sale si no hay a quien enviarle { return; } if (rule.RuleType == 1) { //Created LogError pattern = new LogError(); if (!string.IsNullOrEmpty(rule.IntAttrib1)) { pattern.Category = rule.IntAttrib1.Split('=')[1]; } //Obteniendo la lista de documentos que coinciden IList <Int64> listObj = Factory.DaoLogError().SelectRulesMessage((LogError)pattern, rule); if (listObj == null || listObj.Count == 0) { return; } LogError data = null; foreach (Int64 rID in listObj) { data = Factory.DaoLogError().SelectById(new LogError { LogErrorID = rID }); ProcessMessageObject(data, (Int32)rID, "", rule, EntityID.LogError); } } }
private string AddDocumentDetails(MessageRuleByCompany rule, Int32 ID, String Code) { string message = ""; DataTable dt; string Query; Query = rule.Template.DetailQuery.Replace("__PARAM1", ID.ToString()); Query = Query.Replace("__CODE1", Code); IList <Object[]> objList = Factory.DaoMenuOptionExtension().GetReportObject(Query, new List <String>()); //Query //Creado el objeto a desplegar dt = GetDataTableSchema(rule.Template.DetailColumns.Split(','), "dt0", objList); if (dt == null || dt.Rows.Count == 0) { return(message); } message += ConvertDataTableToHtml(dt, "Document Details"); return(message); }
public void DeleteMessageRuleByCompany(MessageRuleByCompany data) { try { SetService(); SerClient.DeleteMessageRuleByCompany(data); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
public MessageRuleByCompany SaveMessageRuleByCompany(MessageRuleByCompany data) { try { SetService(); return SerClient.SaveMessageRuleByCompany(data); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
public MessageRuleByCompany SelectById(MessageRuleByCompany data) { return((MessageRuleByCompany)base.SelectById(data)); }
public Boolean Delete(MessageRuleByCompany data) { return(base.Delete(data)); }
public Boolean Update(MessageRuleByCompany data) { return(base.Update(data)); }
public MessageRuleByCompany Save(MessageRuleByCompany data) { return((MessageRuleByCompany)base.Save(data)); }