134 lines
3.9 KiB
C#
134 lines
3.9 KiB
C#
using CMS_SC_Data;
|
|
using Microsoft.Reporting.WebForms;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Web.UI;
|
|
|
|
namespace CMS_SC.WebUserControls
|
|
{
|
|
public partial class mod_reportCompleto : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// Tipo di report richiesto (da URL): Full / Cli / Short
|
|
/// </summary>
|
|
public string TipoReport { get; set; }
|
|
/// <summary>
|
|
/// Fase x report richiesto
|
|
/// </summary>
|
|
public string Fase { get; set; }
|
|
/// <summary>
|
|
/// REV Fase x report richiesto
|
|
/// </summary>
|
|
public int Rev { get; set; }
|
|
/// <summary>
|
|
/// Lingua x report richiesto
|
|
/// </summary>
|
|
public string Lingua { get; set; }
|
|
/// <summary>
|
|
/// dossier di cui creare report
|
|
/// </summary>
|
|
protected int IdxDossier
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.QSI("IdxDossier");
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// sistema dati x report
|
|
/// </summary>
|
|
public void fixReport()
|
|
{
|
|
ReportCMS.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
|
|
LocalReport localReport = ReportCMS.LocalReport;
|
|
localReport.EnableExternalImages = true;
|
|
|
|
// se HO un dossier e ho un tipo report...
|
|
if (TipoReport != "" && IdxDossier > 0)
|
|
{
|
|
|
|
// 1) impostazione file report
|
|
localReport.ReportPath = string.Format(@".\Reports\Report_{0}.rdlc", TipoReport);
|
|
|
|
// 2) caricamento tab dati
|
|
DataTable tabDati = new DataTable();
|
|
DataTable tabVoc = new DataTable();
|
|
tabDati = (DataTable)DtProxy.man.taRep.GetData(IdxDossier, Fase, Rev, Lingua, TipoReport);
|
|
tabVoc = (DataTable)DtProxy.man.taVoc.getByLinguaLemmaLike(Lingua, "SC_PRT");
|
|
|
|
// 3) inserimento dataset nel report
|
|
localReport.DataSources.Clear();
|
|
localReport.DataSources.Add(new ReportDataSource("dsSchedaCollaudo", tabDati));
|
|
localReport.DataSources.Add(new ReportDataSource("dsVocabolario", tabVoc));
|
|
|
|
// mostro!
|
|
showReport(true);
|
|
}
|
|
else
|
|
{
|
|
// indico che mancano dati...
|
|
showReport(false);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Stampa il report selezionato
|
|
/// </summary>
|
|
/// <param name="outFilePath">Nome del file per salvataggio report</param>
|
|
public void printReport(string outFilePath)
|
|
{
|
|
logger.lg.scriviLog($"Inizio printReport da {ReportCMS.LocalReport.ReportPath}");
|
|
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);
|
|
// se è un percorso virtuale faccio mapPath...
|
|
string FilePath = "";
|
|
if (Path.IsPathRooted(outFilePath))
|
|
{
|
|
FilePath = outFilePath;
|
|
}
|
|
else
|
|
{
|
|
FilePath = Server.MapPath(outFilePath);
|
|
}
|
|
using (FileStream fs = new FileStream(FilePath, FileMode.Create))
|
|
{
|
|
fs.Write(bytes, 0, bytes.Length);
|
|
}
|
|
}
|
|
logger.lg.scriviLog($"Effettuato printReport di {outFilePath}");
|
|
}
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(string lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma);
|
|
}
|
|
/// <summary>
|
|
/// sistema visibilità report
|
|
/// </summary>
|
|
/// <param name="showRep"></param>
|
|
private void showReport(bool showRep)
|
|
{
|
|
ReportCMS.Visible = showRep;
|
|
lblOut.Visible = !showRep;
|
|
}
|
|
}
|
|
} |