Commit inicial Ventas Productivo

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-08-14 16:40:54 -07:00
commit c35cf91883
13328 changed files with 3711549 additions and 0 deletions

350
PortalGPS/InicioGPS.aspx Normal file
View File

@@ -0,0 +1,350 @@
<%@ Page Title="" Language="VB" MasterPageFile="~/SiteGPS.master" AutoEventWireup="false" CodeFile="InicioGPS.aspx.vb" Inherits="GPS_PruebaMaster" %>
<%@ MasterType VirtualPath="~/SiteGPS.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#map {
width: 100%;
height: calc(100% - 51px);
margin: 0;
padding: 0;
}
#map {
position: fixed !important;
}
.pac-container.pac-logo {
z-index: 100000;
}
</style>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="C" runat="Server">
<div id="map"></div>
<asp:UpdatePanel runat="server" ID="UP">
<ContentTemplate>
<asp:HiddenField ID="HdnCveDipositivo" runat="server" ClientIDMode="Static" />
<asp:Button runat="server" ID="BtnCargar" />
</ContentTemplate>
</asp:UpdatePanel>
<div id="divComandos" class="modal ADS fade" role="dialog">
<div class="modal-dialog">
<asp:UpdatePanel ID="UpAgregar" class="modal-content rowpadding" tabindex="-1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="myModalLabel">Comandos para vehículo: </h4>
</div>
<div class="modal-body">
<asp:UpdatePanel ID="UpBodyTipoEquipo" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Button runat="server" ID="BtnCargaComandos" Style="display: none" />
<asp:GridView ID="GvComandos" runat="server" DataKeyNames="CveComando, RequiereValor" Style="table-layout: fixed" AutoGenerateColumns="False" ShowHeader="True" EmptyDataText="No se encontraron comandos para este modelo" GridLines="none" ToolTip="Listado de Comandos" data-sort="false" CssClass="table table-striped table-hover Widthall ScrollAD">
<Columns>
<asp:TemplateField ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Button ID="BtnEnviar" runat="server" CssClass="btn btn-primary" CommandName="EnviarComando" CommandArgument="<%# CType(Container, GridViewRow).RowIndex %>" Text="Enviar" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Comando" DataField="Comando" ItemStyle-Width="40%" FooterStyle-HorizontalAlign="Left" />
<asp:TemplateField ItemStyle-Width="20%" ItemStyle-HorizontalAlign="Center">
<HeaderTemplate>Valor</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="TxtValor" Visible="false" Width="99px" runat="server" Text=""></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UltimaFechaEjecucion" ItemStyle-Width="20%" HeaderText="Última Ejecución" ItemStyle-HorizontalAlign="center" />
<asp:BoundField DataField="FechaRespuesta" ItemStyle-Width="20%" HeaderText="Última Respuesta" ItemStyle-HorizontalAlign="center" />
</Columns>
</asp:GridView>
<%--<div class="row" style="margin-left: 0px; margin-top: 5px; margin-bottom: 15px;">
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnApagarMotor" CssClass="btn btn-danger" Text="Apagar Motor" />
</div>
<div class="col-md-4" style="padding-right: 0px">
<asp:TextBox ID="TxtTelefonoPanico" runat="server" Style="width: 150px; height: 100%; float: right;" Type="number" MaxLength="10" />
<asp:RequiredFieldValidator ID="RFVTelefonoPanico" runat="server" ControlToValidate="TxtTelefonoPanico" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Telefono''</b> es necesario, por favor ingréselo." ValidationGroup="GrpBotonPanico"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCETelefonoPanico" runat="server" HighlightCssClass="vco" TargetControlID="RFVTelefonoPanico" Width="350px"></ajax:ValidatorCalloutExtender>
</div>
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnTelefonoPanico" CssClass="btn btn-danger" Text="Telefono Panico" ValidationGroup="GrpBotonPanico" />
</div>
</div>
<div class="row" style="margin-left: 0px; margin-top: 5px; margin-bottom: 15px;">
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnEncenderMotor" CssClass="btn btn-success" Text="Encender Motor" />
</div>
<div class="col-md-4" style="padding-right: 0px">
<asp:DropDownList CssClass="form-control input-sm" Style="float: right; height: 100%;" ID="DdlTipoBateria" runat="server" Width="150px">
<asp:ListItem Value="0" Text="ST Solo en Movimiento"></asp:ListItem>
<asp:ListItem Value="1" Text="Intervalos de Tiempo" Selected="True"></asp:ListItem>
</asp:DropDownList>
</div>
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnAhorroBateria" CssClass="btn btn-success" Text="Ahorro Bateria" />
</div>
</div>
<div class="row" style="margin-left: 0px; margin-top: 5px; margin-bottom: 15px;">
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnProbarEncendido" CssClass="btn btn-primary" Text="Abrir Compuerta" />
</div>
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnInfoDispositivo" CssClass="btn btn-primary" Text="Cerrar Compuerta" />
</div>
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnReinicio" CssClass="btn btn-primary" Text="Reiniciar" />
</div>
</div>--%>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<%--<div class="modal-footer">
<asp:UpdatePanel ID="UpFooter" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton ID="BtnBuscarEquipoC" runat="server" CssClass="btn btn-primary" ValidationGroup="GrpObligatorio"> <i class='fa fa-search '></i> Buscar</asp:LinkButton>
<button id="btnCancelar" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</ContentTemplate>
</asp:UpdatePanel>
</div>--%>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
<script>
var image = '/Imagenes/rsz_11rsz_car.png';
var geocoder;
var uluru = { lat: 24.6345, lng: -102.5528 };
var map;
var directionsService;
var directionsDisplay;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: uluru,
zoom: 7
});
google.maps.event.addListener(map, "click", function (event) {
closeLastOpenedInfoWindow();
});
directionsService = new google.maps.DirectionsService;
directionsDisplay = new google.maps.DirectionsRenderer;
directionsDisplay.setOptions({ suppressMarkers: true });
geocoder = new google.maps.Geocoder();
directionsDisplay.setMap(map);
var upControlDiv = document.createElement('div');
var upControl = new ControlLabels(upControlDiv, map);
upControlDiv.index = 1;
map.controls[google.maps.ControlPosition.TOP_LEFT].push(upControlDiv);
//var trafficLayer = new google.maps.TrafficLayer();
//trafficLayer.setMap(map);
}
var markers = [];
var lastOpenedInfoWindow;
function CreaMarcador(coords, nomEquipo, ContentString, imagen) {
if (typeof imagen === 'undefined') { imagen = image; }
var markerIcon = {
url: imagen,
labelOrigin: new google.maps.Point(26, 43)
};
var marker = new google.maps.Marker({
position: coords,
title: nomEquipo,
map: map,
icon: markerIcon
});
marker.Nombre = nomEquipo;
var infowindow = new google.maps.InfoWindow({
content: ContentString
});
marker.addListener('click', function () {
closeLastOpenedInfoWindow();
GetDirecciones(coords, infowindow, marker);
infowindow.open(map, marker);
lastOpenedInfoWindow = infowindow;
});
markers.push(marker);
map.setCenter(coords);
}
function fitBoundsToVisibleMarkers() {
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < markers.length; i++) {
if (markers[i].getVisible()) {
bounds.extend(markers[i].getPosition());
}
}
map.fitBounds(bounds);
}
function closeLastOpenedInfoWindow() {
if (lastOpenedInfoWindow) {
lastOpenedInfoWindow.close();
}
}
function DeleteMarkers() {
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(null);
}
markers = [];
directionsDisplay.setMap(null);
}
$(document).ready(function () {
initMap();
$('#C_BtnCargar').click();
});
function CargaComandos(Vehiculo, CveDispositivo) {
$("#HdnCveDipositivo").val(CveDispositivo)
// if (open) { FNShowDiv(); }
$("#myModalLabel").text("Comando para vehículo: " + Vehiculo)
closeLastOpenedInfoWindow();
$("#divComandos").modal()
$("#C_BtnCargaComandos").click()
}
function ControlLabels(controlDiv, map) {
// Set CSS for the control border.
var controlUI = document.createElement('div');
controlUI.style.marginLeft = '10px';
controlUI.style.zIndex = '0';
controlUI.style.cursor = 'pointer';
// controlUI.style.position = 'absolute';
controlUI.style.left = "0px";
controlUI.style.width = "150px";
controlUI.style.marginTop = "10px"
controlUI.style.top = "0px";
controlUI.className = 'gmnoprint';
controlDiv.appendChild(controlUI);
var ControlSub1 = document.createElement('div')
ControlSub1.style.float = 'left';
ControlSub1.className = 'gm-style-mtc'
controlUI.appendChild(ControlSub1)
var ControlSub2 = document.createElement('div')
ControlSub2.style.direction = 'ltr';
ControlSub2.style.overflow = 'hidden';
ControlSub2.id = "LnkEtiquetas"
ControlSub2.style.textAlign = 'center';
ControlSub2.style.position = 'relative';
ControlSub2.style.color = 'rgb(0,0,0)';
ControlSub2.style.fontFamily = ' "Open Sans", sans-serif; ';
ControlSub2.style.msUserSelect = 'none;';
ControlSub2.style.fontSize = '11px'
ControlSub2.style.backgroundColor = 'rgb(255,255,255)'
ControlSub2.style.padding = '11px'
ControlSub2.style.backgroundClip = 'padding-box'
ControlSub2.style.minWidth = '28px'
ControlSub2.style.fontWeight = '500'
ControlSub2.style.boxShadow = '0 1px 4px -1px rgba(0,0,0,.3)';
ControlSub2.innerHTML = 'Mostrar Etiquetas'
ControlSub1.appendChild(ControlSub2)
ControlSub1.addEventListener('click', function () {
EscondeLabels();
});
}
var visible = false
function EscondeLabels() {
if (visible) {
for (var i = 0; i < markers.length; i++) {
markers[i].setLabel(null);
}
visible = false
} else {
for (var i = 0; i < markers.length; i++) {
var label = {
text: markers[i].Nombre,
fontSize: "12px",
color: 'black',
fontWeight: 'bolder'
}
markers[i].setLabel(label);
}
visible = true
}
}
function GetDirecciones(posicion, infowindow, marker) {
if (marker.formatted_address) { return false; }
else if (marker.formatted_addressrow) {
infowindow.setContent(infowindow.getContent() + "<div style='margin-left:5px'>" + "Dirección: " + marker.formatted_addressrow + "</div>");
marker.formatted_address = marker.formatted_addressrow
}
else {
var lat = posicion.lat
var lng = posicion.lng
var url = '<%= ClsPaginas.UrlDirecciones%>' + 'nominatim/reverse.php?format=jsonv2&lat=' + lat + '&lon=' + lng;
$.getJSON(url, function (data) {
if (typeof (data.error) === 'undefined') {
marker.formatted_address = data.display_name
infowindow.setContent(infowindow.getContent() + "<div style='margin-left:5px'>" + "Dirección: " + data.display_name + "</div>");
} else {
marker.formatted_address = "Dirección no encontrada";
infowindow.setContent(infowindow.getContent() + "<div style='margin-left:5px'> Dirección: No Encontrada </div>");
}
});
}
}
</script>
<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAF7s8wwhzCVXDUYopc9mXxqaWB33cDro4&libraries=places">
</script>
<%--<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAJnZ1CoEUX425C20aqzFw4dYxFL_LfThk&libraries=places">
</script>--%>
</asp:Content>

