Cambios en Trayectos

This commit is contained in:
2021-05-19 10:16:49 -07:00
parent 1bff45d151
commit 68c6d1b3d1
5 changed files with 518 additions and 154 deletions

View File

@@ -28,7 +28,7 @@ public partial class GPS_CatEstatusTrayectos : ClsPaginas
{ {
if (ObjGPS.GetEstatusTrayectos(-1, UsuarioActual.CveCliente)) if (ObjGPS.GetEstatusTrayectos(-1, UsuarioActual.CveCliente))
{ {
DtEstatus = ObjGPS.DtResultados; DtEstatus = ObjGPS.DtResultados.FiltraParametros("CveCliente > 0");
GvEstatus.DataSource = DtEstatus; GvEstatus.DataSource = DtEstatus;
GvEstatus.DataBind(); GvEstatus.DataBind();
CargaEstatus(); CargaEstatus();

View File

@@ -36,9 +36,12 @@
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server"> <asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
<asp:UpdatePanel runat="server" UpdateMode="Conditional"> <asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate> <ContentTemplate>
<li> <li>
<asp:LinkButton runat="server" ID="BtnTerminarTrayeto" OnClick="BtnTerminarTrayeto_Click"><i class="fa fa-map-marker"></i>Terminar Trayecto</asp:LinkButton> <asp:LinkButton runat="server" ID="BtnTerminarTrayeto" OnClick="BtnTerminarTrayeto_Click"><i class="fa fa-map-marker"></i>Terminar Trayecto</asp:LinkButton>
</li> </li>
<li>
<asp:LinkButton runat="server" ID="LnkActualizarEstatus" OnClick="LnkActualizarEstatus_Click"><i class="fa fa-refresh"></i>Actualizar al estatus siguiente</asp:LinkButton>
</li>
<li> <li>
<asp:LinkButton ID="LnkAgregar" OnClick="LnkAgregar_Click" runat="server"><i class="fa fa-plus"></i>Agregar Gasto</asp:LinkButton> <asp:LinkButton ID="LnkAgregar" OnClick="LnkAgregar_Click" runat="server"><i class="fa fa-plus"></i>Agregar Gasto</asp:LinkButton>
</li> </li>
@@ -223,6 +226,16 @@
<div class="col-md-4 v-center"> <div class="col-md-4 v-center">
<asp:Literal ID="LtlExcesosVelo" runat="server"></asp:Literal> <asp:Literal ID="LtlExcesosVelo" runat="server"></asp:Literal>
</div> </div>
<div class="col-md-2 v-center">
<b>
<asp:Literal runat="server" Text="Tiempo Estimado:"></asp:Literal></b>
</div>
<div class="col-md-3 v-center">
<asp:Label ID="LblETA" runat="server" ClientIDMode="Static"></asp:Label>
</div>
<div class="col-md-1 v-center">
<asp:LinkButton ID="BtnRecalcular" runat="server" Text="" OnClick="BtnRecalcular_Click" CssClass="btn btn-sm btn-circle btn-primary" ><i class='fa fa-refresh' aria-hidden='true'></i></asp:LinkButton>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -469,7 +482,7 @@
</div> </div>
<div class="portlet-body form"> <div class="portlet-body form">
<div style="max-height: 392px; overflow-y: scroll"> <div style="max-height: 392px; overflow-y: scroll">
<asp:GridView ID="GvGastos" runat="server" GridLines="None" CssClass="table table-striped table-advance table-hover Widthall ScrollAD" <asp:GridView ID="GvGastos" runat="server" GridLines="None" CssClass="table table-striped table-advance table-hover Widthall ScrollAD"
data-sort="true" data-rows="1" AutoGenerateColumns="False" EmptyDataText="No se encontraron registros" OnRowDataBound="GvGastos_RowDataBound"> data-sort="true" data-rows="1" AutoGenerateColumns="False" EmptyDataText="No se encontraron registros" OnRowDataBound="GvGastos_RowDataBound">
<Columns> <Columns>
<asp:BoundField DataField="Cantidad" HeaderText="Cantidad" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField DataField="Cantidad" HeaderText="Cantidad" DataFormatString="{0:N2}" ItemStyle-HorizontalAlign="Left" />
@@ -547,28 +560,70 @@
</ContentTemplate> </ContentTemplate>
</asp:UpdatePanel> </asp:UpdatePanel>
</div> </div>
<asp:Button ID="BtnRefrescarPagina" runat="server" ClientIDMode="Static" Text="Refrescar" Style="display: none;" />
</asp:Content> </asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server"> <asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
<script type="text/javascript"> <script type="text/javascript">
var map; var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: { lat: 29.0730, lng: -110.9559 },
zoom: 7
});
}
var polylines = []; var polylines = [];
var polygons = []; var polygons = [];
var polybounds = []; var polybounds = [];
var markers = []; var markers = [];
var GeoReferencias = [] var GeoReferencias = [];
var posicionesETA = [];
var lastOpenedInfoWindow; var lastOpenedInfoWindow;
var directionsDisplay; var directionsDisplay;
var posInicio, posFin;
function initMap() {
polylines = [];
polygons = [];
polybounds = [];
markers = [];
GeoReferencias = [];
posicionesETA = [];
map = new google.maps.Map(document.getElementById('map'), {
center: { lat: 29.0730, lng: -110.9559 },
zoom: 7
});
//CalcularRuta();
}
function RefrescarPagina() {
$('#BtnRefrescarPagina').click();
}
function CalcularRuta() {
var origin1 = new google.maps.LatLng(55.930385, -3.118425);
var destinationA = 'Stockholm, Sweden';
var destinationB = new google.maps.LatLng(50.087692, 14.421150);
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [origin1],
destinations: [destinationA, destinationB],
travelMode: 'DRIVING'
//transitOptions: TransitOptions,
//drivingOptions: DrivingOptions,
//unitSystem: UnitSystem,
//avoidHighways: Boolean,
//avoidTolls: Boolean,
}, callback);
function callback(response, status) {
if (status !== "OK") {
alert("Error was: " + status);
} else {
alert(JSON.stringify(response));
}
}
}
//$(document).ready(function () {
// initMap();
// DeleteMarkers();
//});
function DeleteMarkers() { function DeleteMarkers() {
for (var i = 0; i < markers.length; i++) { for (var i = 0; i < markers.length; i++) {
markers[i].setMap(null); markers[i].setMap(null);
@@ -582,13 +637,14 @@
directionsDisplay.setMap(null); directionsDisplay.setMap(null);
} }
} }
function doScaledCLick(boton) { function doScaledCLick(boton) {
setTimeout(function () { setTimeout(function () {
$(boton).click(); $(boton).click();
}, 250); }, 250);
} }
function creaPoligono(coords, color, Geocerca, Estatus, InicioFin, CveEstatus, CveEstatusAnterior) { function creaPoligono(coords, color, Geocerca, Estatus, InicioFin, CveEstatus, CveEstatusAnterior, cruzo) {
var polygon = new google.maps.Polygon({ var polygon = new google.maps.Polygon({
paths: coords, paths: coords,
strokeColor: color, strokeColor: color,
@@ -600,11 +656,10 @@
polygon.setMap(map); polygon.setMap(map);
polygons.push(polygon); polygons.push(polygon);
CreaMarcadorPoligono(coords, Geocerca, Estatus, InicioFin, CveEstatus, CveEstatusAnterior) CreaMarcadorPoligono(coords, Geocerca, Estatus, InicioFin, CveEstatus, CveEstatusAnterior, cruzo)
} }
var posInicio, posFin;
function CreaMarcadorPoligono(coords, GeoCerca, Estatus, InicioFin, CveEstatus, CveEstatusAnterior, cruzo) {
function CreaMarcadorPoligono(coords, GeoCerca, Estatus, InicioFin, CveEstatus, CveEstatusAnterior) {
var bounds = new google.maps.LatLngBounds(); var bounds = new google.maps.LatLngBounds();
for (i = 0; i < coords.length; i++) { for (i = 0; i < coords.length; i++) {
bounds.extend(coords[i]); bounds.extend(coords[i]);
@@ -629,6 +684,12 @@
calculateAndDisplayRoute(directionsService, directionsDisplay, posInicio, posFin); calculateAndDisplayRoute(directionsService, directionsDisplay, posInicio, posFin);
} }
if (cruzo == "0") {
var center = bounds.getCenter();
posicionesETA.push({ lat: center.lat(), lng: center.lng() });
}
var marker = new google.maps.Marker({ var marker = new google.maps.Marker({
position: bounds.getCenter(), position: bounds.getCenter(),
title: GeoCerca, title: GeoCerca,
@@ -647,6 +708,7 @@
markers.push(marker); markers.push(marker);
} }
function calculateAndDisplayRoute(directionsService, directionsDisplay, pointA, pointB) { function calculateAndDisplayRoute(directionsService, directionsDisplay, pointA, pointB) {
var waypts = []; var waypts = [];
var orden = GeoReferencias.sort((a, b) => parseInt(a.CveEstatusAnterior) - parseInt(b.CveEstatusAnterior)); var orden = GeoReferencias.sort((a, b) => parseInt(a.CveEstatusAnterior) - parseInt(b.CveEstatusAnterior));
@@ -669,6 +731,7 @@
} }
}); });
} }
function CenterPoligono(coords) { function CenterPoligono(coords) {
var bounds = new google.maps.LatLngBounds(); var bounds = new google.maps.LatLngBounds();
for (i = 0; i < coords.length; i++) { for (i = 0; i < coords.length; i++) {
@@ -706,6 +769,29 @@
map.fitBounds(bounds) map.fitBounds(bounds)
} }
function CreaMarcadorPI(coords, nomPunto, ContentString) {
var marker = new google.maps.Marker({
position: coords,
title: nomPunto,
map: map
});
var infowindow = new google.maps.InfoWindow({
content: ContentString
});
marker.addListener('click', function () {
closeLastOpenedInfoWindow();
infowindow.open(map, marker);
lastOpenedInfoWindow = infowindow;
});
markers.push(marker);
if (markers.length > 1) {
fitBoundsToVisibleMarkers()
} else if (markers.length === 1) {
map.setZoom(15);
map.setCenter(coords);
}
}
function CreaMarcador(coords, nomEquipo, ContentString, imagen) { function CreaMarcador(coords, nomEquipo, ContentString, imagen) {
//setTimeout(function () { //setTimeout(function () {
@@ -729,7 +815,7 @@
lastOpenedInfoWindow = infowindow; lastOpenedInfoWindow = infowindow;
}); });
markers.push(marker); markers.push(marker);
posicionesETA.push(coords);
} }
function creaPolyline(coords, color, GeoCerca) { function creaPolyline(coords, color, GeoCerca) {
@@ -782,7 +868,97 @@
} }
function CreaCirculo(coords, color) {
//var Circle = new google.maps.Circle({
// strokeColor: color,
// strokeOpacity: 0.8,
// strokeWeight: 2,
// fillColor: color,
// fillOpacity: 0.35,
// map: map,
// center: coords,
// radius: 15
//});
var Circle = new google.maps.Marker({
position: coords,
icon: {
path: google.maps.SymbolPath.CIRCLE,
scale: 10,
fillColor: color,
fillOpacity: 0.35,
strokeWeight: 2,
strokeColor: color,
strokeOpacity: 0.8
},
map: map
});
circles.push(Circle);
}
function CalcularETA() {
if (posicionesETA.length > 1) {
var latlongs = [];
var destinations = [];
var sources = [];
for (var i = 0; i < posicionesETA.length; i++) {
latlongs.push([posicionesETA[i].lng, posicionesETA[i].lat]);
if (i > 0) {
destinations.push(i);
}
if (i < posicionesETA.length - 1) {
sources.push(i);
}
}
const body = { locations: latlongs, destinations: destinations, sources: sources, resolve_locations: true };
fetch('https://api.openrouteservice.org/v2/matrix/driving-car', {
method: 'POST', // or 'PUT'
headers: {
'Content-Type': 'application/json',
'Authorization': '5b3ce3597851110001cf624839503f1e326e4ab8aa8a27afbcf30f6a'
},
body: JSON.stringify(body),
})
.then(response => response.json())
.then(data => {
let duracionTotal = 0;
if (data.durations.length > 0) {
for (var j = 0; j < data.durations.length; j++) {
let duracionPunto = data.durations[j][j]
duracionTotal += duracionPunto;
}
}
LblETA.innerText = formatETA(duracionTotal);
})
.catch((error) => {
alert('Error:' + error);
});
}
}
function formatETA(time) {
// Hours, minutes and seconds
var hrs = ~~(time / 3600);
var mins = ~~((time % 3600) / 60);
var secs = ~~time % 60;
// Output like "1:01" or "4:03:59" or "123:03:59"
var ret = "";
if (hrs > 0) {
ret += "" + hrs + " horas " + (mins < 10 ? "0" : "");
}
ret += "" + mins + " minutos " + (secs < 10 ? "0" : "");
ret += "" + secs + " segundos";
return ret;
}
</script> </script>
<script src="<%= String.Format("https://maps.googleapis.com/maps/api/js?key={0}&libraries=places", Extensiones.GOOGLE_MAPS_API_KEY) %>"></script> <script src="<%= String.Format("https://maps.googleapis.com/maps/api/js?key={0}&libraries=places", Extensiones.GOOGLE_MAPS_API_KEY) %>"></script>
</asp:Content> </asp:Content>

