From 1a2422b613fb3ab5856963d966afef8ea31d54ae Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 14 Apr 2021 17:09:04 -0700 Subject: [PATCH] Cambio en correo de notificaciones --- App_Code/ClsSisNotificaciones.vb | 14 +-- Sistemas/PopUpAddUsuario.aspx.vb | 175 +++++++++++++++++++++++++++---- 2 files changed, 162 insertions(+), 27 deletions(-) diff --git a/App_Code/ClsSisNotificaciones.vb b/App_Code/ClsSisNotificaciones.vb index be0a9a61e..4aafd6454 100644 --- a/App_Code/ClsSisNotificaciones.vb +++ b/App_Code/ClsSisNotificaciones.vb @@ -357,7 +357,7 @@ Public Class ClsSisNotificaciones If LSRutasMail.Count > 0 Then Dim ObjMail As New ClsSisMail() Dim ResultadoMail As Integer = 0 - If ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then + If ObjMail.SendMail(ClsPaginas.EmpresaNotificacionesGPS, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then UpdateNotificacionesBitacoraNotifico(CveNotificacionBitacora, 1) End If End If @@ -418,7 +418,7 @@ Public Class ClsSisNotificaciones End If If Archivos.Count > 0 Then - If ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", $"Se adjunta el {Formato} en el Reporte Programado.", "", Archivos) Then + If ObjMail.SendMail(ClsPaginas.EmpresaNotificacionesGPS, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", $"Se adjunta el {Formato} en el Reporte Programado.", "", Archivos) Then UpdateNotificacionesBitacoraNotifico(CveNotificacionBitacora, 1) End If End If @@ -467,7 +467,7 @@ Public Class ClsSisNotificaciones If LSRutasMail.Count > 0 Then Dim ObjMail As New ClsSisMail() Dim ResultadoMail As Integer = 0 - If ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then + If ObjMail.SendMail(ClsPaginas.EmpresaNotificacionesGPS, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then UpdateNotificacionesBitacoraNotifico(CveNotificacionBitacora, 1) End If End If @@ -509,7 +509,7 @@ Public Class ClsSisNotificaciones If LSRutasMail.Count > 0 Then Dim ObjMail As New ClsSisMail() Dim ResultadoMail As Integer = 0 - If ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then + If ObjMail.SendMail(ClsPaginas.EmpresaNotificacionesGPS, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then UpdateNotificacionesBitacoraNotifico(CveNotificacionBitacora, 1) End If End If @@ -557,7 +557,7 @@ Public Class ClsSisNotificaciones If LSRutasMail.Count > 0 Then Dim ObjMail As New ClsSisMail() Dim ResultadoMail As Integer = 0 - If ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then + If ObjMail.SendMail(ClsPaginas.EmpresaNotificacionesGPS, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then UpdateNotificacionesBitacoraNotifico(CveNotificacionBitacora, 1) End If End If @@ -596,7 +596,7 @@ Public Class ClsSisNotificaciones If LSRutasMail.Count > 0 Then Dim ObjMail As New ClsSisMail() Dim ResultadoMail As Integer = 0 - If ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then + If ObjMail.SendMail(ClsPaginas.EmpresaNotificacionesGPS, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then UpdateNotificacionesBitacoraNotifico(CveNotificacionBitacora, 1) End If End If @@ -635,7 +635,7 @@ Public Class ClsSisNotificaciones If LSRutasMail.Count > 0 Then Dim ObjMail As New ClsSisMail() Dim ResultadoMail As Integer = 0 - If ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then + If ObjMail.SendMail(ClsPaginas.EmpresaNotificacionesGPS, Correos, $"Reporte Programado {Date.Today.ToShortDateString}", "Se adjunta en pdf el Reporte Programado.", "", LSRutasMail) Then UpdateNotificacionesBitacoraNotifico(CveNotificacionBitacora, 1) End If End If diff --git a/Sistemas/PopUpAddUsuario.aspx.vb b/Sistemas/PopUpAddUsuario.aspx.vb index b48a4fd17..1ec6d9763 100644 --- a/Sistemas/PopUpAddUsuario.aspx.vb +++ b/Sistemas/PopUpAddUsuario.aspx.vb @@ -1,7 +1,7 @@ Imports Extensiones Imports System.Data Partial Class Sistemas_PopUpAddUsuario - Inherits ClsPaginas + Inherits ClsPaginas #Region "PROPIEDADES" Public Property CveCliente As Integer Get @@ -51,7 +51,7 @@ Partial Class Sistemas_PopUpAddUsuario Set(value As Integer) ViewState("CvePlataforma") = value End Set - End Property + End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then @@ -164,8 +164,14 @@ Partial Class Sistemas_PopUpAddUsuario If ObjUsuario.UpdateUsuario(LtlUsuario.Text, TxtNombre.Text, -1, TxtEmail.Text, -1, -1, True, True, -1, CveUsuario, -1, -1) Then Alert("La contraseña se reestableció correctamente a la contraseña por default '-acceso-'.") Dim Liga As String = $"{Context.Request.Url.OriginalString.Substring(0, Context.Request.Url.OriginalString.Length - Context.Request.Url.PathAndQuery.Length)}/LogIn.aspx" - Dim LigaActivar As String = Liga & "?p=" & Encripta("CveU=" & CveUsuario & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks& & "&CveE=" & UsuarioActual.CveEmpresa) - EnviaCorreo(Liga, LigaActivar) + Dim LigaActivar As String = Liga & "?p=" & Encripta("CveU=" & CveUsuario & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks& & "&CveE=" & UsuarioActual.CveEmpresa) + + If UsuarioActual.Empresa.CvePlataforma = 3 Then + EnviaCorreoGPS(Liga, LigaActivar) + Else + EnviaCorreo(Liga, LigaActivar) + End If + End If End If ObjUsuario.Dispose() @@ -251,8 +257,14 @@ Partial Class Sistemas_PopUpAddUsuario 'ENVIA CORREO If CveUsuario > 0 Then Dim Liga As String = $"{Context.Request.Url.OriginalString.Substring(0, Context.Request.Url.OriginalString.Length - Context.Request.Url.PathAndQuery.Length)}/LogIn.aspx" - Dim LigaActivar As String = Liga & "?p=" & Encripta("CveU=" & CveUsuario & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks& & "&CveE=" & UsuarioActual.CveEmpresa) - Mensaje = EnviaCorreo(Liga, LigaActivar) + Dim LigaActivar As String = Liga & "?p=" & Encripta("CveU=" & CveUsuario & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks& & "&CveE=" & UsuarioActual.CveEmpresa) + + If UsuarioActual.Empresa.CvePlataforma = 3 Then + Mensaje = EnviaCorreoGPS(Liga, LigaActivar) + Else + Mensaje = EnviaCorreo(Liga, LigaActivar) + End If + Else HuboError = True End If @@ -651,16 +663,139 @@ Partial Class Sistemas_PopUpAddUsuario OnError("Ocurrió error al mandar MAIL", ex) End Try + Return Retorno + End Function + + Private Function EnviaCorreoGPS(Liga As String, LigaActivar As String) As String + Dim Retorno As String = "" + Try + 'Dim URL As String = "https://gps.signalsgps.com/" + LigaActivar + + Dim Para = TxtEmail.Text.Trim + Dim Asunto = "ACCESO A SIGNALS GPS" + + 'Dim SBBody As New StringBuilder + ''Linia de estilos + 'SBBody.Append("") + ''incio Cuerpo del correo + 'SBBody.Append("
") + 'SBBody.Append("
") + 'SBBody.Append("
") + 'SBBody.Append("ALTA DE CUENTA") + 'SBBody.Append("
") + 'SBBody.Append("
") + 'SBBody.AppendFormat(" Estimado {0}:
", TxtNombre.Text.ToUpper) + 'SBBody.AppendFormat("El presente correo es para informarle que se le han asignado los siguientes datos para el acceso a la Plataforma de: {0}

", UsuarioActual.Empresa.Empresa) + 'SBBody.Append("
") + 'SBBody.Append("
Datos de usuario
") + 'SBBody.Append("
") + 'SBBody.Append("
") + 'SBBody.Append("
") + 'SBBody.Append("
Usuario
") + 'SBBody.AppendFormat("
{0}
", TxtEmail.Text) + 'SBBody.Append("
") + 'SBBody.Append("
") + 'SBBody.Append("
Accesé al sistema dando click a la liga y estableciendo su contraseña
") + 'SBBody.AppendFormat("", LigaActivar) + 'SBBody.Append("
") + 'SBBody.Append("
") + 'SBBody.Append("
") + 'SBBody.Append("
") + 'SBBody.Append("Para Activar su cuenta debera cambiar su contraseña.

") + 'SBBody.Append("
") + 'SBBody.Append("Nota Favor de NO responder este correo. ") + 'SBBody.Append("


") + 'SBBody.AppendFormat("", URL) + 'SBBody.Append("
") + 'SBBody.Append("
") + + Dim SBBody As New StringBuilder() + + SBBody.Append("
") + SBBody.Append("
") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append("
 ") + SBBody.Append("

DATOS DE ACCESO

") + SBBody.Append("

 

") + SBBody.Append("
") + SBBody.Append("
") + SBBody.AppendFormat("


Estimado / a {0}:

", TxtNombre.Text) + SBBody.Append("

El presente correo es para informarle que se le han asignado los siguentes datos para el acceso a la plataforma SIGNALS GPS

") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append(" ") + SBBody.Append("") + SBBody.Append("
") + SBBody.Append("

USUARIO ASIGNADO

") + SBBody.Append("
") + SBBody.Append("

Usuario:

") + SBBody.AppendFormat("

{0}

", TxtEmail.Text) + SBBody.Append("
") + SBBody.Append("

Contraseña:

") + SBBody.Append("

-acceso-

") + SBBody.Append("
") + SBBody.AppendFormat("

👆INGRESAR A SIGNALS GPS👆

", LigaActivar) + SBBody.Append("
") + SBBody.Append("
") + SBBody.Append("


Favor de NO responder este correo.

") + SBBody.Append("
") + SBBody.Append("

 

") + SBBody.Append("
") + 'Termino Cuerpo del correo + + Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo(Asunto, Para, SBBody.ToString)) + Hilo.Start() + + 'Dim JSBTN As String = "" + 'If UsuarioActual.CveCliente > 0 Then + ' JSBTN = $"document.location.href=""javascript: Ir2({CveCliente})"";" + 'ElseIf CveCliente > 0 Then + ' JSBTN = $"document.location.href=""javascript:Ir({CveCliente})"";" + 'End If + 'If UsuarioActual.Empresa.CvePlataforma = 3 Then + ' Alert("El correo se ha enviado correctamente a: " + TxtEmail.Text + ".", TipoMensaje.MsgInformacion, JSBTN) + 'End If + + Retorno = $"El correo se ha enviado correctamente a: {TxtEmail.Text}." + + Catch ex As Exception + OnError("Ocurrió error al mandar MAIL", ex) + End Try + Return Retorno End Function Private Sub MandaCorreo(Asunto As String, Para As String, Body As String) Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para) a.GuardaLog() Dim Mail As New ClsSisMail() - Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body) - End Sub -#End Region + Dim EmpresaEnvio As Empresa = ClsPaginas.EmpresaNotificaciones + + If UsuarioActual.Empresa.CvePlataforma = 3 Then + EmpresaEnvio = ClsPaginas.EmpresaNotificacionesGPS + End If + + Mail.SendMail(EmpresaEnvio, Para, Asunto, Body) + End Sub +#End Region + #Region "M O D U L O S" Public Sub CargaModulosAcceso() Dim ObjPermisos As New ClsSisUsuarios @@ -808,11 +943,11 @@ Partial Class Sistemas_PopUpAddUsuario End If End If - End Sub - - + End Sub + + #End Region - + #Region "V E H I C U L O S" Private Sub CargaDispositivos() GvDispositivos.DataSource = GlobalDTDispositivos(CveCliente).FiltraParametros("Estatus = 1 ") @@ -826,10 +961,10 @@ Partial Class Sistemas_PopUpAddUsuario End If End If End If - End Sub - + End Sub + #End Region - + #Region "N O T I F I C A C I O N E S" Private Sub CargarNotificaciones() Dim ObjNotificaciones As New ClsSisNotificaciones @@ -851,11 +986,11 @@ Partial Class Sistemas_PopUpAddUsuario e.Row.FCCheckBox("chkApp").Checked = If(DtNotificacionesUsuarios.FiltroPrimeroValor("Alerta_App", $"CveNotificacion = {e.Row.DBCampo("CveNotificacion")}").ToString = "True", True, False) End If End If - End Sub - - + End Sub + + #End Region - + Protected Sub BtnCambiarUsuario_Click(sender As Object, e As EventArgs) CveUsuario = -1