-- eFacturas. generacion de facturas en hilo en pdf
This commit is contained in:
@@ -173,9 +173,13 @@ Public Class ClsPaginas
|
||||
Dim tHora As Integer = 0
|
||||
'If UsuarioActual IsNot Nothing AndAlso UsuarioActual.Empresa IsNot Nothing Then tHora = UsuarioActual.Empresa.UTCOffset
|
||||
Try
|
||||
If HttpContext.Current.Session IsNot Nothing AndAlso HttpContext.Current.Session("UsuarioSIG") IsNot Nothing AndAlso CType(HttpContext.Current.Session("UsuarioSIG"), Usuario).Empresa IsNot Nothing Then tHora = CType(HttpContext.Current.Session("UsuarioSIG"), Usuario).Empresa.UTCOffset
|
||||
If HttpContext.Current IsNot Nothing Then
|
||||
If HttpContext.Current.Session IsNot Nothing AndAlso HttpContext.Current.Session("UsuarioSIG") IsNot Nothing AndAlso CType(HttpContext.Current.Session("UsuarioSIG"), Usuario).Empresa IsNot Nothing Then
|
||||
tHora = CType(HttpContext.Current.Session("UsuarioSIG"), Usuario).Empresa.UTCOffset
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
|
||||
tHora = 0
|
||||
End Try
|
||||
|
||||
Return If(tHora <> 0, Now.ToUniversalTime.AddMinutes(tHora), Now)
|
||||
|
||||
@@ -331,7 +331,7 @@ Namespace Extensiones
|
||||
Public Sub GuardaLogAD(Mensaje As String, Optional Archivo As String = "Log")
|
||||
Dim ArchivoW As StreamWriter
|
||||
|
||||
Dim MensajeFormato As String = String.Format("{0}{1}Log: {2} | Fecha:{3}", Chr(13), Chr(10), Mensaje, ClsPaginas.NowADS().ToString("dd/MM/yyyy HH:mm"))
|
||||
Dim MensajeFormato As String = String.Format("{0}{1}Log: {2} | Fecha:{3}", Chr(13), Chr(10), Mensaje, DateTime.Now.ToString("dd/MM/yyyy HH:mm"))
|
||||
|
||||
Try
|
||||
ArchivoW = New StreamWriter(String.Format("{0}\Log\{1}.txt", AppDomain.CurrentDomain.BaseDirectory, Archivo), True, System.Text.Encoding.UTF8)
|
||||
|
||||
@@ -27,6 +27,7 @@ Imports SharpCompress.Reader
|
||||
Imports System.Drawing
|
||||
Imports Microsoft.Owin.Security.Provider
|
||||
Imports Telerik.Web.UI
|
||||
Imports Stimulsoft.Base.StiDbType
|
||||
'Imports Telerik.Web.UI
|
||||
|
||||
|
||||
@@ -785,7 +786,7 @@ Partial Class Compras_eFacturas
|
||||
End If
|
||||
|
||||
CargaGvBitacora()
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
MostrarSolcitudesSAT()
|
||||
|
||||
If UsuarioActual.CveRol = 1 Then
|
||||
@@ -810,10 +811,10 @@ Partial Class Compras_eFacturas
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
Private Sub CargaDatos(NowEmpresa As DateTime)
|
||||
|
||||
DTTraslados = New DataTable
|
||||
|
||||
@@ -832,7 +833,7 @@ Partial Class Compras_eFacturas
|
||||
FechaI = MinFecha
|
||||
FechaF = MaxFecha
|
||||
txtFechaI.Text = MinFecha.ToString
|
||||
txtFechaF.Text = NowADS().ToShortDateString
|
||||
txtFechaF.Text = NowEmpresa.ToShortDateString
|
||||
End If
|
||||
|
||||
Dim DtPagos As DataTable = Nothing
|
||||
@@ -887,13 +888,13 @@ Partial Class Compras_eFacturas
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
|
||||
GenerarPDF("Excel")
|
||||
GenerarPDF(NowADS(), "Excel")
|
||||
End Sub
|
||||
|
||||
Protected Sub ImgRefresh_Click(sender As Object, e As EventArgs) Handles ImgRefresh.Click
|
||||
|
||||
If VerificaCorreo() Then
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End If
|
||||
|
||||
End Sub
|
||||
@@ -1137,11 +1138,11 @@ Partial Class Compras_eFacturas
|
||||
ObjDatos.Dispose()
|
||||
|
||||
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End Sub
|
||||
Protected Sub GvDatos_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvD.RowCancelingEdit
|
||||
GvD.EditIndex = -1
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -1157,7 +1158,7 @@ Partial Class Compras_eFacturas
|
||||
|
||||
Protected Sub GvDatos_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvD.RowEditing
|
||||
GvD.EditIndex = e.NewEditIndex
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End Sub
|
||||
|
||||
Protected Sub GvDatos_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvD.RowCommand
|
||||
@@ -1187,7 +1188,7 @@ Partial Class Compras_eFacturas
|
||||
|
||||
ObjDatos.Dispose()
|
||||
If Correcto Then
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End If
|
||||
|
||||
End Sub
|
||||
@@ -1300,15 +1301,15 @@ Partial Class Compras_eFacturas
|
||||
GvPagos.EditIndex = -1
|
||||
End If
|
||||
ObjDatos.Dispose()
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End Sub
|
||||
Protected Sub GvPagos_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvPagos.RowCancelingEdit
|
||||
GvPagos.EditIndex = -1
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End Sub
|
||||
Protected Sub GvPagos_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvPagos.RowEditing
|
||||
GvPagos.EditIndex = e.NewEditIndex
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End Sub
|
||||
Protected Sub imgDP_Click(sender As Object, e As EventArgs)
|
||||
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
||||
@@ -1347,7 +1348,7 @@ Partial Class Compras_eFacturas
|
||||
|
||||
ObjDatos.Dispose()
|
||||
If Correcto Then
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End If
|
||||
End Sub
|
||||
#End Region
|
||||
@@ -1386,7 +1387,7 @@ Partial Class Compras_eFacturas
|
||||
If Not ErrorTrans Then
|
||||
|
||||
Alert("La verificación masiva ha terminado", TipoMensaje.MsgInformacion)
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
|
||||
End If
|
||||
|
||||
@@ -1432,11 +1433,11 @@ Partial Class Compras_eFacturas
|
||||
|
||||
DtNoRecibidas.Dispose()
|
||||
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End Sub
|
||||
|
||||
#Region "G E N E R A P D F "
|
||||
Private Sub GenerarPDF(Optional Tipo As String = "PDF")
|
||||
Private Sub GenerarPDF(Fecha As DateTime, Optional Tipo As String = "PDF")
|
||||
Dim ObjDatos As New ClsCompras
|
||||
Dim FechaI As String = txtFechaI.Text
|
||||
Dim FechaF As String = txtFechaF.Text
|
||||
@@ -1470,7 +1471,7 @@ Partial Class Compras_eFacturas
|
||||
params.Add(New ReportParameter("FechaInicio", FechaI))
|
||||
params.Add(New ReportParameter("FechaFin", FechaF))
|
||||
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString))
|
||||
params.Add(New ReportParameter("FechaImpresion", Fecha.ToDateTime.ToShortDateString))
|
||||
|
||||
If Imagen.Exists Then
|
||||
params.Add(New ReportParameter("LogoPath", $"file//:{Imagen.FullName}"))
|
||||
@@ -1481,9 +1482,9 @@ Partial Class Compras_eFacturas
|
||||
|
||||
If Tab.ActiveTabIndex = 2 Then
|
||||
|
||||
ImprimirPDF("Empresas/Grales/Formatos/RepFacturas.rdlc", DTTraslados, params, $"FacturasBuzon_{NowADS().ToString("yyyyMMyyddmmss")}", Tipo)
|
||||
ImprimirPDF("Empresas/Grales/Formatos/RepFacturas.rdlc", DTTraslados, params, $"FacturasBuzon_{Fecha.ToString("yyyyMMyyddmmss")}", Tipo)
|
||||
Else
|
||||
ImprimirPDF("Empresas/Grales/Formatos/RepFacturas.rdlc", dt, params, $"FacturasBuzon_{NowADS().ToString("yyyyMMyyddmmss")}", Tipo)
|
||||
ImprimirPDF("Empresas/Grales/Formatos/RepFacturas.rdlc", dt, params, $"FacturasBuzon_{Fecha.ToString("yyyyMMyyddmmss")}", Tipo)
|
||||
End If
|
||||
|
||||
|
||||
@@ -1491,7 +1492,7 @@ Partial Class Compras_eFacturas
|
||||
|
||||
End Sub
|
||||
Protected Sub LnkPdf_Click(sender As Object, e As EventArgs) Handles LnkPdf.Click
|
||||
GenerarPDF()
|
||||
GenerarPDF(NowADS())
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
@@ -1556,7 +1557,7 @@ Partial Class Compras_eFacturas
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub SubirFacturas(ByRef ListComprimidos As List(Of String), ByRef ListXML As List(Of String), ByRef ListPDF As List(Of String))
|
||||
Private Sub SubirFacturas(ByRef ListComprimidos As List(Of String), ByRef ListXML As List(Of String), ByRef ListPDF As List(Of String), Optional Validada As Integer = 0)
|
||||
Dim DTLOG As New DataTable
|
||||
DTLOG.Columns.Add("Serie", GetType(String))
|
||||
DTLOG.Columns.Add("Folio", GetType(String))
|
||||
@@ -1638,35 +1639,6 @@ Partial Class Compras_eFacturas
|
||||
Next
|
||||
|
||||
|
||||
'Dim fileEntries As String() = Directory.GetFiles(String.Format("{0}Temp\Facturas", UsuarioActual.Empresa.Ruta))
|
||||
|
||||
'Dim ListaDirectoriosTemporales As New List(Of String)
|
||||
'Dim ListaComprimidos As New List(Of String)
|
||||
|
||||
''Dim fileName As String
|
||||
'Dim ArchivoExtension As String
|
||||
'Dim sOnlyFilename As String
|
||||
|
||||
'For Each filePath As String In fileEntries
|
||||
|
||||
' ArchivoExtension = IO.Path.GetExtension(String.Format("{0}", filePath)).Replace(".", "")
|
||||
' sOnlyFilename = System.IO.Path.GetFileName(filePath)
|
||||
|
||||
' If ArchivoExtension.ToUpper = "RAR" Or ArchivoExtension.ToUpper = "ZIP" Then
|
||||
' ListXML.Add(filePath)
|
||||
' End If
|
||||
'Next
|
||||
|
||||
'Dim Arreglo As New ArrayList()
|
||||
'Dim Bandera As Boolean = True
|
||||
'Dim Retorno As String = ""
|
||||
'Dim ListaArchivosMail As New List(Of ClsSisMail.ArchivoMail)
|
||||
|
||||
'sw.Stop()
|
||||
'swTiempo.AppendFormat("ReadFiles: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds)
|
||||
'swmili = sw.ElapsedMilliseconds
|
||||
'sw.Start()
|
||||
|
||||
Anexo.Text = ""
|
||||
UPAddFacturas.Update()
|
||||
|
||||
@@ -1710,12 +1682,13 @@ Partial Class Compras_eFacturas
|
||||
|
||||
If File.Exists(filePathXML) Then
|
||||
Dim a As New ComprobanteFactura(eFacturasLog)
|
||||
Dim FF As Factura = a.CargaComprobanteXML(File.ReadAllText(filePathXML), UsuarioActual.Empresa.Ruta, UsuarioActual.Empresa.RFC, UsuarioActual.CveEmpresa, True, rowLog, NombreArchivo:=fInfoXML.Name)
|
||||
Dim FF As Factura = a.CargaComprobanteXML(File.ReadAllText(filePathXML), UsuarioActual.Empresa.Ruta, UsuarioActual.Empresa.RFC, UsuarioActual.CveEmpresa, True, rowLog, NombreArchivo:=fInfoXML.Name, Validada:=Validada)
|
||||
|
||||
If FF IsNot Nothing AndAlso FF.CveFactura > 0 Then
|
||||
|
||||
If RutaPDF = "" Then
|
||||
a.GeneraPDF(UsuarioActual.Empresa.Ruta, FF, UsuarioActual.Empresa.Ruta, True)
|
||||
Dim Hilo As New System.Threading.Thread(Sub() ProcesarPDF(UsuarioActual, a, FF))
|
||||
Hilo.Start()
|
||||
Else
|
||||
Dim PDfDestino As String = $"{UsuarioActual.Empresa.Ruta}\Compras\{FF.EmisorRFC}\{FF.CveFactura}.PDF"
|
||||
If File.Exists(PDfDestino) Then
|
||||
@@ -1736,40 +1709,6 @@ Partial Class Compras_eFacturas
|
||||
swmili = sw.ElapsedMilliseconds
|
||||
sw.Start()
|
||||
|
||||
'If ListaArchivosMail.Count > 0 Then
|
||||
|
||||
' Dim Correo As New ClsSisMail
|
||||
|
||||
' 'If Correo.SendMail(UsuarioActual.Empresa, "sig.buzon@gmail.com", "Facturas Efacturas " & NowADS().ToString("yyyyMMddhhmmss"), "Facturas", Archivos:=ListaArchivosMail) Then
|
||||
|
||||
' If Correo.SendMail(UsuarioActual.Empresa, UsuarioActual.Empresa.Buzon_Mail, "Facturas Efacturas " & NowADS().ToString("yyyyMMddhhmmss"), "Facturas", Archivos:=ListaArchivosMail) Then
|
||||
|
||||
' sw.Stop()
|
||||
' swTiempo.AppendFormat("EnvioCorreo: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds)
|
||||
' swmili = sw.ElapsedMilliseconds
|
||||
' sw.Start()
|
||||
' System.Threading.Thread.Sleep(3000)
|
||||
' 'ProcesaBuzon()
|
||||
|
||||
' sw.Stop()
|
||||
' swTiempo.AppendFormat("espera: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds)
|
||||
' swmili = sw.ElapsedMilliseconds
|
||||
' sw.Start()
|
||||
|
||||
' If VerificaCorreo(True) Then
|
||||
' CargaDatos()
|
||||
' End If
|
||||
|
||||
' sw.Stop()
|
||||
' swTiempo.AppendFormat("Verifica En la app: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds)
|
||||
' swmili = sw.ElapsedMilliseconds
|
||||
' sw.Start()
|
||||
' Else
|
||||
' Alert("Se presento un error al procesar las facturas.")
|
||||
' End If
|
||||
|
||||
'End If
|
||||
|
||||
|
||||
sw.Stop()
|
||||
swTiempo.AppendFormat("BorrarInicio: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds)
|
||||
@@ -1777,38 +1716,6 @@ Partial Class Compras_eFacturas
|
||||
sw.Start()
|
||||
|
||||
|
||||
'For Each filePath As String In ListXML
|
||||
' Try
|
||||
' File.Delete(filePath)
|
||||
' Catch ex As Exception
|
||||
' End Try
|
||||
'Next
|
||||
|
||||
|
||||
'For Each filePath As String In ListPDF
|
||||
' Try
|
||||
' File.Delete(filePath)
|
||||
' Catch ex As Exception
|
||||
' End Try
|
||||
'Next
|
||||
|
||||
'For Each s As String In ListaComprimidos
|
||||
' Try
|
||||
' File.Delete(s)
|
||||
' Catch ex As Exception
|
||||
' End Try
|
||||
'Next
|
||||
|
||||
|
||||
|
||||
|
||||
'For Each d As String In ListaDirectoriosTemporales
|
||||
' Try
|
||||
' Directory.Delete(d, True)
|
||||
' Catch ex As Exception
|
||||
' End Try
|
||||
'Next
|
||||
|
||||
For Each s As String In ListXML
|
||||
Try
|
||||
File.Delete(s)
|
||||
@@ -1829,74 +1736,6 @@ Partial Class Compras_eFacturas
|
||||
|
||||
GuardaLogefacturas(swTiempo.ToString())
|
||||
|
||||
|
||||
'ArchivoExtension = IO.Path.GetExtension(String.Format("{0}", filePath)).Replace(".", "")
|
||||
'NombreArchivo = System.IO.Path.GetFileName(filePath)
|
||||
'If ArchivoExtension.ToUpper = "XML" Then
|
||||
' Dim ArchivoInfo As New FileInfo(filePath)
|
||||
' Dim Fact2 As Modelos.eFactura = GuardaArchivoXML(filePath)
|
||||
|
||||
' If Fact2 IsNot Nothing Then
|
||||
' Fact2.DirectorioTemporal = ArchivoInfo.DirectoryName & "\"
|
||||
' Arreglo.Add(Fact2)
|
||||
' End If
|
||||
'End If
|
||||
|
||||
|
||||
'If Arreglo.Count > 0 Then
|
||||
' For Each Fact As Modelos.eFactura In Arreglo
|
||||
' ' si es exploraciones, no debe de insertar del 2013
|
||||
|
||||
' If UsuarioActual.CveEmpresa = 13 And Convert.ToDateTime(Fact.Fecha).Year < 2014 And Fact.TipodeComprobante <> "egreso" Then
|
||||
' Bandera = False
|
||||
' 'ModExtensiones.GuardaLog("'*******noingreso :" + Fact.ArchivoXML + " RFC: " + tRF + " Anio" + Convert.ToDateTime(Fact.Fecha).Year)
|
||||
' End If
|
||||
|
||||
' 'por default, no alimentar facturas menores al 2013
|
||||
|
||||
' If Convert.ToDateTime(Fact.Fecha).Year < 2013 Then
|
||||
' Bandera = False
|
||||
' 'ModExtensiones.GuardaLog("'*******noingreso :" + Fact.ArchivoXML + " RFC: " + tRF + " Anio" + Convert.ToDateTime(Fact.Fecha).Year)
|
||||
' End If
|
||||
' If Bandera Then
|
||||
' If Not String.IsNullOrEmpty(Fact.TFDUUID) Then
|
||||
' Dim Valida As New ClsValidaCFDi(Fact.TFDUUID, Fact.EmisorRFC, Fact.ReceptorRFC, Fact.Total, Fact.Fecha)
|
||||
' If Valida.EsValida = 1 Then
|
||||
' Fact.Validada = 1
|
||||
' End If
|
||||
' Valida.Dispose()
|
||||
|
||||
' If Not String.IsNullOrEmpty(Fact.ArchivoPDF) Then
|
||||
' Retorno = AgregaFactura(Fact)
|
||||
' Else
|
||||
' If GeneraPDF(Fact.DirectorioTemporal, Fact) Then
|
||||
' ListPDF.Add(Fact.ArchivoPDF)
|
||||
' Retorno = AgregaFactura(Fact)
|
||||
' ' ModExtensiones.GuardaLog("'*******se genero el pdf :" + String.Format("{0}Empresas\{1}\Temp", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa) + Fact.ArchivoXML + " RFC: " + tRF + " Anio" + Convert.ToDateTime(Fact.Fecha).Year + "Retorno:" + Retorno)
|
||||
' Else
|
||||
' ' ModExtensiones.GuardaLog("'*******no se genero el pdf :" + String.Format("{0}Empresas\{1}\Temp", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa) + Fact.ArchivoXML + " RFC: " + tRF + " Anio" + Convert.ToDateTime(Fact.Fecha).Year + "Retorno:" + Retorno)
|
||||
|
||||
' End If
|
||||
' End If
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' Bandera = True
|
||||
' Try
|
||||
' If File.Exists(String.Format("{0}{1}", Fact.DirectorioTemporal, Fact.ArchivoXML)) Then
|
||||
' File.Delete(String.Format("{0}{1}", Fact.DirectorioTemporal, Fact.ArchivoXML))
|
||||
' End If
|
||||
|
||||
' If File.Exists(String.Format("{0}{1}", Fact.DirectorioTemporal, Fact.ArchivoPDF)) Then
|
||||
' File.Delete(String.Format("{0}{1}", Fact.DirectorioTemporal, Fact.ArchivoPDF))
|
||||
' End If
|
||||
' Catch ex As Exception
|
||||
|
||||
' End Try
|
||||
' Next
|
||||
'End If
|
||||
|
||||
|
||||
mesajeFaturasSubidas(DTLOG)
|
||||
|
||||
|
||||
@@ -1905,6 +1744,10 @@ Partial Class Compras_eFacturas
|
||||
'Alert(String.Format("Se cargaron {0} Facturas", Arreglo.Count), TipoMensaje.MsgInformacion)
|
||||
End Sub
|
||||
|
||||
Private Sub ProcesarPDF(UsuarioActual As Usuario, a As ComprobanteFactura, FF As Factura)
|
||||
a.GeneraPDF(UsuarioActual, UsuarioActual.Empresa.Ruta, FF, UsuarioActual.Empresa.Ruta, True)
|
||||
End Sub
|
||||
|
||||
Private Sub mesajeFaturasSubidas(DTLOG As DataTable)
|
||||
|
||||
|
||||
@@ -2430,7 +2273,7 @@ Partial Class Compras_eFacturas
|
||||
'_TFDNoCertSAT = XMLDoc.DocumentElement("cfdi:Complemento").FirstChild.Attributes("noCertificadoSAT").InnerText
|
||||
'_TFDSelloSAT = XMLDoc.DocumentElement("cfdi:Complemento").FirstChild.Attributes("selloSAT").InnerText
|
||||
End Sub
|
||||
Public Function GeneraPDF(Ruta As String, Fact As Modelos.eFactura) As Boolean
|
||||
Public Function GeneraPDF(UsuarioActual As Usuario, Ruta As String, Fact As Modelos.eFactura) As Boolean
|
||||
Dim RutaXML As String = String.Empty
|
||||
Dim RutaPDF As String = String.Empty
|
||||
Dim Retorno As Boolean = False
|
||||
@@ -2709,7 +2552,7 @@ Partial Class Compras_eFacturas
|
||||
|
||||
Using nom As ClsNominas = New ClsNominas()
|
||||
|
||||
If nom.SolicitudesGet(-1, UsuarioActual.CveEmpresa, CveTipoSolicitud:=2, Estatus:=0, Top:=50) Then
|
||||
If nom.SolicitudesGet(1611, UsuarioActual.CveEmpresa, CveTipoSolicitud:=2, Estatus:=-1, Top:=50) Then
|
||||
GVSolicitudesPendientes.DataSource = nom.DtResultados
|
||||
|
||||
If nom.DtResultados.Rows.Count > 0 Then
|
||||
@@ -3057,15 +2900,20 @@ Partial Class Compras_eFacturas
|
||||
|
||||
If ResultadoSolicitudOK And Verificar Then
|
||||
|
||||
Dim ObjApiVerificacion As JToken = CType(api.VerificaSolicitudesNominas(UsuarioActual.CveEmpresa, CveTipoSolicitud, CveSolicitudActual), JToken)
|
||||
If EsProduccion Then
|
||||
Dim ObjApiVerificacion As JToken = CType(api.VerificaSolicitudesNominas(UsuarioActual.CveEmpresa, CveTipoSolicitud, CveSolicitudActual), JToken)
|
||||
|
||||
If Not (ObjApiVerificacion Is Nothing) Then
|
||||
resultVerificacion = ObjApiVerificacion.[Select](Function(token) token.Values().Aggregate(Function(i, j) $"{i}|{j}").Value(Of String)()).ToList()
|
||||
If Not (ObjApiVerificacion Is Nothing) Then
|
||||
resultVerificacion = ObjApiVerificacion.[Select](Function(token) token.Values().Aggregate(Function(i, j) $"{i}|{j}").Value(Of String)()).ToList()
|
||||
|
||||
ResultadoVerificaionOK = Boolean.Parse(resultVerificacion(0))
|
||||
SeVerifico = True
|
||||
ResultadoVerificaionOK = Boolean.Parse(resultVerificacion(0))
|
||||
SeVerifico = True
|
||||
Else
|
||||
TipoMensaje = ModExtensiones.TipoMensaje.MsgAdvertencia
|
||||
End If
|
||||
Else
|
||||
TipoMensaje = ModExtensiones.TipoMensaje.MsgAdvertencia
|
||||
ResultadoVerificaionOK = True
|
||||
SeVerifico = True
|
||||
End If
|
||||
|
||||
Dim Archivo = New FileInfo(String.Format("{0}DescargasSATXML\Compras\{1}.zip", UsuarioActual.Empresa.Ruta, CveSolicitudDetalle))
|
||||
@@ -3103,7 +2951,7 @@ Partial Class Compras_eFacturas
|
||||
End If
|
||||
|
||||
If SeVerifico Then
|
||||
SubirFacturas(ListComprimidos, ListXML, ListPDF)
|
||||
SubirFacturas(ListComprimidos, ListXML, ListPDF, Validada:=1)
|
||||
End If
|
||||
|
||||
'If UsuarioActual.CveRol = 1 Then
|
||||
@@ -3342,7 +3190,7 @@ Partial Class Compras_eFacturas
|
||||
GvD.EditIndex = -1
|
||||
RegistraScript(String.Format("$('#{0}').modal('hide');", "divDescripcion"))
|
||||
Alert("La factura se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
UpBitacora.Update()
|
||||
End If
|
||||
|
||||
@@ -3367,7 +3215,7 @@ Partial Class Compras_eFacturas
|
||||
GvPagos.EditIndex = -1
|
||||
RegistraScript("$('#divDescripcionPago').modal('hide');")
|
||||
Alert("La factura se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
UpBitacora.Update()
|
||||
End If
|
||||
|
||||
@@ -4039,7 +3887,7 @@ Partial Class Compras_eFacturas
|
||||
|
||||
Alert("El pago fue vinculado correctamente", TipoMensaje.MsgInformacion)
|
||||
RegistraScript("$('#ModalVincularPago').modal('hide')", "VincularPagoModalHide")
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
Else
|
||||
ObjCompra.RollBack()
|
||||
Alert("Ocurrió un error al vincular el pago. Por favor verifique y vuelva a intentar", TipoMensaje.MsgError)
|
||||
@@ -4490,7 +4338,7 @@ Partial Class Compras_eFacturas
|
||||
Alert($"PDF Error se genero nulo", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
|
||||
Catch ex As Exception
|
||||
Alert($"PDF Error {ex.Message} -- > {ex.StackTrace}", TipoMensaje.MsgAdvertencia)
|
||||
@@ -4964,7 +4812,7 @@ Partial Class Compras_eFacturas
|
||||
If CountVinculados > 0 Then
|
||||
|
||||
Alert($"Se vincularon {CountVinculados} complementos")
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
|
||||
End If
|
||||
|
||||
@@ -5099,7 +4947,7 @@ Partial Class Compras_eFacturas
|
||||
|
||||
ObjDatos.Dispose()
|
||||
If Correcto Then
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -5172,7 +5020,7 @@ Partial Class Compras_eFacturas
|
||||
|
||||
If ProcesoOk Then
|
||||
RegistraScript("$('#DvModalVincularTrasaldo').modal('hide');")
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
Alert("Traslado Vinculado correctamente.")
|
||||
End If
|
||||
|
||||
@@ -5494,7 +5342,7 @@ Partial Class Compras_eFacturas
|
||||
Next
|
||||
|
||||
If Not ErrorProceso Then
|
||||
CargaDatos()
|
||||
CargaDatos(NowADS())
|
||||
If Contador > 0 Then
|
||||
Alert($"Se registraron {Contador} Compras")
|
||||
End If
|
||||
@@ -7780,7 +7628,7 @@ Namespace ADS.eFacturas
|
||||
' End If
|
||||
|
||||
'End Sub
|
||||
Public Function CargaComprobanteXML(StrFuente As String, DirectorioEmpresa As String, RFCEmpresa As String, CveEmpresa As Integer, Registrar As Boolean, ByRef rowLog As DataRow, NombreArchivo As String) As Factura
|
||||
Public Function CargaComprobanteXML(StrFuente As String, DirectorioEmpresa As String, RFCEmpresa As String, CveEmpresa As Integer, Registrar As Boolean, ByRef rowLog As DataRow, NombreArchivo As String, Optional Validada As Integer = 0) As Factura
|
||||
|
||||
|
||||
Dim SeValido As Boolean = False
|
||||
@@ -8040,6 +7888,8 @@ Namespace ADS.eFacturas
|
||||
|
||||
If Fact.ReceptorRFC = RFCEmpresa Then
|
||||
|
||||
Fact.Validada = Validada
|
||||
|
||||
Dim ObjCompra As New ClsCompras
|
||||
Dim Correcto As Boolean = False
|
||||
|
||||
@@ -8135,7 +7985,7 @@ Namespace ADS.eFacturas
|
||||
|
||||
|
||||
|
||||
Public Function GeneraPDF(ByVal Ruta As String, ByVal Fact As Factura, DirectorioEmpresa As String, Guardar As Boolean) As Boolean
|
||||
Public Function GeneraPDF(UsuarioActual As Usuario, ByVal Ruta As String, ByVal Fact As Factura, DirectorioEmpresa As String, Guardar As Boolean) As Boolean
|
||||
Dim RutaXML As String = String.Empty
|
||||
Dim RutaPDF As String = String.Empty
|
||||
Dim Retorno As Boolean = False
|
||||
@@ -8198,7 +8048,7 @@ Namespace ADS.eFacturas
|
||||
If (Fact.Version = "3.3" Or Fact.Version = "4.0") Then
|
||||
Dim cxml As XmlSatCFDI = XmlSatCFDI.readXML(ArchivoXML, ArchivoLog)
|
||||
ModExtensiones.GuardaLogAD(String.Format(" *********** UUID : {0} ***********", cxml.complemento.UUID), ArchivoLog)
|
||||
cxml.ImprimirPDF(TmpArchivoPDF, DirectorioEmpresa, Fact.TipoComprobante)
|
||||
cxml.ImprimirPDF(UsuarioActual, TmpArchivoPDF, DirectorioEmpresa, Fact.TipoComprobante)
|
||||
Fact.ArchivoPDF = Path.GetFileName(TmpArchivoPDF)
|
||||
|
||||
Try
|
||||
@@ -8217,9 +8067,9 @@ Namespace ADS.eFacturas
|
||||
ModExtensiones.GuardaLogAD(String.Format(" *********** TFDUUID : {0} ***********", Fact.UUID), ArchivoLog)
|
||||
Dim DomFiscal As String = String.Format("Domicilio Fiscal {0}{1} {2}{0}Col.{3}{0}CP. {4} {5},{6},{7}", vbCr, Fact.DomFisCalle, Fact.DomFisNoExt, Fact.DomFisCol, Fact.DomFisCP, Fact.DomFisMun, Fact.DomFisEst, Fact.DomFisPais)
|
||||
|
||||
If GeneraPDFNew(TmpArchivoPDF, Fact.UUID, Fact.SubTotal, Fact.Descuento, Fact.Total, Fact.TrasladoIVA.FormatoNumero(), Fact.Moneda, Fact.FormaDePago, Fact.TFDNoCertSAT, Fact.TFDFechaTimbrado.ToDate(), Fact.noCertificado,
|
||||
If GeneraPDFNew(UsuarioActual, TmpArchivoPDF, Fact.UUID, Fact.SubTotal, Fact.Descuento, Fact.Total, Fact.TrasladoIVA.FormatoNumero(), Fact.Moneda, Fact.FormaDePago, Fact.TFDNoCertSAT, Fact.TFDFechaTimbrado.ToDate(), Fact.noCertificado,
|
||||
Fact.DTConceptos, Fact.TFDSelloCFD, Fact.TFDSelloSAT, TmpArchivoQR, Fact.Serie + Fact.Folio, Fact.TipoComprobante, "", Fact.ReceptorRFC, Fact.RecNombre, Fact.DomRecCalle, Fact.DomRecCol, Fact.DomRecFisNoExt,
|
||||
Fact.DomRecFisNoInt, Fact.DomRecCP, Fact.DomRecMun, Fact.DomRecEst, Fact.Regimen, Fact.condicionesDePago, Fact.MetododePago, Fact.NumCtaPagoNumCtaPago, NowADS, Fact.DtPagos, Fact.DtDocumentosR, Fact.RetencionIVA,
|
||||
Fact.DomRecFisNoInt, Fact.DomRecCP, Fact.DomRecMun, Fact.DomRecEst, Fact.Regimen, Fact.condicionesDePago, Fact.MetododePago, Fact.NumCtaPagoNumCtaPago, DateTime.Now, Fact.DtPagos, Fact.DtDocumentosR, Fact.RetencionIVA,
|
||||
Fact.RetencionISR, Fact.EmiNombre, Fact.EmiRFC, Fact.ReceptorNombre, DirectorioEmpresa, DomFiscal) Then
|
||||
|
||||
Fact.ArchivoPDF = Path.GetFileName(TmpArchivoPDF)
|
||||
@@ -8260,7 +8110,7 @@ Namespace ADS.eFacturas
|
||||
End Function
|
||||
|
||||
|
||||
Private Function GeneraPDFNew(ByVal TmpArchivoPDF As String, ByVal FolioFiscal As String, ByVal SubTotal As Decimal, ByVal Descuento As Decimal, ByVal Total As Decimal, ByVal IVA As String, ByVal Moneda As String, ByVal FormaDePago As String,
|
||||
Private Function GeneraPDFNew(UsuarioActual As Usuario, ByVal TmpArchivoPDF As String, ByVal FolioFiscal As String, ByVal SubTotal As Decimal, ByVal Descuento As Decimal, ByVal Total As Decimal, ByVal IVA As String, ByVal Moneda As String, ByVal FormaDePago As String,
|
||||
ByVal NoSerieCertificado As String, ByVal FechaCertificacion As DateTime, ByVal NoSerieCertificadoContribuyente As String, ByVal DTConceptos As DataTable, ByVal SelloCFDi As String, ByVal SelloSAT As String,
|
||||
ByVal CBB As String, ByVal Folio As String, ByVal TipodeComprobante As String, ByVal CadenaOriginalCFD As String, ByVal RFC As String, ByVal Cliente As String, ByVal Direccion As String, ByVal Colonia As String,
|
||||
ByVal NoExt As String, ByVal NoInt As String, ByVal CP As String, ByVal Ciudad As String, ByVal Estado As String, ByVal Regimen As String, ByVal CondicionPago As String, ByVal MetodoPago As String, ByVal NumCtaPago As String,
|
||||
@@ -8268,7 +8118,7 @@ Namespace ADS.eFacturas
|
||||
Optional EmiNombre As String = "", Optional EmiRFC As String = "", Optional NombreEmpresa As String = "", Optional DirectorioEmpresa As String = "", Optional DomFiscal As String = "") As Boolean
|
||||
|
||||
|
||||
Dim RutaRDLC As String = If(TipodeComprobante = "Pag", $"{DirectorioEmpresa}..\Grales\Formatos\CFDIPago.rdlc", $"{DirectorioEmpresa}..\Grales\Formatos\CFDI.rdlc")
|
||||
Dim RutaRDLC As String = If(TipodeComprobante = "Pag", "Grales\Formatos\CFDIPago.rdlc", "Grales\Formatos\CFDI.rdlc")
|
||||
|
||||
Dim Retorno As Boolean = False
|
||||
Dim NombreArchivo As String = TmpArchivoPDF
|
||||
@@ -8320,47 +8170,44 @@ Namespace ADS.eFacturas
|
||||
parametros.Add(New ReportParameter("Empresa", NombreEmpresa))
|
||||
|
||||
|
||||
Dim listaDs As New List(Of ReportDataSource)
|
||||
|
||||
Using MR As New ReportViewer()
|
||||
Dim rds1 As New ReportDataSource()
|
||||
rds1.Name = "DsOC"
|
||||
rds1.Value = DTConceptos
|
||||
Dim rds1 As New ReportDataSource()
|
||||
rds1.Name = "DsOC"
|
||||
rds1.Value = DTConceptos
|
||||
|
||||
MR.LocalReport.DataSources.Add(rds1)
|
||||
'MR.LocalReport.DataSources.Add(rds1)
|
||||
listaDs.Add(rds1)
|
||||
|
||||
If DtPagos IsNot Nothing Then
|
||||
Dim rds2 As New ReportDataSource()
|
||||
rds2.Name = "DsPago"
|
||||
rds2.Value = DtPagos
|
||||
MR.LocalReport.DataSources.Add(rds2)
|
||||
End If
|
||||
If DtRelacionados IsNot Nothing Then
|
||||
Dim rds3 As New ReportDataSource()
|
||||
rds3.Name = "DsDocRelacionados"
|
||||
rds3.Value = DtRelacionados
|
||||
MR.LocalReport.DataSources.Add(rds3)
|
||||
End If
|
||||
If DtPagos IsNot Nothing Then
|
||||
Dim rds2 As New ReportDataSource()
|
||||
rds2.Name = "DsPago"
|
||||
rds2.Value = DtPagos
|
||||
'MR.LocalReport.DataSources.Add(rds2)
|
||||
listaDs.Add(rds2)
|
||||
End If
|
||||
|
||||
MR.LocalReport.ReportPath = RutaFormato
|
||||
MR.ProcessingMode = ProcessingMode.Local
|
||||
MR.LocalReport.EnableExternalImages = True
|
||||
MR.LocalReport.SetParameters(parametros)
|
||||
MR.LocalReport.Refresh()
|
||||
If DtRelacionados IsNot Nothing Then
|
||||
Dim rds3 As New ReportDataSource()
|
||||
rds3.Name = "DsDocRelacionados"
|
||||
rds3.Value = DtRelacionados
|
||||
'MR.LocalReport.DataSources.Add(rds3)
|
||||
listaDs.Add(rds3)
|
||||
End If
|
||||
|
||||
Dim warnings As Warning() = Nothing
|
||||
Dim streamids As String() = Nothing
|
||||
Dim mimeType As String = Nothing
|
||||
Dim encoding As String = Nothing
|
||||
Dim extension As String = Nothing
|
||||
Dim bytes As Byte() = Nothing
|
||||
bytes = MR.LocalReport.Render("PDF", Nothing, mimeType, encoding, extension, streamids, warnings)
|
||||
|
||||
Dim bytes As Byte() = Nothing
|
||||
|
||||
bytes = StreamPDF(UsuarioActual, RutaRDLC, listaDs, parametros, NombreArchivo:=NombreArchivo, Formato:="PDF")
|
||||
If bytes IsNot Nothing Then
|
||||
Using fs As New FileStream(NombreArchivo, FileMode.Create)
|
||||
fs.Write(bytes, 0, bytes.Length)
|
||||
fs.Close()
|
||||
End Using
|
||||
End Using
|
||||
Retorno = True
|
||||
Retorno = True
|
||||
Else
|
||||
Retorno = False
|
||||
End If
|
||||
Else
|
||||
ModExtensiones.GuardaLogAD("ERROR: No existe Formato Base", ArchivoLog)
|
||||
End If
|
||||
@@ -8424,7 +8271,7 @@ Namespace ADS.eFacturas
|
||||
|
||||
Dim Pagos As New List(Of Pago)()
|
||||
For Each nodePago As XmlNode In NodosNodePagos
|
||||
Dim FechaPago As DateTime = NowADS()
|
||||
Dim FechaPago As DateTime = DateTime.Now
|
||||
Try
|
||||
FechaPago = ValorXML(nodePago, "FechaPago").ToDate()
|
||||
Catch e As Exception
|
||||
@@ -8502,6 +8349,115 @@ Namespace ADS.eFacturas
|
||||
End Function
|
||||
|
||||
|
||||
Public Function StreamPDF(UsuarioActual As Usuario, RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing, Optional SubReportData As Modelos.MSubReportData = Nothing) As Byte()
|
||||
'limpio ReportViwer
|
||||
Dim sw As Stopwatch = Stopwatch.StartNew()
|
||||
|
||||
|
||||
Dim Bytes As Byte() = Nothing
|
||||
Dim CveUsuario As Integer = 0
|
||||
Dim CveEmpresa As Integer = 0
|
||||
Dim RutaEmpresa As String = ""
|
||||
If UsuarioActual IsNot Nothing Then
|
||||
CveUsuario = UsuarioActual.CveUsuario
|
||||
CveEmpresa = UsuarioActual.CveEmpresa
|
||||
RutaEmpresa = UsuarioActual.Empresa.Ruta
|
||||
End If
|
||||
|
||||
Dim bdir As String = If(RutaReporte.Contains("Empresas"), ModExtensiones.DirectorioBaseEmpresas, AppDomain.CurrentDomain.BaseDirectory)
|
||||
'TOMAR LA RUTA BASE PARA EL DIRECTORIO DE LA EMPRESA
|
||||
If Not String.IsNullOrEmpty(RutaEmpresa) AndAlso Not RutaReporte.Contains("Grales") AndAlso Not RutaReporte.Contains("Contabilidad/Reportes/") AndAlso Not RutaReporte.Contains("Contabilidad/Reportes/") AndAlso Not RutaReporte.Contains("AC/Reportes/") Then
|
||||
bdir = RutaEmpresa.Replace($"{CveEmpresa}/", "")
|
||||
End If
|
||||
RutaReporte.Replace("/", "\")
|
||||
If Not RutaReporte.ToUpper().StartsWith(bdir.ToUpper()) Then
|
||||
RutaReporte = String.Format("{0}{1}", bdir, RutaReporte)
|
||||
End If
|
||||
If EsProduccion Then
|
||||
Dim wsreport As New WSRDLC2.WebServiceSoapClient
|
||||
Dim params As New List(Of WSRDLC2.ReportParameter)
|
||||
Dim reportobjects As New List(Of WSRDLC2.ReportObjects)
|
||||
Dim jsonData As String = Nothing
|
||||
If SubReportData IsNot Nothing Then
|
||||
jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(SubReportData)
|
||||
End If
|
||||
Dim ds As New DataSet
|
||||
For Each rpds As ReportDataSource In DataSource
|
||||
If rpds.Value IsNot Nothing Then
|
||||
If rpds.Value.GetType().ToString() = "System.Data.DataTable" Then
|
||||
Dim dt As DataTable = DirectCast(rpds.Value, Data.DataTable)
|
||||
dt = dt.Copy()
|
||||
dt.TableName = rpds.Name
|
||||
ds.Tables.Add(dt)
|
||||
Else
|
||||
Dim ojext As New WSRDLC2.ReportObjects
|
||||
ojext.Name = rpds.Name
|
||||
ojext.Value = rpds.Value
|
||||
reportobjects.Add(ojext)
|
||||
End If
|
||||
Else
|
||||
Dim dt As DataTable = New DataTable()
|
||||
dt.TableName = If(String.IsNullOrEmpty(rpds.Name), "DataTable1", rpds.Name)
|
||||
ds.Tables.Add(dt)
|
||||
End If
|
||||
Next
|
||||
For Each rpds As ReportParameter In Parametros
|
||||
Dim param As New WSRDLC2.ReportParameter
|
||||
param.Name = rpds.Name
|
||||
'SI ES TEXTO, QUITAR TABS Y OTROS ESPACIOS QUE DEN PROBLEMAS AL MANDAR LA PETICION
|
||||
If rpds IsNot Nothing AndAlso rpds.Values IsNot Nothing AndAlso rpds.Values.Count > 0 AndAlso rpds.Values(0) IsNot Nothing AndAlso rpds.Values(0).GetType() = GetType(String) Then
|
||||
param.Values = {rpds.Values(0).Replace(vbVerticalTab, "")}
|
||||
Else
|
||||
param.Values = {rpds.Values(0)}
|
||||
End If
|
||||
params.Add(param)
|
||||
Next
|
||||
Bytes = wsreport.StreamNEWPDFBytes(RutaReporte, ds, reportobjects.ToArray(), params.ToArray(), NombreArchivo, Formato, CveEmpresa, CveUsuario, jsonData)
|
||||
wsreport = Nothing
|
||||
params = Nothing
|
||||
ds.Dispose() : ds = Nothing
|
||||
Else
|
||||
If IsNothing(MR) Then MR = New ReportViewer
|
||||
Try
|
||||
' MasterReporteador.LocalReport.DataSources.Clear()
|
||||
For Each RDS As ReportDataSource In DataSource
|
||||
MR.LocalReport.DataSources.Add(RDS)
|
||||
Next
|
||||
MR.LocalReport.ReportPath = RutaReporte
|
||||
MR.ProcessingMode = ProcessingMode.Local
|
||||
MR.LocalReport.EnableExternalImages = True
|
||||
MR.LocalReport.SetParameters(Parametros)
|
||||
MR.LocalReport.Refresh()
|
||||
Dim Warnings As Warning() = Nothing
|
||||
Dim StreamIds As String() = Nothing
|
||||
Dim MimeType As String = Nothing
|
||||
Dim Encoding As String = Nothing
|
||||
Dim Extension As String = Nothing
|
||||
Bytes = MR.LocalReport.Render(Formato, Nothing, MimeType, Encoding, Extension, StreamIds, Warnings)
|
||||
Catch ex As Microsoft.Reporting.WebForms.ScriptManagerNotFoundException
|
||||
GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}")
|
||||
'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017
|
||||
'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}")
|
||||
Catch ex As Exception
|
||||
GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}")
|
||||
'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017
|
||||
'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}")
|
||||
End Try
|
||||
Try
|
||||
MR.Dispose()
|
||||
Catch ex As Exception
|
||||
GuardaLog($"Error: { ex.ToString() }")
|
||||
End Try
|
||||
MR = Nothing
|
||||
|
||||
End If
|
||||
sw.Stop()
|
||||
If sw.Elapsed.TotalSeconds > 5 Then
|
||||
GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ")
|
||||
End If
|
||||
Return Bytes
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
@@ -8976,10 +8932,10 @@ Namespace ADS.eFacturas
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Sub ImprimirPDF(NombreArchivo As String, DirectorioEmpresa As String, TipodeComprobante As String)
|
||||
Public Sub ImprimirPDF(UsuarioActual As Usuario, NombreArchivo As String, DirectorioEmpresa As String, TipodeComprobante As String)
|
||||
Dim objxml As XmlSatCFDI = Me
|
||||
|
||||
Dim rutaReporte As String = If(TipodeComprobante = "Pag", $"{DirectorioEmpresa}..\Grales\Formatos\CFDIV3Pago.rdlc", $"{DirectorioEmpresa}..\Grales\Formatos\CFDIV3.rdlc")
|
||||
Dim rutaReporte As String = If(TipodeComprobante = "Pag", "Grales\Formatos\CFDIV3Pago.rdlc", "Grales\Formatos\CFDIV3.rdlc")
|
||||
|
||||
|
||||
Dim cQr As Byte() = Nothing
|
||||
@@ -9044,7 +9000,8 @@ Namespace ADS.eFacturas
|
||||
parametros.Add(New ReportParameter("CPCtaBeneficiario", objxml.complemento.Pagos.CtaBeneficiario))
|
||||
End If
|
||||
|
||||
Using MR As New ReportViewer()
|
||||
Try
|
||||
Dim listaDS As New List(Of ReportDataSource)
|
||||
Dim rdsTotales As New ReportDataSource()
|
||||
Dim ltotales As New List(Of utilValores)()
|
||||
ltotales.Add(New utilValores("Subtotal", objxml.comprobante.SubTotal.ToString("N2")))
|
||||
@@ -9063,51 +9020,49 @@ Namespace ADS.eFacturas
|
||||
ltotales.Add(New utilValores("Total", objxml.comprobante.Total.ToString("N2")))
|
||||
rdsTotales.Name = "dsTotales"
|
||||
rdsTotales.Value = ltotales
|
||||
MR.LocalReport.DataSources.Add(rdsTotales)
|
||||
listaDS.Add(rdsTotales)
|
||||
|
||||
Dim rds2 As New ReportDataSource()
|
||||
Dim limagenes As New List(Of utilImage)()
|
||||
limagenes.Add(New utilImage(cQr))
|
||||
rds2.Name = "dsImagenes"
|
||||
rds2.Value = limagenes
|
||||
MR.LocalReport.DataSources.Add(rds2)
|
||||
listaDS.Add(rds2)
|
||||
|
||||
Dim rdsrelacionados As New ReportDataSource()
|
||||
rdsrelacionados.Name = "dsRelacionados"
|
||||
rdsrelacionados.Value = objxml.cFDIRelacionados
|
||||
MR.LocalReport.DataSources.Add(rdsrelacionados)
|
||||
listaDS.Add(rdsrelacionados)
|
||||
|
||||
Dim rds1 As New ReportDataSource()
|
||||
rds1.Name = "dsConceptos"
|
||||
rds1.Value = objxml.GetConceptosforpdf()
|
||||
MR.LocalReport.DataSources.Add(rds1)
|
||||
listaDS.Add(rds1)
|
||||
|
||||
If objxml.complemento.Pagos IsNot Nothing Then
|
||||
Dim rdsp As New ReportDataSource()
|
||||
rdsp.Name = "dsPagos"
|
||||
rdsp.Value = objxml.complemento.Pagos.doctosRelacionados
|
||||
MR.LocalReport.DataSources.Add(rdsp)
|
||||
listaDS.Add(rdsp)
|
||||
End If
|
||||
|
||||
MR.LocalReport.ReportPath = rutaReporte
|
||||
MR.ProcessingMode = ProcessingMode.Local
|
||||
MR.LocalReport.EnableExternalImages = True
|
||||
MR.LocalReport.SetParameters(parametros)
|
||||
MR.LocalReport.Refresh()
|
||||
|
||||
Dim warnings As Warning() = Nothing
|
||||
Dim streamids As String() = Nothing
|
||||
Dim mimeType As String = Nothing
|
||||
Dim encoding As String = Nothing
|
||||
Dim extension As String = Nothing
|
||||
'Dim bytes As Byte() = Nothing
|
||||
'bytes = MR.LocalReport.Render("PDF", Nothing, mimeType, encoding, extension, streamids, warnings)
|
||||
Dim bytes As Byte() = Nothing
|
||||
bytes = MR.LocalReport.Render("PDF", Nothing, mimeType, encoding, extension, streamids, warnings)
|
||||
bytes = StreamPDF(UsuarioActual, rutaReporte, listaDs, parametros, NombreArchivo:=NombreArchivo, Formato:="PDF")
|
||||
|
||||
If bytes IsNot Nothing Then
|
||||
Using fs As New FileStream(NombreArchivo, FileMode.Create)
|
||||
fs.Write(bytes, 0, bytes.Length)
|
||||
fs.Close()
|
||||
End Using
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
ex.ToString().GuardaLogAD()
|
||||
End Try
|
||||
|
||||
Using fs As New FileStream(NombreArchivo, FileMode.Create)
|
||||
fs.Write(bytes, 0, bytes.Length)
|
||||
fs.Close()
|
||||
End Using
|
||||
End Using
|
||||
End Sub
|
||||
|
||||
Public Class utilValores
|
||||
@@ -9125,6 +9080,117 @@ Namespace ADS.eFacturas
|
||||
End Sub
|
||||
Public Property ImagenByte As Byte()
|
||||
End Class
|
||||
|
||||
Public Function StreamPDF(UsuarioActual As Usuario, RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing, Optional SubReportData As Modelos.MSubReportData = Nothing) As Byte()
|
||||
'limpio ReportViwer
|
||||
Dim sw As Stopwatch = Stopwatch.StartNew()
|
||||
|
||||
|
||||
Dim Bytes As Byte() = Nothing
|
||||
Dim CveUsuario As Integer = 0
|
||||
Dim CveEmpresa As Integer = 0
|
||||
Dim RutaEmpresa As String = ""
|
||||
If UsuarioActual IsNot Nothing Then
|
||||
CveUsuario = UsuarioActual.CveUsuario
|
||||
CveEmpresa = UsuarioActual.CveEmpresa
|
||||
RutaEmpresa = UsuarioActual.Empresa.Ruta
|
||||
End If
|
||||
|
||||
Dim bdir As String = If(RutaReporte.Contains("Empresas"), ModExtensiones.DirectorioBaseEmpresas, AppDomain.CurrentDomain.BaseDirectory)
|
||||
'TOMAR LA RUTA BASE PARA EL DIRECTORIO DE LA EMPRESA
|
||||
If Not String.IsNullOrEmpty(RutaEmpresa) AndAlso Not RutaReporte.Contains("Grales") AndAlso Not RutaReporte.Contains("Contabilidad/Reportes/") AndAlso Not RutaReporte.Contains("Contabilidad/Reportes/") AndAlso Not RutaReporte.Contains("AC/Reportes/") Then
|
||||
bdir = RutaEmpresa.Replace($"{CveEmpresa}/", "")
|
||||
End If
|
||||
RutaReporte.Replace("/", "\")
|
||||
If Not RutaReporte.ToUpper().StartsWith(bdir.ToUpper()) Then
|
||||
RutaReporte = String.Format("{0}{1}", bdir, RutaReporte)
|
||||
End If
|
||||
If EsProduccion Then
|
||||
Dim wsreport As New WSRDLC2.WebServiceSoapClient
|
||||
Dim params As New List(Of WSRDLC2.ReportParameter)
|
||||
Dim reportobjects As New List(Of WSRDLC2.ReportObjects)
|
||||
Dim jsonData As String = Nothing
|
||||
If SubReportData IsNot Nothing Then
|
||||
jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(SubReportData)
|
||||
End If
|
||||
Dim ds As New DataSet
|
||||
For Each rpds As ReportDataSource In DataSource
|
||||
If rpds.Value IsNot Nothing Then
|
||||
If rpds.Value.GetType().ToString() = "System.Data.DataTable" Then
|
||||
Dim dt As DataTable = DirectCast(rpds.Value, Data.DataTable)
|
||||
dt = dt.Copy()
|
||||
dt.TableName = rpds.Name
|
||||
ds.Tables.Add(dt)
|
||||
Else
|
||||
Dim ojext As New WSRDLC2.ReportObjects
|
||||
ojext.Name = rpds.Name
|
||||
ojext.Value = rpds.Value
|
||||
reportobjects.Add(ojext)
|
||||
End If
|
||||
Else
|
||||
Dim dt As DataTable = New DataTable()
|
||||
dt.TableName = If(String.IsNullOrEmpty(rpds.Name), "DataTable1", rpds.Name)
|
||||
ds.Tables.Add(dt)
|
||||
End If
|
||||
Next
|
||||
For Each rpds As ReportParameter In Parametros
|
||||
Dim param As New WSRDLC2.ReportParameter
|
||||
param.Name = rpds.Name
|
||||
'SI ES TEXTO, QUITAR TABS Y OTROS ESPACIOS QUE DEN PROBLEMAS AL MANDAR LA PETICION
|
||||
If rpds IsNot Nothing AndAlso rpds.Values IsNot Nothing AndAlso rpds.Values.Count > 0 AndAlso rpds.Values(0) IsNot Nothing AndAlso rpds.Values(0).GetType() = GetType(String) Then
|
||||
param.Values = {rpds.Values(0).Replace(vbVerticalTab, "")}
|
||||
Else
|
||||
param.Values = {rpds.Values(0)}
|
||||
End If
|
||||
params.Add(param)
|
||||
Next
|
||||
Bytes = wsreport.StreamNEWPDFBytes(RutaReporte, ds, reportobjects.ToArray(), params.ToArray(), NombreArchivo, Formato, CveEmpresa, CveUsuario, jsonData)
|
||||
wsreport = Nothing
|
||||
params = Nothing
|
||||
ds.Dispose() : ds = Nothing
|
||||
Else
|
||||
If IsNothing(MR) Then MR = New ReportViewer
|
||||
Try
|
||||
' MasterReporteador.LocalReport.DataSources.Clear()
|
||||
For Each RDS As ReportDataSource In DataSource
|
||||
MR.LocalReport.DataSources.Add(RDS)
|
||||
Next
|
||||
MR.LocalReport.ReportPath = RutaReporte
|
||||
MR.ProcessingMode = ProcessingMode.Local
|
||||
MR.LocalReport.EnableExternalImages = True
|
||||
MR.LocalReport.SetParameters(Parametros)
|
||||
MR.LocalReport.Refresh()
|
||||
Dim Warnings As Warning() = Nothing
|
||||
Dim StreamIds As String() = Nothing
|
||||
Dim MimeType As String = Nothing
|
||||
Dim Encoding As String = Nothing
|
||||
Dim Extension As String = Nothing
|
||||
Bytes = MR.LocalReport.Render(Formato, Nothing, MimeType, Encoding, Extension, StreamIds, Warnings)
|
||||
Catch ex As Microsoft.Reporting.WebForms.ScriptManagerNotFoundException
|
||||
GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}")
|
||||
'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017
|
||||
'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}")
|
||||
Catch ex As Exception
|
||||
GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}")
|
||||
'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017
|
||||
'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}")
|
||||
End Try
|
||||
|
||||
Try
|
||||
MR.Dispose()
|
||||
Catch ex As Exception
|
||||
GuardaLog($"Error: { ex.ToString() }")
|
||||
End Try
|
||||
|
||||
MR = Nothing
|
||||
|
||||
End If
|
||||
sw.Stop()
|
||||
If sw.Elapsed.TotalSeconds > 5 Then
|
||||
GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ")
|
||||
End If
|
||||
Return Bytes
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Public Module InlineAssignHelper
|
||||
|
||||
Reference in New Issue
Block a user