Cambios en servicio de fidelity

This commit is contained in:
2023-08-03 10:01:17 -07:00
parent 620625e3e9
commit c8c50379b1
2 changed files with 109 additions and 9 deletions

View File

@@ -33,7 +33,7 @@ Public Class ClsSisMail
Return Resultado Return Resultado
End Function 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 Dim ObjMail As New Mail
ObjMail.ObjEmpresa = ObjEmpresa ObjMail.ObjEmpresa = ObjEmpresa
ObjMail.De = If(Displayname.Trim = String.Empty, "", Displayname) ObjMail.De = If(Displayname.Trim = String.Empty, "", Displayname)
@@ -41,6 +41,7 @@ Public Class ClsSisMail
ObjMail.CCP = CCP ObjMail.CCP = CCP
ObjMail.Asunto = Asunto ObjMail.Asunto = Asunto
ObjMail.Body = Body ObjMail.Body = Body
ObjMail.CCO = CCO
If Archivos IsNot Nothing AndAlso Archivos.Count > 0 Then ' si tiene adjuntos, me crea el objeto If Archivos IsNot Nothing AndAlso Archivos.Count > 0 Then ' si tiene adjuntos, me crea el objeto
ObjMail.Archivos = New List(Of ArchivoMail) ObjMail.Archivos = New List(Of ArchivoMail)
@@ -85,6 +86,7 @@ Public Class ClsSisMail
Dim Mensaje As String = String.Empty Dim Mensaje As String = String.Empty
Dim ArrayPara() As String = ObjMail.Para.Replace(",", ";").Split(";"c) Dim ArrayPara() As String = ObjMail.Para.Replace(",", ";").Split(";"c)
Dim ArrayCCP() As String = ObjMail.CCP.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" '"sgd.facturacion@adsistemas.mx"
If ObjMail.De = String.Empty Then If ObjMail.De = String.Empty Then
@@ -103,6 +105,12 @@ Public Class ClsSisMail
For Each CorreoCCPPara As String In ArrayCCP.Distinct For Each CorreoCCPPara As String In ArrayCCP.Distinct
If IsMail(CorreoCCPPara.Trim) Then Correo.To.Add(CorreoCCPPara.Trim) If IsMail(CorreoCCPPara.Trim) Then Correo.To.Add(CorreoCCPPara.Trim)
Next 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 End If
Correo.Subject = ObjMail.Asunto Correo.Subject = ObjMail.Asunto
@@ -120,7 +128,6 @@ Public Class ClsSisMail
Correo.Body = Mensaje & ObjMail.Body Correo.Body = Mensaje & ObjMail.Body
Correo.IsBodyHtml = True Correo.IsBodyHtml = True
Correo.Priority = Net.Mail.MailPriority.Normal Correo.Priority = Net.Mail.MailPriority.Normal
If ObjMail.Archivos IsNot Nothing Then If ObjMail.Archivos IsNot Nothing Then
For Each Item As ArchivoMail In ObjMail.Archivos For Each Item As ArchivoMail In ObjMail.Archivos
If Item.ArchivoBinario IsNot Nothing Then If Item.ArchivoBinario IsNot Nothing Then
@@ -190,6 +197,7 @@ Public Class ClsSisMail
Public Property Para As String Public Property Para As String
Public Property Asunto As String Public Property Asunto As String
Public Property CCP As String Public Property CCP As String
Public Property CCO As String
Public Property Body As String Public Property Body As String
Public Property Archivos As List(Of ArchivoMail) Public Property Archivos As List(Of ArchivoMail)
End Class End Class

View File

