539 lines
17 KiB
VB.net
539 lines
17 KiB
VB.net
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
Partial Class DashboardGPS
|
|
Inherits ClsPaginas
|
|
|
|
#Region "Propiedades"
|
|
Private StrArreglo As StringBuilder
|
|
|
|
Public Property FechaI As DateTime
|
|
Get
|
|
Return ViewState("FechaI").ToString.ToDateTime
|
|
End Get
|
|
Set(value As DateTime)
|
|
ViewState("FechaI") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property FechaF As DateTime
|
|
Get
|
|
Return ViewState("FechaF").ToString.ToDateTime
|
|
End Get
|
|
Set(value As DateTime)
|
|
ViewState("FechaF") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Public Enum Colores As Integer
|
|
AzulFuerte = 1
|
|
Azul = 2
|
|
Verde = 3
|
|
Amarillo = 4
|
|
Naranja = 5
|
|
Rojo = 6
|
|
Morado = 7
|
|
Negro = 8
|
|
End Enum
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
StrArreglo = New StringBuilder
|
|
|
|
txtFechaI.Text = Now.AddMonths(-1).ToShortDateString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
|
|
FechaI = txtFechaI.Text.ToDate.Add(Now.TimeOfDay).ToDateTime
|
|
FechaF = txtFechaF.Text.ToDate.Add(Now.TimeOfDay).ToDateTime
|
|
|
|
CargarKilometrajeUnidades(5)
|
|
CargarPuntosInteresVisitados(10)
|
|
CargarMejoresConductores(5)
|
|
CargarUnidadesReportando()
|
|
CargarRendimientoCombustible(5)
|
|
CargarTiemposOperacion(5)
|
|
CargarTiempoPuntosInteres(5)
|
|
CargarEventos()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ObtenerColor(color As Colores) As String
|
|
Select Case color
|
|
|
|
Case Colores.AzulFuerte
|
|
Return "#337ab7"
|
|
|
|
Case Colores.Azul
|
|
Return "#08A3CC"
|
|
|
|
Case Colores.Verde
|
|
Return "#1BA39C"
|
|
|
|
Case Colores.Amarillo
|
|
Return "#F1C40F"
|
|
|
|
Case Colores.Naranja
|
|
Return "#E87E04"
|
|
|
|
Case Colores.Rojo
|
|
Return "#ed6b75"
|
|
|
|
Case Colores.Morado
|
|
Return "#8E44AD"
|
|
|
|
Case Colores.Negro
|
|
Return "#22313F"
|
|
|
|
Case Else
|
|
Return "#337ab7"
|
|
|
|
End Select
|
|
End Function
|
|
|
|
Private Sub CargarKilometrajeUnidades(Top As Integer, Optional Div As String = "chartdivKilometrajeUnidades")
|
|
Dim ObjGPS As New ClsGPS
|
|
Dim Contador As Integer = 0
|
|
|
|
StrArreglo.Clear()
|
|
|
|
If ObjGPS.GetKilometrajeDispositivos(UsuarioActual.CveCliente, FechaI, FechaF, Top) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
|
|
StrArreglo.Append("[")
|
|
|
|
For Each row As DataRow In ObjGPS.DtResultados.Rows
|
|
|
|
If Contador > 0 Then
|
|
StrArreglo.Append(", {")
|
|
Else
|
|
StrArreglo.Append("{")
|
|
End If
|
|
|
|
StrArreglo.Append($"""dispositivos"": ""{row("NoEconomico").ToString}"",""kilometros"": {row("Dist").ToString},""color"": ""#337ab7""")
|
|
StrArreglo.Append("}")
|
|
|
|
Contador += 1
|
|
Next
|
|
|
|
StrArreglo.Append("]")
|
|
|
|
RegistraScript($"KilometrajeDispositivos({StrArreglo.ToString}, {Div});", "2")
|
|
End If
|
|
|
|
ObjGPS.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargarPuntosInteresVisitados(Top As Integer, Optional Div As String = "chartdivPIVisitados")
|
|
|
|
Dim ObjGPS As New ClsGPS
|
|
Dim Contador As Integer = 0
|
|
Dim Total As Integer = 0
|
|
|
|
StrArreglo.Clear()
|
|
|
|
If ObjGPS.GetPuntosDeInteresDispositivos(UsuarioActual.CveCliente, FechaI, FechaF, -1, "-1", Top) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
|
|
Total = ObjGPS.DtResultados(0)("Visitas").ToString.ToEntero
|
|
|
|
StrArreglo.Append("{ """ + Total.ToString + """: [")
|
|
|
|
For Each row As DataRow In ObjGPS.DtResultados.Rows
|
|
If Contador = 0 Then
|
|
Contador += 1
|
|
Continue For
|
|
Else
|
|
|
|
If Contador > 1 Then
|
|
StrArreglo.Append(", {")
|
|
Else
|
|
StrArreglo.Append("{")
|
|
End If
|
|
|
|
StrArreglo.Append($"""title"": ""{row("PuntoDeInteres").ToString}"",""size"": {row("Visitas").ToString},""color"": ""{ObtenerColor(CType(Contador, Colores))}""")
|
|
StrArreglo.Append("}")
|
|
|
|
End If
|
|
|
|
Contador += 1
|
|
Next
|
|
|
|
StrArreglo.Append("]}")
|
|
|
|
RegistraScript($"PuntosDeInteresDispositivos({Total}, {StrArreglo.ToString}, {Div});", "2")
|
|
End If
|
|
|
|
ObjGPS.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargarMejoresConductores(Top As Integer, Optional Div As String = "chartdivMejoresConductores")
|
|
Dim ObjGPS As New ClsGPS
|
|
Dim Contador As Integer = 0
|
|
Dim Valor As Integer = 1
|
|
|
|
StrArreglo.Clear()
|
|
|
|
If ObjGPS.GetMejoresConductores(UsuarioActual.CveCliente, Top) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
StrArreglo.Append("[")
|
|
For Each row As DataRow In ObjGPS.DtResultados.Rows
|
|
|
|
If Contador > 0 Then
|
|
StrArreglo.Append(", {")
|
|
Else
|
|
StrArreglo.Append("{")
|
|
End If
|
|
|
|
If row("Total").ToString.ToDouble >= 70 Then
|
|
Valor = 3
|
|
ElseIf row("Total").ToString.ToDouble >= 50 Then
|
|
Valor = 4
|
|
Else
|
|
Valor = 6
|
|
End If
|
|
|
|
StrArreglo.Append($"""conductor"": ""{row("Conductor").ToString}"",""valor"": {row("Total").ToString},""color"": ""{ObtenerColor(CType(Valor, Colores))}""")
|
|
StrArreglo.Append("}")
|
|
|
|
Contador += 1
|
|
|
|
Next
|
|
|
|
StrArreglo.Append("]")
|
|
|
|
RegistraScript($"MejoresConductores({StrArreglo.ToString}, {Div});", "2")
|
|
End If
|
|
|
|
ObjGPS.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargarUnidadesReportando()
|
|
Dim ObjGPS As New ClsGPS
|
|
Dim Reportando As Double
|
|
Dim Total As Double
|
|
Dim Porcentaje As String
|
|
|
|
If ObjGPS.GetUnidadesReportando(UsuarioActual.CveCliente) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
Reportando = ObjGPS.DtResultados(0)("Reportando").ToString.ToDouble
|
|
Total = ObjGPS.DtResultados(0)("Total").ToString.ToDouble
|
|
Porcentaje = Math.Round(Reportando / Total, 2).ToString
|
|
RegistraScript($"UnidadesReportando(""{ObjGPS.DtResultados(0)("Reportando").ToString}"",""{ObjGPS.DtResultados(0)("Total").ToString}"", ""{Porcentaje}%"", {"chartdivUnidadesReportando"});", "2")
|
|
End If
|
|
|
|
ObjGPS.Dispose()
|
|
End Sub
|
|
|
|
'[{
|
|
' "dispositivo": "#01",
|
|
' "apagado": 6,
|
|
' "encendido": 18,
|
|
'}, {
|
|
' "dispositivo": "#02",
|
|
' "apagado": 8,
|
|
' "encendido": 16,
|
|
'}]
|
|
Private Sub CargarTiemposOperacion(Top As Integer, Optional Div As String = "chartdivTiempoOperacion")
|
|
Dim ObjGPS As New ClsGPS
|
|
Dim Contador As Integer = 0
|
|
Dim minutesDiff = DateDiff(DateInterval.Minute, FechaI, FechaF) / 3
|
|
|
|
StrArreglo.Clear()
|
|
|
|
If ObjGPS.GetKilometrajeDispositivos(UsuarioActual.CveCliente, txtFechaI.Text.ToDate.Add(Now.TimeOfDay).ToDateTime, txtFechaF.Text.ToDate.Add(Now.TimeOfDay).ToDateTime, Top) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
|
|
StrArreglo.Append("[")
|
|
|
|
For Each row As DataRow In ObjGPS.DtResultados.Rows
|
|
|
|
If Contador > 0 Then
|
|
StrArreglo.Append(", {")
|
|
Else
|
|
StrArreglo.Append("{")
|
|
End If
|
|
|
|
StrArreglo.Append($"""dispositivo"": ""{row("NoEconomico").ToString}"",""apagado"": {Math.Round((minutesDiff - row("TiempoOperativo").ToString.ToDouble) / 60, 2)},""encendido"": {Math.Round(row("TiempoOperativo").ToString.ToDouble / 60, 2)}")
|
|
StrArreglo.Append("}")
|
|
|
|
Contador += 1
|
|
Next
|
|
|
|
StrArreglo.Append("]")
|
|
|
|
RegistraScript($"TiempoDeOperacion({StrArreglo.ToString}, {Div});", "2")
|
|
End If
|
|
|
|
ObjGPS.Dispose()
|
|
End Sub
|
|
|
|
'[{
|
|
' "dispositivo": "#01",
|
|
' "combustible": 100,
|
|
' "kilometraje": 1000,
|
|
'}, {
|
|
' "dispositivo": "#02",
|
|
' "combustible": 200,
|
|
' "kilometraje": 1500,
|
|
'}]
|
|
Private Sub CargarRendimientoCombustible(Top As Integer, Optional Div As String = "chartdivRendimientoCombustible")
|
|
Dim ObjGPS As New ClsGPS
|
|
Dim Contador As Integer = 0
|
|
|
|
StrArreglo.Clear()
|
|
|
|
If ObjGPS.GetKilometrajeDispositivos(UsuarioActual.CveCliente, FechaI, FechaF, Top) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
|
|
StrArreglo.Append("[")
|
|
|
|
For Each row As DataRow In ObjGPS.DtResultados.Rows
|
|
|
|
If Contador > 0 Then
|
|
StrArreglo.Append(", {")
|
|
Else
|
|
StrArreglo.Append("{")
|
|
End If
|
|
|
|
StrArreglo.Append($"""dispositivo"": ""{row("NoEconomico").ToString}"",""combustible"": {Math.Round(row("Dist").ToString.ToDouble / 9.5, 2)},""kilometraje"": {row("Dist").ToString}")
|
|
StrArreglo.Append("}")
|
|
|
|
Contador += 1
|
|
Next
|
|
|
|
StrArreglo.Append("]")
|
|
|
|
RegistraScript($"RendimientoCombustible({StrArreglo.ToString},{Div});", "2")
|
|
End If
|
|
|
|
ObjGPS.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargarTiempoPuntosInteres(Top As Integer, Optional Div As String = "chartdivTiempoPI")
|
|
|
|
Dim ObjGPS As New ClsGPS
|
|
Dim Contador As Integer = 0
|
|
Dim Total As Integer = 0
|
|
|
|
StrArreglo.Clear()
|
|
|
|
If ObjGPS.GetPuntosDeInteresTiempo(UsuarioActual.CveCliente, FechaI, FechaF, -1, "-1", Top) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
|
|
StrArreglo.Append("[")
|
|
|
|
For Each row As DataRow In ObjGPS.DtResultados.Rows
|
|
|
|
If Contador > 0 Then
|
|
StrArreglo.Append(", {")
|
|
Else
|
|
StrArreglo.Append("{")
|
|
End If
|
|
|
|
StrArreglo.Append($"""pi"": ""{row("PuntoDeInteres").ToString}"",""duracion"": {row("Duracion").ToString.ToDouble.FormatoNumero(2)},""color"": ""{ObtenerColor(CType(2, Colores))}""")
|
|
StrArreglo.Append("}")
|
|
|
|
Contador += 1
|
|
Next
|
|
|
|
StrArreglo.Append("]")
|
|
|
|
RegistraScript($"TiempoPuntosInteres({StrArreglo.ToString},{Div});", "2")
|
|
End If
|
|
|
|
ObjGPS.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargarEventos()
|
|
Dim ObjGPS As New ClsGPS
|
|
|
|
If ObjGPS.GetEventosDashboard(UsuarioActual.CveCliente, FechaI, FechaF) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
LblBotonPanico.Text = ObjGPS.DtResultados(0)("BotonPanico").ToString.ToEntero.ToString
|
|
LblDesconexion.Text = ObjGPS.DtResultados(0)("DesconexionBateria").ToString.ToEntero.ToString
|
|
End If
|
|
|
|
If ObjGPS.GetRalentiDashboard(UsuarioActual.CveCliente, txtFechaI.Text.ToDate.Add(Now.TimeOfDay).ToDateTime, txtFechaF.Text.ToDate.Add(Now.TimeOfDay).ToDateTime) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
LblRalenti.Text = ObjGPS.DtResultados(0)("Ralenti").ToString.ToEntero.ToString
|
|
End If
|
|
|
|
ObjGPS.Dispose()
|
|
End Sub
|
|
|
|
Private Sub lnkBusqueda_Click(sender As Object, e As EventArgs) Handles lnkBusqueda.Click
|
|
RegistraScript("$('#dvConsulta').modal();")
|
|
End Sub
|
|
|
|
Private Sub BtnRastrear_Click(sender As Object, e As EventArgs) Handles BtnRastrear.Click
|
|
|
|
If HdnTipoFecha.Value = "5" Then
|
|
FechaI = txtFechaI.Text.ToDateTime
|
|
Else
|
|
FechaI = txtFechaI.Text.ToDate.Add(Now.TimeOfDay).ToDateTime
|
|
End If
|
|
|
|
FechaF = txtFechaF.Text.ToDate.Add(Now.TimeOfDay).ToDateTime
|
|
|
|
StrArreglo = New StringBuilder
|
|
|
|
CargarKilometrajeUnidades(5)
|
|
CargarPuntosInteresVisitados(10)
|
|
CargarMejoresConductores(5)
|
|
CargarUnidadesReportando()
|
|
CargarRendimientoCombustible(5)
|
|
CargarTiemposOperacion(5)
|
|
CargarTiempoPuntosInteres(5)
|
|
CargarEventos()
|
|
|
|
RegistraScript("$('#dvConsulta').modal('hide')")
|
|
UpGraficas.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub BtnTrampa_Click(sender As Object, e As EventArgs) Handles BtnTrampa.Click
|
|
Select Case HdnTipoFecha.Value.ToString.ToEntero
|
|
|
|
Case 1 'Ultimo Dia
|
|
txtFechaI.Text = Now.AddDays(-1).ToShortDateString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
Case 2 'Ultima Semana
|
|
txtFechaI.Text = Now.AddDays(-7).ToShortDateString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
Case 3 'Ultimo Mes
|
|
txtFechaI.Text = Now.AddMonths(-1).ToShortDateString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
Case 4 'Ultimo Año
|
|
txtFechaI.Text = Now.AddYears(-1).ToShortDateString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
Case 5 'Dia Corriente
|
|
txtFechaI.Text = Now.ToShortDateString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
Case 6 'Semana Corriente
|
|
Dim DiaSemana = Now.DayOfWeek
|
|
txtFechaI.Text = Now.AddDays((-1 * DiaSemana) + 1).ToString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
Case 7 'Mes Corriente
|
|
txtFechaI.Text = DateSerial(Year(Now), Month(Now), 1).ToString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
Case 8 'Año Corriente
|
|
Dim DiaAño = Now.DayOfYear
|
|
txtFechaI.Text = Now.AddDays((-1 * DiaAño) + 1).ToString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
|
|
End Select
|
|
|
|
UPConsulta.Update()
|
|
End Sub
|
|
|
|
Private Sub ExtenderGrafica(Grafica As Integer)
|
|
StrArreglo = New StringBuilder
|
|
Select Case Grafica
|
|
Case 1 'Kilometraje
|
|
CargarKilometrajeUnidades(20, "chartdivGraficaGrande")
|
|
LblGrafica.Text = "Kilometraje de Unidades"
|
|
|
|
Case 2 'Puntos Interes Visitados
|
|
CargarPuntosInteresVisitados(20, "chartdivGraficaGrande")
|
|
LblGrafica.Text = "Puntos de Interés Visitados"
|
|
|
|
Case 3 'Mejores Conductores
|
|
CargarMejoresConductores(20, "chartdivGraficaGrande")
|
|
LblGrafica.Text = "Mejores Conductores"
|
|
|
|
Case 4 'Tiempos de Operacion
|
|
CargarTiemposOperacion(20, "chartdivGraficaGrande")
|
|
LblGrafica.Text = "Tiempos de Operación"
|
|
|
|
Case 5 'Rendimiento De Combustible
|
|
CargarRendimientoCombustible(20, "chartdivGraficaGrande")
|
|
LblGrafica.Text = "Rendimiento De Combustible"
|
|
|
|
Case 6 'Tiempo en Puntos de Interes
|
|
CargarTiempoPuntosInteres(20, "chartdivGraficaGrande")
|
|
LblGrafica.Text = "Tiempo en Puntos de Interés"
|
|
End Select
|
|
|
|
UpTituloGraficaGrande.Update()
|
|
End Sub
|
|
|
|
Private Sub LnkKilometraje_Click(sender As Object, e As EventArgs) Handles LnkKilometraje.Click
|
|
RegistraScript("$('#DivGrafica').modal();", "1")
|
|
ExtenderGrafica(1)
|
|
End Sub
|
|
|
|
Private Sub LnkPIVisitados_Click(sender As Object, e As EventArgs) Handles LnkPIVisitados.Click
|
|
RegistraScript("$('#DivGrafica').modal();", "1")
|
|
ExtenderGrafica(2)
|
|
End Sub
|
|
|
|
Private Sub LnkTiempoPuntosInteres_Click(sender As Object, e As EventArgs) Handles LnkTiempoPuntosInteres.Click
|
|
RegistraScript("$('#DivGrafica').modal();", "1")
|
|
ExtenderGrafica(6)
|
|
End Sub
|
|
|
|
Private Sub LnkRendimientoCombustible_Click(sender As Object, e As EventArgs) Handles LnkRendimientoCombustible.Click
|
|
RegistraScript("$('#DivGrafica').modal();", "1")
|
|
ExtenderGrafica(5)
|
|
End Sub
|
|
|
|
Private Sub LnkTiemposOperacion_Click(sender As Object, e As EventArgs) Handles LnkTiemposOperacion.Click
|
|
RegistraScript("$('#DivGrafica').modal();", "1")
|
|
ExtenderGrafica(4)
|
|
End Sub
|
|
|
|
Private Sub LnkMejoresConductores_Click(sender As Object, e As EventArgs) Handles LnkMejoresConductores.Click
|
|
RegistraScript("$('#DivGrafica').modal();", "1")
|
|
ExtenderGrafica(3)
|
|
End Sub
|
|
End Class
|
|
|
|
|
|
'Dona
|
|
'var chartData = {
|
|
' "124": [
|
|
' { "title": "Soriana1", "color": "#337ab7", "size": 3.9 },
|
|
' { "title": "Soriana2", "color": "#08A3CC", "size": 0.2 },
|
|
' { "title": "Soriana6", "color": "#1BA39C", "size": 16.6 },
|
|
' { "title": "Soriana4", "color": "#F1C40F", "size": 2.7 },
|
|
' { "title": "Soriana5", "color": "#E87E04", "size": 5.6 },
|
|
' { "title": "Soriana3", "color": "#ed6b75", "size": 14.5 },
|
|
' { "title": "Soriana7", "color": "#8E44AD", "size": 10.5 },
|
|
' { "title": "Soriana8", "color": "#22313F", "size": 26.5 }]
|
|
'};
|
|
|
|
'Barras
|
|
'[{
|
|
' "country": "#01",
|
|
' "visits": 2025,
|
|
' "color": "#08A3CC"
|
|
'}, {
|
|
' "country": "#02",
|
|
' "visits": 1882,
|
|
' "color": "#08A3CC"
|
|
'}, {
|
|
' "country": "#03",
|
|
' "visits": 1809,
|
|
' "color": "#08A3CC"
|
|
'}, {
|
|
' "country": "#04",
|
|
' "visits": 1322,
|
|
' "color": "#08A3CC"
|
|
'}, {
|
|
' "country": "#05",
|
|
' "visits": 1122,
|
|
' "color": "#08A3CC"
|
|
'}, {
|
|
' "country": "#06",
|
|
' "visits": 1114,
|
|
' "color": "#08A3CC"
|
|
'}, {
|
|
' "country": "#07",
|
|
' "visits": 984,
|
|
' "color": "#08A3CC"
|
|
'}, {
|
|
' "country": "#08",
|
|
' "visits": 711,
|
|
' "color": "#08A3CC"
|
|
'}, {
|
|
' "country": "#09",
|
|
' "visits": 665,
|
|
' "color": "#08A3CC"
|
|
'}, {
|
|
' "country": "",
|
|
' "visits": ""
|
|
'}]
|