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 { /// /// Tipo di report richiesto (da URL): Full / Cli / Short /// public string TipoReport { get; set; } /// /// Fase x report richiesto /// public string Fase { get; set; } /// /// REV Fase x report richiesto /// public int Rev { get; set; } /// /// Lingua x report richiesto /// public string Lingua { get; set; } /// /// dossier di cui creare report /// protected int IdxDossier { get { return memLayer.ML.QSI("IdxDossier"); } } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { } } /// /// sistema dati x report /// 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); } } /// /// Stampa il report selezionato /// /// Nome del file per salvataggio report 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}"); } /// /// wrapper traduzione /// /// /// public string traduci(string lemma) { return user_std.UtSn.Traduci(lemma); } /// /// sistema visibilità report /// /// private void showReport(bool showRep) { ReportCMS.Visible = showRep; lblOut.Visible = !showRep; } } }