diff --git a/App_Code/ClsSisMail.vb b/App_Code/ClsSisMail.vb
index 232d38e36..6bdb5ef93 100644
--- a/App_Code/ClsSisMail.vb
+++ b/App_Code/ClsSisMail.vb
@@ -33,7 +33,7 @@ Public Class ClsSisMail
Return Resultado
End Function
- Public Function SendMail(ObjEmpresa As Empresa, Para As String, Asunto As String, Body As String, Optional CCP As String = "", Optional Archivos As List(Of ArchivoMail) = Nothing, Optional Displayname As String = "") As Boolean
+ Public Function SendMail(ObjEmpresa As Empresa, Para As String, Asunto As String, Body As String, Optional CCP As String = "", Optional Archivos As List(Of ArchivoMail) = Nothing, Optional Displayname As String = "", Optional CCO As String = "") As Boolean
Dim ObjMail As New Mail
ObjMail.ObjEmpresa = ObjEmpresa
ObjMail.De = If(Displayname.Trim = String.Empty, "", Displayname)
@@ -41,6 +41,7 @@ Public Class ClsSisMail
ObjMail.CCP = CCP
ObjMail.Asunto = Asunto
ObjMail.Body = Body
+ ObjMail.CCO = CCO
If Archivos IsNot Nothing AndAlso Archivos.Count > 0 Then ' si tiene adjuntos, me crea el objeto
ObjMail.Archivos = New List(Of ArchivoMail)
@@ -85,6 +86,7 @@ Public Class ClsSisMail
Dim Mensaje As String = String.Empty
Dim ArrayPara() As String = ObjMail.Para.Replace(",", ";").Split(";"c)
Dim ArrayCCP() As String = ObjMail.CCP.Replace(",", ";").Split(";"c)
+ Dim ArrayBCC() As String = ObjMail.CCO.Replace(",", ";").Split(";"c)
'"sgd.facturacion@adsistemas.mx"
If ObjMail.De = String.Empty Then
@@ -103,6 +105,12 @@ Public Class ClsSisMail
For Each CorreoCCPPara As String In ArrayCCP.Distinct
If IsMail(CorreoCCPPara.Trim) Then Correo.To.Add(CorreoCCPPara.Trim)
Next
+ End If
+
+ If ArrayBCC IsNot Nothing AndAlso ArrayBCC.Length > 0 Then
+ For Each CorreoCCOPara As String In ArrayBCC.Distinct
+ If IsMail(CorreoCCOPara.Trim) Then Correo.Bcc.Add(CorreoCCOPara.Trim)
+ Next
End If
Correo.Subject = ObjMail.Asunto
@@ -120,7 +128,6 @@ Public Class ClsSisMail
Correo.Body = Mensaje & ObjMail.Body
Correo.IsBodyHtml = True
Correo.Priority = Net.Mail.MailPriority.Normal
-
If ObjMail.Archivos IsNot Nothing Then
For Each Item As ArchivoMail In ObjMail.Archivos
If Item.ArchivoBinario IsNot Nothing Then
@@ -190,6 +197,7 @@ Public Class ClsSisMail
Public Property Para As String
Public Property Asunto As String
Public Property CCP As String
+ Public Property CCO As String
Public Property Body As String
Public Property Archivos As List(Of ArchivoMail)
End Class
diff --git a/Ashx/E141.ashx b/Ashx/E141.ashx
index 9e87ebed5..7428ce2a6 100644
--- a/Ashx/E141.ashx
+++ b/Ashx/E141.ashx
@@ -130,7 +130,7 @@ Public Class E141 : Implements IHttpHandler
End If
Catch ex As Exception
- GuardaLogAD("Ocurrió un error al descargar el pdf. " + ex.ToString() + ".parametros: " + Params, "LogE141")
+ GuardaLogAD("Ocurrió un error al descargar el pdf. " + ex.ToString() + ".parametros: " + Params, "LogE141Descargas")
End Try
Else
@@ -250,6 +250,16 @@ Public Class E141 : Implements IHttpHandler
Else
retorno = "False"
End If
+ Case "EnviarCorreoAltasSemanal"
+ GuardaLogAD("CA-Inicia envio de correo semanal", "LogE141")
+ respuesta = EnviarCorreoActualizarProductos()
+ GuardaLogAD("CA-Finaliza envio de correo semanal", "LogE141")
+ If respuesta Then
+ retorno = "True"
+ Else
+ retorno = "False"
+ End If
+
End Select
End If
@@ -268,6 +278,27 @@ Public Class E141 : Implements IHttpHandler
End Try
End Sub
+ Private Sub EnviarCorreoNotificacion(TareaNotificar As String, Cuerpo As String)
+ Dim ResultadoMail As Integer = 0
+ Dim CorreoDestino As String = "atencion@fidelityapps.mx"
+ Dim MailCC As String = "citas@econollantas.com;sixrogs@hotmail.com;ffelix@econollantas.com"
+ Dim MailCCO As String = "jonathan.perez@adssistemas.mx;rene.molina@adsistemas.mx"
+
+ If Not EsProduccion Then
+ CorreoDestino = "jonathan.perez@adssistemas.mx"
+ MailCC = "rene.molina@adsistemas.mx"
+ MailCCO = "japmx95@gmail.com"
+ End If
+
+ Dim ObjMail As New ClsSisMail
+ If ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, CorreoDestino, TareaNotificar, Cuerpo, CCP:=MailCC, CCO:=MailCCO) Then
+ GuardaLogAD($"EC-Envio de correo exitoso. Tarea: {TareaNotificar}", "LogE141")
+ Else
+ GuardaLogAD($"EC-No se pudo enviar el correo. Tarea: {TareaNotificar}", "LogE141")
+ End If
+
+ End Sub
+
Private Function ValidarSolicitud(ByVal context As HttpContext) As AuthMessage
Dim unauthorized As Boolean = True
Dim respuesta As New AuthMessage
@@ -1729,6 +1760,38 @@ Public Class E141 : Implements IHttpHandler
'End Function
#Region "C R E A C I Ó N / A C T U A L I Z A C I Ó N - P R O D U C T O S"
+ Private Function EnviarCorreoActualizarProductos() As Boolean
+ Dim Retorno As Boolean = True
+
+ Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0
+
+ Dim DtPS As DataTable = Nothing
+ Using ObjPS As New ClsProductosServicios
+ 'OBTENER LOS PRODUCTOS NUEVOS EN LA ULTIMA SEMANA
+ If ObjPS.GetProductosModificados(CveEmpresa, 44, HorasDiferencia:=(24 * 7)) Then
+ DtPS = ObjPS.DtResultados
+ End If
+ End Using
+
+ If DtPS IsNot Nothing Then
+ Dim sb As New StringBuilder
+ For Each Row As DataRow In DtPS.Rows
+ sb.AppendFormat("- {0}.
", Row("CodigoPS"))
+ Next
+ Dim msg As String = ""
+
+ If sb.Length > 0 Then
+ msg = $"Se enviaron los siguientes productos:
{sb.ToString()}
Fecha y hora: {Now.ToString("dd/MM/yyyy hh:mm:ss tt")}"
+ Else
+ msg = $"No se enviaron productos esta semana
Fecha y hora: {Now.ToString("dd/MM/yyyy hh:mm:ss tt")}"
+ End If
+
+ EnviarCorreoNotificacion("SIG - Productos enviados en la semana", msg)
+ End If
+
+ Return Retorno
+ End Function
+
Private Function CrearActualizarProductos(Todos As Boolean) As Boolean
Dim Retorno As Boolean = False
Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0
@@ -1738,6 +1801,8 @@ Public Class E141 : Implements IHttpHandler
'OBTERNER PRECIOS DE PUBLICO GENERAL
If ObjPS.GetProductosModificados(CveEmpresa, 44, If(Todos, -1, 26)) Then
DtPS = ObjPS.DtResultados.Copy()
+ Else
+ GuardaLogAD($"NP-Ocurrió un error al obtener los productos", "LogE141")
End If
End Using
@@ -1759,10 +1824,10 @@ Public Class E141 : Implements IHttpHandler
CountPeticionesExitosas += 1
GuardaLogAD("NP-Creacion/actualizacion de productos exitosa", "LogE141")
Else
- GuardaLogAD($"NP-No se pudo realizar la Creacion/actualizacion de productos ${respuesta.ToString()}", "LogE141")
+ GuardaLogAD($"NP-No se pudo realizar la Creacion/actualizacion de productos ${respuesta.ToString()}", "LogE141")
End If
Else
- GuardaLogAD($"NP-No se pudo realizar la Creacion/actualizacion de productos ${resp}", "LogE141")
+ GuardaLogAD($"NP-No se pudo realizar la Creacion/actualizacion de productos ${resp}", "LogE141")
End If
Else
@@ -1799,16 +1864,18 @@ Public Class E141 : Implements IHttpHandler
CountPeticionesExitosas += 1
GuardaLogAD("NP-Creacion/actualizacion de productos exitosa", "LogE141")
Else
- GuardaLogAD($"NP-No se pudo realizar la Creacion/actualizacion de productos ${respuesta.ToString()}", "LogE141")
+ GuardaLogAD($"NP-No se pudo realizar la Creacion/actualizacion de productos ${respuesta.ToString()}", "LogE141")
End If
Else
- GuardaLogAD($"NP-No se pudo realizar la Creacion/actualizacion de productos ${resp}", "LogE141")
+ GuardaLogAD($"NP-No se pudo realizar la Creacion/actualizacion de productos ${resp}", "LogE141")
End If
Threading.Thread.Sleep(1000)
End While
End If
-
+ If DtPS.Rows.Count > 0 Then
+ EnviarCorreoNotificacion("SIG - Actualización de productos", $"Se ejecuto la tarea de actualización de productos.
Fecha y hora: {Now.ToString("dd/MM/yyyy hh:mm:ss tt")}")
+ End If
End If
If CountPeticionesExitosas = CountPeticiones Then
@@ -1826,7 +1893,7 @@ Public Class E141 : Implements IHttpHandler
Dim DtPS As DataTable = Nothing
Using ObjPS As New ClsProductosServicios
'OBTERNER PRECIOS DE PUBLICO GENERAL
- If ObjPS.GetProductosModificados(CveEmpresa, 44, If(Todos, -1, 1)) Then
+ If ObjPS.GetProductosModificados(CveEmpresa, 44, If(Todos, -1, 26)) Then
DtPS = ObjPS.DtResultados.Copy()
End If
End Using
@@ -1890,6 +1957,12 @@ Public Class E141 : Implements IHttpHandler
Private Function ActualizarPrecios(Todos As Boolean) As Boolean
Dim Retorno As Boolean = False
+ 'ENVIAR PRECIOS SOLO DE 8am a 7pm
+ If Now.Hour < 7 OrElse Now.Hour > 21 Then
+ Retorno = True
+ Return Retorno
+ End If
+
Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0
Dim DtPS As DataTable = Nothing
@@ -1897,6 +1970,8 @@ Public Class E141 : Implements IHttpHandler
'OBTERNER PRECIOS DE PUBLICO GENERAL
If ObjPS.GetPreciosModificados(CveEmpresa, 44, If(Todos, -1, 1)) Then
DtPS = ObjPS.DtResultados.Copy()
+ Else
+ GuardaLogAD($"AP-Ocurrió un error al obtener los precios", "LogE141")
End If
End Using
@@ -1965,8 +2040,13 @@ Public Class E141 : Implements IHttpHandler
End While
End If
+ If DtPS.Rows.Count > 0 Then
+ EnviarCorreoNotificacion("SIG - Actualización de precios", $"Se ejecuto la tarea de actualización de precios.
Fecha y hora: {Now.ToString("dd/MM/yyyy hh:mm:ss tt")}")
+ End If
+
End If
+
Return Retorno
End Function
@@ -2017,11 +2097,19 @@ Public Class E141 : Implements IHttpHandler
Dim Retorno As Boolean = False
Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0
+ 'ENVIAR SOLO DE 8am a 8pm
+ If Now.Hour < 7 OrElse Now.Hour > 21 Then
+ Retorno = True
+ Return Retorno
+ End If
+
Dim DtPS As DataTable = Nothing
Using ObjPS As New ClsProductosServicios
'OBTERNER PRECIOS DE PUBLICO GENERAL
If ObjPS.GetExistenciasEmpresa("-1", CveEmpresa) Then
DtPS = ObjPS.DtResultados.Copy()
+ Else
+ GuardaLogAD($"AE-Ocurrió un error al obtener las existencias", "LogE141")
End If
End Using
@@ -2087,6 +2175,10 @@ Public Class E141 : Implements IHttpHandler
Threading.Thread.Sleep(1000)
End While
End If
+
+ If DtPS.Rows.Count > 0 Then
+ EnviarCorreoNotificacion("SIG - Actualización de existencias", $"Se ejecuto la tarea de actualización de existencias.
Fecha y hora: {Now.ToString("dd/MM/yyyy hh:mm:ss tt")}")
+ End If
End If
If CountPeticionesExitosas = CountPeticiones Then