Notificaciones Trayectos

This commit is contained in:
2020-01-21 15:54:15 -07:00
parent 7eb64f0243
commit 0493a18d50
3 changed files with 237 additions and 120 deletions

View File

@@ -8,10 +8,11 @@ Imports Extensiones
Imports Microsoft.Reporting.WebForms
Imports Newtonsoft.Json.Linq
Imports System.Linq
Imports System.Net.Http
Partial Class GPS_Trayectos
Inherits ClsPaginas
Inherits ClsPaginas
#Region "P R O P I E D A D E S"
Private Property DtGeocercasAgregar As DataTable
Get
@@ -36,9 +37,9 @@ Partial Class GPS_Trayectos
Set(value As DataTable)
ViewState("DtPosiciones") = 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
DirectCast(Master.FindControl("TSM"), ScriptManager).EnablePageMethods = True
@@ -276,12 +277,12 @@ Partial Class GPS_Trayectos
Private Sub LimpiaCampos()
TxtNombre.Text = ""
DdlDispositivo.SelectedIndex = 0
End Sub
End Sub
#Region "C O N S U L T A "
Protected Sub LnkConsultar_Click(sender As Object, e As EventArgs)
CargaTrayectos()
End Sub
End Sub
#End Region
Protected Sub GvBarra_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
@@ -413,105 +414,29 @@ Partial Class GPS_Trayectos
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim CveTrayecto As Integer = GvRow.DataKey("CveTrayecto").ToEntero()
Dim EnviarLiga As Boolean = CBool(GvRow.DataKey("EnviarLiga"))
If CveTrayecto > 0 Then
Dim DtInfoTrayecto As DataTable = Nothing
Using ObjGPS As New ClsGPS
If ObjGPS.GetTrayectosDatos(CveTrayecto) Then
DtInfoTrayecto = ObjGPS.DtSetResultados.Tables(0).Copy()
Dim Url = New Uri(String.Format("{0}/ashx/SIGGPS.ashx?metodo=EjecutaTrayectos&CveTrayecto={1}", "https://gps.signalsgps.com", CveTrayecto))
Dim Retorno As String = "{}"
Try
Using httpClient = New HttpClient()
httpClient.Timeout = New TimeSpan(0, 0, 15)
Using request = New HttpRequestMessage(HttpMethod.Get, Url)
Dim response = httpClient.SendAsync(request).Result
If response.StatusCode = Net.HttpStatusCode.OK Then
Retorno = response.Content.ReadAsStringAsync().Result
End If
End Using
End Using
Dim Resp = JObject.Parse(Retorno)
If CBool(Resp("EnvioCorreo").ToString()) Then
Alert(Resp("Mensaje").ToString(), TipoMensaje.MsgInformacion)
Else
Alert(Resp("Mensaje").ToString(), TipoMensaje.MsgError)
End If
End Using
If DtInfoTrayecto IsNot Nothing AndAlso DtInfoTrayecto.Rows.Count > 0 Then
Dim Row As DataRow = DtInfoTrayecto.Rows(0)
GeneraCorreo(CveTrayecto, EnviarLiga, Row)
End If
Catch ex As Exception
OnError("Ocurrió un error al descargar la factura", ex)
End Try
End If
End Sub
Protected Function GeneraCorreo(CveTrayecto As Integer, EnviarLiga As Boolean, Row As DataRow) As String
Dim strBody As New StringBuilder
Try
strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
strBody.Append("<head> ")
strBody.Append(" <style type=""text/css""> ")
strBody.Append(" body ")
strBody.Append(" { ")
strBody.Append(" margin:0px; ")
strBody.Append(" padding:0px 0px 0px 0px; ")
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
strBody.Append(" font-size: 10px; ")
strBody.Append(" background-color:#F0F0F0; ")
strBody.Append(" } ")
strBody.Append(" a.Texto ")
strBody.Append(" { ")
strBody.Append(" font-size:11px; ")
strBody.Append(" background-color:#F7F6F3; ")
strBody.Append(" text-decoration:none; ")
strBody.Append(" font-weight:bold; ")
strBody.Append(" } ")
strBody.Append(" .Texto ")
strBody.Append(" { ")
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
strBody.Append(" } ")
strBody.Append(" .TextoAlterno ")
strBody.Append(" { ")
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
strBody.Append(" vertical-align:middle; height:20px;")
strBody.Append(" } ")
strBody.Append(" .BarraIdentidad ")
strBody.Append(" { ")
strBody.Append(" color:#FFFFFF; ")
strBody.Append(" background:#F0F0F0; ")
strBody.Append(" font-weight:bold; ")
strBody.Append(" font-size:19px; ")
strBody.Append(" font-style:oblique; ")
strBody.Append(" } ")
strBody.Append(" .Titulos ")
strBody.Append(" { ")
strBody.Append(" background-color: Gray;")
strBody.Append(" color:White; ")
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
strBody.Append(" text-decoration:none; ")
strBody.Append(" } ")
strBody.Append(" .Verde {color: #00CC00;} ")
strBody.Append(" .Negro {color: #000000;} ")
strBody.Append(" .Rojo {color: #FF0000;} ")
strBody.Append(" </style> ")
strBody.Append("</head> ")
strBody.Append("<body> ")
strBody.Append(" <h5> ")
strBody.Append(" ")
strBody.Append(" </h5> ")
strBody.Append(" <div id=""C_divOC"" > <fieldset> <legend><b> Datos del Trayecto</b></legend> ")
strBody.Append(" <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""550px""> ")
strBody.Append(" <tr style=""height: 22px""> ")
strBody.AppendFormat(" <td> Trayecto:</td><td colspan=""3""><b>{0}</b></td> ", Row("Trayecto"))
strBody.Append(" </tr> ")
strBody.Append(" <tr style=""height: 22px""> ")
strBody.AppendFormat(" <td> Vehículo:</td><td colspan=""3""><b>{0}</b></td> ", Row("Vehiculo"))
strBody.Append(" </tr> ")
strBody.Append(" <tr style=""height: 22px""> ")
strBody.AppendFormat(" <td>Estatus:</td><td colspan='3'><b>{0}</b></td> ", Row("Estatus"))
strBody.Append(" </tr> ")
If EnviarLiga Then
strBody.Append(" <tr style=""height: 22px""> ")
strBody.AppendFormat(" <td>Rastrea Equipo:</td><td colspan='3'><b>{0}</b></td> ", String.Format("http://gps.signalsgps.com/GPS/RastreoTrayectos.aspx?P={0}", Encripta($"CveTrayecto={CveTrayecto}")))
strBody.Append(" </tr> ")
End If
strBody.Append(" <tr > ")
strBody.AppendFormat(" <td>Posición:</td><td colspan='3'><img src=""{0}""></td> ", Row("LigaImagen"))
strBody.Append(" </tr> ")
strBody.Append(" </table> ")
strBody.Append(" </fieldset> ")
strBody.Append(" <h5> ")
strBody.Append(" ")
strBody.Append(" </h5> ")
strBody.Append(" </div> ")
strBody.Append("</body></html>")
Catch ex As Exception
OnError("Ocurrio un error al general el correo.", ex)
End Try
Return strBody.ToString()
End Function
End Class