View File

@@ -9,10 +9,12 @@ Imports Microsoft.Reporting.WebForms
Imports Newtonsoft.Json.Linq Imports Newtonsoft.Json.Linq
Imports System.Linq Imports System.Linq
Imports System.Net.Http Imports System.Net.Http
Imports System.Net.Http.Headers
Imports Newtonsoft.Json
Partial Class GPS_TrayectoDetalle Partial Class GPS_TrayectoDetalle
Inherits ClsPaginas Inherits ClsPaginas
#Region "P R O P I E D A D E S" #Region "P R O P I E D A D E S"
Private Property DtGeocercas As DataTable Private Property DtGeocercas As DataTable
Get Get
@@ -29,9 +31,8 @@ Partial Class GPS_TrayectoDetalle
Set(value As DataTable) Set(value As DataTable)
ViewState("DtPosiciones") = value ViewState("DtPosiciones") = value
End Set End Set
End Property End Property
#End Region
Private Property CveTrayecto As Integer Private Property CveTrayecto As Integer
Get Get
Return CType(ViewState("CveTrayecto"), Integer) Return CType(ViewState("CveTrayecto"), Integer)
@@ -39,8 +40,20 @@ Partial Class GPS_TrayectoDetalle
Set(value As Integer) Set(value As Integer)
ViewState("CveTrayecto") = value ViewState("CveTrayecto") = value
End Set End Set
End Property End Property
Private Property CveEstatusActual As Integer
Get
Return CType(ViewState("CveEstatusActual"), Integer)
End Get
Set(value As Integer)
ViewState("CveEstatusActual") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then If Not Page.IsPostBack Then
DirectCast(Master.FindControl("TSM"), ScriptManager).EnablePageMethods = True DirectCast(Master.FindControl("TSM"), ScriptManager).EnablePageMethods = True
@@ -52,102 +65,205 @@ Partial Class GPS_TrayectoDetalle
End If End If
End Sub End Sub
Private Sub CargaTrayectoHistorial(CveTrayecto As Integer) Private Sub CargaTrayectoHistorial(CveTrayecto As Integer)
Dim ObjGPS As New ClsGPS If CveTrayecto > 0 Then
Try Dim CveDispositivo As Integer = -1
If CveTrayecto > 0 Then
RegistraScript("initMap();") Dim ObjGPS As New ClsGPS
If ObjGPS.GetTrayectosEstatusHistorial(CveTrayecto) Then
Dim Direcciones = ConsultarDirecciones(ObjGPS.DtResultados) Dim DtEstatusHistorial As DataTable = Nothing
For Each Dir As JObject In Direcciones Dim DtPuntosInteres As DataTable = Nothing
ObjGPS.DtResultados.Rows(Dir("Indice").ToEntero())("Direccion") = Dir("Direccion").ToString()
Next Dim DsDatos As DataSet = Nothing
GvEstatus.DataSource = ObjGPS.DtResultados
GvEstatus.DataBind() Dim FechaInicio As DateTime = MinFecha
End If Dim FechaFin As DateTime = MaxFecha
If ObjGPS.GetTrayectosDatos(CveTrayecto) Then
Dim DtDatos = ObjGPS.DtSetResultados.Tables(0) Try
If DtDatos.Rows.Count > 0 Then If ObjGPS.GetTrayectosDatos(CveTrayecto) Then
Dim RowEstatus As DataRow = DtDatos.Rows(0) DsDatos = ObjGPS.DtSetResultados.Copy
LblTitulo.Text = $"Trayecto: {RowEstatus("Trayecto")}" If DsDatos IsNot Nothing AndAlso DsDatos.Tables.Count > 0 Then
LtlEstatusActual.Text = RowEstatus("Estatus").ToString() CveDispositivo = DsDatos.Tables(0).Rows(0)("CveDispositivo").ToString().ToEntero
LtlDispositivo.Text = RowEstatus("Vehiculo").ToString()
LtlFechaI.Text = If(String.IsNullOrEmpty(RowEstatus("FechaInicio").ToString()), "No ha ingresado a la geocerca de inicio", String.Format("{0:dd/MM/yyyy HH:mm tt}", RowEstatus("FechaInicio").ToString().ToDateTime())) If Not String.IsNullOrEmpty(DsDatos.Tables(0).Rows(0)("FechaInicio").ToString()) Then
LtlFechaF.Text = If(String.IsNullOrEmpty(RowEstatus("FechaFin").ToString()), "No ha Terminado", String.Format("{0:dd/MM/yyyy HH:mm tt}", RowEstatus("FechaFin").ToString().ToDateTime())) FechaInicio = DsDatos.Tables(0).Rows(0)("FechaInicio").ToString().ToDateTime
LtlVMedia.Text = String.Format("{0:N2} KM/H", RowEstatus("VMedia")) End If
LtlVMax.Text = String.Format("{0:N2} KM/H", RowEstatus("VMax"))
LtlTiempo.Text = String.Format("{0}", RowEstatus("TiempoOperativo")) If Not String.IsNullOrEmpty(DsDatos.Tables(0).Rows(0)("FechaFin").ToString()) Then
LtlKM.Text = String.Format("{0:N2} KM", RowEstatus("Dist")) FechaFin = DsDatos.Tables(0).Rows(0)("FechaFin").ToString().ToDateTime
LtlExcesosVelo.Text = String.Format("{0}", RowEstatus("ExcesosVelocidad")) End If
LtlCombustibleI.Text = If(String.IsNullOrEmpty(RowEstatus("CombustibleInicial").ToString()), "No Disponible", String.Format("{0:N2}", RowEstatus("CombustibleInicial"))) End If
LtlCombustibleF.Text = If(String.IsNullOrEmpty(RowEstatus("CombustibleFinal").ToString()), "No Disponible", String.Format("{0:N2}", RowEstatus("CombustibleFinal"))) End If
LtlCargas.Text = String.Format("{0:N0}", RowEstatus("Cargas")) If ObjGPS.GetTrayectosGeoReferencias(CveTrayecto) Then
LtlDescargas.Text = String.Format("{0:N0}", RowEstatus("Descargas")) DtGeocercas = ObjGPS.DtResultados.Copy
LtlCombustibleConsumido.Text = String.Format("{0:N2} L", RowEstatus("CombustibleConsumido")) End If
LtlRendimiento.Text = String.Format("{0:N2} KM/L", RowEstatus("Rendimiento"))
'If ObjGPS.GetTrayectosHistorial(CveTrayecto, UsuarioActual.CveCliente) Then
GvIgnicion.DataSource = ObjGPS.DtSetResultados.Tables(1) ' DtPosiciones = ObjGPS.DtResultados.Copy()
GvIgnicion.DataBind() 'End If
GvExcesos.DataSource = ObjGPS.DtSetResultados.Tables(2) If CveDispositivo > 0 Then
GvExcesos.DataBind() If ObjGPS.UltimaPosicionEquipoGet(CveDispositivo.ToString(), UsuarioActual.CveCliente) Then
DtPosiciones = ObjGPS.DtResultados.Copy()
GvRalenti.DataSource = ObjGPS.DtSetResultados.Tables(3) End If
GvRalenti.DataBind() End If
GvCombustible.DataSource = ObjGPS.DtSetResultados.Tables(4) If ObjGPS.GetTrayectosEstatusHistorial(CveTrayecto) Then
GvCombustible.DataBind() DtEstatusHistorial = ObjGPS.DtResultados.Copy
End If
GvGastos.DataSource = ObjGPS.DtSetResultados.Tables(5)
GvGastos.DataBind() If FechaInicio > MinFecha Then
End If If FechaFin <= MinFecha Then
End If FechaFin = MaxFecha
Dim count = 0 End If
If ObjGPS.GetTrayectosGeoReferencias(CveTrayecto) Then
DtGeocercas = ObjGPS.DtResultados If ObjGPS.RepPuntosGet(-1, CveDispositivo.ToString(), FechaInicio, FechaFin, UsuarioActual.CveCliente) Then
If DtGeocercas IsNot Nothing Then DtPuntosInteres = ObjGPS.DtResultados.Copy
Dim Coord As String = "" End If
Dim CoordAnterior As String = "" End If
Dim CveEstatus As Integer = -1
Dim CveEstatusAnterior As Integer = -1
'GEOCERCAS Catch ex As Exception
For Each Row As DataRow In DtGeocercas.Rows OnError("Ocurrió un error al consultar el trayecto.", ex)
count += 1 End Try
Coord = SQLToGmaps(Row("Geom").ToString, "POLYGON") ObjGPS.Dispose()
CveEstatus = Row("CveEstatusTrayecto").ToString.ToEntero
CveEstatusAnterior = Row("CveEstatusAnterior").ToString.ToEntero Try
Dim EsInicio As Boolean = CBool(IfNull(Row("EsInicio"), 0)) RegistraScript("initMap();")
Dim EsFin As Boolean = CBool(IfNull(Row("EsFin"), 0))
Dim InicioFin As Integer = If(EsInicio, 1, If(EsFin, 2, 0)) If DtEstatusHistorial IsNot Nothing AndAlso DtEstatusHistorial.Rows.Count > 0 Then
RegistraScript($"creaPoligono({Coord}, '{Row("Color").ToString}', '{Row("GeoReferencia")}', '{Row("EstatusTrayecto")}',{InicioFin},{CveEstatus},{CveEstatusAnterior})", count.ToString()) Dim Direcciones = ConsultarDirecciones(DtEstatusHistorial)
Next For Each Dir As JObject In Direcciones
End If DtEstatusHistorial.Rows(Dir("Indice").ToEntero())("Direccion") = Dir("Direccion").ToString()
End If Next
If ObjGPS.GetTrayectosHistorial(CveTrayecto, UsuarioActual.CveCliente) Then GvEstatus.DataSource = DtEstatusHistorial
DtPosiciones = ObjGPS.DtResultados GvEstatus.DataBind()
If DtPosiciones IsNot Nothing Then End If
Dim Fecha, Vehiculo, Icono, CoordDis, Info As String
For Each Row As DataRow In DtPosiciones.Rows If DsDatos IsNot Nothing AndAlso DsDatos.Tables.Count > 0 Then
CoordDis = Row("PosicionVehiculo").ToString.SQLToGmaps("POINT") Dim RowEstatus As DataRow = DsDatos.Tables(0).Rows(0)
Fecha = Row("FechaTrama").ToString
Vehiculo = Row("Vehiculo").ToString LblTitulo.Text = $"Trayecto: {RowEstatus("Trayecto")}"
Info = InfoWindow($"{Row("EventoTexto")}", "-1", Row("CveDispositivo").ToString.ToEntero, Row, PermisoComandos:=False) LtlEstatusActual.Text = RowEstatus("Estatus").ToString()
If Row("Velocidad").ToString.ToDouble > 1 Then CveEstatusActual = RowEstatus("CveEstatusActual").ToString().ToEntero()
Icono = $"/Imagenes/{Row("Icono")}green.png"
Else If CBool(RowEstatus("EsFin")) Then
Icono = $"/Imagenes/{Row("Icono")}.png" BtnTerminarTrayeto.Visible = False
End If LnkActualizarEstatus.Visible = False
RegistraScript($"CreaMarcador({CoordDis},'{Row("Vehiculo")}', '{Info}', '{Icono}');", count.ToString()) BtnRecalcular.Visible = False
Next LblETA.Text = "TERMINADO"
End If End If
End If
End If LtlDispositivo.Text = RowEstatus("Vehiculo").ToString()
Catch ex As Exception LtlFechaI.Text = If(String.IsNullOrEmpty(RowEstatus("FechaInicio").ToString()), "No ha ingresado a la geocerca de inicio", String.Format("{0:dd/MM/yyyy HH:mm tt}", RowEstatus("FechaInicio").ToString().ToDateTime()))
OnError("Ocurrió un error al consultar el trayecto.", ex) LtlFechaF.Text = If(String.IsNullOrEmpty(RowEstatus("FechaFin").ToString()), "No ha Terminado", String.Format("{0:dd/MM/yyyy HH:mm tt}", RowEstatus("FechaFin").ToString().ToDateTime()))
End Try LtlVMedia.Text = String.Format("{0:N2} KM/H", RowEstatus("VMedia"))
ObjGPS.Dispose() LtlVMax.Text = String.Format("{0:N2} KM/H", RowEstatus("VMax"))
LtlTiempo.Text = String.Format("{0}", RowEstatus("TiempoOperativo"))
LtlKM.Text = String.Format("{0:N2} KM", RowEstatus("Dist"))
LtlExcesosVelo.Text = String.Format("{0}", RowEstatus("ExcesosVelocidad"))
LtlCombustibleI.Text = If(String.IsNullOrEmpty(RowEstatus("CombustibleInicial").ToString()), "No Disponible", String.Format("{0:N2}", RowEstatus("CombustibleInicial")))
LtlCombustibleF.Text = If(String.IsNullOrEmpty(RowEstatus("CombustibleFinal").ToString()), "No Disponible", String.Format("{0:N2}", RowEstatus("CombustibleFinal")))
LtlCargas.Text = String.Format("{0:N0}", RowEstatus("Cargas"))
LtlDescargas.Text = String.Format("{0:N0}", RowEstatus("Descargas"))
LtlCombustibleConsumido.Text = String.Format("{0:N2} L", RowEstatus("CombustibleConsumido"))
LtlRendimiento.Text = String.Format("{0:N2} KM/L", RowEstatus("Rendimiento"))
GvIgnicion.DataSource = DsDatos.Tables(1)
GvIgnicion.DataBind()
GvExcesos.DataSource = DsDatos.Tables(2)
GvExcesos.DataBind()
GvRalenti.DataSource = DsDatos.Tables(3)
GvRalenti.DataBind()
GvCombustible.DataSource = DsDatos.Tables(4)
GvCombustible.DataBind()
GvGastos.DataSource = DsDatos.Tables(5)
GvGastos.DataBind()
End If
Dim count = 0
If DtPosiciones IsNot Nothing AndAlso DtPosiciones.Rows.Count > 0 Then
Dim Fecha, Vehiculo, Icono, CoordDis, Info As String
For Each Row As DataRow In DtPosiciones.Rows
count += 1
CoordDis = Row("Posicion").ToString.SQLToGmaps("POINT")
Fecha = Row("FechaTrama").ToString
Vehiculo = Row("NombreVehiculo").ToString
Info = InfoWindow($"{Vehiculo}", "-1", Row("CveDispositivo").ToString.ToEntero, Row, PermisoComandos:=False)
If Row("Velocidad").ToString.ToDouble > 1 Then
Icono = $"/Imagenes/{Row("Icono")}green.png"
Else
Icono = $"/Imagenes/{Row("Icono")}.png"
End If
RegistraScript($"CreaMarcador({CoordDis},'{Vehiculo}', '{Info}', '{Icono}');", count.ToString())
Next
End If
If DtGeocercas IsNot Nothing AndAlso DtGeocercas.Rows.Count > 0 Then
Dim Coord As String = ""
Dim CoordAnterior As String = ""
Dim CveEstatus As Integer = -1
Dim CveEstatusAnterior As Integer = -1
'GEOCERCAS
For Each Row As DataRow In DtGeocercas.Rows
count += 1
Coord = SQLToGmaps(Row("Geom").ToString, "POLYGON")
CveEstatus = Row("CveEstatusTrayecto").ToString.ToEntero
CveEstatusAnterior = Row("CveEstatusAnterior").ToString.ToEntero
Dim EsInicio As Boolean = CBool(IfNull(Row("EsInicio"), 0))
Dim EsFin As Boolean = CBool(IfNull(Row("EsFin"), 0))
Dim InicioFin As Integer = If(EsInicio, 1, If(EsFin, 2, 0))
Dim Cruzo As String = IfNull(Row("Cruzo"), "0").ToString()
RegistraScript($"creaPoligono({Coord}, '{Row("Color").ToString}', '{Row("GeoReferencia")}', '{Row("EstatusTrayecto")}',{InicioFin},{CveEstatus},{CveEstatusAnterior},{Cruzo})", count.ToString())
Next
End If
If DtPuntosInteres IsNot Nothing Then
Dim SBBody As New StringBuilder
Dim CoordsPoligono = ""
Dim Coords = ""
Dim Titulo = ""
Dim Info = ""
Dim GeoCercas = ""
Dim Color = ""
For Each RowPI As DataRow In DtPuntosInteres.Rows
count += 1
Coords = SQLToGmaps(RowPI("Punto").ToString, "POINT")
SBBody.Append($"<div>")
SBBody.Append($"<div><h5><b> Punto: {RowPI("PuntoDeInteres")}</b></h5></div>")
Color = "#26C281"
SBBody.Append($"<div><table>")
SBBody.Append($"<tr><td><b>{RowPI("Vehiculo")}:</b> {RowPI("Visitas")} visitas</td></tr>")
SBBody.Append($"<tr><td>Última Visita: {RowPI("UltimaVisita")}</td></tr>")
SBBody.Append($"</table></div>")
SBBody.Append($"</div>")
RegistraScript($"CreaCirculo({Coords},'{Color}');CreaMarcadorPI({Coords},'{RowPI("PuntoDeInteres")}','{SBBody.ToString}');", count.ToString())
Next
count += 1
RegistraScript("CalcularETA();", count.ToString())
End If
Catch ex As Exception
OnError("Ocurrió un error al cargar los datos del trayecto", ex)
End Try
End If
'UpIgniciones.Update() 'UpIgniciones.Update()
'UpEventos.Update() 'UpEventos.Update()
@@ -206,17 +322,24 @@ Partial Class GPS_TrayectoDetalle
Protected Sub BtnTerminarTrayeto_Click(sender As Object, e As EventArgs) Protected Sub BtnTerminarTrayeto_Click(sender As Object, e As EventArgs)
Dim DtEstatus As DataTable = Nothing Dim DtEstatus As DataTable = Nothing
Dim ObjGPS As New ClsGPS Dim ObjGPS As New ClsGPS
If ObjGPS.GetEstatusTrayectos(-1, UsuarioActual.CveCliente) Then
DtEstatus = ObjGPS.DtResultados.Copy() Try
End If If ObjGPS.GetEstatusTrayectos(-1, UsuarioActual.CveCliente) Then
Dim CveEstatusFinal As Integer = DtEstatus.FiltroPrimeroValor("CveEstatusTrayecto", "EsFin = True").ToEntero() DtEstatus = ObjGPS.DtResultados.Copy()
If CveEstatusFinal > 0 Then End If
If ObjGPS.UpdateTrayectoEstatus(CveTrayecto, CveEstatusFinal) Then
Alert("El trayecto se finalizo correctamente") Dim CveEstatusFinal As Integer = DtEstatus.FiltroPrimeroValor("CveEstatusTrayecto", "EsFin = True").ToEntero()
End If If CveEstatusFinal > 0 Then
Else If ObjGPS.UpdateTrayectoEstatus(CveTrayecto, CveEstatusFinal) Then
Alert("No se pudo obtener el estatus final", TipoMensaje.MsgError) Alert("El trayecto se finalizo correctamente", JSBtnAceptar:="RefrescarPagina();", ShowCloseButton:=False)
End If End If
Else
Alert("No se pudo obtener el estatus final", TipoMensaje.MsgError)
End If
Catch ex As Exception
OnError("Ocurrió un error al actualizar el trayecto", ex)
End Try
ObjGPS.Dispose() ObjGPS.Dispose()
End Sub End Sub
Protected Sub GvGastos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Protected Sub GvGastos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
@@ -256,4 +379,50 @@ Partial Class GPS_TrayectoDetalle
2, UsuarioActual.CveUsuario, UsuarioActual.CveCliente, CveTrayecto:=Me.CveTrayecto) Then 2, UsuarioActual.CveUsuario, UsuarioActual.CveCliente, CveTrayecto:=Me.CveTrayecto) Then
RegistraScript("$('#DModal').modal('hide')") RegistraScript("$('#DModal').modal('hide')")
Alert("El Gasto se agregó correctamente.", TipoMensaje.MsgInformacion) Alert("El Gasto se agregó correctamente.", TipoMensaje.MsgInformacion)
End If
ObjPS.Dispose()
'CargaDatos()
End Sub
Protected Sub BtnRecalcular_Click(sender As Object, e As EventArgs)
If CveTrayecto > 0 Then
CargaTrayectoHistorial(CveTrayecto)
CargaReporte()
End If
End Sub
Protected Sub LnkActualizarEstatus_Click(sender As Object, e As EventArgs)
Dim CveEstatusSiguiente As Integer = -1
Dim Estatus As String = ""
Using ObjGPS As New ClsGPS
If ObjGPS.GetTrayectosGeoReferencias(CveTrayecto) Then
Dim Row As DataRow = ObjGPS.DtResultados.FiltroPrimero($"CveEstatusTrayecto = {CveEstatusActual}")
If Row IsNot Nothing Then
CveEstatusSiguiente = Row("CveEstatusSiguiente").ToString().ToEntero()
End If
End If
If CveEstatusSiguiente > 0 Then
If ObjGPS.GetEstatusTrayectos(CveEstatusSiguiente, UsuarioActual.CveCliente) Then
Estatus = ObjGPS.DtResultados.FiltroPrimeroValor("Estatus")
End If
If Not String.IsNullOrEmpty(Estatus) Then
If ObjGPS.UpdateTrayectoEstatus(CveTrayecto, CveEstatusSiguiente) Then
Alert($"El trayecto se cambió al estatus <b>{Estatus}</b>.", JSBtnAceptar:="RefrescarPagina();", ShowCloseButton:=False)
End If
Else
Alert("No se pudo cambiar al estatus siguiente.", TipoMensaje.MsgError)
End If
Else
Alert("No se pudo cambiar al estatus siguiente.", TipoMensaje.MsgError)
End If
End Using
End Sub