251
PortalGPS/InicioGPS.aspx.vb Normal file
View File

@@ -0,0 +1,251 @@
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()
Dim ObjClientes As New ClsClientes
Try
If ObjClientes.GetClientes(UsuarioActual.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1, Estatus:=1) Then
If ObjClientes.DtResultados.Rows.Count = 1 Then
Offset = ObjClientes.DtResultados(0)("UTCOffset").ToString().ToEntero()
End If
End If
Catch ex As Exception
OnError("Ocurrió un error al obtener la zona horaria.", ex)
Finally
ObjClientes.Dispose()
End Try
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")
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

27
PortalGPS/Penske.aspx Normal file
View File

@@ -0,0 +1,27 @@
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="Penske.aspx.vb" Inherits="PortalGPS_Penske" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="E" runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="HB" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="HA" runat="Server">
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="C" runat="Server">
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Timer runat="server" ID="TimerNoti" Enabled="true" Interval="900000"></asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
<script>
self.close();
</script>
</asp:Content>

116
PortalGPS/Penske.aspx.vb Normal file
View File

@@ -0,0 +1,116 @@
Imports System.Data
Imports Extensiones
Imports System.Data.SqlClient
Imports Microsoft.AspNet.SignalR
Imports System.IO
Imports System.Net.Http
Imports Newtonsoft.Json.Linq
Partial Class PortalGPS_Penske
Inherits System.Web.UI.Page
Private Sub PortalGPS_Penske_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
EnviarDatos()
End If
End Sub
Private Sub EnviarDatos()
Dim ObjTsoft As New ClsTSoft
Try
GuardaLog($"Empecé Task. Fecha: {DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")}")
If ObjTsoft.GetInfoWSPenske() AndAlso ObjTsoft.DtResultados.Rows.Count > 0 Then
Dim Direcciones As JArray = ConsultarDirecciones(ObjTsoft.DtResultados)
For Each Dir As JObject In Direcciones
IterarWS(ObjTsoft.DtResultados.Rows(Dir("Indice").ToEntero()), Dir("Direccion").ToString())
Next
End If
Catch ex As Exception
GuardaLog(ex.ToString())
Finally
GuardaLog($"Terminé Task, se reportaron: {ObjTsoft.DtResultados.Rows.Count} registros. Fecha: {DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")}")
ObjTsoft.Dispose()
End Try
End Sub
Private Sub IterarWS(row As DataRow, direccion As String)
Try
Dim ws As New WSPenske.ReceiveGPSInfo
Dim info As New WSPenske.GPSInfo
info.Proveedor = row("Proveedor").ToString
info.Latitud = row("Lat").ToString
info.Longitud = row("Lng").ToString
info.NumUnidad = row("NoEconomico").ToString
info.NumRemolque = row("NumeroRemolque").ToString
info.Velocidad = row("Velocidad").ToString
info.Placas = row("PlacasVehiculo").ToString
info.Trackingnumber = row("TrackingNumber").ToString
info.Ubicacion = direccion
info.FechaHoraEvento = row("FechaTrama").ToString
info.FechaRecepcion = DateTime.Now.AddMinutes(120)
info.Username = row("Usuario").ToString
info.Password = row("PWD").ToString
Dim Protocol As New WSPenske.Protocolo
Protocol = ws.ReceiveGPSInformation_Objeto(info)
GuardaLog($"Se envio informacion del vehículo: {row("NoEconomico").ToString}. Processed: {Protocol.Processed}. Message: {Protocol.Message}. Fecha Recepcion: {Protocol.ReceptionDate.ToString("dd/MM/yyyy HH:mm:ss")} ")
Catch ex As Exception
GuardaLog(ex.ToString())
End Try
End Sub
Protected Sub TimerNoti_Tick(sender As Object, e As EventArgs) Handles TimerNoti.Tick
EnviarDatos()
End Sub
Public Function ConsultarDirecciones(Dt As DataTable) As JArray
Dim retorno As JArray = Nothing
Dim posicionesArray = New JArray(From Row As DataRow In Dt
Let index = Dt.Rows().IndexOf(Row)
Select New JObject(
New JProperty("indice", index),
New JProperty("cveTrama", -1),
New JProperty("lat", Row("Lat").ToString.ToDouble),
New JProperty("lon", Row("Lng").ToString.ToDouble)
))
Dim Base64array = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(posicionesArray.ToString()))
Using wc As New HttpClient()
Try
Dim Url = New Uri($"{ClsPaginas.UrlDirecciones}nominatim/reverseMultiple.php")
Dim FormStuff = String.Format("formato=json&posiciones={0}", Base64array)
Dim content = New StringContent(FormStuff, Encoding.UTF8, "application/x-www-form-urlencoded")
Dim response = wc.PostAsync(Url, content).Result
Dim result = response.Content.ReadAsStringAsync().Result
retorno = JArray.Parse(result)
Catch ex As Exception
OnError("Ocurrió un error al obtener las direcciones", ex)
End Try
End Using
Return retorno
End Function
Public Sub GuardaLog(Str As String)
Dim ArchivoW As StreamWriter
Dim strLineaTMP As String
' strLineaTMP = Chr(13) & Chr(10) & Day(Now) & "/" & Month(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minuto & ". " & Str & Chr(13) & Chr(10)
strLineaTMP = String.Format("{0}{1}Log: {2}{3}:{4}", Chr(13), Chr(10), Str, DateTime.Now.ToShortDateString, DateTime.Now.ToShortTimeString)
Try
ArchivoW = New StreamWriter(String.Format("{0}\LogPenske.txt", AppDomain.CurrentDomain.BaseDirectory), True, System.Text.Encoding.UTF8)
Catch ex As UnauthorizedAccessException
'Alert("No hay permisos para guardar en el Log.", Extensiones.TipoMensaje.MsgError)
Exit Sub
Catch ex As Exception
Exit Sub
End Try
Try
ArchivoW.WriteLine(strLineaTMP)
Catch
End Try
ArchivoW.Close()
ArchivoW.Dispose()
End Sub
End Class

