diff --git a/App_Code/ClsGPS.vb b/App_Code/ClsGPS.vb index 1488d68ff..4f24d2b76 100644 --- a/App_Code/ClsGPS.vb +++ b/App_Code/ClsGPS.vb @@ -5365,6 +5365,109 @@ Public Class ClsGPS #End Region +#Region "R E C U R S O - C O N F I A B L E" + Public Function AddRCTracking(Nombre As String, CveDispositivo As Integer, Shipment As String, CveUsuarioIngreso As Integer, CveCliente As Integer, CveEmpresa As Integer) As Integer + Dim retorno As Integer = -1 + DataAdapter("PA_GPS_RC_TrackingAdd", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@Nombre", SqlDbType.VarChar).Value = Nombre + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@Shipment", SqlDbType.VarChar).Value = Shipment + .Add("@CveUsuarioIngreso", SqlDbType.Int).Value = CveUsuarioIngreso + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveRCTracking", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + retorno = SqlAdapter.SelectCommand.Parameters("@CveRCTracking").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error al agregar un tracking.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return retorno + End Function + + Public Function UpdateRCTrackingEstatus(CveRCTracking As Integer, CveEstatus As Boolean, CveUsuarioModifico As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_GPS_RC_TrackingEstatusUpdate", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CveRCTracking", SqlDbType.Int).Value = CveRCTracking + .Add("@CveEstatus", SqlDbType.Bit).Value = CveEstatus + .Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico + End With + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar un tracking.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return retorno + End Function + + Public Function GetRCTracking(CveRCTracking As Integer, CveDispositivo As Integer, CveEstatus As Integer, CveCliente As Integer, CveEmpresa As Integer, Optional FechaI As DateTime = ModExtensiones.MinFecha, Optional FechaF As DateTime = ModExtensiones.MaxFecha) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_GPS_RC_TrackingGet", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CveRCTracking", SqlDbType.Int).Value = CveRCTracking + .Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@FechaI", SqlDbType.DateTime).Value = FechaI + .Add("@FechaF", SqlDbType.DateTime).Value = FechaF + End With + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener un tracking.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return retorno + End Function + + Public Function GetRCTrackingDatos(CveRCTracking As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_GPS_RC_TrackingDatosGet", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CveRCTracking", SqlDbType.Int).Value = CveRCTracking + End With + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener los datos de un tracking.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return retorno + End Function + + Public Function RemoveRCTracking(CveRCTracking As Integer) As Boolean + Dim retorno As Boolean = False + DataAdapter("PA_GPS_RC_TrackingEstatusRemove", CommandType.StoredProcedure) + With SqlAdapter.SelectCommand.Parameters + .Add("@CveRCTracking", SqlDbType.Int).Value = CveRCTracking + End With + + Try + SqlAdapter.Fill(Data) + retorno = True + Catch ex As Exception + OnError("Ocurrió un error al eliminar un tracking.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return retorno + End Function + + +#End Region + Protected Sub addParameters(name As String, tipo As SqlDbType, valor As Object) If SqlConexion.State = ConnectionState.Open Then SqlAdapter.SelectCommand.Parameters.Add(name, tipo).Value = valor diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 66e6e4384..21eb83cd4 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4372,6 +4372,7 @@ Public Class ClsPaginas PaginaDict.Add("/GPS/Notificaciones.aspx".ToUpper(), -1) PaginaDict.Add("/GPS/Shipments.aspx".ToUpper(), 673) PaginaDict.Add("/GPS/RepGastos.aspx".ToUpper(), 685) + PaginaDict.Add("/GPS/RecursoConfiableTracking.aspx".ToUpper(), 692) #End Region 'INVENTARIOS diff --git a/App_WebReferences/RCGPSService/RCService.disco b/App_WebReferences/RCGPSService/RCService.disco new file mode 100644 index 000000000..fc35eddd5 --- /dev/null +++ b/App_WebReferences/RCGPSService/RCService.disco @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/App_WebReferences/RCGPSService/RCService.wsdl b/App_WebReferences/RCGPSService/RCService.wsdl new file mode 100644 index 000000000..e4de999c0 --- /dev/null +++ b/App_WebReferences/RCGPSService/RCService.wsdl @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/RCGPSService/RCService.xsd b/App_WebReferences/RCGPSService/RCService.xsd new file mode 100644 index 000000000..999d861b1 --- /dev/null +++ b/App_WebReferences/RCGPSService/RCService.xsd @@ -0,0 +1,21 @@ + + + + + + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/RCGPSService/RCService1.xsd b/App_WebReferences/RCGPSService/RCService1.xsd new file mode 100644 index 000000000..8e338436c --- /dev/null +++ b/App_WebReferences/RCGPSService/RCService1.xsd @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/RCGPSService/RCService2.xsd b/App_WebReferences/RCGPSService/RCService2.xsd new file mode 100644 index 000000000..0108d9eb2 --- /dev/null +++ b/App_WebReferences/RCGPSService/RCService2.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/RCGPSService/RCService3.xsd b/App_WebReferences/RCGPSService/RCService3.xsd new file mode 100644 index 000000000..32e1c19af --- /dev/null +++ b/App_WebReferences/RCGPSService/RCService3.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/RCGPSService/Reference.svcmap b/App_WebReferences/RCGPSService/Reference.svcmap new file mode 100644 index 000000000..fbaf7a130 --- /dev/null +++ b/App_WebReferences/RCGPSService/Reference.svcmap @@ -0,0 +1,35 @@ + + + + false + true + + false + false + false + + + true + Auto + true + true + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/RCGPSService/configuration.svcinfo b/App_WebReferences/RCGPSService/configuration.svcinfo new file mode 100644 index 000000000..e70db96fc --- /dev/null +++ b/App_WebReferences/RCGPSService/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/RCGPSService/configuration91.svcinfo b/App_WebReferences/RCGPSService/configuration91.svcinfo new file mode 100644 index 000000000..74eb6fcf0 --- /dev/null +++ b/App_WebReferences/RCGPSService/configuration91.svcinfo @@ -0,0 +1,201 @@ + + + + + + + BasicHttpBinding_IRCService + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + None + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (Collection) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + + + http://gps.rcontrol.com.mx/Tracking/wcf/RCService.svc + + + + + + basicHttpBinding + + + BasicHttpBinding_IRCService + + + RCGPSService.IRCService + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + BasicHttpBinding_IRCService + + + + + + + + + + + \ No newline at end of file diff --git a/Ashx/SIGGPSRCService.ashx b/Ashx/SIGGPSRCService.ashx new file mode 100644 index 000000000..fdf23c18b --- /dev/null +++ b/Ashx/SIGGPSRCService.ashx @@ -0,0 +1,162 @@ +<%@ WebHandler Language="C#" Class="SIGGPSRCService" %> + +using System; +using System.Web; +using System.Web.SessionState; +using System.Data; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Extensiones; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.IO; +using System.Net.Http; +using System.Text; + +public class SIGGPSRCService : IHttpHandler, IRequiresSessionState +{ + private Usuario ValidaUsuarioSistema(int CveEmpresa) + { + Usuario UsuarioActual = null; + ClsSisUsuarios ObjUsuarios = new ClsSisUsuarios(); + if (ObjUsuarios.GetUsuarios(1727)) + { + if (ObjUsuarios.DtResultados.Rows.Count > 0) + { + var Usuario = ObjUsuarios.DtResultados.Rows[0]["Usuario"].ToString(); + var Contrasenia = ObjUsuarios.DtResultados.Rows[0]["Contraseña"].ToString(); + + UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, ModExtensiones.IMEI, CveEmpresa); + + UsuarioActual.CveEmpresa = CveEmpresa; + UsuarioActual.CveCliente = 183798; + + CreaObjetoEmpresa(ref UsuarioActual); + CargaZonasHorarias(ref UsuarioActual); + } + } + ObjUsuarios.Dispose(); + return UsuarioActual; + } + private void CreaObjetoEmpresa(ref Usuario UsuarioActual) + { + ClsSisEmpresas ObjEmpresa = new ClsSisEmpresas(); + if (ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1")) + { + if (ObjEmpresa.GetEmpresasFuncionalidades(UsuarioActual.CveEmpresa)) + { + System.Data.DataTable dttmp = ObjEmpresa.DtResultados; + + var EmpresasFuncionalidades = new HybridDictionary(); + foreach (System.Data.DataRow Row in dttmp.Rows) + EmpresasFuncionalidades.Add(Convert.ToInt32(Row["CveFuncionalidad"]), Row["Valor"].ToString()); + + ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades); + } + + UsuarioActual.Empresa = ObjEmpresa.Empresa; + } + ObjEmpresa.Dispose(); + } + private void CargaZonasHorarias(ref Usuario UsuarioActual) + { + ClsClientes ObjClientes = new ClsClientes(); + try + { + if (ObjClientes.GetClientes(UsuarioActual.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1, Estatus: 1)) + { + if (ObjClientes.DtResultados.Rows.Count == 1) + UsuarioActual.UTCOffset = ObjClientes.DtResultados.Rows[0]["UTCOffset"].ToString().ToEntero(); + } + } + catch (Exception ex) + { + ex.ToString().GuardaLog(); + } + finally + { + ObjClientes.Dispose(); + } + } + + public bool IsReusable => false; + + public void ProcessRequest(HttpContext context) + { + try + { + context.Response.ContentType = "application/json"; + IniciarTransmision(context); + } + catch (Exception ex) + { + ex.GuardaLog(ex.Message); + } + } + + private void IniciarTransmision(HttpContext context) + { + var UsuarioActual = ValidaUsuarioSistema(121); + + var WS = new RCGPSService.RCServiceClient(); + + RCGPSService.UserTokenResult Token = WS.GetUserToken(UserService, PasswordService); + List ListaEventos = new List(); + + DataTable DtTrackings = null; + var ObjGPS = new ClsGPS(); + try + { + if (ObjGPS.GetRCTracking(-1, -1, 1, -1, -1)) + { + DtTrackings = ObjGPS.DtResultados.Copy(); + } + + if (DtTrackings != null) + { + foreach (DataRow RowTrack in DtTrackings.Rows) + { + DataTable dtTracking = null; + if (ObjGPS.GetRCTrackingDatos(RowTrack["CveRCTracking"].ToString().ToEntero())) + { + dtTracking = ObjGPS.DtResultados.Copy(); + } + if (dtTracking != null) + { + foreach (DataRow Row in dtTracking.Rows) + { + ListaEventos.Add(new RCGPSService.Event() + { + code = "STT", + date = Row["Fecha"].ToString().ToDateTime(), + latitude = Row["Latitud"].ToString(), + longitude = Row["Longitud"].ToString(), + asset = Row["PlacasVehiculo"].ToString(), + speed = Row["Velocidad"].ToString(), + shipment = Row["Shipment"].ToString() + }); + } + } + dtTracking.Dispose(); + dtTracking = null; + } + } + } + catch (Exception ex) + { + this.OnError("Ocurrió un error al enviar los datos", ex); + } + ObjGPS.Dispose(); + DtTrackings.Dispose(); + DtTrackings = null; + + var respuesta = WS.GPSAssetTracking(Token.token, ListaEventos.ToArray()); + + WS.Close(); + context.Response.Write(JsonConvert.SerializeObject(respuesta)); + + } + + private string UserService => "demo_cedis_corp"; + private string PasswordService => "xxxxxxxx"; +} \ No newline at end of file diff --git a/GPS/RecursoConfiableTracking.aspx b/GPS/RecursoConfiableTracking.aspx new file mode 100644 index 000000000..2326002ed --- /dev/null +++ b/GPS/RecursoConfiableTracking.aspx @@ -0,0 +1,153 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RecursoConfiableTracking.aspx.vb" Inherits="GPS_RecursoConfiableTracking" %> + + + + + + + Recurso Confiable con Prestadores AVL + + + + + + +
  • + +
  • +
    +
    +
    + + + + + +
    +
    +
    + +
    +
    +
      +
    • Vehículo: + + +
    • +
    • Estatus: + + + + + +
    • +
    • Fecha Inicio: +
      + +
      +
    • +
    • Fecha Fin: +
      + +
      +
    • +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + +
    + + + diff --git a/GPS/RecursoConfiableTracking.aspx.vb b/GPS/RecursoConfiableTracking.aspx.vb new file mode 100644 index 000000000..7faaaf405 --- /dev/null +++ b/GPS/RecursoConfiableTracking.aspx.vb @@ -0,0 +1,119 @@ +Option Strict On +Option Explicit On + +Imports System.Data +Imports System.IO +Imports System.Net +Imports Extensiones +Imports Microsoft.Reporting.WebForms +Imports Newtonsoft.Json.Linq +Imports System.Linq +Imports System.Net.Http + +Partial Class GPS_RecursoConfiableTracking + Inherits ClsPaginas + + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + If Not Page.IsPostBack Then + CargaDatos() + End If + End Sub + Private Sub CargaDatos() + CargaDispositivos() + CargaTracking() + End Sub + + Public Sub CargaDispositivos() + + DdlDispositivoFiltro.DataSource = GlobalDTDispositivosUsuarios(UsuarioActual.CveCliente, UsuarioActual.CveUsuario) + DdlDispositivoFiltro.DataBind() + DdlDispositivoFiltro.Items.Insert(0, New ListItem("Todos", "-1")) + + DdlDispositivo.DataSource = GlobalDTDispositivosUsuarios(UsuarioActual.CveCliente, UsuarioActual.CveUsuario).FiltraParametros("PlacasVehiculo <> ''") + DdlDispositivo.DataBind() + DdlDispositivo.Items.Insert(0, New ListItem("Seleccione", "-1")) + + UpAgregar.Update() + End Sub + Private Sub CargaTracking() + Dim FechaI As DateTime = If(IsDate(txtFechaI.Text), txtFechaI.Text.ToDateTime(), MinFecha) + Dim FechaF As DateTime = If(IsDate(txtFechaF.Text), txtFechaF.Text.ToDateTime(), MaxFecha) + + Dim ObjGPS As New ClsGPS + If ObjGPS.GetRCTracking(-1, DdlDispositivoFiltro.SelectedValue.ToEntero(), DdlEstatus.SelectedValue.ToEntero(), UsuarioActual.CveCliente, UsuarioActual.CveEmpresa, FechaI, FechaF) Then + GvDatos.DataSource = ObjGPS.DtResultados + End If + ObjGPS.Dispose() + GvDatos.DataBind() + UpDatos.Update() + End Sub + + Protected Sub LnkAgregarTracking_Click(sender As Object, e As EventArgs) + RegistraScript("$('#DivAgregar').modal('show');") + End Sub + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + CargaTracking() + End Sub + Protected Sub LnkCambiarEstatus_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + Dim CveRCTracking As Integer = GvRow.DataKey("CveRCTracking").ToEntero() + Dim Estatus As Boolean = CBool(GvRow.DataKey("CveEstatus").ToEntero()) + + Dim ObjGPS As New ClsGPS + If ObjGPS.UpdateRCTrackingEstatus(CveRCTracking, Not Estatus, UsuarioActual.CveUsuario) Then + Alert("El tracking fue desactivado correctamente") + Else + Alert("Ocurrió un error al actualizar el estatus", TipoMensaje.MsgError) + End If + ObjGPS.Dispose() + + CargaDatos() + End Sub + Protected Sub GvDatos_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) + + End Sub + Protected Sub BtnAgregar_Click(sender As Object, e As EventArgs) + Dim Nombre As String = TxtNombre.Text.Trim() + Dim CveDispositivo As Integer = DdlDispositivo.SelectedValue.ToEntero() + Dim Shipment As String = TxtShipment.Text.Trim() + + Dim ObjGPS As New ClsGPS + Dim CveRCTracking As Integer = ObjGPS.AddRCTracking(Nombre, CveDispositivo, Shipment, UsuarioActual.CveUsuario, UsuarioActual.CveCliente, UsuarioActual.CveEmpresa) + If CveRCTracking > 0 Then + Alert("El tracking fue agregado correctamente") + Else + Alert("Ocurrió un error el tracking", TipoMensaje.MsgError) + End If + ObjGPS.Dispose() + + CargaDatos() + RegistraScript("$('#DivAgregar').modal('hide');") + End Sub + + Protected Sub DdlDispositivo_SelectedIndexChanged(sender As Object, e As EventArgs) + Dim CveDispositivo As Integer = DdlDispositivo.SelectedValue.ToEntero() + + Dim RowDispositivo As DataRow = GlobalDTDispositivosUsuarios(UsuarioActual.CveCliente, UsuarioActual.CveUsuario).FiltroPrimero($"CveDispositivo = {CveDispositivo}") + + If RowDispositivo IsNot Nothing Then + If String.IsNullOrEmpty(RowDispositivo("PlacasVehiculo").ToString()) Then + Alert("El vehiculo no tiene placas asignadas", TipoMensaje.MsgAdvertencia) + BtnAgregar.Enabled = False + Else + BtnAgregar.Enabled = True + End If + End If + UpAgregar.Update() + End Sub + Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CveEstatus") = "1" Then + e.Row.FCLabel("LblEstatus").CssClass = "badge badge-success" + ElseIf e.Row.DBCampo("CveEstatus") = "0" Then + e.Row.FCLabel("LblEstatus").CssClass = "badge badge-secondary" + End If + End If + End Sub +End Class