Fix definitivo x generazione e merge pdf + refresh! installabile..

This commit is contained in:
Samuele E. Locatelli
2019-11-26 23:26:12 +01:00
parent e5509c2744
commit 153b6501f3
3 changed files with 57 additions and 15 deletions
+33 -13
View File
@@ -27,13 +27,13 @@ namespace CMS_SC
//mod_reportCompleto.Fase = ddlFase.SelectedValue;
//mod_reportCompleto.Lingua = ddlLingue.SelectedValue;
fixSelReport();
fixFullReportVisibility();
fixReportAndSpecBtn();
}
}
/// <summary>
/// Controllo visibilità button full report: SOLO SE utente ha permesso...
/// </summary>
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();
}
/// <summary>
/// cambio lingua
@@ -85,6 +86,7 @@ namespace CMS_SC
protected void ddlLingue_SelectedIndexChanged(object sender, EventArgs e)
{
fixSelReport();
fixReportAndSpecBtn();
}
/// <summary>
/// Cambio revisione
@@ -94,6 +96,7 @@ namespace CMS_SC
protected void ddlRev_SelectedIndexChanged(object sender, EventArgs e)
{
fixSelReport();
fixReportAndSpecBtn();
}
/// <summary>
/// Sistemazione report con parametri
@@ -109,7 +112,20 @@ namespace CMS_SC
mod_reportCompleto.Lingua = ddlLingue.SelectedValue;
mod_reportCompleto.fixReport();
}
/// <summary>
/// Sistemazione report con parametri + stampa pdf con nome indicato
/// </summary>
/// <param name="outFilePath"></param>
private void printReport(string outFilePath)
{
fixSelReport();
mod_reportCompleto.printReport(outFilePath);
}
/// <summary>
/// Premuto button x generare un unico PDF dei report...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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<string> elencoPdf = new List<string>();
// 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();
}
}
}
@@ -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();
}
}
/// <summary>
@@ -80,6 +79,29 @@ namespace CMS_SC.WebUserControls
}
}
/// <summary>
/// Stampa il report selezionato
/// </summary>
/// <param name="outFilePath">Nome del file per salvataggio report</param>
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);
}
}
}
/// <summary>
/// wrapper traduzione
/// </summary>
/// <param name="lemma"></param>
Binary file not shown.