View File

@@ -0,0 +1,285 @@
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="PruebaTSoft.aspx.vb" Inherits="PruebaTSoft" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="E" Runat="Server">
<asp:Label ID="LblTitulo" runat="server" Text="Remisiones"></asp:Label>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="HB" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" Runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="HA" Runat="Server">
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="C" Runat="Server">
<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UpDatos">
<ContentTemplate>
<div class="portlet smmallpadding light bordered" id="Div3" runat="server">
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span class="caption-subject bold uppercase">Historial de Remision</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body form">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-4">
Folio Remisión:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtFolioRemision" width="400px"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-md-4">
No. Economico:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtNoEconomico" width="400px"></asp:TextBox>
</div>
</div>
<div class="align-right">
<asp:Button runat="server" ID="BtnGetRemision" Text="Consultar" CssClass="btn btn-primary"/>
</div>
</div>
<div class="col-md-6">
<asp:Label runat="server" ID="LtlRemision" Text="" ></asp:Label>
</div>
</div>
</div>
</div>
<br />
<br />
<div class="portlet smmallpadding light bordered" id="Div1" runat="server">
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span class="caption-subject bold uppercase">Agregar una Remisión</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body form">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-4">
Folio Remisión:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtRemision2" width="400px"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-md-4">
No. Economico:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtNoEconomico2" width="400px"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-md-4">
Clave Estatus:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtCveEstatus" width="400px" TextMode="Number"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-md-4">
Geo Inicio:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtGeoInicio" width="400px"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-md-4">
Geo Fin:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtGeoFin" width="400px"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-md-4">
Fecha:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtFecha" width="400px"></asp:TextBox>
</div>
</div>
<div class="align-right">
<asp:Button runat="server" ID="BtnAddRemision" Text="Agregar" CssClass="btn btn-primary"/>
</div>
</div>
<div class="col-md-6">
<asp:Label runat="server" ID="LblAddRemision" Text="" ></asp:Label>
</div>
</div>
</div>
</div>
<br />
<br />
<div class="portlet smmallpadding light bordered" id="Div2" runat="server">
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span class="caption-subject bold uppercase">Actualizar Remisión</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body form">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-4">
Folio Remisión:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtFolioRemision3" width="400px"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-md-4">
Clave Estatus:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtClaveEstatus3" width="400px" TextMode="Number"></asp:TextBox>
</div>
</div>
<div class="align-right">
<asp:Button runat="server" ID="BtnUpdateREmision" Text="Actualizar" CssClass="btn btn-primary" />
</div>
</div>
<div class="col-md-6">
<asp:Label runat="server" ID="LblUpdateRemision" Text="" ></asp:Label>
</div>
</div>
</div>
</div>
<br />
<br />
<div class="portlet smmallpadding light bordered" id="Div4" runat="server">
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span class="caption-subject bold uppercase">Término Remisión</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body form">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-4">
Folio Remisión:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtFolio4" width="400px"></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-md-4">
Número Economico:
</div>
<div class="col-md-8">
<asp:TextBox runat="server" ID="TxtNoEconomico4" width="400px" TextMode="Number"></asp:TextBox>
</div>
</div>
<div class="align-right">
<asp:Button runat="server" ID="BtnTerminoRemision" Text="Guardar" CssClass="btn btn-primary" />
</div>
</div>
<div class="col-md-6">
<asp:Label runat="server" ID="LblTerminoRemision" Text="" ></asp:Label>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" Runat="Server">
</asp:Content>

