Concepto de NC E140
This commit is contained in:
125
Ashx/E141.ashx
125
Ashx/E141.ashx
@@ -47,6 +47,25 @@ Public Class E141 : Implements IHttpHandler
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property TokenAutorizacion As String
|
||||
Get
|
||||
If EsProduccion Then
|
||||
Return "$2y$10$AGCCDbEoGEpd0ys89fuBXedtWlunwUeLRlo4MdeLyxDvJF4GwpL7a"
|
||||
Else
|
||||
Return "$2y$10$8Mk3YeIkJESilIwD.U5dG.SsA4JloycJKbaGls8TNEw/AKBE1qane"
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property URLBase As String
|
||||
Get
|
||||
If EsProduccion Then
|
||||
Return "https://services.fidelityapps.mx/"
|
||||
Else
|
||||
Return "https://econollantas-pruebas.fidelityapps.mx/"
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
||||
context.Response.ContentType = "application/json"
|
||||
@@ -66,20 +85,22 @@ Public Class E141 : Implements IHttpHandler
|
||||
|
||||
Dim Metodo = If(context.Request("Metodo") = Nothing, "", context.Request("Metodo").ToString())
|
||||
|
||||
Dim FiltrarTodos = If(context.Request("FiltrarTodos") = Nothing, "", context.Request("FiltrarTodos").ToString())
|
||||
|
||||
If Metodo = "CrearActualizarProductos" Then
|
||||
retorno = CrearActualizarProductos()
|
||||
retorno = CrearActualizarProductos(If(FiltrarTodos = "1", True, False))
|
||||
End If
|
||||
|
||||
If Metodo = "ActualizarPrecios" Then
|
||||
retorno = ActualizarPrecios()
|
||||
retorno = ActualizarPrecios(If(FiltrarTodos = "1", True, False))
|
||||
End If
|
||||
|
||||
If Metodo = "ActualizarExistencias" Then
|
||||
retorno = ActualizarExistencias()
|
||||
retorno = ActualizarExistencias(If(FiltrarTodos = "1", True, False))
|
||||
End If
|
||||
|
||||
If Metodo = "ActualizarVendedores" Then
|
||||
retorno = ActualizarVendedores()
|
||||
retorno = ActualizarVendedores(If(FiltrarTodos = "1", True, False))
|
||||
End If
|
||||
|
||||
If Metodo = "GetExistencia" Then
|
||||
@@ -162,7 +183,7 @@ Public Class E141 : Implements IHttpHandler
|
||||
Try
|
||||
Using httpClient = New HttpClient()
|
||||
Using request = New HttpRequestMessage(HttpMethod.Post, New Uri(url))
|
||||
request.Headers.Add("token", "$2y$10$LGqtRWUloKQmAt.jcUldc.PmS5LJ6l.WU2w1G4PBOTLMVKZRNQFPS")
|
||||
request.Headers.Add("token", TokenAutorizacion)
|
||||
|
||||
Using content = New StringContent(payload, Encoding.UTF8, "application/json")
|
||||
request.Content = content
|
||||
@@ -184,63 +205,45 @@ Public Class E141 : Implements IHttpHandler
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Private Function EnviarInformacion2(url As String, payload As String) As String
|
||||
Dim Retorno As String = "{}"
|
||||
Try
|
||||
Dim Request As WebRequest = WebRequest.Create(url)
|
||||
Request.Method = "post"
|
||||
Request.ContentType = "application/json"
|
||||
Request.Headers.Add("token", "$2y$10$LGqtRWUloKQmAt.jcUldc.PmS5LJ6l.WU2w1G4PBOTLMVKZRNQFPS")
|
||||
'Private Function EnviarInformacion2(url As String, payload As String) As String
|
||||
' Dim Retorno As String = "{}"
|
||||
' Try
|
||||
' Dim Request As WebRequest = WebRequest.Create(url)
|
||||
' Request.Method = "post"
|
||||
' Request.ContentType = "application/json"
|
||||
' Request.Headers.Add("token", TokenAutorizacion)
|
||||
|
||||
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(payload)
|
||||
Request.ContentLength = byteArray.Length
|
||||
' Dim byteArray As Byte() = Encoding.UTF8.GetBytes(payload)
|
||||
' Request.ContentLength = byteArray.Length
|
||||
|
||||
Using dataStream As Stream = Request.GetRequestStream()
|
||||
dataStream.Write(byteArray, 0, byteArray.Length)
|
||||
Using tResponse As WebResponse = Request.GetResponse()
|
||||
Using dataStreamResponse As Stream = tResponse.GetResponseStream()
|
||||
Using tReader As New StreamReader(dataStreamResponse)
|
||||
Retorno = tReader.ReadToEnd()
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
Retorno = New JObject(New JProperty("Error", ex.ToString())).ToString()
|
||||
OnError("Ocurrió un error al enviar la informacion", ex)
|
||||
End Try
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
' var httpWebRequest = (httpWebRequest)WebRequest.Create("http://url");
|
||||
'httpWebRequest.ContentType = "application/json";
|
||||
'httpWebRequest.Method = "POST";
|
||||
|
||||
'Using (var streamWriter = New StreamWriter(httpWebRequest.GetRequestStream()))
|
||||
'{
|
||||
' String json = "{\"user\":\"test\"," +
|
||||
' "\"password\":\"bla\"}";
|
||||
|
||||
' streamWriter.Write(json);
|
||||
'}
|
||||
|
||||
'var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
|
||||
'Using (var streamReader = New StreamReader(httpResponse.GetResponseStream()))
|
||||
'{
|
||||
' var result = StreamReader.ReadToEnd();
|
||||
'}
|
||||
' Using dataStream As Stream = Request.GetRequestStream()
|
||||
' dataStream.Write(byteArray, 0, byteArray.Length)
|
||||
' Using tResponse As WebResponse = Request.GetResponse()
|
||||
' Using dataStreamResponse As Stream = tResponse.GetResponseStream()
|
||||
' Using tReader As New StreamReader(dataStreamResponse)
|
||||
' Retorno = tReader.ReadToEnd()
|
||||
' End Using
|
||||
' End Using
|
||||
' End Using
|
||||
' End Using
|
||||
' Catch ex As Exception
|
||||
' Retorno = New JObject(New JProperty("Error", ex.ToString())).ToString()
|
||||
' OnError("Ocurrió un error al enviar la informacion", ex)
|
||||
' End Try
|
||||
' Return Retorno
|
||||
'End Function
|
||||
#Region "C R E A C I Ó N / A C T U A L I Z A C I Ó N - P R O D U C T O S"
|
||||
Private Function CrearActualizarProductos() As String
|
||||
Return EnviarInformacion("https://services.fidelityapps.mx/api/services/products/import", GetProductosModificados())
|
||||
Private Function CrearActualizarProductos(Todos As Boolean) As String
|
||||
Return EnviarInformacion($"{Me.URLBase}api/services/products/import", GetProductosModificados(Todos))
|
||||
End Function
|
||||
|
||||
Private Function GetProductosModificados() As String
|
||||
Private Function GetProductosModificados(Todos As Boolean) As String
|
||||
Dim Retorno As String = "{}"
|
||||
|
||||
Dim DtPS As DataTable = Nothing
|
||||
Using ObjPS As New ClsProductosServicios
|
||||
'OBTERNER PRECIOS DE PUBLICO GENERAL
|
||||
If ObjPS.GetProductosModificados(CveEmpresa, 44) Then
|
||||
If ObjPS.GetProductosModificados(CveEmpresa, 44, If(Todos, -1, 1)) Then
|
||||
DtPS = ObjPS.DtResultados.Copy()
|
||||
End If
|
||||
End Using
|
||||
@@ -294,17 +297,17 @@ Public Class E141 : Implements IHttpHandler
|
||||
|
||||
#Region "A C T U A L I Z A R - P R E C I O S"
|
||||
|
||||
Private Function ActualizarPrecios() As String
|
||||
Return EnviarInformacion("https://services.fidelityapps.mx/api/services/products/price-import", GetPreciosModificados())
|
||||
Private Function ActualizarPrecios(Todos As Boolean) As String
|
||||
Return EnviarInformacion($"{Me.URLBase}api/services/products/price-import", GetPreciosModificados(Todos))
|
||||
End Function
|
||||
|
||||
Private Function GetPreciosModificados() As String
|
||||
Private Function GetPreciosModificados(Todos As Boolean) As String
|
||||
Dim Retorno As String = "{}"
|
||||
|
||||
Dim DtPS As DataTable = Nothing
|
||||
Using ObjPS As New ClsProductosServicios
|
||||
'OBTERNER PRECIOS DE PUBLICO GENERAL
|
||||
If ObjPS.GetPreciosModificados(CveEmpresa, 44) Then
|
||||
If ObjPS.GetPreciosModificados(CveEmpresa, 44, If(Todos, -1, 1)) Then
|
||||
DtPS = ObjPS.DtResultados.Copy()
|
||||
End If
|
||||
End Using
|
||||
@@ -332,7 +335,7 @@ Public Class E141 : Implements IHttpHandler
|
||||
#Region "A C T U A L I Z A R - E X I S T E N C I A S"
|
||||
|
||||
Private Function ActualizarExistencias() As String
|
||||
Return EnviarInformacion("https://services.fidelityapps.mx/api/services/products/stock", GetPSExistencias())
|
||||
Return EnviarInformacion($"{Me.URLBase}api/services/products/stock", GetPSExistencias())
|
||||
End Function
|
||||
|
||||
Private Function GetPSExistencias() As String
|
||||
@@ -369,17 +372,17 @@ Public Class E141 : Implements IHttpHandler
|
||||
|
||||
#Region "A C T U A L I Z A R - E X I S T E N C I A S"
|
||||
|
||||
Private Function ActualizarVendedores() As String
|
||||
Return EnviarInformacion("https://services.fidelityapps.mx/api/v1/sellers/import", GetVendedores())
|
||||
Private Function ActualizarVendedores(Todos As Boolean) As String
|
||||
Return EnviarInformacion($"{Me.URLBase}api/v1/sellers/import", GetVendedores(Todos))
|
||||
End Function
|
||||
|
||||
Private Function GetVendedores() As String
|
||||
Private Function GetVendedores(Todos As Boolean) As String
|
||||
Dim Retorno As String = "{}"
|
||||
|
||||
Dim DtVendedores As DataTable = Nothing
|
||||
Using ObjPS As New ClsProductosServicios
|
||||
'OBTERNER PRECIOS DE PUBLICO GENERAL
|
||||
If ObjPS.GetVendedoresModificados(CveEmpresa) Then
|
||||
If ObjPS.GetVendedoresModificados(CveEmpresa, If(Todos, -1, 1)) Then
|
||||
DtVendedores = ObjPS.DtResultados.Copy()
|
||||
End If
|
||||
End Using
|
||||
|
||||
Reference in New Issue
Block a user