View File

@@ -126,7 +126,7 @@
</li> </li>
<li>Mostrar Solo Activas: <li>Mostrar Solo Activas:
<asp:CheckBox ID="ChkActivas" Text=" " runat="server" CssClass="chksino" Width="250px"></asp:CheckBox> <asp:CheckBox ID="ChkActivas" Text=" " runat="server" CssClass="chksino" Width="250px" Checked="true"></asp:CheckBox>
</li> </li>
</ul> </ul>
</div> </div>
@@ -134,18 +134,29 @@
</div> </div>
</ContentTemplate> </ContentTemplate>
</asp:UpdatePanel> </asp:UpdatePanel>
<div class="row"> <asp:UpdatePanel runat="server" ID="UPGV" UpdateMode="Conditional">
<div class="col-md-12"> <ContentTemplate>
<div class="row" style="margin-left: 0px; margin-top: 5px; margin-bottom: 5px; text-align: right" align="left"> <div class="row">
<div style="margin-right: 15px"> <div class="col-md-12">
<input type="text" id="TxtBusquedaG" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtBusquedaG','{0}')", GvBarra.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" /> <div class="row" style="margin-left: 0px; margin-top: 5px; margin-bottom: 5px; text-align: right" align="left">
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusquedaG','{0}')", GvBarra.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a> <div class="col-md-6">
</div> <div class="row">
</div> <label class="col-md-3 trucate"><b>Consultar Automaticamente</b></label>
<asp:UpdatePanel runat="server" ID="UPGV" UpdateMode="Conditional"> <div class="col-md-1">
<ContentTemplate> <asp:CheckBox ID="ChkTimmer" OnCheckedChanged="ChkTimmer_CheckedChanged" AutoPostBack="true" Text=" " runat="server" CssClass="chksino" Checked="true"></asp:CheckBox>
</div>
<div class="col-md-8">
<asp:Timer runat="server" ID="TimmerRefresh" Interval="30000" OnTick="TimmerRefresh_Tick"></asp:Timer>
</div>
</div>
</div>
<div style="margin-right: 15px">
<input type="text" id="TxtBusquedaG" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtBusquedaG','{0}')", GvBarra.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" />
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusquedaG','{0}')", GvBarra.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
</div>
</div>
<asp:HiddenField ID="HdnTrayecto" runat="server" ClientIDMode="Static" Value="" /> <asp:HiddenField ID="HdnTrayecto" runat="server" ClientIDMode="Static" Value="" />
<asp:GridView ID="GvBarra" runat="server" Style="overflow-x: auto;" GridLines="None" OnRowDataBound="GvBarra_RowDataBound" OnRowDeleting="GvBarra_RowDeleting1" <asp:GridView ID="GvBarra" runat="server" Style="overflow-x: auto;" GridLines="None" OnRowDataBound="GvBarra_RowDataBound" OnRowDeleting="GvBarra_RowDeleting1"
DataKeyNames="CveTrayecto,EnviarNotificacion,CorreosNotificacion,Intervalo,EnviarLiga" CssClass="table table-striped table-advance table-hover Widthall ScrollAD" data-sort="true" data-sortindex="1" AutoGenerateColumns="False" EmptyDataText="No se encontraron registros" ToolTip="Listado de Trayectos"> DataKeyNames="CveTrayecto,EnviarNotificacion,CorreosNotificacion,Intervalo,EnviarLiga" CssClass="table table-striped table-advance table-hover Widthall ScrollAD" data-sort="true" data-sortindex="1" AutoGenerateColumns="False" EmptyDataText="No se encontraron registros" ToolTip="Listado de Trayectos">
<Columns> <Columns>
<asp:BoundField DataField="Trayecto" HeaderText="Nombre del Trayecto" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="20%" /> <asp:BoundField DataField="Trayecto" HeaderText="Nombre del Trayecto" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="20%" />
@@ -170,11 +181,10 @@
</asp:TemplateField> </asp:TemplateField>
</Columns> </Columns>
</asp:GridView> </asp:GridView>
</ContentTemplate> </div>
</asp:UpdatePanel> </div>
</div> </ContentTemplate>
</div> </asp:UpdatePanel>
<div id="DivAgregar" class="modal ADS fade" role="dialog"> <div id="DivAgregar" class="modal ADS fade" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">

