From b62b1a1c46e6d4971f3fecb0a66efaa3dfbd7455 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 5 May 2023 16:15:37 -0700 Subject: [PATCH] Mejores en descarga de pdf de econo --- App_Code/ClsPaginas.vb | 2 +- Ashx/E141.ashx | 32 ++++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index c3dfdb544..8413198cf 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -6040,7 +6040,7 @@ Public Class ClsPaginas If UsuarioActual.CveEmpresa.Contiene(141, 152, 159, 160, 161, 162, 163) Then Dim QRDescarga As String = "" Dim cfdi As New RVCFDI33.GeneraCFDI() - Dim Parametros As String = Encripta($"CveVenta={Vta.CveVenta}&CveEmpresa={Vta.CveEmpresa}") + Dim Parametros As String = Encripta($"SerieFolio={Vta.SerieFolio}&TipoDocto={Vta.TipoDocto}&CveEmpresa={Vta.CveEmpresa}") Dim b As Byte() = cfdi.ConvertirQrCode($"http://econollantas.adssistemas.mx/Ashx/E141.ashx?PV={Parametros}") QRDescarga = Convert.ToBase64String(b) params.Add(New ReportParameter("QRDescarga", QRDescarga)) diff --git a/Ashx/E141.ashx b/Ashx/E141.ashx index 7f6bf47cb..9e87ebed5 100644 --- a/Ashx/E141.ashx +++ b/Ashx/E141.ashx @@ -99,16 +99,36 @@ Public Class E141 : Implements IHttpHandler Dim retorno As String = "" Try Dim Params = If(context.Request("P") = Nothing, "", context.Request("P").ToString()) + Dim ParamsV = If(context.Request("PV") = Nothing, "", context.Request("PV").ToString()) + + Dim ParametrosNuevos As Boolean = False + If Not String.IsNullOrEmpty(ParamsV) Then + ParametrosNuevos = True + Params = ParamsV + End If 'DESCARGA DEL PDF If Not String.IsNullOrEmpty(Params) Then Try - Dim UrlParametros As Hashtable = Parametros(Decripta(Params)) + If ParametrosNuevos Then + Dim UrlParametros As Hashtable = Parametros(Decripta(Params)) - Dim File As String = UrlParametros("FILE").ToString() - If Not String.IsNullOrEmpty(File) Then - ImprimirbytesPDF(context, DescargarFactura(File), File) + Dim File As String = String.Format("{0}.pdf", UrlParametros("SERIEFOLIO").ToString()) + Dim TipoDocto As String = UrlParametros("TIPODOCTO").ToString() + Dim CveEmpresaParam As Integer = UrlParametros("CVEEMPRESA").ToString().ToEntero() + + If Not String.IsNullOrEmpty(File) AndAlso Not String.IsNullOrEmpty(TipoDocto) AndAlso CveEmpresaParam > 0 Then + ImprimirbytesPDF(context, DescargarFactura(File, CveEmpresaParam, TipoDocto), File) + End If + Else + Dim UrlParametros As Hashtable = Parametros(Decripta(Params)) + + Dim File As String = UrlParametros("FILE").ToString() + If Not String.IsNullOrEmpty(File) Then + ImprimirbytesPDF(context, DescargarFactura(File, Me.CveEmpresa), File) + End If End If + Catch ex As Exception GuardaLogAD("Ocurrió un error al descargar el pdf. " + ex.ToString() + ".parametros: " + Params, "LogE141") End Try @@ -2202,8 +2222,8 @@ Public Class E141 : Implements IHttpHandler #Region "D E S C A R G A - P D F" - Private Function DescargarFactura(FilePDF As String) As Byte() - Dim Url = New Uri(String.Format("{0}://{1}:{2}/Compras/PopUpVerFactura.aspx?TipoDocto=Ing&File={3}&TipoArchivo=PDF", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, FilePDF)) + Private Function DescargarFactura(FilePDF As String, CveEmpresa As Integer, Optional TipoDocto As String = "Ing") As Byte() + Dim Url = New Uri(String.Format("{0}://{1}:{2}/Compras/PopUpVerFactura.aspx?TipoDocto={4}&File={3}&TipoArchivo=PDF", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, FilePDF, TipoDocto)) Dim File As Byte() = Nothing Try Using httpClient = New HttpClient()