396 lines
19 KiB
VB.net
396 lines
19 KiB
VB.net
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
|
|
Partial Class GPS_Soporte
|
|
Inherits ClsPaginas
|
|
|
|
|
|
#Region "PROPIEDADES"
|
|
Private Property TmpDT As DataTable
|
|
Get
|
|
Return CType(ViewState("TmpDT"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDT") = 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
|
|
CargaDispositivos()
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaDispositivos()
|
|
Dim GPS As New ClsGPS
|
|
|
|
If GPS.DispositivosGet(-1, -1, -1, UsuarioActual.CveEmpresa) AndAlso GPS.DtResultados.Rows.Count > 0 Then
|
|
DdlDispositivo.DataSource = GPS.DtResultados
|
|
DdlDispositivosLog.DataSource = GPS.DtResultados
|
|
End If
|
|
GPS.Dispose()
|
|
DdlDispositivo.DataBind()
|
|
DdlDispositivosLog.DataBind()
|
|
DdlDispositivo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlDispositivosLog.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
DdlClientes.DataBind()
|
|
DdlClientes.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim GPS As New ClsGPS
|
|
|
|
If GPS.DispositivosGet(DdlDispositivo.SelectedValue, -1, -1) AndAlso GPS.DtResultados.Rows.Count > 0 Then
|
|
TxtIp.Text = GPS.DtResultados.Rows(0)("IP").ToString
|
|
TxtPuerto.Text = "80"
|
|
TxtAPN.Text = GPS.DtResultados.Rows(0)("APN").ToString
|
|
TxtPlanDatos.Text = GPS.DtResultados.Rows(0)("PlanDato").ToString
|
|
TxtSim.Text = GPS.DtResultados.Rows(0)("SSID").ToString
|
|
TxtNoLinea.Text = GPS.DtResultados.Rows(0)("NumeroTelefono").ToString
|
|
TxtMarca.Text = GPS.DtResultados.Rows(0)("Marca").ToString
|
|
TxtModelo.Text = GPS.DtResultados.Rows(0)("Modelo").ToString
|
|
TxtImei.Text = GPS.DtResultados.Rows(0)("IMEI").ToString
|
|
TxtSerie.Text = GPS.DtResultados.Rows(0)("Serie").ToString
|
|
TxtUnidad.Text = "SIG"
|
|
TxtCliente.Text = GPS.DtResultados.Rows(0)("Cliente").ToString
|
|
TxtEstatus.Text = If(GPS.DtResultados.Rows(0)("Estatus").ToString = "1", "Activo", "Inactivo")
|
|
TxtFechaInstalacion.Text = GPS.DtResultados.Rows(0)("FechaInstalacion").ToString
|
|
'TxtFechaReinstalacion.Text = GPS.DtResultados.Rows(0)("FechaReinstalacion").ToString
|
|
bodydatos.Visible = True
|
|
ltlSerieConsulta.Text = GPS.DtResultados.Rows(0)("Serie").ToString
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
GPS.Dispose()
|
|
CargaReportes()
|
|
UpInfo.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnCargaDispositivo_Click(sender As Object, e As EventArgs) Handles BtnCargaDispositivo.Click
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
Private Sub CargaReportes()
|
|
Dim GPS As New ClsGPS
|
|
RegistraScript("DeleteMarkers();")
|
|
|
|
|
|
If DdlTipoConsulta.SelectedValue = "Last" Then
|
|
If GPS.GetRepDispositivo(DdlDispositivo.SelectedValue.ToEntero, MinFecha, MaxFecha, "Top 1") Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
Dim Coord As String = SQLToGmaps(GPS.DtResultados.Rows(0)("Punto"), "POINT")
|
|
RegistraScript($"CreaMarcador({Coord},'{DdlDispositivo.SelectedItem.Text}');")
|
|
GvReportes.DataSource = GPS.DtResultados
|
|
GvVLog.DataSource = GPS.DtResultados
|
|
bodyreportes.Visible = True
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ElseIf DdlTipoConsulta.SelectedValue = "Last10" Then
|
|
If GPS.GetRepDispositivo(DdlDispositivo.SelectedValue.ToEntero, MinFecha, MaxFecha, "TOP 10") Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
For Each row As DataRow In GPS.DtResultados.Rows
|
|
Dim Coord As String = SQLToGmaps(row("Punto"), "POINT")
|
|
RegistraScript($"CreaMarcador({Coord},'{DdlDispositivo.SelectedItem.Text}: {row("FechaIng").ToString}');")
|
|
Next
|
|
GvReportes.DataSource = GPS.DtResultados
|
|
GvVLog.DataSource = GPS.DtResultados
|
|
bodyreportes.Visible = True
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ElseIf DdlTipoConsulta.SelectedValue = "Today" Then
|
|
If GPS.GetRepDispositivo(DdlDispositivo.SelectedValue.ToEntero, DateTime.Today.AddHours(-1), DateTime.Today.AddDays(1)) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
For Each row As DataRow In GPS.DtResultados.Rows
|
|
Dim Coord As String = SQLToGmaps(row("Punto"), "POINT")
|
|
RegistraScript($"CreaMarcador({Coord},'{DdlDispositivo.SelectedItem.Text}: {row("FechaIng")}');")
|
|
Next
|
|
GvReportes.DataSource = GPS.DtResultados
|
|
GvVLog.DataSource = GPS.DtResultados
|
|
bodyreportes.Visible = True
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ElseIf DdlTipoConsulta.SelectedValue = "Yesterday" Then
|
|
If GPS.GetRepDispositivo(DdlDispositivo.SelectedValue.ToEntero, DateTime.Today.AddDays(-1).AddHours(-1), DateTime.Today) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
For Each row As DataRow In GPS.DtResultados.Rows
|
|
Dim Coord As String = SQLToGmaps(row("Punto"), "POINT")
|
|
RegistraScript($"CreaMarcador({Coord},'{DdlDispositivo.SelectedItem.Text}: {row("FechaIng")}');")
|
|
Next
|
|
GvReportes.DataSource = GPS.DtResultados
|
|
GvVLog.DataSource = GPS.DtResultados
|
|
bodyreportes.Visible = True
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ElseIf DdlTipoConsulta.SelectedValue = "Week" Then
|
|
If GPS.GetRepDispositivo(DdlDispositivo.SelectedValue.ToEntero, DateTime.Today.AddDays(-7).AddHours(-1), DateTime.Today.AddDays(1)) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
Dim dr As DataRow = TmpDT.NewRow
|
|
For Each row As DataRow In GPS.DtResultados.Rows
|
|
Dim Coord As String = SQLToGmaps(row("Punto"), "POINT")
|
|
RegistraScript($"CreaMarcador({Coord},'{DdlDispositivo.SelectedItem.Text}: {row("FechaIng")}');")
|
|
Next
|
|
GvReportes.DataSource = GPS.DtResultados
|
|
GvVLog.DataSource = GPS.DtResultados
|
|
bodyreportes.Visible = True
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ElseIf DdlTipoConsulta.SelectedValue = "All" Then
|
|
Dim FechaI = If(txtFechaI.Text.Trim = "", MinFecha, txtFechaI.Text.Trim.ToDateTime.AddHours(-1))
|
|
Dim FechaF = If(txtFechaF.Text.Trim = "", MaxFecha, txtFechaF.Text.Trim.ToDateTime.AddDays(1))
|
|
If GPS.GetRepDispositivo(DdlDispositivo.SelectedValue.ToEntero, FechaI.AddHours(-1), FechaF.AddDays(1)) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
Dim dr As DataRow = TmpDT.NewRow
|
|
For Each row As DataRow In GPS.DtResultados.Rows
|
|
Dim Coord As String = SQLToGmaps(row("Punto"), "POINT")
|
|
RegistraScript($"CreaMarcador({Coord},'{DdlDispositivo.SelectedItem.Text}: {row("FechaIng")}');")
|
|
Next
|
|
GvReportes.DataSource = GPS.DtResultados
|
|
GvVLog.DataSource = GPS.DtResultados
|
|
bodyreportes.Visible = True
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
Dim CveTrama = GPS.DtResultados.Rows(0)("CveTrama").ToString.ToEntero
|
|
If GPS.RepEventosDispositivosGet(CveTrama) Then
|
|
Dim nRows As Double = (GPS.DtResultados.Rows.Count / 3)
|
|
If nRows > 0 Then
|
|
If Math.Abs(nRows Mod 1) < Double.Epsilon Then
|
|
gvH1.DataSource = GPS.DtResultados().FiltraParametros($"RowNumber <= {nRows}")
|
|
gvH2.DataSource = GPS.DtResultados().FiltraParametros($"RowNumber > {nRows} AND RowNumber <= {nRows * 2} ")
|
|
gvH3.DataSource = GPS.DtResultados().FiltraParametros($"RowNumber > {nRows * 2} AND RowNumber <= {nRows * 3} ")
|
|
Else
|
|
nRows = Math.Ceiling(nRows)
|
|
gvH1.DataSource = GPS.DtResultados().FiltraParametros($"RowNumber <= {nRows}")
|
|
gvH2.DataSource = GPS.DtResultados().FiltraParametros($"RowNumber > {nRows} AND RowNumber <= {nRows * 2} ")
|
|
gvH3.DataSource = GPS.DtResultados().FiltraParametros($"RowNumber > {nRows * 2} AND RowNumber <= {GPS.DtResultados.Rows.Count} ")
|
|
End If
|
|
Else
|
|
gvH1.DataSource = Nothing
|
|
gvH2.DataSource = Nothing
|
|
gvH3.DataSource = Nothing
|
|
gvH2.Visible = False
|
|
gvH3.Visible = False
|
|
End If
|
|
Else
|
|
gvH1.DataSource = Nothing
|
|
gvH2.DataSource = Nothing
|
|
gvH3.DataSource = Nothing
|
|
gvH2.Visible = False
|
|
gvH3.Visible = False
|
|
End If
|
|
End If
|
|
|
|
GPS.Dispose()
|
|
gvH1.DataBind()
|
|
gvH2.DataBind()
|
|
gvH3.DataBind()
|
|
GvReportes.DataBind()
|
|
GvVLog.DataBind()
|
|
UpReportes.Update()
|
|
UPVlog.Update()
|
|
upHistorico.Update()
|
|
|
|
|
|
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(" ")
|
|
Var = $"{Var}{{lat: {latlng(1)}, lng: {latlng(0)} }}"
|
|
Else
|
|
Dim latlng() As String = coordenada.Trim.Split(" ")
|
|
Var = $"{Var}{{lat: {latlng(1)}, lng: {latlng(0)} }},"
|
|
End If
|
|
Next
|
|
Return Var
|
|
End Function
|
|
|
|
Private Sub CreaTmpDT(Opcion As String)
|
|
TmpDT = New DataTable
|
|
If Opcion = 1 Then
|
|
TmpDT.Columns.Add("Fecha", GetType(String))
|
|
TmpDT.Columns.Add("Valor", GetType(String))
|
|
TmpDT.Columns.Add("CveTrama", GetType(Integer))
|
|
ElseIf Opcion = 2 Then
|
|
TmpDT.Columns.Add("Trama", GetType(String))
|
|
TmpDT.Columns.Add("CveTrama", GetType(Integer))
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub DdlTipoConsulta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoConsulta.SelectedIndexChanged
|
|
If DdlTipoConsulta.SelectedValue = "All" Then
|
|
liFechai.Visible = True
|
|
liFechaF.Visible = True
|
|
Else
|
|
liFechai.Visible = False
|
|
liFechaF.Visible = False
|
|
End If
|
|
upDispositivo.Update()
|
|
End Sub
|
|
Protected Sub BtnCargaLog_Click(sender As Object, e As EventArgs) Handles BtnCargaLog.Click
|
|
Dim GPS As New ClsGPS
|
|
|
|
If GPS.DispositivosGet(DdlDispositivo.SelectedValue, -1, -1) AndAlso GPS.DtResultados.Rows.Count > 0 Then
|
|
ltlSerieLog.Text = GPS.DtResultados.Rows(0)("Serie").ToString
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
GPS.Dispose()
|
|
CargaLog()
|
|
End Sub
|
|
|
|
Protected Sub DdlTipoConsultaLog_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoConsultaLog.SelectedIndexChanged
|
|
If DdlTipoConsultaLog.SelectedValue = "All" Then
|
|
liFechaLogI.Visible = True
|
|
liFechaLogF.Visible = True
|
|
Else
|
|
liFechaLogI.Visible = False
|
|
liFechaLogF.Visible = False
|
|
End If
|
|
UpDispositivoLog.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaLog()
|
|
Dim GPS As New ClsGPS
|
|
CreaTmpDT(2)
|
|
RegistraScript("DeleteMarkers();")
|
|
|
|
|
|
If DdlTipoConsultaLog.SelectedValue = "Last" Then
|
|
If GPS.GetRepDispositivo(DdlDispositivosLog.SelectedValue.ToEntero, MinFecha, MaxFecha) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
Dim dr As DataRow = TmpDT.NewRow
|
|
dr("Trama") = GPS.DtResultados(0)("Trama").ToString
|
|
dr("CveTrama") = GPS.DtResultados(0)("CveTrama").ToString
|
|
TmpDT.Rows.Add(dr)
|
|
GVLog.DataSource = TmpDT
|
|
bodyreportes.Visible = True
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ElseIf DdlTipoConsultaLog.SelectedValue = "Last10" Then
|
|
If GPS.GetRepDispositivo(DdlDispositivosLog.SelectedValue.ToEntero, MinFecha, MaxFecha) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
Dim dr As DataRow = TmpDT.NewRow
|
|
For rowindex = 0 To 9 Step 1
|
|
dr = TmpDT.NewRow
|
|
dr("Trama") = GPS.DtResultados(rowindex)("Trama").ToString
|
|
dr("CveTrama") = GPS.DtResultados(rowindex)("CveTrama").ToString
|
|
TmpDT.Rows.Add(dr)
|
|
Next
|
|
GVLog.DataSource = TmpDT
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ElseIf DdlTipoConsultaLog.SelectedValue = "Today" Then
|
|
If GPS.GetRepDispositivo(DdlDispositivosLog.SelectedValue.ToEntero, DateTime.Today.AddHours(-1), DateTime.Today.AddDays(1)) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
Dim dr As DataRow = TmpDT.NewRow
|
|
For Each row As DataRow In GPS.DtResultados.Rows
|
|
dr = TmpDT.NewRow
|
|
dr("Trama") = row("Trama").ToString
|
|
dr("CveTrama") = row("CveTrama").ToString
|
|
TmpDT.Rows.Add(dr)
|
|
Next
|
|
GVLog.DataSource = TmpDT
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ElseIf DdlTipoConsultaLog.SelectedValue = "Yesterday" Then
|
|
If GPS.GetRepDispositivo(DdlDispositivosLog.SelectedValue.ToEntero, DateTime.Today.AddDays(-1).AddHours(-1), DateTime.Today) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
Dim dr As DataRow = TmpDT.NewRow
|
|
For Each row As DataRow In GPS.DtResultados.Rows
|
|
Dim Coord As String = SQLToGmaps(row("Punto"), "POINT")
|
|
dr = TmpDT.NewRow
|
|
dr("Trama") = row("Trama").ToString
|
|
dr("CveTrama") = row("CveTrama").ToString
|
|
TmpDT.Rows.Add(dr)
|
|
Next
|
|
GVLog.DataSource = TmpDT
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ElseIf DdlTipoConsultaLog.SelectedValue = "Week" Then
|
|
If GPS.GetRepDispositivo(DdlDispositivosLog.SelectedValue.ToEntero, DateTime.Today.AddDays(-7).AddHours(-1), DateTime.Today.AddDays(1)) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
Dim dr As DataRow = TmpDT.NewRow
|
|
For Each row As DataRow In GPS.DtResultados.Rows
|
|
dr = TmpDT.NewRow
|
|
dr("Trama") = row("Trama").ToString
|
|
dr("CveTrama") = row("CveTrama").ToString
|
|
TmpDT.Rows.Add(dr)
|
|
Next
|
|
GVLog.DataSource = TmpDT
|
|
Else
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ElseIf DdlTipoConsultaLog.SelectedValue = "All" Then
|
|
Dim FechaI = If(TxtFechaLogI.Text.Trim = "", MinFecha, TxtFechaLogI.Text.Trim.ToDateTime.AddHours(-1))
|
|
Dim FechaF = If(TxtFechaLogF.Text.Trim = "", MaxFecha, TxtFechaLogF.Text.Trim.ToDateTime.AddDays(1))
|
|
If GPS.GetRepDispositivo(DdlDispositivosLog.SelectedValue.ToEntero, FechaI, FechaF) Then
|
|
If GPS.DtResultados.Rows.Count > 0 Then
|
|
Dim dr As DataRow = TmpDT.NewRow
|
|
For Each row As DataRow In GPS.DtResultados.Rows
|
|
dr = TmpDT.NewRow
|
|
dr("Trama") = row("Trama").ToString
|
|
dr("CveTrama") = row("CveTrama").ToString
|
|
TmpDT.Rows.Add(dr)
|
|
Next
|
|
GVLog.DataSource = TmpDT
|
|
Else
|
|
GVLog.DataSource = Nothing
|
|
Alert("No se encontraron resultados con el equipo seleccionado", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
GPS.Dispose()
|
|
GVLog.DataBind()
|
|
UpGVLog.Update()
|
|
End Sub
|
|
|
|
Protected Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles btnAgregar.Click
|
|
Dim GPS As New ClsGPS
|
|
If GPS.DispositivosGet(-1, -1, DdlClientes.SelectedValue, UsuarioActual.CveEmpresa) Then
|
|
GvConsultaM.DataSource = GPS.DtResultados
|
|
Else
|
|
GvConsultaM.DataSource = GPS.DtResultados
|
|
End If
|
|
GPS.Dispose()
|
|
GvConsultaM.DataBind()
|
|
DvConsultar.Visible = True
|
|
End Sub
|
|
End Class
|