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

@@ -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}. <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
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. <br/> 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. <br/> 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. <br/> Fecha y hora: {Now.ToString("dd/MM/yyyy hh:mm:ss tt")}")
End If
End If
If CountPeticionesExitosas = CountPeticiones Then