@@ -130,7 +130,7 @@ Public Class E141 : Implements IHttpHandler
End If End If
Catch ex As Exception 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 End Try
Else Else
@@ -250,6 +250,16 @@ Public Class E141 : Implements IHttpHandler
Else Else
retorno = "False" retorno = "False"
End If 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 Select
End If End If
@@ -268,6 +278,27 @@ Public Class E141 : Implements IHttpHandler
End Try End Try
End Sub 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 Private Function ValidarSolicitud(ByVal context As HttpContext) As AuthMessage
Dim unauthorized As Boolean = True Dim unauthorized As Boolean = True
Dim respuesta As New AuthMessage Dim respuesta As New AuthMessage
@@ -1729,6 +1760,38 @@ Public Class E141 : Implements IHttpHandler
'End Function '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" #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}. <br/>", Row("CodigoPS"))
Next
Dim msg As String = ""
If sb.Length > 0 Then
msg = $"Se enviaron los siguientes productos: <br/> {sb.ToString()} <br/> Fecha y hora: {Now.ToString("dd/MM/yyyy hh:mm:ss tt")}"
Else
msg = $"No se enviaron productos esta semana <br/> 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 Private Function CrearActualizarProductos(Todos As Boolean) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0
@@ -1738,6 +1801,8 @@ Public Class E141 : Implements IHttpHandler
'OBTERNER PRECIOS DE PUBLICO GENERAL 'OBTERNER PRECIOS DE PUBLICO GENERAL
If ObjPS.GetProductosModificados(CveEmpresa, 44, If(Todos, -1, 26)) Then If ObjPS.GetProductosModificados(CveEmpresa, 44, If(Todos, -1, 26)) Then
DtPS = ObjPS.DtResultados.Copy() DtPS = ObjPS.DtResultados.Copy()
Else
GuardaLogAD($"NP-Ocurrió un error al obtener los productos", "LogE141")
End If End If
End Using End Using
@@ -1759,10 +1824,10 @@ Public Class E141 : Implements IHttpHandler
CountPeticionesExitosas += 1 CountPeticionesExitosas += 1
GuardaLogAD("NP-Creacion/actualizacion de productos exitosa", "LogE141") GuardaLogAD("NP-Creacion/actualizacion de productos exitosa", "LogE141")
Else 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 End If
Else 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 End If
Else Else
@@ -1799,16 +1864,18 @@ Public Class E141 : Implements IHttpHandler
CountPeticionesExitosas += 1 CountPeticionesExitosas += 1
GuardaLogAD("NP-Creacion/actualizacion de productos exitosa", "LogE141") GuardaLogAD("NP-Creacion/actualizacion de productos exitosa", "LogE141")
Else 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 End If
Else 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 End If
Threading.Thread.Sleep(1000) Threading.Thread.Sleep(1000)
End While End While
End If End If
If DtPS.Rows.Count > 0 Then
EnviarCorreoNotificacion("SIG - Actualización de productos", $"Se ejecuto la tarea de actualización de productos. <br/> Fecha y hora: {Now.ToString("dd/MM/yyyy hh:mm:ss tt")}")
End If
End If End If
If CountPeticionesExitosas = CountPeticiones Then If CountPeticionesExitosas = CountPeticiones Then
@@ -1826,7 +1893,7 @@ Public Class E141 : Implements IHttpHandler
Dim DtPS As DataTable = Nothing Dim DtPS As DataTable = Nothing
Using ObjPS As New ClsProductosServicios Using ObjPS As New ClsProductosServicios
'OBTERNER PRECIOS DE PUBLICO GENERAL '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() DtPS = ObjPS.DtResultados.Copy()
End If End If
End Using End Using
@@ -1890,6 +1957,12 @@ Public Class E141 : Implements IHttpHandler
Private Function ActualizarPrecios(Todos As Boolean) As Boolean Private Function ActualizarPrecios(Todos As Boolean) As Boolean
Dim Retorno As Boolean = False 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 CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0
Dim DtPS As DataTable = Nothing Dim DtPS As DataTable = Nothing
@@ -1897,6 +1970,8 @@ Public Class E141 : Implements IHttpHandler
'OBTERNER PRECIOS DE PUBLICO GENERAL 'OBTERNER PRECIOS DE PUBLICO GENERAL
If ObjPS.GetPreciosModificados(CveEmpresa, 44, If(Todos, -1, 1)) Then If ObjPS.GetPreciosModificados(CveEmpresa, 44, If(Todos, -1, 1)) Then
DtPS = ObjPS.DtResultados.Copy() DtPS = ObjPS.DtResultados.Copy()
Else
GuardaLogAD($"AP-Ocurrió un error al obtener los precios", "LogE141")
End If End If
End Using End Using
@@ -1965,8 +2040,13 @@ Public Class E141 : Implements IHttpHandler
End While End While
End If End If
If DtPS.Rows.Count > 0 Then
EnviarCorreoNotificacion("SIG - Actualización de precios", $"Se ejecuto la tarea de actualización de precios. <br/> Fecha y hora: {Now.ToString("dd/MM/yyyy hh:mm:ss tt")}")
End If
End If End If
Return Retorno Return Retorno
End Function End Function
@@ -2017,11 +2097,19 @@ Public Class E141 : Implements IHttpHandler
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 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 Dim DtPS As DataTable = Nothing
Using ObjPS As New ClsProductosServicios Using ObjPS As New ClsProductosServicios
'OBTERNER PRECIOS DE PUBLICO GENERAL 'OBTERNER PRECIOS DE PUBLICO GENERAL
If ObjPS.GetExistenciasEmpresa("-1", CveEmpresa) Then If ObjPS.GetExistenciasEmpresa("-1", CveEmpresa) Then
DtPS = ObjPS.DtResultados.Copy() DtPS = ObjPS.DtResultados.Copy()
Else
GuardaLogAD($"AE-Ocurrió un error al obtener las existencias", "LogE141")
End If End If
End Using End Using
@@ -2087,6 +2175,10 @@ Public Class E141 : Implements IHttpHandler
Threading.Thread.Sleep(1000) Threading.Thread.Sleep(1000)
End While End While
End If End If
If DtPS.Rows.Count > 0 Then
EnviarCorreoNotificacion("SIG - Actualización de existencias", $"Se ejecuto la tarea de actualización de existencias. <br/> Fecha y hora: {Now.ToString("dd/MM/yyyy hh:mm:ss tt")}")
End If
End If End If
If CountPeticionesExitosas = CountPeticiones Then If CountPeticionesExitosas = CountPeticiones Then