Direcciones en historico app gps
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<%@ WebService Language="VB" Class="WSGPSApp" %>
|
||||
<%@ WebService Language="VB" Class="WSGPSApp" %>
|
||||
Option Strict On
|
||||
|
||||
Imports System.Web
|
||||
@@ -13,6 +13,7 @@ Imports System.Web.Script.Services
|
||||
Imports System.Web.Script.Serialization
|
||||
Imports ADGPSModels
|
||||
Imports System.IO
|
||||
Imports System.Net.Http
|
||||
|
||||
|
||||
Public Class AuthHeader
|
||||
@@ -30,8 +31,8 @@ Public Class WSGPSApp
|
||||
Inherits System.Web.Services.WebService
|
||||
|
||||
Private Const LongValue As Long = &H100000000
|
||||
Public Property Credentials As AuthHeader
|
||||
|
||||
Public Property Credentials As AuthHeader
|
||||
|
||||
#Region "G L O B A L S"
|
||||
Property GlobalDTDispositivos(CveCliente As Integer) As DataTable
|
||||
Get
|
||||
@@ -89,7 +90,7 @@ Public Class WSGPSApp
|
||||
Set(value As DataTable)
|
||||
Application("GlobalDTDispositivosUsuarios") = value
|
||||
End Set
|
||||
End Property
|
||||
End Property
|
||||
#End Region
|
||||
Private Sub CreaObjetoEmpresa(ByRef UsuarioActual As Usuario)
|
||||
|
||||
@@ -162,11 +163,11 @@ Public Class WSGPSApp
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
'MARCA PARA EL RASTREO SOLO INICIO
|
||||
If UsuarioRetorno.CveUsuario = 3612 Then
|
||||
UsuarioRetorno.RastreoSoloInicio = True
|
||||
End If
|
||||
|
||||
'MARCA PARA EL RASTREO SOLO INICIO
|
||||
If UsuarioRetorno.CveUsuario = 3612 Then
|
||||
UsuarioRetorno.RastreoSoloInicio = True
|
||||
End If
|
||||
|
||||
UsuarioRetorno.Clientes = Clientes
|
||||
@@ -239,11 +240,11 @@ Public Class WSGPSApp
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
'MARCA PARA EL RASTREO SOLO INICIO
|
||||
If UsuarioRetorno.CveUsuario = 3612 Then
|
||||
UsuarioRetorno.RastreoSoloInicio = True
|
||||
End If
|
||||
|
||||
'MARCA PARA EL RASTREO SOLO INICIO
|
||||
If UsuarioRetorno.CveUsuario = 3612 Then
|
||||
UsuarioRetorno.RastreoSoloInicio = True
|
||||
End If
|
||||
|
||||
UsuarioRetorno.Clientes = Clientes
|
||||
@@ -660,7 +661,6 @@ Public Class WSGPSApp
|
||||
<WebMethod>
|
||||
Public Function GetHistoricoPosicionesEquipo(params As String) As String
|
||||
Dim Retorno As String = ""
|
||||
Dim ObjGPS As New ClsGPS()
|
||||
Try
|
||||
Dim Estructura = New With
|
||||
{
|
||||
@@ -671,27 +671,140 @@ Public Class WSGPSApp
|
||||
}
|
||||
Dim jsonParams As String = Decripta(params)
|
||||
Dim parametros = JsonConvert.DeserializeAnonymousType(jsonParams, Estructura)
|
||||
|
||||
Dim FechaI As DateTime = StartOfDay(parametros.FechaI)
|
||||
Dim FechaF As DateTime = EndOfDay(parametros.FechaF)
|
||||
|
||||
Dim coords As New List(Of MWSGeolocation2)
|
||||
If ObjGPS.GetPosicionEquipo(parametros.CveDispositivo, parametros.FechaI, parametros.FechaF) Then
|
||||
If ObjGPS.DtResultados.Rows.Count > 0 Then
|
||||
For Each Row As DataRow In ObjGPS.DtResultados.Rows
|
||||
Dim Coord As MWSGeolocation2 = SQLToGmaps(Row("Posicion").ToString, "POINT")
|
||||
Coord.FechaTrama = Row("FechaTrama").ToString
|
||||
coords.Add(Coord)
|
||||
Next
|
||||
Dim DtRetorno As DataTable = Nothing
|
||||
|
||||
Using ObjGPS As New ClsGPS()
|
||||
If ObjGPS.GetPosicionEquipo(parametros.CveDispositivo, FechaI, FechaF) Then
|
||||
DtRetorno = ObjGPS.DtResultados.Copy()
|
||||
End If
|
||||
End Using
|
||||
|
||||
If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then
|
||||
|
||||
Dim Direcciones As JArray = ConsultarDirecciones(DtRetorno)
|
||||
|
||||
For Each Dir As JObject In Direcciones
|
||||
DtRetorno.Rows(Dir("Indice").ToEntero())("Direccion") = Dir("Direccion").ToString()
|
||||
Next
|
||||
|
||||
For Each Row As DataRow In DtRetorno.Rows
|
||||
Dim Coord As MWSGeolocation2 = SQLToGmaps(Row("Posicion").ToString, "POINT")
|
||||
Coord.Velocidad = Row("Velocidad").ToString().ToDouble().RoundSQL(0)
|
||||
Coord.FechaTrama = Row("FechaTrama").ToString
|
||||
Coord.Direccion = Row("Direccion").ToString
|
||||
Coord.Combustible = Row("Combustible").ToString().ToDouble().RoundSQL(2)
|
||||
coords.Add(Coord)
|
||||
Next
|
||||
End If
|
||||
|
||||
If coords.Count > 0 Then
|
||||
Retorno = JsonConvert.SerializeObject(coords)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrio un error al obtener las posiciones historicas de un dispositivo.", ex)
|
||||
Finally
|
||||
ObjGPS.Dispose()
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
<WebMethod>
|
||||
Public Function GetHistoricoPosicionesEquipo2(params As String) As String
|
||||
Dim Retorno As String = ""
|
||||
Try
|
||||
Dim Estructura = New With
|
||||
{
|
||||
Key .[CveDispositivo] = -1,
|
||||
Key .[FechaI] = DateTime.Now,
|
||||
Key .[FechaF] = DateTime.Now,
|
||||
Key .[Ticks] = ""
|
||||
}
|
||||
Dim jsonParams As String = Decripta(params)
|
||||
Dim parametros = JsonConvert.DeserializeAnonymousType(jsonParams, Estructura)
|
||||
|
||||
Dim FechaI As DateTime = parametros.FechaI
|
||||
Dim FechaF As DateTime = parametros.FechaF
|
||||
|
||||
Dim coords As New List(Of MWSGeolocation2)
|
||||
Dim DtRetorno As DataTable = Nothing
|
||||
|
||||
Using ObjGPS As New ClsGPS()
|
||||
If ObjGPS.GetPosicionEquipo(parametros.CveDispositivo, FechaI, FechaF) Then
|
||||
DtRetorno = ObjGPS.DtResultados.Copy()
|
||||
End If
|
||||
End Using
|
||||
|
||||
If DtRetorno IsNot Nothing AndAlso DtRetorno.Rows.Count > 0 Then
|
||||
|
||||
Dim Direcciones As JArray = ConsultarDirecciones(DtRetorno)
|
||||
|
||||
For Each Dir As JObject In Direcciones
|
||||
DtRetorno.Rows(Dir("Indice").ToEntero())("Direccion") = Dir("Direccion").ToString()
|
||||
Next
|
||||
|
||||
For Each Row As DataRow In DtRetorno.Rows
|
||||
Dim Coord As MWSGeolocation2 = SQLToGmaps(Row("Posicion").ToString, "POINT")
|
||||
Coord.Velocidad = Row("Velocidad").ToString().ToDouble().RoundSQL(0)
|
||||
Coord.FechaTrama = Row("FechaTrama").ToString
|
||||
Coord.Direccion = Row("Direccion").ToString
|
||||
Coord.Combustible = Row("Combustible").ToString().ToDouble().RoundSQL(2)
|
||||
coords.Add(Coord)
|
||||
Next
|
||||
End If
|
||||
|
||||
If coords.Count > 0 Then
|
||||
Retorno = JsonConvert.SerializeObject(coords)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrio un error al obtener las posiciones historicas de un dispositivo.", ex)
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Public Function ConsultarDirecciones(Dt As DataTable) As JArray
|
||||
Dim retorno As JArray = Nothing
|
||||
Dim posicionesArray = New JArray(From Row As DataRow In Dt
|
||||
Select New JObject(
|
||||
New JProperty("indice", Dt.Rows().IndexOf(Row)),
|
||||
New JProperty("cveTrama", -1),
|
||||
New JProperty("lat", Row("lat").ToString()),
|
||||
New JProperty("lon", Row("lon").ToString())
|
||||
))
|
||||
|
||||
Dim Base64array = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(posicionesArray.ToString()))
|
||||
|
||||
Using wc As New HttpClient()
|
||||
Try
|
||||
wc.Timeout = New TimeSpan(0, 0, 15)
|
||||
Dim Url = New Uri(String.Format("{0}nominatim/reverseMultiple.php", ClsPaginas.UrlDirecciones))
|
||||
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)
|
||||
response.Dispose()
|
||||
content = Nothing
|
||||
Url = Nothing
|
||||
FormStuff = Nothing
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al obtener las direcciones", ex)
|
||||
End Try
|
||||
End Using
|
||||
Return retorno
|
||||
End Function
|
||||
|
||||
Public Function EndOfDay(ByVal fecha As DateTime) As DateTime
|
||||
Return New DateTime(fecha.Year, fecha.Month, fecha.Day, 23, 59, 59, 999)
|
||||
End Function
|
||||
|
||||
Public Function StartOfDay(ByVal fecha As DateTime) As DateTime
|
||||
Return New DateTime(fecha.Year, fecha.Month, fecha.Day, 0, 0, 0, 0)
|
||||
End Function
|
||||
<WebMethod>
|
||||
Public Function GetEquipoMasCercano(params As String) As String
|
||||
Dim json = "[]"
|
||||
@@ -1035,8 +1148,8 @@ Public Class WSGPSApp
|
||||
|
||||
Return Retorno
|
||||
|
||||
End Function
|
||||
|
||||
End Function
|
||||
|
||||
#Region "F U N C I O N E S"
|
||||
Private Function CargarEventos(CveCliente As Integer, FechaI As DateTime, FechaF As DateTime) As MWSDashboard2
|
||||
Dim ObjGPS As New ClsGPS
|
||||
@@ -1145,7 +1258,7 @@ Public Class WSGPSApp
|
||||
OnError("Acceso no autorizado", New SoapException("Unauthorized", SoapException.ClientFaultCode))
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
End Function
|
||||
#End Region
|
||||
End Class
|
||||
Namespace ADGPSModels
|
||||
@@ -1193,6 +1306,8 @@ Namespace ADGPSModels
|
||||
Public Property Longitud As Double
|
||||
Public Property FechaTrama As String
|
||||
Public Property Velocidad As Double
|
||||
Public Property Combustible As Double
|
||||
Public Property Direccion As String
|
||||
End Class
|
||||
<Serializable>
|
||||
Public Class MPosicion2
|
||||
|
||||
Reference in New Issue
Block a user