Direcciones en historico app gps
This commit is contained in:
@@ -13,6 +13,7 @@ Imports System.Web.Script.Services
|
|||||||
Imports System.Web.Script.Serialization
|
Imports System.Web.Script.Serialization
|
||||||
Imports ADGPSModels
|
Imports ADGPSModels
|
||||||
Imports System.IO
|
Imports System.IO
|
||||||
|
Imports System.Net.Http
|
||||||
|
|
||||||
|
|
||||||
Public Class AuthHeader
|
Public Class AuthHeader
|
||||||
@@ -660,7 +661,6 @@ Public Class WSGPSApp
|
|||||||
<WebMethod>
|
<WebMethod>
|
||||||
Public Function GetHistoricoPosicionesEquipo(params As String) As String
|
Public Function GetHistoricoPosicionesEquipo(params As String) As String
|
||||||
Dim Retorno As String = ""
|
Dim Retorno As String = ""
|
||||||
Dim ObjGPS As New ClsGPS()
|
|
||||||
Try
|
Try
|
||||||
Dim Estructura = New With
|
Dim Estructura = New With
|
||||||
{
|
{
|
||||||
@@ -671,27 +671,140 @@ Public Class WSGPSApp
|
|||||||
}
|
}
|
||||||
Dim jsonParams As String = Decripta(params)
|
Dim jsonParams As String = Decripta(params)
|
||||||
Dim parametros = JsonConvert.DeserializeAnonymousType(jsonParams, Estructura)
|
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)
|
Dim coords As New List(Of MWSGeolocation2)
|
||||||
If ObjGPS.GetPosicionEquipo(parametros.CveDispositivo, parametros.FechaI, parametros.FechaF) Then
|
Dim DtRetorno As DataTable = Nothing
|
||||||
If ObjGPS.DtResultados.Rows.Count > 0 Then
|
|
||||||
For Each Row As DataRow In ObjGPS.DtResultados.Rows
|
Using ObjGPS As New ClsGPS()
|
||||||
Dim Coord As MWSGeolocation2 = SQLToGmaps(Row("Posicion").ToString, "POINT")
|
If ObjGPS.GetPosicionEquipo(parametros.CveDispositivo, FechaI, FechaF) Then
|
||||||
Coord.FechaTrama = Row("FechaTrama").ToString
|
DtRetorno = ObjGPS.DtResultados.Copy()
|
||||||
coords.Add(Coord)
|
|
||||||
Next
|
|
||||||
End If
|
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
|
End If
|
||||||
|
|
||||||
If coords.Count > 0 Then
|
If coords.Count > 0 Then
|
||||||
Retorno = JsonConvert.SerializeObject(coords)
|
Retorno = JsonConvert.SerializeObject(coords)
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
OnError("Ocurrio un error al obtener las posiciones historicas de un dispositivo.", ex)
|
OnError("Ocurrio un error al obtener las posiciones historicas de un dispositivo.", ex)
|
||||||
Finally
|
|
||||||
ObjGPS.Dispose()
|
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
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>
|
<WebMethod>
|
||||||
Public Function GetEquipoMasCercano(params As String) As String
|
Public Function GetEquipoMasCercano(params As String) As String
|
||||||
Dim json = "[]"
|
Dim json = "[]"
|
||||||
@@ -1193,6 +1306,8 @@ Namespace ADGPSModels
|
|||||||
Public Property Longitud As Double
|
Public Property Longitud As Double
|
||||||
Public Property FechaTrama As String
|
Public Property FechaTrama As String
|
||||||
Public Property Velocidad As Double
|
Public Property Velocidad As Double
|
||||||
|
Public Property Combustible As Double
|
||||||
|
Public Property Direccion As String
|
||||||
End Class
|
End Class
|
||||||
<Serializable>
|
<Serializable>
|
||||||
Public Class MPosicion2
|
Public Class MPosicion2
|
||||||
|
|||||||
Reference in New Issue
Block a user