View File

@@ -44,6 +44,7 @@ Partial Class GPS_Trayectos
If Not Page.IsPostBack Then If Not Page.IsPostBack Then
DirectCast(Master.FindControl("TSM"), ScriptManager).EnablePageMethods = True DirectCast(Master.FindControl("TSM"), ScriptManager).EnablePageMethods = True
CargaDatos() CargaDatos()
TimmerRefresh.Enabled = ChkTimmer.Checked
End If End If
End Sub End Sub
Private Sub CargaDatos() Private Sub CargaDatos()
@@ -111,7 +112,7 @@ Partial Class GPS_Trayectos
Public Sub CargaEstatus() Public Sub CargaEstatus()
Dim ObjGPS As New ClsGPS Dim ObjGPS As New ClsGPS
If ObjGPS.GetEstatusTrayectos(-1, UsuarioActual.CveCliente) Then If ObjGPS.GetEstatusTrayectos(-1, UsuarioActual.CveCliente) Then
GvEstatus.DataSource = ObjGPS.DtResultados GvEstatus.DataSource = ObjGPS.DtResultados.FiltraParametros("CveCliente > 0")
GvEstatusNuevo.DataSource = ObjGPS.DtResultados GvEstatusNuevo.DataSource = ObjGPS.DtResultados
DdlEstatusTrayecto.DataSource = ObjGPS.DtResultados DdlEstatusTrayecto.DataSource = ObjGPS.DtResultados
End If End If
@@ -443,4 +444,12 @@ Partial Class GPS_Trayectos
Alert("No se pudo identificar el trayecto", TipoMensaje.MsgError) Alert("No se pudo identificar el trayecto", TipoMensaje.MsgError)
End If End If
End Sub End Sub
Protected Sub TimmerRefresh_Tick(sender As Object, e As EventArgs)
CargaTrayectos()
End Sub
Protected Sub ChkTimmer_CheckedChanged(sender As Object, e As EventArgs)
TimmerRefresh.Enabled = ChkTimmer.Checked
UPGV.Update()
End Sub
End Class End Class