diff --git a/CMS_SC/ReportCompleto.aspx.cs b/CMS_SC/ReportCompleto.aspx.cs index 8f1847d..1e47325 100644 --- a/CMS_SC/ReportCompleto.aspx.cs +++ b/CMS_SC/ReportCompleto.aspx.cs @@ -27,13 +27,13 @@ namespace CMS_SC //mod_reportCompleto.Fase = ddlFase.SelectedValue; //mod_reportCompleto.Lingua = ddlLingue.SelectedValue; fixSelReport(); - fixFullReportVisibility(); + fixReportAndSpecBtn(); } } /// /// Controllo visibilità button full report: SOLO SE utente ha permesso... /// - private void fixFullReportVisibility() + private void fixReportAndSpecBtn() { lbtExportWithAttach.Visible = devicesAuthProxy.stObj.userHasRight("ReportFullPdf") || devicesAuthProxy.stObj.userHasRight("CapoOfficina"); hlDownloadPdf.Visible = false; @@ -76,6 +76,7 @@ namespace CMS_SC ddlRev.DataBind(); // fix! fixSelReport(); + fixReportAndSpecBtn(); } /// /// cambio lingua @@ -85,6 +86,7 @@ namespace CMS_SC protected void ddlLingue_SelectedIndexChanged(object sender, EventArgs e) { fixSelReport(); + fixReportAndSpecBtn(); } /// /// Cambio revisione @@ -94,6 +96,7 @@ namespace CMS_SC protected void ddlRev_SelectedIndexChanged(object sender, EventArgs e) { fixSelReport(); + fixReportAndSpecBtn(); } /// /// Sistemazione report con parametri @@ -109,7 +112,20 @@ namespace CMS_SC mod_reportCompleto.Lingua = ddlLingue.SelectedValue; mod_reportCompleto.fixReport(); } - + /// + /// Sistemazione report con parametri + stampa pdf con nome indicato + /// + /// + private void printReport(string outFilePath) + { + fixSelReport(); + mod_reportCompleto.printReport(outFilePath); + } + /// + /// Premuto button x generare un unico PDF dei report... + /// + /// + /// protected void lbtExportWithAttach_Click(object sender, EventArgs e) { // effettua merge Report Completo + allegati: registro in primis la richiesta! @@ -122,12 +138,17 @@ namespace CMS_SC string currOutPath = $"\\tmp\\{idxDossier}"; fileMover.obj.setDirectoryMapPath(currOutPath); fileMover.obj.checkDir(); + // eventualmente elimino dalla directory i pdf contenuti... + fileMover.obj.svuotaDir("*.pdf"); // path scehde! string urlSchede = memLayer.ML.CRS("urlSchede"); string pdfInFullPath = ""; List elencoPdf = new List(); - // step 2: esporta pdf collaudo in dir temporanea come PRIMO file !!!FARE!!! - + // step 2: esporta pdf collaudo in dir temporanea come PRIMO file + string fullReportFilename = $"{currOutPath}\\ReportOnly.pdf"; + printReport(fullReportFilename); + // aggiungo primo PDF all'elenco... + elencoPdf.Add(Server.MapPath(fullReportFilename)); // step 3: colleziona allegati schede e li copia in locale var tabDati = DtProxy.man.taASC.getByDossier(idxDossier); foreach (var item in tabDati) @@ -140,16 +161,15 @@ namespace CMS_SC } } // step 4: MERGE di tutti i pdf nel file di output - string outFile = $"{Server.MapPath(currOutPath)}\\ReportFull_{idxDossier}.pdf"; - pdfUtils.mergePdfFiles(outFile, elencoPdf); - // step 5: chiamo pagina x download nuovo file composto... - // aggiorno button! + string outFilePath = $"ReportAndSpec_{idxDossier}.pdf"; + string outFilePathMapped = $"{Server.MapPath(currOutPath)}\\{outFilePath}"; + pdfUtils.mergePdfFiles(outFilePathMapped, elencoPdf); + // step 5: chiamo pagina x download nuovo file composto... aggiornando hyperLink button x scaricare in target "_blank" il report creato... lbtExportWithAttach.Visible = false; - hlDownloadPdf.NavigateUrl = $"downloadReport?baseDir={currOutPath}&fileName=ReportFull_{idxDossier}.pdf&cType=pdf"; hlDownloadPdf.Visible = true; - //Response.Redirect($"downloadReport?baseDir={currOutPath}&fileName=ReportFull_{idxDossier}.pdf&cType=pdf"); - - + hlDownloadPdf.NavigateUrl = $"downloadReport?baseDir={currOutPath}&fileName={outFilePath}&cType=pdf"; + // refresh finale report mostrato (ho usaro reportviewer x export pdf...) + fixSelReport(); } } } diff --git a/CMS_SC/WebUserControls/mod_reportCompleto.ascx.cs b/CMS_SC/WebUserControls/mod_reportCompleto.ascx.cs index 67b365a..39428cd 100644 --- a/CMS_SC/WebUserControls/mod_reportCompleto.ascx.cs +++ b/CMS_SC/WebUserControls/mod_reportCompleto.ascx.cs @@ -3,6 +3,7 @@ using Microsoft.Reporting.WebForms; using SteamWare; using System; using System.Data; +using System.IO; using System.Web.UI; namespace CMS_SC.WebUserControls @@ -39,8 +40,6 @@ namespace CMS_SC.WebUserControls { if (!Page.IsPostBack) { - //// collego il report... - //fixReport(); } } /// @@ -80,6 +79,29 @@ namespace CMS_SC.WebUserControls } } /// + /// Stampa il report selezionato + /// + /// Nome del file per salvataggio report + public void printReport(string outFilePath) + { + LocalReport localReport = ReportCMS.LocalReport; + Warning[] warnings; + string[] streamIds; + string mimeType = string.Empty; + string encoding = string.Empty; + string extension = string.Empty; + // se HO un dossier e ho un tipo report... + if (TipoReport != "" && IdxDossier > 0) + { + byte[] bytes = localReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings); + string FilePath = Server.MapPath(outFilePath); + using (FileStream fs = new FileStream(FilePath, FileMode.Create)) + { + fs.Write(bytes, 0, bytes.Length); + } + } + } + /// /// wrapper traduzione /// /// diff --git a/CMS_SC/tmp/1101/ReportFull_1101.pdf b/CMS_SC/tmp/1101/ReportFull_1101.pdf deleted file mode 100644 index dd1fa88..0000000 Binary files a/CMS_SC/tmp/1101/ReportFull_1101.pdf and /dev/null differ