--Metodo para obtener productos en API JAM
This commit is contained in:
@@ -5984,6 +5984,25 @@ Public Class ClsInventarios
|
|||||||
Return Retorno
|
Return Retorno
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function GetJAM_APIs(Optional Opcion As Integer = 1) As Boolean
|
||||||
|
Dim Retorno As Boolean = False
|
||||||
|
Dataset = New DataSet()
|
||||||
|
DataAdapter("PA_JAM_APIs")
|
||||||
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
|
.Add("@Opcion", SqlDbType.Int).Value = Opcion
|
||||||
|
End With
|
||||||
|
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
Retorno = True
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al obtener los productos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return Retorno
|
||||||
|
|
||||||
|
End Function
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,17 +47,6 @@ Public Class E119 : Implements IHttpHandler
|
|||||||
End If
|
End If
|
||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
Public ReadOnly Property TokenAutorizacion As String
|
|
||||||
Get
|
|
||||||
Return "$2y$10$LGqtRWUloKQmAt.jcUldc.PmS5LJ6l.WU2w1G4PBOTLMVKZRNQFPS"
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
|
|
||||||
Public ReadOnly Property URLBase As String
|
|
||||||
Get
|
|
||||||
Return "https://services.fidelityapps.mx/"
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
|
|
||||||
|
|
||||||
#Region "V A L I D A - D A T O S"
|
#Region "V A L I D A - D A T O S"
|
||||||
@@ -99,19 +88,31 @@ Public Class E119 : Implements IHttpHandler
|
|||||||
Dim retorno As String = ""
|
Dim retorno As String = ""
|
||||||
Try
|
Try
|
||||||
Dim Metodo = If(context.Request("Metodo") = Nothing, "", context.Request("Metodo").ToString())
|
Dim Metodo = If(context.Request("Metodo") = Nothing, "", context.Request("Metodo").ToString())
|
||||||
'OBTENER EXISTENCIAS
|
|
||||||
'If Metodo = "BASF_POG40" Then
|
|
||||||
' context.Response.ContentType = "application/json"
|
|
||||||
' Dim Auth = ValidarSolicitud(context)
|
|
||||||
|
|
||||||
' If Auth.IsSucces Then
|
If Metodo = "BASF_POG40" Then
|
||||||
' retorno = ConsultaDatos(context)
|
context.Response.ContentType = "application/json"
|
||||||
' Else
|
Dim Auth = ValidarSolicitud(context)
|
||||||
' context.Response.StatusCode = Auth.StatusCode
|
|
||||||
' retorno = JsonConvert.SerializeObject(Auth.ErrorMessage)
|
|
||||||
' End If
|
|
||||||
|
|
||||||
'End If
|
If Auth.IsSucces Then
|
||||||
|
retorno = ConsultaDatos(context)
|
||||||
|
Else
|
||||||
|
context.Response.StatusCode = Auth.StatusCode
|
||||||
|
retorno = JsonConvert.SerializeObject(Auth.ErrorMessage)
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Metodo = "ConsultarProductos" Then
|
||||||
|
context.Response.ContentType = "application/json"
|
||||||
|
Dim Auth = ValidarSolicitud(context)
|
||||||
|
|
||||||
|
If Auth.IsSucces Then
|
||||||
|
retorno = ConsultaProductos(context)
|
||||||
|
Else
|
||||||
|
context.Response.StatusCode = Auth.StatusCode
|
||||||
|
retorno = JsonConvert.SerializeObject(Auth.ErrorMessage)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
context.Response.Write(retorno)
|
context.Response.Write(retorno)
|
||||||
|
|
||||||
@@ -220,6 +221,41 @@ Public Class E119 : Implements IHttpHandler
|
|||||||
End If
|
End If
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Private Function ConsultaProductos(ByVal context As HttpContext) As String
|
||||||
|
Dim Respuesta As New ResponseMsg
|
||||||
|
Dim RespuestaError As New ResponseMsgError
|
||||||
|
Dim TieneError As Boolean = False
|
||||||
|
|
||||||
|
Dim Productos As JArray = Nothing
|
||||||
|
|
||||||
|
Using ObjInventario As New ClsInventarios
|
||||||
|
If ObjInventario.GetJAM_APIs(1) AndAlso ObjInventario.DtResultados IsNot Nothing Then
|
||||||
|
Productos = JArray.Parse(ObjInventario.DtResultados.DataTableToJSONIPP())
|
||||||
|
Else
|
||||||
|
RespuestaError.message = "no se pudo obtener los datos"
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
End Using
|
||||||
|
|
||||||
|
Dim Msg As String = "Información día " & Now.ToShortDateString & If(RespuestaError.message <> "", " Error: " & RespuestaError.message, "")
|
||||||
|
Msg.GuardaLogAD("LogE119")
|
||||||
|
|
||||||
|
If TieneError Then
|
||||||
|
context.Response.StatusCode = 200
|
||||||
|
Return JsonConvert.SerializeObject(RespuestaError)
|
||||||
|
Else
|
||||||
|
context.Response.StatusCode = 200
|
||||||
|
Try
|
||||||
|
Respuesta.data = New JObject(New JProperty("Productos", Productos))
|
||||||
|
Respuesta.message = "Los datos se obtuvieron correctamente"
|
||||||
|
Return JsonConvert.SerializeObject(Respuesta)
|
||||||
|
Catch ex As Exception
|
||||||
|
RespuestaError.message = "Ocurrió un error al generar la petición"
|
||||||
|
Return JsonConvert.SerializeObject(RespuestaError)
|
||||||
|
End Try
|
||||||
|
End If
|
||||||
|
End Function
|
||||||
|
|
||||||
Private Class ResponseMsg
|
Private Class ResponseMsg
|
||||||
Sub New()
|
Sub New()
|
||||||
status = "success"
|
status = "success"
|
||||||
|
|||||||
Reference in New Issue
Block a user