255 lines
12 KiB
VB.net
255 lines
12 KiB
VB.net
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Partial Class GPS_PruebaMaster
|
|
Inherits ClsPaginas
|
|
|
|
#Region "P R O P I E D A D E S"
|
|
Public Property Offset() As Integer
|
|
Get
|
|
Return DirectCast(IfNull(ViewState("Offset"), 0), Integer)
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
ViewState("Offset") = value
|
|
End Set
|
|
End Property
|
|
Public ReadOnly Property FechaCliente() As DateTime
|
|
Get
|
|
Return DateTime.UtcNow.AddMinutes(10).AddMinutes(Offset)
|
|
End Get
|
|
End Property
|
|
Private Property DTEquipos As DataTable
|
|
Get
|
|
Return CType(ViewState("DTEquipos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTEquipos") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
If UsuarioActual.Contraseña = (ContraseñaPredeterminadaEncriptada) OrElse UsuarioActual.ActCambiarContraseña Then
|
|
Response.Redirect("/Sistemas/CatContrasenia.aspx")
|
|
Else
|
|
CargaDispositivos()
|
|
CargaZonasHorarias()
|
|
End If
|
|
End If
|
|
End Sub
|
|
Private Sub CargaZonasHorarias()
|
|
Using ObjGPS As New ClsGPS
|
|
Dim CveZonaHoraria As Integer = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveZonaHoraria", $"CveCliente = {UsuarioActual.CveCliente}").ToEntero()
|
|
If ObjGPS.GetZonasHorarias() Then
|
|
If ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
Offset = ObjGPS.DtResultados.FiltroPrimeroValor("UTCOffset", $"CveZonaHoraria = {CveZonaHoraria}").ToEntero()
|
|
End If
|
|
End If
|
|
End Using
|
|
End Sub
|
|
|
|
Private Sub CargaDispositivos()
|
|
DTEquipos = GlobalDTDispositivosUsuarios(UsuarioActual.CveCliente, UsuarioActual.CveUsuario).FiltraParametros("Estatus = 1")
|
|
End Sub
|
|
|
|
Private Function SQLToGmaps(CoordsSQL As String, Tipo As String) As String
|
|
Dim CoordsPoligono As String = CoordsSQL.Replace($"{Tipo}", "").Replace(")", "").Replace("(", "")
|
|
Dim CoordsPuntos() As String = CoordsPoligono.Split(","c)
|
|
Dim Var As String = ""
|
|
For Each coordenada As String In CoordsPuntos
|
|
If coordenada Is CoordsPuntos.Last Then
|
|
Dim latlng() As String = coordenada.Trim.Split(" "c)
|
|
Var = $"{Var}{{lat: {latlng(1)}, lng: {latlng(0)} }}"
|
|
Else
|
|
Dim latlng() As String = coordenada.Trim.Split(" "c)
|
|
Var = $"{Var}{{lat: {latlng(1)}, lng: {latlng(0)} }},"
|
|
End If
|
|
Next
|
|
Return Var
|
|
End Function
|
|
|
|
Protected Sub BtnCargar_Click(sender As Object, e As EventArgs) Handles BtnCargar.Click
|
|
Dim SBBody As New StringBuilder
|
|
Dim Info As String
|
|
Dim GPS As New ClsGPS
|
|
Dim Icono As String = ""
|
|
Dim SB = New StringBuilder()
|
|
For Each row As DataRow In DTEquipos.Rows
|
|
SB.Append($"{row("CveDispositivo")};")
|
|
Next
|
|
|
|
If GPS.UltimaPosicionEquipoGet(SB.ToString, UsuarioActual.CveCliente) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
For Each row As DataRow In GPS.DtResultados.Rows
|
|
Dim Coord As String '= SQLToGmaps(row("Posicion").ToString, "POINT")
|
|
|
|
Try
|
|
Coord= SQLToGmaps(row("Posicion").ToString, "POINT")
|
|
|
|
Catch ex As Exception
|
|
GuardaLog($"{SB.ToString} {UsuarioActual.CveCliente}{ex.ToString()}")
|
|
End Tryy
|
|
Info = InfoWindowCombustible($"Vehículo: {row("Vehiculo").ToString}", "-1", row("CveDispositivo").ToString.ToEntero, row)
|
|
Dim Fecha = row("FechaTrama").ToString
|
|
Dim Diferencia As Long = DateDiff(DateInterval.Minute, Fecha.ToDateTime(), FechaCliente)
|
|
|
|
If Diferencia >= 30 AndAlso Diferencia < 120 Then
|
|
Icono = $"/Imagenes/rsz_11rsz_car_disconnected.png"
|
|
ElseIf Diferencia >= 120 Then
|
|
Icono = $"/Imagenes/rsz_11rsz_car_disable.png"
|
|
Else
|
|
If row("SPD").ToString.ToDouble > 1 Then
|
|
Icono = $"/Imagenes/{GlobalDTDispositivos(UsuarioActual.CveCliente).FiltroPrimeroValor("Icono", $"CveDispositivo = {row("CveDispositivo").ToString}")}green.png"
|
|
Else
|
|
Icono = $"/Imagenes/{GlobalDTDispositivos(UsuarioActual.CveCliente).FiltroPrimeroValor("Icono", $"CveDispositivo = {row("CveDispositivo").ToString}")}.png"
|
|
End If
|
|
End If
|
|
|
|
SBBody.Append($"</table></div><div></div></div>")
|
|
RegistraScript($"CreaMarcador({Coord},'{row("Vehiculo").ToString}', '{Info}', '{Icono}');", row("CveDispositivo").ToString)
|
|
Next
|
|
End If
|
|
End If
|
|
RegistraScript("fitBoundsToVisibleMarkers();", "2")
|
|
GPS.Dispose()
|
|
End Sub
|
|
|
|
|
|
#Region "Herramientas - GPS"
|
|
|
|
Protected Sub BtnCargaComandos_Click(sender As Object, e As EventArgs) Handles BtnCargaComandos.Click
|
|
CargaComandos()
|
|
End Sub
|
|
Private Sub CargaComandos()
|
|
'Dim ObjGps As New ClsGPS
|
|
'If ObjGps.GetComandosModeloDispositivo(HdnCveDipositivo.Value.ToEntero) AndAlso ObjGps.DtResultados.Rows.Count > 0 Then
|
|
' GvComandos.DataSource = ObjGps.DtResultados.FiltraParametros("CveComando IN (6, 7, 32, 36, 8, 9)")
|
|
' GvComandos.DataBind()
|
|
' UpBodyTipoEquipo.Update()
|
|
'End If
|
|
|
|
'ObjGps.Dispose()
|
|
|
|
Dim ObjGps As New ClsGPS
|
|
If ObjGps.GetComandosModeloDispositivoUsuarios(HdnCveDipositivo.Value.ToEntero, UsuarioActual.CveUsuario, 1) Then
|
|
GvComandos.DataSource = ObjGps.DtResultados
|
|
End If
|
|
ObjGps.Dispose()
|
|
GvComandos.DataBind()
|
|
|
|
UpBodyTipoEquipo.Update()
|
|
End Sub
|
|
|
|
Private Sub GvComandos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvComandos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
'Select Case e.Row.DBCampo("CveComando").ToEntero
|
|
' Case 6
|
|
' e.Row.Cells(1).Text = "Apagar Motor"
|
|
' Case 7
|
|
' e.Row.Cells(1).Text = "Encender Motor"
|
|
' Case 32
|
|
' e.Row.Cells(1).Text = "Reiniciar Dispositivo"
|
|
' Case 36
|
|
' e.Row.Cells(1).Text = "Telefono de Pánico"
|
|
' Case 8
|
|
' e.Row.Cells(1).Text = "Abrir Compuerta"
|
|
' Case 9
|
|
' e.Row.Cells(1).Text = "Cerrar Compuerta"
|
|
'End Select
|
|
|
|
If e.Row.DataKey("RequiereValor").ToEntero = 1 Then
|
|
e.Row.FCTextBox("TxtValor").Visible = True
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GvComandos_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvComandos.RowCommand
|
|
If (e.CommandName = "EnviarComando") Then
|
|
|
|
Dim ObjHerramientas As New ClsGPSHerramientas
|
|
|
|
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
|
|
Dim row As GridViewRow = GvComandos.Rows(index)
|
|
|
|
ObjHerramientas.EjecutarComandoGPRS(row.DataKey("CveComando").ToEntero, HdnCveDipositivo.Value.ToEntero, UsuarioActual.CveUsuario, row.FCTextBox("TxtValor").Text)
|
|
|
|
ObjHerramientas.Dispose()
|
|
|
|
End If
|
|
End Sub
|
|
|
|
'Private Sub BtnApagarMotor_Click(sender As Object, e As EventArgs) Handles BtnApagarMotor.Click
|
|
' 'Comando 6
|
|
' Dim ObjGPSHerramientas As New ClsGPSHerramientas
|
|
' ObjGPSHerramientas.EjecutarComandoGPRS(6, HdnCveDipositivo.Value.ToEntero, UsuarioActual.CveUsuario, "")
|
|
' ObjGPSHerramientas.Dispose()
|
|
'End Sub
|
|
|
|
'Private Sub BtnEncenderMotor_Click(sender As Object, e As EventArgs) Handles BtnEncenderMotor.Click
|
|
' 'Comando 7
|
|
' Dim ObjGPSHerramientas As New ClsGPSHerramientas
|
|
' ObjGPSHerramientas.EjecutarComandoGPRS(7, HdnCveDipositivo.Value.ToEntero, UsuarioActual.CveUsuario, "")
|
|
' ObjGPSHerramientas.Dispose()
|
|
'End Sub
|
|
|
|
'Private Sub BtnReinicio_Click(sender As Object, e As EventArgs) Handles BtnReinicio.Click
|
|
' 'Comando 32
|
|
' Dim ObjGPSHerramientas As New ClsGPSHerramientas
|
|
' ObjGPSHerramientas.EjecutarComandoGPRS(32, HdnCveDipositivo.Value.ToEntero, UsuarioActual.CveUsuario, "")
|
|
' ObjGPSHerramientas.Dispose()
|
|
'End Sub
|
|
|
|
'Private Sub BtnTelefonoPanico_Click(sender As Object, e As EventArgs) Handles BtnTelefonoPanico.Click
|
|
' 'Comando 36
|
|
' Dim ObjGPSHerramientas As New ClsGPSHerramientas
|
|
' ObjGPSHerramientas.EjecutarComandoGPRS(36, HdnCveDipositivo.Value.ToEntero, UsuarioActual.CveUsuario, TxtTelefonoPanico.Text.Trim)
|
|
' ObjGPSHerramientas.Dispose()
|
|
'End Sub
|
|
|
|
'Private Sub BtnProbarEncendido_Click(sender As Object, e As EventArgs) Handles BtnProbarEncendido.Click
|
|
' 'Comando 8 'Abrir Compuerta
|
|
' Dim ObjGPSHerramientas As New ClsGPSHerramientas
|
|
' ObjGPSHerramientas.EjecutarComandoGPRS(8, HdnCveDipositivo.Value.ToEntero, UsuarioActual.CveUsuario, "")
|
|
' ObjGPSHerramientas.Dispose()
|
|
'End Sub
|
|
|
|
'Private Sub BtnInfoDispositivo_Click(sender As Object, e As EventArgs) Handles BtnInfoDispositivo.Click
|
|
' 'Comando 9 'Cerrar Compuerta
|
|
' Dim ObjGPSHerramientas As New ClsGPSHerramientas
|
|
' ObjGPSHerramientas.EjecutarComandoGPRS(9, HdnCveDipositivo.Value.ToEntero, UsuarioActual.CveUsuario, "")
|
|
' ObjGPSHerramientas.Dispose()
|
|
'End Sub
|
|
|
|
'Private Sub BtnAhorroBateria_Click(sender As Object, e As EventArgs) Handles BtnAhorroBateria.Click
|
|
' 'Comando 40
|
|
' Dim ObjGPSHerramientas As New ClsGPSHerramientas
|
|
' ObjGPSHerramientas.EjecutarComandoGPRS(40, HdnCveDipositivo.Value.ToEntero, UsuarioActual.CveUsuario, DdlTipoBateria.SelectedValue)
|
|
' ObjGPSHerramientas.Dispose()
|
|
'End Sub
|
|
#End Region
|
|
Public Function InfoWindowCombustible(Header As String, ExtraBody As String, CveDispositivo As Integer, row As DataRow, Optional PermisoComandos As Boolean = True) As String
|
|
Dim SBuilder As New StringBuilder
|
|
SBuilder.Clear()
|
|
SBuilder.Append($"<div>")
|
|
SBuilder.Append($"<div><h5><a target=\'_blank\' href=\'/GPS/Vehiculos.aspx?CveDispositivo={CveDispositivo}\'><b>{Header}</b></a></h5></div>")
|
|
SBuilder.Append($"<div><table>")
|
|
SBuilder.Append($"<tr><td>Fecha : {row("FechaTrama")} </td></tr>")
|
|
SBuilder.Append($"<tr><td>Conductor : {row("Conductor").ToString}</td></tr>")
|
|
SBuilder.Append($"<tr><td>Combustible : {IfNull(row("Combustible"), "NO DISPONIBLE", $"{row("Combustible").ToString.FormatoNumero} lts").ToString}</td></tr>")
|
|
If row("SPD").ToString <> "-1" Then
|
|
SBuilder.Append($"<tr><td>Velocidad : {row("SPD").ToString} KM/H </td></tr>")
|
|
End If
|
|
If ExtraBody <> "" AndAlso ExtraBody <> "-1" Then
|
|
SBuilder.Append(ExtraBody)
|
|
End If
|
|
If PermisoComandos Then
|
|
SBuilder.Append($"<tr><td><a href=""javascript:;"" onclick=""CargaComandos(\'{row("Vehiculo").ToString}\',{CveDispositivo});"">Comandos</a></td></tr>")
|
|
End If
|
|
SBuilder.AppendFormat("<tr><td><a target=\'_blank\' href=\'https://www.google.com/maps/search/{0},{1}/\'>Ver en google maps</a></td></tr>", row("Lat").ToString, row("Lng").ToString)
|
|
SBuilder.Append($"</table></div><div></div></div>")
|
|
Return SBuilder.ToString
|
|
End Function
|
|
End Class
|