--mejoras en descarga de pdf, cambios en factura USA
This commit is contained in:
@@ -6,6 +6,7 @@ Imports System.IO
|
||||
Imports Extensiones
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
Imports Newtonsoft.Json
|
||||
Imports System.Net.Http
|
||||
|
||||
Public Class SIGDesc : Implements IHttpHandler, IRequiresSessionState
|
||||
|
||||
@@ -35,11 +36,47 @@ Public Class SIGDesc : Implements IHttpHandler, IRequiresSessionState
|
||||
context.Response.Flush()
|
||||
context.Response.WriteFile(FileInfo.FullName)
|
||||
context.Response.End()
|
||||
Else
|
||||
DescargarPDFVentaPeticion(context, ObjFactura)
|
||||
End If
|
||||
FileInfo = Nothing
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub DescargarPDFVentaPeticion(ByVal context As HttpContext, ObjFactura As Modelos.Factura)
|
||||
Dim usuario As Usuario = UsuarioActual(context)
|
||||
If Not IsNothing(usuario) Then
|
||||
Dim strURLHOST = String.Format("{0}://{1}:{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port)
|
||||
|
||||
Dim Url As New Uri(String.Format("{0}/Compras/PopUpVerFactura.aspx?P={1}", strURLHOST, Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1®ENERAR={1}", ObjFactura.CveVenta, "1"))))
|
||||
Dim File As Byte() = Nothing
|
||||
Try
|
||||
Using httpClient As New HttpClient()
|
||||
httpClient.Timeout = New TimeSpan(0, 1, 0)
|
||||
Using request As New HttpRequestMessage(HttpMethod.Get, Url)
|
||||
request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CveUsuario={2}", ObjFactura.CveEmpresa, DateTime.UtcNow.Ticks, ObjFactura.CveUsuario)))
|
||||
Dim response = httpClient.SendAsync(request).Result
|
||||
If response.StatusCode = Net.HttpStatusCode.OK Then
|
||||
File = response.Content.ReadAsByteArrayAsync().Result
|
||||
End If
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
File = Nothing
|
||||
OnError("Ocurrió un error al descargar la factura", ex)
|
||||
End Try
|
||||
|
||||
context.Response.Buffer = True
|
||||
context.Response.Clear()
|
||||
context.Response.ContentType = "application/pdf"
|
||||
context.Response.ClearHeaders()
|
||||
context.Response.AddHeader("content-disposition", String.Format("{0}; filename=""{1}.{2}""", "attachment", ObjFactura.SerieFolio, "pdf"))
|
||||
context.Response.BinaryWrite(File) ' create the file
|
||||
context.Response.End()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
|
||||
Get
|
||||
Return False
|
||||
|
||||
Reference in New Issue
Block a user