--fix de envio de correo de factura

This commit is contained in:
2024-01-13 13:12:24 -07:00
parent c19159aadd
commit 95292f428b
2 changed files with 39 additions and 2 deletions

View File

@@ -2137,7 +2137,17 @@ Partial Class Clientes
Protected Sub BtnSendMail_Click(sender As Object, e As System.EventArgs) Handles BtnSendMail.Click
Try
If HdnCveVenta.Value <> "-1" AndAlso HdnFolioVenta.Value <> "-1" Then
If HdnCveVenta.Value <> "-1" AndAlso HdnFolioVenta.Value <> "-1" Then
Dim ArchivoPDF As String = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, HdnTipoDocto.Value, HdnFolioVenta.Value)
'REGENERAR EL PDF
If Not File.Exists(ArchivoPDF) Then
Try
GenerarPDFVenta(HdnCveVenta.Value.ToEntero(), AplicaPagare:="1", GuardarPDF:=True, RegenerarPDF:=True, DescargarArchivo:=False)
Catch ex As Exception
OnError("Ocurrió un error al regenerar el PDF", ex)
End Try
End If
Dim ObjMail As New ClsSisMail()
Dim Ruta As String = UsuarioActual.Empresa.Ruta

View File

@@ -15556,7 +15556,7 @@ Partial Class Ventas
'TIMBRADO NUEVO
Try
GenerarPDFVenta(Factura.CveVenta, AplicaPagare:="1", GuardarPDF:=True, RegenerarPDF:=True, DescargarArchivo:=False)
DescargarFactura(Factura.CveVenta, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, Regenerar:=True, strURLHOST:=strURLHOST)
Catch ex As Exception
OnError("Ocurrió un error al generar el PDF", ex)
End Try
@@ -33471,6 +33471,33 @@ Partial Class Ventas
End If
End Sub
Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer, CveUsuarioCreo As Integer, Optional GetBytes As Boolean = True, Optional Regenerar As Boolean = False, Optional strURLHOST As String = "") As Byte()
If String.IsNullOrEmpty(strURLHOST) Then
strURLHOST = String.Format("{0}://{1}:{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port)
End If
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&REGENERAR={1}", CveVenta, If(Regenerar, "1", "0")))))
Dim File As Byte() = Nothing
Try
Using httpClient As New HttpClient()
httpClient.Timeout = New TimeSpan(0, 2, 0)
Using request As New HttpRequestMessage(HttpMethod.Get, Url)
request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CveUsuario={2}", CveEmpresa, DateTime.UtcNow.Ticks, CveUsuarioCreo)))
Dim response = httpClient.SendAsync(request).Result
If GetBytes AndAlso 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
Return File
End Function
Protected Sub LnkGenerarOC_Click(sender As Object, e As EventArgs)
Response.Redirect($"~/OC/OC.aspx?CveCotizacion={Me.CveVenta}&Tipo=OC")
End Sub