View File

@@ -0,0 +1,32 @@
Option Strict On
Imports Extensiones
Partial Class PruebaTSoft
Inherits System.Web.UI.Page
Private Sub BtnAddRemision_Click(sender As Object, e As EventArgs) Handles BtnAddRemision.Click
Dim ObjWS As New MyPRTSoft.WsTSoftSoapClient
Dim Resultado = ObjWS.AddRemision(TxtRemision2.Text, TxtNoEconomico2.Text, TxtCveEstatus.Text.ToEntero, TxtGeoInicio.Text, TxtGeoFin.Text, TxtFecha.Text)
LblAddRemision.Text = Resultado
UpDatos.Update()
End Sub
Private Sub BtnGetRemision_Click(sender As Object, e As EventArgs) Handles BtnGetRemision.Click
Dim ObjWS As New MyPRTSoft.WsTSoftSoapClient
Dim Resultado = ObjWS.GetRemisionHistorial(TxtFolioRemision.Text, TxtNoEconomico.Text)
LtlRemision.Text = Resultado
UpDatos.Update()
End Sub
Private Sub BtnUpdateREmision_Click(sender As Object, e As EventArgs) Handles BtnUpdateREmision.Click
Dim ObjWS As New MyPRTSoft.WsTSoftSoapClient
Dim Resultado = ObjWS.UpEstatusRemision(TxtFolioRemision3.Text, TxtClaveEstatus3.Text)
LblUpdateRemision.Text = Resultado
UpDatos.Update()
End Sub
Private Sub BtnTerminoRemision_Click(sender As Object, e As EventArgs) Handles BtnTerminoRemision.Click
Dim ObjWS As New MyPRTSoft.WsTSoftSoapClient
Dim Resultado = ObjWS.TerminoRemision(TxtFolio4.Text, TxtNoEconomico4.Text)
LblTerminoRemision.Text = Resultado
UpDatos.Update()
End Sub
End Class

