From b56f9aa4ce5177c1f577cb55f26045abcf56c1cf Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sat, 9 Jul 2022 00:23:58 -0700 Subject: [PATCH] Editar formatos de stimulsoft --- App_Code/ClsPaginas.vb | 88 ++++++++++++++++++-------------- Sistemas/ListadoReportes.aspx | 81 +++++++++++++++++++++++++++++ Sistemas/ListadoReportes.aspx.cs | 46 +++++++++++++++++ 3 files changed, 177 insertions(+), 38 deletions(-) create mode 100644 Sistemas/ListadoReportes.aspx create mode 100644 Sistemas/ListadoReportes.aspx.cs diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index d5147673d..1ed0e6bf2 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4324,6 +4324,7 @@ Public Class ClsPaginas PaginaDict.Add("/OC/OCPendientes.aspx".ToUpper(), -1) PaginaDict.Add("/Sistemas/Registro.aspx".ToUpper(), -1) PaginaDict.Add("/Sistemas/WizardRegistro.aspx".ToUpper(), -1) + PaginaDict.Add("/Sistemas/ListadoReportes.aspx".ToUpper(), 702) PaginaDict.Add("/Ventas/VentasRene.aspx".ToUpper(), -1) PaginaDict.Add("/Contratos/Contrato2.aspx".ToUpper(), -1) PaginaDict.Add("/Flotillas/CatMantenimientos.aspx".ToUpper(), -1) @@ -6962,7 +6963,8 @@ Public Class ClsPaginas ' GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex)) ' End Try 'End Sub - Public Function PdfFactura(ByRef Vta As Modelos.Factura, Optional AplicaPagare As String = "0", Optional Guardar As Boolean = True, Optional SubReportData As Modelos.MSubReportData = Nothing) As Byte() + + Public Function PdfFactura(ByRef Vta As Modelos.Factura, Optional AplicaPagare As String = "0", Optional Guardar As Boolean = True, Optional SubReportData As Modelos.MSubReportData = Nothing, Optional UsarStimulsoft As Boolean = False) As Byte() Dim retorno As Byte() = Nothing ' Dim ObjVentas As New ClsVentas @@ -7789,46 +7791,52 @@ Public Class ClsPaginas Next End If - Dim Archivo As New System.IO.FileInfo(RutaFormato) - 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, SubReportData:=SubReportData) + If Not UsarStimulsoft Then + Dim Archivo As New System.IO.FileInfo(RutaFormato) + 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, SubReportData:=SubReportData) - 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 Not ArchivoPDF.Exists Then - Try - DirectoryExistsCreate(String.Format("{0}PDF", UsuarioActual.Empresa.Ruta)) - DirectoryExistsCreate(String.Format("{0}PDF\{1}", UsuarioActual.Empresa.Ruta, Vta.TipoDocto)) - File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) - Catch ex As Exception - Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) - End Try - Else - Try - ArchivoPDF.Delete() - File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) - Catch ex As Exception - Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) - End Try + 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 Not ArchivoPDF.Exists Then + Try + DirectoryExistsCreate(String.Format("{0}PDF", UsuarioActual.Empresa.Ruta)) + DirectoryExistsCreate(String.Format("{0}PDF\{1}", UsuarioActual.Empresa.Ruta, Vta.TipoDocto)) + File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) + Catch ex As Exception + Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) + End Try + Else + Try + ArchivoPDF.Delete() + File.WriteAllBytes(String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, Vta.TipoDocto, Vta.SerieFolio), retorno) + Catch ex As Exception + Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) + End Try + End If End If + Else + params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)) + 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, SubReportData:=SubReportData) End If Else - params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)) - 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, SubReportData:=SubReportData) + RutaFormato = RutaFormato.Replace(".rdlc", ".mrt") + retorno = StreamBytesStimulsoft("Facturas", RutaFormato, lrds, params, NombreArchivo:=NombreArchivo, Formato:="PDF") End If + Catch ex As Exception GuardaLog(String.Format("Ocurrio un error al generar el reporte RLDC {0}", ex)) End Try @@ -7864,9 +7872,12 @@ Public Class ClsPaginas If Not RutaReporte.ToUpper().StartsWith(bdir.ToUpper()) Then RutaReporte = String.Format("{0}{1}", bdir, RutaReporte) End If - + Dim urlHost As String = "http://localhost:2202/" + If EsProduccion Then + urlHost = "http://sig.adssistemas.mx:6599/" + End If 'SITIO DE PRUEBA EN IIS - Dim Url = New Uri(String.Format("{0}{1}", "http://localhost:2202/", Opcion)) + Dim Url = New Uri(String.Format("{0}{1}", urlHost, Opcion)) Try Dim dataSourceArray As New JArray() @@ -7883,6 +7894,7 @@ Public Class ClsPaginas Dim payload As New JObject( New JProperty("formato", Formato), New JProperty("ruta", RutaReporte), + New JProperty("UsarFormatoCompilado", false), New JProperty("parametros", paramsArray), New JProperty("dataSource", dataSourceArray) ) diff --git a/Sistemas/ListadoReportes.aspx b/Sistemas/ListadoReportes.aspx new file mode 100644 index 000000000..04c7bdaa4 --- /dev/null +++ b/Sistemas/ListadoReportes.aspx @@ -0,0 +1,81 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ListadoReportes.aspx.cs" Inherits="Sistemas_ListadoReportes" %> + + + + + + + Listado de reportes de Stimulsoft + + + + + + + + + + +
+
+
+
+
+ Listado de formatos +
+
+
+
+
+ " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
+
+
+
+
+
+ + + + + + + + + + + + +
+
+
+
+
+
+
+ + + + diff --git a/Sistemas/ListadoReportes.aspx.cs b/Sistemas/ListadoReportes.aspx.cs new file mode 100644 index 000000000..4ab288968 --- /dev/null +++ b/Sistemas/ListadoReportes.aspx.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using static Extensiones.ModExtensiones; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +public partial class Sistemas_ListadoReportes : ClsPaginas +{ + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + CargaDatos(); + } + } + + private void CargaDatos() + { + string RutaReportes = string.Format("{0}/Formatos", UsuarioActual.Empresa.Ruta); + + string[] allfiles = Directory.GetFiles(RutaReportes, "*.mrt", SearchOption.AllDirectories); + + GvDatos.DataSource = (from Reporte in allfiles + let file = new FileInfo(Reporte) + select new { RutaReporte = file.FullName, Reporte = file.Name.Replace(".mrt","") }).QueryToDataTable(true); + GvDatos.DataBind(); + UPDatos.Update(); + } + + protected void BtnEditar_Click(object sender, EventArgs e) + { + GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); + var RutaReporteEncriptada = Encripta(GvRow.DataKey("RutaReporte")); + var hostURL = "https://localhost:7162"; + if (UsuarioActual.Empresa.FacturaProduccion) + { + hostURL = "http://sig.adssistemas.mx:6599"; + } + var strURL = $"{hostURL}/Designer/EditReport?P={RutaReporteEncriptada}"; + + RegistraScript($"openWindow('{strURL}');"); + } +} \ No newline at end of file