176 lines
5.8 KiB
C#
176 lines
5.8 KiB
C#
using CMS_SC_Data;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web.UI;
|
|
|
|
namespace CMS_SC
|
|
{
|
|
public partial class ReportCompleto : System.Web.UI.Page
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
ddlFase.DataBind();
|
|
ddlLingue.DataBind();
|
|
string _idxDossier = memLayer.ML.QSS("IdxDossier");
|
|
int idxReq = 0;
|
|
int.TryParse(_idxDossier, out idxReq);
|
|
idxDossier = idxReq;
|
|
// se c'è seleziono fase...
|
|
ddlFase.SelectedValue = memLayer.ML.QSS("Fase");
|
|
// fix x revisione...
|
|
ddlRev.DataBind();
|
|
// fix x button download
|
|
lbtExportWithAttach.DataBind();
|
|
//mod_reportCompleto.Fase = ddlFase.SelectedValue;
|
|
//mod_reportCompleto.Lingua = ddlLingue.SelectedValue;
|
|
fixSelReport();
|
|
fixReportAndSpecBtn();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Controllo visibilità button full report: SOLO SE utente ha permesso...
|
|
/// </summary>
|
|
private void fixReportAndSpecBtn()
|
|
{
|
|
lbtExportWithAttach.Visible = devicesAuthProxy.stObj.userHasRight("ReportFullPdf") || devicesAuthProxy.stObj.userHasRight("CapoOfficina");
|
|
hlDownloadPdf.Visible = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Valore dossier salvato nell'hidden input
|
|
/// </summary>
|
|
protected int idxDossier
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(hfIdxDossier.Value, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
hfIdxDossier.Value = value.ToString();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(string lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma);
|
|
}
|
|
/// <summary>
|
|
/// cambio fase
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlFase_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// update ddl rev...
|
|
odsRev.DataBind();
|
|
ddlRev.DataBind();
|
|
// fix!
|
|
fixSelReport();
|
|
fixReportAndSpecBtn();
|
|
}
|
|
/// <summary>
|
|
/// cambio lingua
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlLingue_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
fixSelReport();
|
|
fixReportAndSpecBtn();
|
|
}
|
|
/// <summary>
|
|
/// Cambio revisione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlRev_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
fixSelReport();
|
|
fixReportAndSpecBtn();
|
|
}
|
|
/// <summary>
|
|
/// Sistemazione report con parametri
|
|
/// </summary>
|
|
private void fixSelReport()
|
|
{
|
|
// recupero num revisione
|
|
int rev = 0;
|
|
int.TryParse(ddlRev.SelectedValue, out rev);
|
|
// imposto!
|
|
mod_reportCompleto.Fase = ddlFase.SelectedValue;
|
|
mod_reportCompleto.Rev = rev;
|
|
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!
|
|
var tabDoss = DtProxy.man.taED.getByDossier(idxDossier);
|
|
if (tabDoss.Count > 0)
|
|
{
|
|
var currDoss = tabDoss[0];
|
|
DtProxy.man.taFRGL.insertQuery(OpAuth.currAuth.email, idxDossier, DateTime.Now, currDoss.Matricola, currDoss.FaseAct, currDoss.RevAct);
|
|
// step 1: genera directory lavoro
|
|
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
|
|
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)
|
|
{
|
|
pdfInFullPath = "";
|
|
if (!elencoPdf.Contains(item.Path))
|
|
{
|
|
pdfInFullPath = Server.MapPath(string.Format(urlSchede, item.Path));
|
|
elencoPdf.Add(pdfInFullPath);
|
|
}
|
|
}
|
|
// step 4: MERGE di tutti i pdf nel file di output
|
|
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.Visible = true;
|
|
hlDownloadPdf.NavigateUrl = $"downloadReport?baseDir={currOutPath}&fileName={outFilePath}&cType=pdf";
|
|
// refresh finale report mostrato (ho usaro reportviewer x export pdf...)
|
|
fixSelReport();
|
|
}
|
|
}
|
|
}
|
|
} |