View File

@@ -0,0 +1,41 @@
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="ServiciosGPS.aspx.vb" Inherits="PortalGPS_ServiciosGPS" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="E" runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="HB" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="HA" runat="Server">
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="C" runat="Server">
<asp:UpdatePanel runat="server" UpdateMode="conditional" ID="UP">
<ContentTemplate>
<div class="row">
<div class="col-md-12">
<asp:Label ID="LblFecha" runat="server" CssClass="form-control labeltext"></asp:Label>
</div>
</div>
<br />
<div class="row">
<div class="col-md-6">
<%--<asp:TextBox ID="TxtCMD" runat="server" CssClass="form-control input-sm"></asp:TextBox>--%>
<asp:RadioButtonList RepeatDirection="horizontal" ID="RdlTipo" runat="server">
<asp:ListItem Value="GPRS" Selected="true">GPRS</asp:ListItem>
<asp:ListItem Value="SMS">SMS</asp:ListItem>
</asp:RadioButtonList>
</div>
<div class="col-md-6">
<asp:Button runat="server" ID="BtnPrueba" CssClass="btn btn-primary" Text="Ejecutar Can Bus" OnClick="BtnPrueba_Click" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="JS" runat="Server">
</asp:Content>

View File

@@ -0,0 +1,82 @@
Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Imports System.Data.SqlClient
Imports Microsoft.AspNet.SignalR
Imports System.IO
Partial Class PortalGPS_ServiciosGPS
Inherits System.Web.UI.Page
Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
If Request("Correr") IsNot Nothing AndAlso Request("Correr").ToString = "1" Then
'Dim Tipo As String = RdlTipo.SelectedValue
EjecutarComandos()
End If
End If
End Sub
Private Sub EjecutarComandos(Optional Tipo As String = "GPRS")
Dim ObjGPS As New ClsGPS
Dim ObjHerra As New ClsGPSHerramientas
If ObjGPS.DispositivosGet(-1, 1, -1, -1) Then
Try
Dim DtDispositivos = ObjGPS.DtResultados.FiltraParametros("Modelo IN ('ST300K','ST300KE','ST300C')")
For Each Dr As DataRow In DtDispositivos.Rows
Dim DevID As String = Dr("DevID").ToString
If Not String.IsNullOrEmpty(DevID) Then
Dim Comando As String = $"ST300GED;{DevID};02"
Dim Telefono As String = Dr("NumeroTelefono").ToString
Dim CveDispositivo As Integer = Dr("CveDispositivo").ToString.ToEntero
Select Case Tipo
Case "GPRS"
If ObjHerra.EjecutarComandoManualGPRS(Comando, Telefono, CveDispositivo, -1) Then
LblFecha.Text = Now.ToString("dd/MM/yyyy")
GuardaLog($"Se ejecuto el comando correctamente vía GPRS. ")
End If
Case "SMS"
If ObjHerra.EjecutarComandoManualSMS(Comando, Telefono, CveDispositivo, -1) Then
LblFecha.Text = Now.ToString("dd/MM/yyyy")
GuardaLog($"Se ejecuto el comando correctamente vía SMS Fecha. ")
End If
End Select
End If
Next
Catch ex As Exception
GuardaLog($"Ocurrió un error al ejecutar el comando. {ex.ToString}")
End Try
End If
ObjGPS.Dispose()
ObjHerra.Dispose()
End Sub
Protected Sub BtnPrueba_Click(sender As Object, e As EventArgs)
Dim Tipo As String = RdlTipo.SelectedValue
EjecutarComandos(Tipo)
End Sub
Public Sub GuardaLog(Str As String)
Dim ArchivoW As StreamWriter
Dim strLineaTMP As String
strLineaTMP = String.Format("{0}{1}Log: {2}{3}:{4}", Chr(13), Chr(10), Str, DateTime.Now.ToShortDateString, DateTime.Now.ToShortTimeString)
Try
ArchivoW = New StreamWriter(String.Format("{0}\LogCanBus.txt", AppDomain.CurrentDomain.BaseDirectory), True, System.Text.Encoding.UTF8)
Catch ex As Exception
Exit Sub
End Try
Try
ArchivoW.WriteLine(strLineaTMP)
Catch
End Try
ArchivoW.Close()
ArchivoW.Dispose()
End Sub
End Class

1
PortalGPS/WsADGPS.asmx Normal file
View File

@@ -0,0 +1 @@
<%@ WebService Language="VB" CodeBehind="~/App_Code/WsADGPS.vb" Class="WsADGPS" %>

18
PortalGPS/web.config Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="Penske.aspx" />
</files>
</defaultDocument>
</system.webServer>
<!--<system.web>
<authentication mode="Forms">
<forms loginUrl="LogInPortal.aspx" protection="All" timeout="20" name=".ASPXSIGPortal" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="ConsultaClientes.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>-->
</configuration>