From 456c6fb4f9cf16f28f4889e3f590e2779ea67d14 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Mon, 18 Sep 2023 17:28:12 -0700 Subject: [PATCH] Endpoint de clasificaciones para E119 --- App_Code/ClsInventarios.vb | 3 ++- Ashx/E119.ashx | 53 +++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index 502282246..d9bc6774f 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -5985,12 +5985,13 @@ Public Class ClsInventarios End Function - Public Function GetJAM_APIs(Optional Opcion As Integer = 1) As Boolean + Public Function GetJAM_APIs(Optional Opcion As Integer = 1, Optional CveClasificacion 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 + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion End With Try diff --git a/Ashx/E119.ashx b/Ashx/E119.ashx index 07a7adc94..1928e7701 100644 --- a/Ashx/E119.ashx +++ b/Ashx/E119.ashx @@ -114,6 +114,18 @@ Public Class E119 : Implements IHttpHandler End If End If + If Metodo = "ConsultarClasificaciones" Then + context.Response.ContentType = "application/json" + Dim Auth = ValidarSolicitud(context) + + If Auth.IsSucces Then + retorno = ConsultaClasificaciones(context) + Else + context.Response.StatusCode = Auth.StatusCode + retorno = JsonConvert.SerializeObject(Auth.ErrorMessage) + End If + End If + context.Response.Write(retorno) Catch ex As Exception @@ -226,10 +238,16 @@ Public Class E119 : Implements IHttpHandler Dim RespuestaError As New ResponseMsgError Dim TieneError As Boolean = False + Dim CveClasificacion = If(context.Request("CveClasificacion") = Nothing, "", context.Request("CveClasificacion").ToString()) + + If String.IsNullOrEmpty(CveClasificacion) Then + CveClasificacion = "-1" + End If + Dim Productos As JArray = Nothing Using ObjInventario As New ClsInventarios - If ObjInventario.GetJAM_APIs(1) AndAlso ObjInventario.DtResultados IsNot Nothing Then + If ObjInventario.GetJAM_APIs(1, CveClasificacion:=CveClasificacion.ToEntero()) AndAlso ObjInventario.DtResultados IsNot Nothing Then Productos = JArray.Parse(ObjInventario.DtResultados.DataTableToJSONIPP()) Else RespuestaError.message = "no se pudo obtener los datos" @@ -256,6 +274,39 @@ Public Class E119 : Implements IHttpHandler End If End Function + Private Function ConsultaClasificaciones(ByVal context As HttpContext) As String + Dim Respuesta As New ResponseMsg + Dim RespuestaError As New ResponseMsgError + Dim TieneError As Boolean = False + + Dim Clasificaciones As JArray = Nothing + + Try + Clasificaciones = JArray.Parse(ClsPaginas.GlobalDTClasificaciones(CveEmpresa).FiltraParametros("", DistinctColumns:={"CveClasificacion", "Clasificacion"}).DataTableToJSONIPP()) + Catch ex As Exception + RespuestaError.message = "no se pudo obtener los datos" + TieneError = True + End Try + + 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("Clasificaciones", Clasificaciones)) + 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 Sub New() status = "success"