Cambios Compras
This commit is contained in:
@@ -273,188 +273,210 @@ public class TareasJam : IHttpHandler
|
||||
|
||||
if (!ErrorProceso)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
this.GuardaLog($"EjecutaThalamus: llenando archivo excel ventas. ");
|
||||
int count = 2;
|
||||
var wbVentas = new ClosedXML.Excel.XLWorkbook(FormatoVentas);
|
||||
var wsVentas = wbVentas.Worksheet(1);
|
||||
|
||||
foreach (DataRow DRow in DTVentas.Rows)
|
||||
try
|
||||
{
|
||||
wsVentas.Cell(count, 1).Value = "'" + DRow["systemId"].ToString();
|
||||
wsVentas.Cell(count, 2).Value = DRow["Branch"].ToString();
|
||||
wsVentas.Cell(count, 3).Value = "'" + DRow["Code"].ToString();
|
||||
wsVentas.Cell(count, 4).Value = DRow["Sale Date"].ToString();
|
||||
wsVentas.Cell(count, 5).Value = DRow["Quantity"].ToString();
|
||||
wsVentas.Cell(count, 6).Value = DRow["Amount"].ToString();
|
||||
wsVentas.Cell(count, 7).Value = DRow["Transaction ID"].ToString();
|
||||
count++;
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
this.GuardaLog($"EjecutaThalamus: llenando archivo excel ventas. ");
|
||||
int count = 2;
|
||||
var wbVentas = new ClosedXML.Excel.XLWorkbook(FormatoVentas);
|
||||
this.GuardaLog($"EjecutaThalamus: archivo excel ventas cargado. ");
|
||||
this.GuardaLog($"EjecutaThalamus: archivo excel ventas creando sheet.");
|
||||
var wsVentas = wbVentas.Worksheet(1);
|
||||
this.GuardaLog($"EjecutaThalamus: archivo excel ventas sheet creada.");
|
||||
|
||||
foreach (DataRow DRow in DTVentas.Rows)
|
||||
{
|
||||
wsVentas.Cell(count, 1).Value = "'" + DRow["systemId"].ToString();
|
||||
wsVentas.Cell(count, 2).Value = DRow["Branch"].ToString();
|
||||
wsVentas.Cell(count, 3).Value = "'" + DRow["Code"].ToString();
|
||||
wsVentas.Cell(count, 4).Value = DRow["Sale Date"].ToString();
|
||||
wsVentas.Cell(count, 5).Value = DRow["Quantity"].ToString();
|
||||
wsVentas.Cell(count, 6).Value = DRow["Amount"].ToString();
|
||||
wsVentas.Cell(count, 7).Value = DRow["Transaction ID"].ToString();
|
||||
count++;
|
||||
}
|
||||
this.GuardaLog($"EjecutaThalamus: guardando archivo excel ventas " + RutaVentas + " ");
|
||||
wbVentas.SaveAs(RutaVentas);
|
||||
|
||||
var wbAlmacenes = new ClosedXML.Excel.XLWorkbook(FormatoAlmacenes);
|
||||
var wsAlmacenes = wbAlmacenes.Worksheet(1);
|
||||
|
||||
count = 2;
|
||||
|
||||
this.GuardaLog($"EjecutaThalamus: llenando archivo excel almacenes. ");
|
||||
foreach (DataRow DRow in DTAlmacenes.Rows)
|
||||
{
|
||||
wsAlmacenes.Cell(count, 1).Value = "'" + DRow["Code"].ToString();
|
||||
wsAlmacenes.Cell(count, 2).Value = DRow["Quantity"].ToString();
|
||||
wsAlmacenes.Cell(count, 3).Value = DRow["Description"].ToString();
|
||||
wsAlmacenes.Cell(count, 4).Value = DRow["Stock Date"].ToString();
|
||||
count++;
|
||||
}
|
||||
this.GuardaLog($"EjecutaThalamus: guardando archivo excel alamcenes " + RutaAlmacenes + " ");
|
||||
wbAlmacenes.SaveAs(RutaAlmacenes);
|
||||
|
||||
var wbAClientes = new ClosedXML.Excel.XLWorkbook(FormatoClientes);
|
||||
var wsClientes = wbAClientes.Worksheet(1);
|
||||
|
||||
count = 2;
|
||||
|
||||
this.GuardaLog($"EjecutaThalamus: llenando archivo excel clientes. ");
|
||||
foreach (DataRow DRow in DTClientes.Rows)
|
||||
{
|
||||
wsClientes.Cell(count, 1).Value = "'" + DRow["systemId"].ToString();
|
||||
wsClientes.Cell(count, 2).Value = DRow["fiscalIdMex"].ToString();
|
||||
wsClientes.Cell(count, 3).Value = DRow["fiscalName"].ToString();
|
||||
wsClientes.Cell(count, 4).Value = DRow["email"].ToString();
|
||||
wsClientes.Cell(count, 5).Value = DRow["address.countryId"].ToString();
|
||||
wsClientes.Cell(count, 6).Value = DRow["address.stateId"].ToString();
|
||||
wsClientes.Cell(count, 7).Value = DRow["address.city"].ToString();
|
||||
wsClientes.Cell(count, 8).Value = DRow["address.street1"].ToString();
|
||||
wsClientes.Cell(count, 9).Value = DRow["address.street2"].ToString();
|
||||
wsClientes.Cell(count, 10).Value = "'" + DRow["address.postalCode"].ToString();
|
||||
wsClientes.Cell(count, 11).Value = DRow["phone.intCode"].ToString();
|
||||
wsClientes.Cell(count, 12).Value = DRow["phone.areaCode"].ToString();
|
||||
wsClientes.Cell(count, 13).Value = "'" + DRow["phone.number"].ToString();
|
||||
wsClientes.Cell(count, 14).Value = DRow["salesman"].ToString();
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
this.GuardaLog($"EjecutaThalamus: guardando archivo excel clientes " + RutaClientes + " ");
|
||||
wbAClientes.SaveAs(RutaClientes);
|
||||
|
||||
var wbProductos = new ClosedXML.Excel.XLWorkbook(FormatoProductos);
|
||||
var wsProductos = wbProductos.Worksheet(1);
|
||||
|
||||
count = 2;
|
||||
this.GuardaLog($"EjecutaThalamus: llenando archivo excel productos. ");
|
||||
foreach (DataRow DRow in DTProductos.Rows)
|
||||
{
|
||||
wsProductos.Cell(count, 1).Value = "'" + DRow["Código Producto Interno"].ToString();
|
||||
wsProductos.Cell(count, 2).Value = DRow["Nombre del Producto"].ToString();
|
||||
wsProductos.Cell(count, 3).Value = DRow["Presentación"].ToString();
|
||||
|
||||
count++;
|
||||
}
|
||||
this.GuardaLog($"EjecutaThalamus: guardando archivo excel productos " + RutaProductos + " ");
|
||||
wbProductos.SaveAs(RutaProductos);
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
this.GuardaLog($"EjecutaThalamus: guardando archivo excel ventas " + RutaVentas + " ");
|
||||
wbVentas.SaveAs(RutaVentas);
|
||||
|
||||
var wbAlmacenes = new ClosedXML.Excel.XLWorkbook(FormatoAlmacenes);
|
||||
var wsAlmacenes = wbAlmacenes.Worksheet(1);
|
||||
|
||||
count = 2;
|
||||
|
||||
this.GuardaLog($"EjecutaThalamus: llenando archivo excel almacenes. ");
|
||||
foreach (DataRow DRow in DTAlmacenes.Rows)
|
||||
catch (Exception ex)
|
||||
{
|
||||
wsAlmacenes.Cell(count, 1).Value = "'" + DRow["Code"].ToString();
|
||||
wsAlmacenes.Cell(count, 2).Value = DRow["Quantity"].ToString();
|
||||
wsAlmacenes.Cell(count, 3).Value = DRow["Description"].ToString();
|
||||
wsAlmacenes.Cell(count, 4).Value = DRow["Stock Date"].ToString();
|
||||
count++;
|
||||
}
|
||||
this.GuardaLog($"EjecutaThalamus: guardando archivo excel alamcenes " + RutaAlmacenes + " ");
|
||||
wbAlmacenes.SaveAs(RutaAlmacenes);
|
||||
|
||||
var wbAClientes = new ClosedXML.Excel.XLWorkbook(FormatoClientes);
|
||||
var wsClientes = wbAClientes.Worksheet(1);
|
||||
|
||||
count = 2;
|
||||
|
||||
this.GuardaLog($"EjecutaThalamus: llenando archivo excel clientes. ");
|
||||
foreach (DataRow DRow in DTClientes.Rows)
|
||||
{
|
||||
wsClientes.Cell(count, 1).Value = "'" + DRow["systemId"].ToString();
|
||||
wsClientes.Cell(count, 2).Value = DRow["fiscalIdMex"].ToString();
|
||||
wsClientes.Cell(count, 3).Value = DRow["fiscalName"].ToString();
|
||||
wsClientes.Cell(count, 4).Value = DRow["email"].ToString();
|
||||
wsClientes.Cell(count, 5).Value = DRow["address.countryId"].ToString();
|
||||
wsClientes.Cell(count, 6).Value = DRow["address.stateId"].ToString();
|
||||
wsClientes.Cell(count, 7).Value = DRow["address.city"].ToString();
|
||||
wsClientes.Cell(count, 8).Value = DRow["address.street1"].ToString();
|
||||
wsClientes.Cell(count, 9).Value = DRow["address.street2"].ToString();
|
||||
wsClientes.Cell(count, 10).Value = "'" + DRow["address.postalCode"].ToString();
|
||||
wsClientes.Cell(count, 11).Value = DRow["phone.intCode"].ToString();
|
||||
wsClientes.Cell(count, 12).Value = DRow["phone.areaCode"].ToString();
|
||||
wsClientes.Cell(count, 13).Value = "'" + DRow["phone.number"].ToString();
|
||||
wsClientes.Cell(count, 14).Value = DRow["salesman"].ToString();
|
||||
|
||||
count++;
|
||||
this.GuardaLog($"EjecutaThalamus: Error procesamiento archivos exel " + ex.StackTrace.ToString() + " ");
|
||||
ErrorProceso = true;
|
||||
Respuesta = false;
|
||||
}
|
||||
|
||||
this.GuardaLog($"EjecutaThalamus: guardando archivo excel clientes " + RutaClientes + " ");
|
||||
wbAClientes.SaveAs(RutaClientes);
|
||||
|
||||
var wbProductos= new ClosedXML.Excel.XLWorkbook(FormatoProductos);
|
||||
var wsProductos = wbProductos.Worksheet(1);
|
||||
|
||||
count = 2;
|
||||
this.GuardaLog($"EjecutaThalamus: llenando archivo excel productos. ");
|
||||
foreach (DataRow DRow in DTProductos.Rows)
|
||||
if (!ErrorProceso)
|
||||
{
|
||||
wsProductos.Cell(count, 1).Value = "'" + DRow["Código Producto Interno"].ToString();
|
||||
wsProductos.Cell(count, 2).Value = DRow["Nombre del Producto"].ToString();
|
||||
wsProductos.Cell(count, 3).Value = DRow["Presentación"].ToString();
|
||||
var FInfoProductos = new FileInfo(RutaProductos);
|
||||
var FInfoVentas = new FileInfo(RutaVentas);
|
||||
var FInfoClientes = new FileInfo(RutaClientes);
|
||||
var FInfoAlmacenes = new FileInfo(RutaAlmacenes);
|
||||
|
||||
count++;
|
||||
}
|
||||
this.GuardaLog($"EjecutaThalamus: guardando archivo excel productos " + RutaProductos + " ");
|
||||
wbProductos.SaveAs(RutaProductos);
|
||||
/////////////////////////////////////////////////////////////
|
||||
bool CargaProductos = false;
|
||||
bool CargaVentas = false;
|
||||
bool CargaClientes = false;
|
||||
bool CargaAlmacenes = false;
|
||||
|
||||
var FInfoProductos = new FileInfo(RutaProductos);
|
||||
var FInfoVentas = new FileInfo(RutaVentas);
|
||||
var FInfoClientes = new FileInfo(RutaClientes);
|
||||
var FInfoAlmacenes = new FileInfo(RutaAlmacenes);
|
||||
|
||||
bool CargaProductos = false;
|
||||
bool CargaVentas = false;
|
||||
bool CargaClientes = false;
|
||||
bool CargaAlmacenes = false;
|
||||
|
||||
SBLog.AppendLine("<b>Cargas</b><br>");
|
||||
SBLog.AppendLine("<table border='1'> <tr><th>Archivo</th><th>Estado</th></tr>");
|
||||
SBLog.AppendLine("<b>Cargas</b><br>");
|
||||
SBLog.AppendLine("<table border='1'> <tr><th>Archivo</th><th>Estado</th></tr>");
|
||||
|
||||
|
||||
this.GuardaLog($"EjecutaThalamus: Cargando archivo excel productos a FTP. ");
|
||||
CargaProductos = CargarArchivos(FInfoProductos, FTPServer, TFPUsr, FTPPass);
|
||||
this.GuardaLog($"EjecutaThalamus: Cargando archivo excel productos a FTP. ");
|
||||
CargaProductos = CargarArchivos(FInfoProductos, FTPServer, TFPUsr, FTPPass);
|
||||
|
||||
if (CargaProductos)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Verificando archivo productos. ");
|
||||
CargaProductos = VerificarArchivo(FInfoProductos, FInfoProductos.Length, FTPServer, TFPUsr, FTPPass);
|
||||
}
|
||||
if (CargaProductos)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Verificando archivo productos. ");
|
||||
CargaProductos = VerificarArchivo(FInfoProductos, FInfoProductos.Length, FTPServer, TFPUsr, FTPPass);
|
||||
}
|
||||
|
||||
if (CargaProductos)
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Productos</td><td>ok</td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Productos</td><td>Error carga</td></tr>");
|
||||
}
|
||||
if (CargaProductos)
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Productos</td><td>ok</td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Productos</td><td>Error carga</td></tr>");
|
||||
}
|
||||
|
||||
if (CargaProductos)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Cargando archivo excel ventas a FTP. ");
|
||||
CargaVentas = CargarArchivos(FInfoVentas, $"{FTPServer}/Ventas", TFPUsr, FTPPass);
|
||||
if (CargaVentas)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Verificando archivo ventas. ");
|
||||
CargaVentas = VerificarArchivo(FInfoVentas, FInfoVentas.Length, $"{FTPServer}/Ventas", TFPUsr, FTPPass);
|
||||
}
|
||||
}
|
||||
|
||||
if (CargaProductos)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Cargando archivo excel ventas a FTP. ");
|
||||
CargaVentas = CargarArchivos(FInfoVentas, $"{FTPServer}/Ventas", TFPUsr, FTPPass);
|
||||
if (CargaVentas)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Verificando archivo ventas. ");
|
||||
CargaVentas = VerificarArchivo(FInfoVentas, FInfoVentas.Length, $"{FTPServer}/Ventas", TFPUsr, FTPPass);
|
||||
SBLog.AppendLine($"<tr><td>Ventas</td><td>ok</td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Ventas</td><td>Error carga</td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
if (CargaVentas)
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Ventas</td><td>ok</td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Ventas</td><td>Error carga</td></tr>");
|
||||
}
|
||||
if (CargaProductos & CargaVentas)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Cargando archivo excel clientes a FTP. ");
|
||||
CargaClientes = CargarArchivos(FInfoClientes, $"{FTPServer}/Clientes", TFPUsr, FTPPass);
|
||||
if (CargaClientes)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Verificando archivo clientes. ");
|
||||
CargaClientes = VerificarArchivo(FInfoClientes, FInfoClientes.Length, $"{FTPServer}/Clientes", TFPUsr, FTPPass);
|
||||
}
|
||||
}
|
||||
|
||||
if (CargaProductos & CargaVentas)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Cargando archivo excel clientes a FTP. ");
|
||||
CargaClientes = CargarArchivos(FInfoClientes, $"{FTPServer}/Clientes", TFPUsr, FTPPass);
|
||||
if (CargaClientes)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Verificando archivo clientes. ");
|
||||
CargaClientes = VerificarArchivo(FInfoClientes, FInfoClientes.Length, $"{FTPServer}/Clientes", TFPUsr, FTPPass);
|
||||
SBLog.AppendLine($"<tr><td>Clientes</td><td>ok</td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
if (CargaClientes)
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Clientes</td><td>ok</td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Clientes</td><td>Error carga</td></tr>");
|
||||
}
|
||||
|
||||
if (CargaProductos & CargaVentas & CargaClientes)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Cargando archivo excel almacenes a FTP. ");
|
||||
CargaAlmacenes = CargarArchivos(FInfoAlmacenes, $"{FTPServer}/Stock", TFPUsr, FTPPass);
|
||||
if (CargaClientes)
|
||||
else
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Verificando archivo almacenes. ");
|
||||
CargaAlmacenes = VerificarArchivo(FInfoAlmacenes, FInfoAlmacenes.Length, $"{FTPServer}/Stock", TFPUsr, FTPPass);
|
||||
SBLog.AppendLine($"<tr><td>Clientes</td><td>Error carga</td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
if (CargaAlmacenes)
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Almacenes</td><td>ok</td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Almacenes</td><td>Error carga</td></tr>");
|
||||
}
|
||||
if (CargaProductos & CargaVentas & CargaClientes)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Cargando archivo excel almacenes a FTP. ");
|
||||
CargaAlmacenes = CargarArchivos(FInfoAlmacenes, $"{FTPServer}/Stock", TFPUsr, FTPPass);
|
||||
if (CargaClientes)
|
||||
{
|
||||
this.GuardaLog($"EjecutaThalamus: Verificando archivo almacenes. ");
|
||||
CargaAlmacenes = VerificarArchivo(FInfoAlmacenes, FInfoAlmacenes.Length, $"{FTPServer}/Stock", TFPUsr, FTPPass);
|
||||
}
|
||||
}
|
||||
|
||||
if (CargaAlmacenes)
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Almacenes</td><td>ok</td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
SBLog.AppendLine($"<tr><td>Almacenes</td><td>Error carga</td></tr>");
|
||||
}
|
||||
|
||||
|
||||
if (CargaProductos & CargaVentas & CargaClientes & CargaAlmacenes)
|
||||
{
|
||||
Respuesta = true;
|
||||
}
|
||||
else
|
||||
if (CargaProductos & CargaVentas & CargaClientes & CargaAlmacenes)
|
||||
{
|
||||
Respuesta = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Respuesta = false;
|
||||
}
|
||||
|
||||
}else
|
||||
{
|
||||
Respuesta = false;
|
||||
}
|
||||
@@ -505,8 +527,8 @@ public class TareasJam : IHttpHandler
|
||||
|
||||
|
||||
ClsSisMail Correo = new ClsSisMail();
|
||||
string Para = "julian@adssistemas.mx;rene.molina@adssistemas.mx;oscar.irigoyen@adssistemas.mx";
|
||||
// string Para = "oscar.irigoyen@adssistemas.mx";
|
||||
string Para = "julian@adssistemas.mx;rene.molina@adssistemas.mx;oscar.irigoyen@adssistemas.mx";
|
||||
// string Para = "oscar.irigoyen@adssistemas.mx";
|
||||
string Asunto = ErrorProceso ? $"Carga Layout Corteva {DateTime.Now.ToString("yyyy-MM-dd")}" : $"Carga Layout Corteva Error {DateTime.Now.ToString("yyyy-MM-dd")}";
|
||||
|
||||
Correo.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Cuerpo, Archivos:ListaArchivos);
|
||||
|
||||
Reference in New Issue
Block a user