Llamada a servicio de impresion de Stimultsoft
This commit is contained in:
@@ -16,6 +16,9 @@ Imports Stimulsoft.Report
|
|||||||
Imports System.Xml
|
Imports System.Xml
|
||||||
Imports System.Web.Http.ValueProviders
|
Imports System.Web.Http.ValueProviders
|
||||||
Imports ADServerControl
|
Imports ADServerControl
|
||||||
|
Imports System.Net.Http
|
||||||
|
Imports Newtonsoft.Json
|
||||||
|
Imports Newtonsoft.Json.Linq
|
||||||
|
|
||||||
|
|
||||||
'NOTA AD TEAM
|
'NOTA AD TEAM
|
||||||
@@ -7681,8 +7684,14 @@ Public Class ClsPaginas
|
|||||||
|
|
||||||
Dim Archivo As New System.IO.FileInfo(RutaFormato)
|
Dim Archivo As New System.IO.FileInfo(RutaFormato)
|
||||||
If Archivo.Exists Then
|
If Archivo.Exists Then
|
||||||
|
'If UsuarioActual.Empresa.Funcionalidad(350) = "1" Then
|
||||||
|
' RutaFormato = RutaFormato.Replace(".rdlc", ".mrt")
|
||||||
|
' retorno = StreamBytesStimulsoft("Facturas", RutaFormato, lrds, params, NombreArchivo:=NombreArchivo, Formato:="PDF")
|
||||||
|
'Else
|
||||||
|
' retorno = StreamPDF(RutaFormato, lrds, params, NombreArchivo, "PDF", MR:=Nothing)
|
||||||
|
'End If
|
||||||
retorno = StreamPDF(RutaFormato, lrds, params, NombreArchivo, "PDF", MR:=Nothing)
|
retorno = StreamPDF(RutaFormato, lrds, params, NombreArchivo, "PDF", MR:=Nothing)
|
||||||
|
|
||||||
Dim ArchivoPDF As New System.IO.FileInfo(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio))
|
Dim ArchivoPDF As New System.IO.FileInfo(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio))
|
||||||
If Guardar Then
|
If Guardar Then
|
||||||
If Not ArchivoPDF.Exists Then
|
If Not ArchivoPDF.Exists Then
|
||||||
@@ -7705,6 +7714,12 @@ Public Class ClsPaginas
|
|||||||
Else
|
Else
|
||||||
params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa))
|
params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa))
|
||||||
params.Add(New ReportParameter("RFC", UsuarioActual.Empresa.RFC))
|
params.Add(New ReportParameter("RFC", UsuarioActual.Empresa.RFC))
|
||||||
|
'If UsuarioActual.Empresa.Funcionalidad(350) = "1" Then
|
||||||
|
' RutaFormato = RutaFormato.Replace(".rdlc", ".mrt")
|
||||||
|
' retorno = StreamBytesStimulsoft("Facturas", RutaFormatoDefault, lrds, params, NombreArchivo:=NombreArchivo, Formato:="PDF")
|
||||||
|
'Else
|
||||||
|
' retorno = StreamPDF(RutaFormatoDefault, lrds, params, NombreArchivo, "PDF", MR:=Nothing)
|
||||||
|
'End If
|
||||||
retorno = StreamPDF(RutaFormatoDefault, lrds, params, NombreArchivo, "PDF", MR:=Nothing)
|
retorno = StreamPDF(RutaFormatoDefault, lrds, params, NombreArchivo, "PDF", MR:=Nothing)
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
@@ -7713,6 +7728,82 @@ Public Class ClsPaginas
|
|||||||
|
|
||||||
Return retorno
|
Return retorno
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Protected Function StreamBytesStimulsoft(Opcion As String, RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF") As Byte()
|
||||||
|
'limpio ReportViwer
|
||||||
|
Dim sw As New System.Diagnostics.Stopwatch()
|
||||||
|
sw.Start()
|
||||||
|
Dim Bytes As Byte() = Nothing
|
||||||
|
|
||||||
|
Dim CveUsuario As Integer = 0
|
||||||
|
Dim CveEmpresa As Integer = 0
|
||||||
|
Dim RutaEmpresa As String = ""
|
||||||
|
|
||||||
|
If Context.Session("UsuarioSIG") IsNot Nothing Then
|
||||||
|
CveUsuario = UsuarioActual.CveUsuario
|
||||||
|
CveEmpresa = UsuarioActual.CveEmpresa
|
||||||
|
RutaEmpresa = UsuarioActual.Empresa.RutaArchivos
|
||||||
|
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/") 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
|
||||||
|
|
||||||
|
'SITIO DE PRUEBA EN IIS
|
||||||
|
Dim Url = New Uri(String.Format("{0}{1}", "http://localhost:2202/", Opcion))
|
||||||
|
|
||||||
|
Try
|
||||||
|
Dim dataSourceArray As New JArray()
|
||||||
|
Dim paramsArray As New JArray()
|
||||||
|
|
||||||
|
For Each rds As ReportDataSource In DataSource
|
||||||
|
dataSourceArray.Add(New JObject(New JProperty("Nombre", rds.Name), New JProperty("Valor", JArray.Parse(JsonConvert.SerializeObject(rds.Value)))))
|
||||||
|
Next
|
||||||
|
|
||||||
|
For Each param As ReportParameter In Parametros
|
||||||
|
paramsArray.Add(New JObject(New JProperty("Nombre", param.Name), New JProperty("Valor", param.Values.Item(0))))
|
||||||
|
Next
|
||||||
|
|
||||||
|
Dim payload As New JObject(
|
||||||
|
New JProperty("formato", Formato),
|
||||||
|
New JProperty("ruta", RutaReporte),
|
||||||
|
New JProperty("parametros", paramsArray),
|
||||||
|
New JProperty("dataSource", dataSourceArray)
|
||||||
|
)
|
||||||
|
|
||||||
|
Dim data = New StringContent(payload.ToString(), Encoding.UTF8, "application/json")
|
||||||
|
|
||||||
|
Using httpClient = New HttpClient()
|
||||||
|
Using request = New HttpRequestMessage(HttpMethod.Post, Url)
|
||||||
|
'request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CVEUSUARIO=100", CveEmpresa, DateTime.UtcNow.Ticks)))
|
||||||
|
request.Content = New StringContent(payload.ToString(), Encoding.UTF8, "application/json")
|
||||||
|
Dim response = httpClient.SendAsync(request).Result
|
||||||
|
If response.StatusCode = Net.HttpStatusCode.OK Then
|
||||||
|
Bytes = response.Content.ReadAsByteArrayAsync().Result
|
||||||
|
End If
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al descargar la factura", ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
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
|
||||||
Private Function ValorNodoXML(n As System.Xml.XmlNode, Campo As String, Optional Retorno As String = "") As String
|
Private Function ValorNodoXML(n As System.Xml.XmlNode, Campo As String, Optional Retorno As String = "") As String
|
||||||
Dim o As System.Xml.XmlNode = n.Attributes.Cast(Of System.Xml.XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0)
|
Dim o As System.Xml.XmlNode = n.Attributes.Cast(Of System.Xml.XmlAttribute)().SingleOrDefault(Function(a) String.Compare(a.Name, Campo, True) = 0)
|
||||||
If o Is Nothing Then
|
If o Is Nothing Then
|
||||||
|
|||||||
Reference in New Issue
Block a user