-- mejoras en visualización de correo
This commit is contained in:
@@ -83,54 +83,53 @@ public class TareasReporteDairio : IHttpHandler
|
|||||||
private string ConvertDataTableToHtml(DataTable table)
|
private string ConvertDataTableToHtml(DataTable table)
|
||||||
{
|
{
|
||||||
StringBuilder html = new StringBuilder();
|
StringBuilder html = new StringBuilder();
|
||||||
|
string ColumnaTitulo = "Titulo";
|
||||||
|
|
||||||
html.Append("<table border='1' style='border-collapse:collapse; width:100%;'>");
|
html.Append("<table border='1' style='border-collapse:collapse; width:100%;'>");
|
||||||
|
if(table.Columns[0].ColumnName==ColumnaTitulo && table.Rows.Count > 0) html.AppendFormat(" <caption style='background-color:#333333;'>{0}</caption>", table.Rows[0][ColumnaTitulo]);
|
||||||
|
|
||||||
|
html.Append("<thead style='background-color:#DDD; padding: 0px;'><tr>");
|
||||||
html.Append("<thead><tr>");
|
|
||||||
foreach (DataColumn column in table.Columns)
|
foreach (DataColumn column in table.Columns)
|
||||||
{
|
{
|
||||||
html.Append($"<th style='padding:5px; text-align:left;'>{column.ColumnName}</th>");
|
if (ColumnaTitulo != column.ColumnName) html.Append($"<th style='padding:5px; text-align:left;'>{column.ColumnName}</th>");
|
||||||
}
|
}
|
||||||
html.Append("</tr></thead>");
|
html.Append("</tr></thead>");
|
||||||
|
|
||||||
|
|
||||||
html.Append("<tbody>");
|
html.Append("<tbody>");
|
||||||
foreach (DataRow row in table.Rows)
|
foreach (DataRow row in table.Rows)
|
||||||
{
|
{
|
||||||
html.Append("<tr>");
|
html.Append("<tr>");
|
||||||
foreach (DataColumn column in table.Columns)
|
foreach (DataColumn column in table.Columns)
|
||||||
{
|
{
|
||||||
object value = row[column];
|
if (ColumnaTitulo != column.ColumnName)
|
||||||
string cellValue;
|
|
||||||
|
|
||||||
|
|
||||||
if (column.DataType == typeof(int) || column.DataType == typeof(decimal) || column.DataType == typeof(double) || column.DataType == typeof(float))
|
|
||||||
{
|
{
|
||||||
if (value != DBNull.Value && decimal.TryParse(value.ToString(), out decimal numericValue))
|
object value = row[column];
|
||||||
|
string cellValue;
|
||||||
|
if (column.DataType == typeof(int) || column.DataType == typeof(decimal) || column.DataType == typeof(double) || column.DataType == typeof(float))
|
||||||
{
|
{
|
||||||
if (numericValue != 0)
|
if (value != DBNull.Value && decimal.TryParse(value.ToString(), out decimal numericValue))
|
||||||
{
|
{
|
||||||
cellValue = numericValue.ToString("N2");
|
if (numericValue != 0)
|
||||||
|
{
|
||||||
|
cellValue = numericValue.ToString("N2");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cellValue = "";//0.00
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cellValue = "";//0.00
|
cellValue = "";//0.00
|
||||||
}
|
}
|
||||||
|
html.Append($"<td style='padding:5px; text-align:right;'>{cellValue}</td>");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
cellValue = value?.ToString() ?? string.Empty;
|
||||||
cellValue = "";//0.00
|
html.Append($"<td style='padding:5px; text-align:left;'>{cellValue}</td>");
|
||||||
}
|
}
|
||||||
html.Append($"<td style='padding:5px; text-align:right;'>{cellValue}</td>");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cellValue = value?.ToString() ?? string.Empty;
|
|
||||||
html.Append($"<td style='padding:5px; text-align:left;'>{cellValue}</td>");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
html.Append("</tr>");
|
html.Append("</tr>");
|
||||||
}
|
}
|
||||||
@@ -180,15 +179,13 @@ public class TareasReporteDairio : IHttpHandler
|
|||||||
|
|
||||||
private void MandaCorreo(string Cuerpo, bool PrceosoOK)
|
private void MandaCorreo(string Cuerpo, bool PrceosoOK)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
List<ClsSisMail.ArchivoMail> ListaArchivos = new List<ClsSisMail.ArchivoMail>();
|
List<ClsSisMail.ArchivoMail> ListaArchivos = new List<ClsSisMail.ArchivoMail>();
|
||||||
ClsSisMail Correo = new ClsSisMail();
|
ClsSisMail Correo = new ClsSisMail();
|
||||||
//string Para = "julian@adssistemas.mx;rene.molina@adssistemas.mx;oscar.irigoyen@adssistemas.mx";
|
//string Para = "julian@adssistemas.mx;rene.molina@adssistemas.mx;oscar.irigoyen@adssistemas.mx";
|
||||||
|
|
||||||
string Para = "oscar.irigoyen@adssistemas.mx;rene.molina@adssistemas.mx";
|
string Para = "rene.molina@adssistemas.mx"; // oscar.irigoyen@adssistemas.mx;
|
||||||
string Asunto = PrceosoOK ? $"Reporte Diario":"Reporte Diario Error";
|
string Asunto = PrceosoOK ? $"Reporte Diario":"Reporte Diario Error";
|
||||||
Asunto = $"{Asunto} {DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")}";
|
Asunto = $"{Asunto} {DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")}";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user