public static Commons.Parameters Get() { Commons.Parameters obj = new Commons.Parameters(); using (IndexEntities db = new IndexEntities()) { spg_Parameters_Result result = db.spg_Parameters().FirstOrDefault(); obj.IVA = result.IVA; obj.ExpirateDateMonts = result.ExpirateDateMonts; obj.DefaultCurrency = result.DefaultCurrency; obj.OpaFrecuencySeconds = result.OpaFrecuencySeconds; obj.OpaDelaySeconds = result.OpaDelaySeconds; obj.OpaServiceUrl = result.OpaServiceUrl; obj.OpaServiceUser = result.OpaServiceUser; obj.OpaServicePassword = result.OpaServicePassword; obj.DaysToExpire = result.DaysToExpire; obj.MailingUser = result.MailingUser; obj.MailingPassword = result.MailingPassword; obj.MailingServer = result.MailingServer; obj.MailingPort = result.MailingPort; obj.MailingUseSsl = result.MailingUseSsl; obj.MailingDisplayName = result.MailingDisplayName; obj.MailingIsHtml = result.MailingIsHtml; obj.OpaEmailBody = result.OpaEmailBody; obj.MailingCC = result.MailingCC; obj.MailingCCO = result.MailingCCO; } return(obj); }
public void SendEmailHTML() { Commons.Parameters param = Dal.Parameters.Get(); List <Dal.spg_TransmitionResult_Result> detail = new List <Dal.spg_TransmitionResult_Result>(); detail.Add(new Dal.spg_TransmitionResult_Result() { IdState = 4, StateName = "Cola", Message = "[NIT invalido]", ExportInfo = "DUA (Exportación) 0001 Línea 1", ImportInfo = "DUA (Importación) 0001 Línea 1", Quantity = 10, CIF = 10, FOB = 10, DAI = 10, IVA = 10 }); String detailMessage = ""; detail.ForEach(x => { detailMessage = detailMessage + "<tr>"; detailMessage = detailMessage + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;'>" + x.StateName + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;color: red;font-size: 10px;border-color: black;'>" + x.Message + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;'>" + x.ExportInfo + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;'>" + x.ImportInfo + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;text-align: center;'>" + x.Quantity + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;text-align: center;'>Q " + x.CIF + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;text-align: center;'>Q " + x.FOB + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;text-align: center;'>Q " + x.DAI + "000000</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;text-align: center;'>Q " + x.IVA + "</td>"; detailMessage = detailMessage + "</tr>"; }); String result = File.ReadAllText(param.OpaEmailBody); //String result = File.ReadAllText(param.OpaEmailBody.Replace("\r", "").Replace("\n", "").Replace("\t", "")); result = result.Replace("@Priority", "Alta") .Replace("@StartDate", "01/01/2017").Replace("@EndDate", "20/01/2017") .Replace("@Customer", "Cliente de prueba").Replace("@Account", "Cuenta de prueba") .Replace("@data", detailMessage); List <String> emails = new List <String>(); List <String> cc = new List <String>(); emails.Add("*****@*****.**"); cc.Add(param.MailingCC); cc.Add(param.MailingCCO); Email mail = new Email(param.MailingUser, param.MailingPassword, param.MailingServer, param.MailingPort, param.MailingUseSsl, param.MailingDisplayName, param.MailingIsHtml); mail.BuildMessage(emails, cc, null, "Notificación de proceso", result); Assert.IsTrue(mail.Send()); }
public HttpResponseMessage Get() { HttpResponseMessage respuesta = null; try { Commons.Parameters result = Dal.Parameters.Get(); respuesta = Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception ex) { respuesta = Request.CreateErrorResponse(HttpStatusCode.Conflict, (ex.InnerException == null) ? ex.Message : ex.InnerException.Message); } return(respuesta); }
public static Boolean SendNotification(spg_Queue_Result document) { using (IndexEntities db = new IndexEntities()) { List <spg_TransmitionResult_Result> detail = db.spg_TransmitionResult(document.IdOpaHeader).ToList(); String email = db.spg_TransmitionGetUserEmail(document.UserName).First().Email; spg_UserProccess_Result header = db.spg_UserProccess(document.IdOpaHeader).FirstOrDefault(); Commons.Parameters param = Dal.Parameters.Get(); String detailMessage = ""; detail.ForEach(x => { detailMessage = detailMessage + "<tr>"; detailMessage = detailMessage + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;'>" + x.StateName + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;color: red;font-size: 10px;border-color: black;'>" + x.Message + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;'>" + x.ExportInfo + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;'>" + x.ImportInfo + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;text-align: center;'>" + x.Quantity + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;text-align: center;'>Q " + x.CIF + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;text-align: center;'>Q " + x.FOB + "</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;text-align: center;'>Q " + x.DAI + "000000</td>" + "<td style='border: solid;font-size: 15px;border-width: 0.5px;border-spacing : 0;padding: 5px 10px;text-align: center;'>Q " + x.IVA + "</td>"; detailMessage = detailMessage + "</tr>"; }); DateTime startdate = (document.StartDate == null) ? DateTime.Now : (DateTime)document.StartDate; DateTime enddate = (document.EndDate == null) ? DateTime.Now : (DateTime)document.EndDate; String HtmlMessage = File.ReadAllText(param.OpaEmailBody); HtmlMessage = HtmlMessage.Replace("@Priority", document.PriorityName) .Replace("@StartDate", startdate.ToString("dd/MM/yyyy")) .Replace("@EndDate", enddate.ToString("dd/MM/yyyy")) .Replace("@Customer", header.CustomerName).Replace("@Account", header.AccountName) .Replace("@data", detailMessage); Functionalities.General.Email mail = new Functionalities.General.Email(param.MailingUser, param.MailingPassword, param.MailingServer, param.MailingPort, param.MailingUseSsl, param.MailingDisplayName, param.MailingIsHtml); mail.BuildMessage(email, param.MailingCC, param.MailingCCO, "Notificación de transmisión OPA", HtmlMessage); mail.Send(); return(true); } }