public async Task <string> GenerateSequenceReport(string template, CaseSequenceData dataSource) { string filePath = System.Configuration.ConfigurationManager.AppSettings["ReportTempLocation"].ToString() + "\\" + Guid.NewGuid().ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".trdx"; XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; Telerik.Reporting.Report report = null; byte[] templateBytes = Convert.FromBase64String(template); File.WriteAllBytes(filePath, templateBytes); using (XmlReader xmlReader = XmlReader.Create(filePath, settings)) { ReportXmlSerializer xmlSerializer = new ReportXmlSerializer(); report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader); } report.DataSource = dataSource; ReportProcessor reportProcessor = new ReportProcessor(); InstanceReportSource instanceReportSource = new InstanceReportSource(); instanceReportSource.ReportDocument = report; RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); return(Convert.ToBase64String(result.DocumentBytes)); }
/// <summary> /// Export report results in a given format /// </summary> /// <param name="reportToExport">Holds report object</param> /// <param name="reportFormat">Hold report format</param> /// <returns>Returns generated file name</returns> private string Export(Telerik.Reporting.Report reportToExport, string reportFormat) { var reportProcessor = new ReportProcessor(); var instanceReportSource = new InstanceReportSource { ReportDocument = reportToExport }; RenderingResult result = reportProcessor.RenderReport(reportFormat, instanceReportSource, null); string dateTimeStamp = DateTime.Now.ToString(Constants.DateTimeExtendedFormat); string fileName = string.Format("{0}{1}.{2}", Constants.ModelingReportFileBaseName, dateTimeStamp, result.Extension); string path = GlobalConfigVariable.ReportsFilePath; string filePath = Path.Combine(path, fileName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (var fs = new FileStream(filePath, FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } return(fileName); }
private void ImprimirXLS(ArrayList ALValorParametrosInternos, Type instance) { try { Telerik.Reporting.Report report1 = (Telerik.Reporting.Report)Activator.CreateInstance(instance); for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++) { report1.ReportParameters[i].Value = ALValorParametrosInternos[i]; } ReportProcessor reportProcessor = new ReportProcessor(); RenderingResult result = reportProcessor.RenderReport("XLS", report1, null); string ruta = Server.MapPath("Reportes") + "\\" + instance.Name + ".xls"; if (File.Exists(ruta)) { File.Delete(ruta); } FileStream fs = new FileStream(ruta, FileMode.Create); fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); fs.Flush(); fs.Close(); RAM1.ResponseScripts.Add("startDownload('" + instance.Name + ".xls');"); } catch (Exception ex) { throw ex; } }
//public async Task<string> GetAccessToken() //{ // UserPasswordCredential creds = new UserPasswordCredential("*****@*****.**", "Welcome@123"); // AuthenticationResult authenticationResult = null; // var authenticationContext = new AuthenticationContext("https://login.windows.net/common/oauth2/token/"); // authenticationResult = await authenticationContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", "c565eea1-4938-468e-8d5f-35b74ac5e8e5", creds);// new ClientCredential(Secrets.ClientID,Secrets.ClientSecret)); // return authenticationResult.AccessToken.ToString(); //} public async Task <string> CreatePGXCaseReport(PGXCaseReportData dataSource) { string filePath = System.Configuration.ConfigurationManager.AppSettings["ReportTemplateLocation"].ToString() + "\\" + dataSource.TemplateName; XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; Telerik.Reporting.Report report = null; using (XmlReader xmlReader = XmlReader.Create(filePath, settings)) { ReportXmlSerializer xmlSerializer = new ReportXmlSerializer(); report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader); } report.DataSource = dataSource; ReportProcessor reportProcessor = new ReportProcessor(); InstanceReportSource instanceReportSource = new InstanceReportSource(); instanceReportSource.ReportDocument = report; RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); return(Convert.ToBase64String(result.DocumentBytes)); }
public static byte[] RenderMachineReport(SQLLib sql, List <string> MachineIDs, DateTime?From, DateTime?To, ReportingFlagsPaper ReportingPaper, string Output = "PDF") { byte[] ReportFile = GetReportPaperData(sql, "COMPUTERREPORT", Resources.Computer_Report); ReportBook RepBook = new ReportBook(); foreach (string MachineID in MachineIDs) { Dictionary <string, object> Params = new Dictionary <string, object>(); Params.Add("MachineID", MachineID); Params.Add("From", From); Params.Add("To", To); Params.Add("ReportingPaper", (int)ReportingPaper); RepBook.ReportSources.Add(RenderReportData(ReportFile, Params)); } InstanceReportSource instance = new InstanceReportSource(); instance.ReportDocument = RepBook; ReportProcessor reportprocessor = new ReportProcessor(); RenderingResult result = reportprocessor.RenderReport(Output, instance, null); return(result.DocumentBytes); }
public async Task <string> GenerateReport(string template, CaseQualitativeData dataSource) { //Reference:http://www.telerik.com/forums/programmatically-use-of-trdp-report //sample reports:C:\Program Files (x86)\Telerik\Reporting R1 2017\Report Designer\Examples string filePath = System.Configuration.ConfigurationManager.AppSettings["ReportTempLocation"].ToString() + "\\" + Guid.NewGuid().ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".trdx"; XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; Telerik.Reporting.Report report = null; byte[] templateBytes = Convert.FromBase64String(template); File.WriteAllBytes(filePath, templateBytes); using (XmlReader xmlReader = XmlReader.Create(filePath, settings)) { ReportXmlSerializer xmlSerializer = new ReportXmlSerializer(); report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader); } report.DataSource = dataSource; ReportProcessor reportProcessor = new ReportProcessor(); InstanceReportSource instanceReportSource = new InstanceReportSource(); instanceReportSource.ReportDocument = report; RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); return(Convert.ToBase64String(result.DocumentBytes)); }
private void ImprimirXLSGral(ArrayList ALValorParametrosGeneral, Type instance) { try { //Reporte de Facturas vigentes Telerik.Reporting.Report report1 = (Telerik.Reporting.Report)Activator.CreateInstance(instance); for (int i = 0; i <= ALValorParametrosGeneral.Count - 1; i++) { report1.ReportParameters[i].AllowNull = true; report1.ReportParameters[i].Value = ALValorParametrosGeneral[i]; } //report1.ReportParameters[23].Value = 1; //report1.ReportParameters[16].Value = 63; //report1.ReportParameters[1].Value = "Pendiente por facturar"; ReportProcessor reportProcessor = new ReportProcessor(); RenderingResult result = reportProcessor.RenderReport("XLS", report1, null); string ruta = Server.MapPath("Reportes") + "\\" + instance.Name + ".xls"; if (File.Exists(ruta)) { File.Delete(ruta); } FileStream fs = new FileStream(ruta, FileMode.Create); fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); fs.Flush(); fs.Close(); RadAjaxManager1.ResponseScripts.Add("startDownload('" + instance.Name + ".xls');"); } catch (Exception ex) { throw ex; } }
public void Report() { var ord = this.order; if (ord is SupplyOrder) { ReportProcessor reportProcessor = new ReportProcessor(); Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource(); instanceReportSource.ReportDocument = new OrderReportCopy(this as SupplyOrderViewModel); RenderingResult result = reportProcessor.RenderReport("XLS", instanceReportSource, null); var fileName = Path.GetTempFileName() + ".XLS"; var file = new FileInfo(fileName); if (file.Exists) { try { file.Delete(); } catch (IOException ex) { System.Windows.Forms.MessageBox.Show("Please close previous report."); } } using (FileStream fs = new FileStream(fileName, FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } System.Diagnostics.Process.Start(fileName); } }
protected void btnExport_Click(object sender, EventArgs e) { if (!DatosOk()) { return; } int id_instalacion = -1; if (instalacion != null) { id_instalacion = instalacion.InstalacionId; } string directorio = MapPath("/") + "\\Repo"; string nombreFichero = String.Format("ACT{0:0000000}_{1:0000}.pdf", id_instalacion, usuario.UsuarioId); string fichero = String.Format("{0}\\{1}", directorio, nombreFichero); ReportProcessor reportProcessor = new ReportProcessor(); RenderingResult renderingResult = null; string nombre = ""; switch (informe) { case "RptActa": Plantilla plantilla = CntLainsaSci.GetPlantilla(1, ctx); // la primera plantilla es la de acta. string numeroAutorizado = ConfigurationManager.AppSettings["NumeroAutorizado"]; string contenido = String.Format(plantilla.Contenido, numeroAutorizado, tecnicoResponsable.Nombre, actaNumero, fechaActa); ReportBook reportBook = new ReportBook(); RptCartaActa rptCartaActa = new RptCartaActa(contenido); reportBook.Reports.Add(rptCartaActa); if (instalacion != null) { RptInformeActa rptInformeActa = new RptInformeActa(instalacion, observaciones, actaNumero, fechaActa, tecnicoResponsable.Nombre, ctx); reportBook.Reports.Add(rptInformeActa); } else { RptInformeActaEmpresa rptInformeActaEmpresa = new RptInformeActaEmpresa(emp, observaciones, actaNumero, fechaActa, tecnicoResponsable.Nombre, ctx); reportBook.Reports.Add(rptInformeActaEmpresa); } renderingResult = reportProcessor.RenderReport("PDF", reportBook, null); break; } FileStream fs = new FileStream(fichero, FileMode.Create); fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length); fs.Close(); // abrir como documento sobre el repositorio nombre = txtActaNumero.Text + "_" + DateTime.Now.ToShortDateString(); string url = String.Format("DocumentoView.aspx?FileName={0}&InstalacionId={1}&Nombre={2}&EmpresaId={3}", nombreFichero, id_instalacion, nombre, emp.EmpresaId); string jCommand = String.Format("parent.openOutSide('{0}', 'DocumentoView');", url); RadAjaxManager1.ResponseScripts.Add(jCommand); //string url = String.Format("VisorInforme.aspx?Informe=RptInformeActaEmpresas&prueba=arg&emp={0}",emp.EmpresaId); //string jCommand = String.Format("parent.openOutSide('{0}','{1}');", url, "VisorInforme"); //RadAjaxManager1.ResponseScripts.Add(jCommand); }
private async Task SaveToDisk(RenderingResult file) { var dir = Path.GetDirectoryName(file.FilePath); if (Directory.Exists(dir) == false) { Directory.CreateDirectory(dir); } await fileReaderWriter.Write(file.FilePath, file.Content); }
/// <summary> /// Procesa un informe en el sentido de crear, o recrear el documento asociado. /// </summary> /// <param name="ip">Informe programado</param> /// <param name="desdeFecha">Desde fecha</param> /// <param name="hastaFecha">Hasta fecha</param> /// <param name="periodicidad">Periodicidad</param> /// <param name="instalacion">Instalacion</param> /// <param name="informe">Informe</param> /// <param name="repositorio">repositorio</param> /// <param name="ctx">Conector a la base de datos</param> public static void ProcesarUnInforme(InformeProgramado ip, DateTime desdeFecha, DateTime hastaFecha, string periodicidad, Instalacion instalacion, string informe, string repositorio, LainsaSci ctx) { Documento documento = new Documento(); if (ip != null) { documento = ip.Documento; } else { ip = new InformeProgramado(); ip.Empresa = instalacion.Empresa; ip.Instalacion = instalacion; ip.Instalacion = null; ip.FechaInicial = desdeFecha; ip.FechaFinal = hastaFecha; ip.ProgramacionInforme = GetProgramacionInforme(informe, periodicidad, ctx); ctx.Add(ip); documento.Empresa = instalacion.Empresa; documento.Instalacion = instalacion; documento.Fecha = DateTime.Now; documento.Comentarios = "Informe generado automáticamente"; documento.Extension = "PDF"; ctx.Add(documento); ip.Documento = documento; ctx.SaveChanges(); } // en cualquier caso hay que generar el documento y a ello vamos. string directorio = repositorio; string nombreFichero = String.Format("{0:000000000}", documento.DocumentoId) + ".PDF"; string fichero = String.Format("{0}\\{1}", directorio, nombreFichero); ReportProcessor reportProcessor = new ReportProcessor(); RenderingResult renderingResult = null; switch (informe) { case "RptResumenEmpresaInstalacion": RptResumenEmpresaInstalacion rptR = new RptResumenEmpresaInstalacion(desdeFecha, hastaFecha, instalacion.Empresa.EmpresaId, instalacion.InstalacionId, ctx); documento.Nombre = String.Format("Resumen Revisiones {0:dd/MM/yyyy} {1:dd/MM/yyyy} (Programado)", desdeFecha, hastaFecha); renderingResult = reportProcessor.RenderReport("PDF", rptR, null); break; case "RptFacturableEmpresaInstalacion": RptFacturableEmpresaInstalacion rptF = new RptFacturableEmpresaInstalacion(desdeFecha, hastaFecha, instalacion.Empresa.EmpresaId, instalacion.InstalacionId, ctx); documento.Nombre = String.Format("Revisiones facturables {0:dd/MM/yyyy} {1:dd/MM/yyyy} (Programado)", desdeFecha, hastaFecha); renderingResult = reportProcessor.RenderReport("PDF", rptF, null); break; } FileStream fs = new FileStream(fichero, FileMode.Create); fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length); fs.Close(); }
public async Task <Project> Mydelagate() { GDFService _svc = new GDFService(); var ret = await _svc.LoginAsync(Session["user"].ToString(), Session["pass"].ToString()); if (!ret) { return(null); } var proj = await _svc.GetProjectAsync(Convert.ToInt32(Session["id"])); // 2. Execute Simulation var task1 = _svc.ExecRenderingAsync( (s, e) => Console.WriteLine("time={0}, status={1}", e.Time, e.Result.RunningStatus), proj ); RenderingResult rets = await task1; { var result = task1.Result; if (result != null) { List <PartLog> partLogs = new List <PartLog>(result.PartLogs); foreach (var i in partLogs) { var a = i.Parts; var b = i.Time; } List <StatusLog> statusLogs = new List <StatusLog>(result.StatusLogs); foreach (var y in statusLogs) { var c = y.Time; var k = y.OperationRateOfStations; } // rets.FlowLogs = result.FlowLogs; // rets.PartLogs = result.PartLogs; // rets.StatusLogs = result.StatusLogs; // rets.Summary = result.Summary; // rets.RenderingTime = result.RenderingTime; var FlowLogs = result.FlowLogs; var PartLogs = result.PartLogs; var StatusLogs = result.StatusLogs; var Summary = result.Summary; var RenderingTime = result.RenderingTime; partLogs.Add(result.PartLogs); } return(null); } }
private static void ExportToPDF(Report report, string exportPath) { var reportProcessor = new ReportProcessor(); var instanceReportSource = new Telerik.Reporting.InstanceReportSource(); instanceReportSource.ReportDocument = report; RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); using (var fs = new FileStream(exportPath, FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } }
private byte[] GenerateReportByteArray(GetLifeFax.Report1 report) { InstanceReportSource instanceReportSource = new InstanceReportSource(); instanceReportSource.ReportDocument = report; ReportProcessor reportProcessor = new ReportProcessor(); RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); //reportToExport.Dispose(); return(result.DocumentBytes); }
private void SaveReport(Telerik.Reporting.Report report, string fileName) { ReportProcessor reportProcessor = new ReportProcessor(); Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource(); instanceReportSource.ReportDocument = report; RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); using (FileStream fs = new FileStream(fileName, FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } }
private async Task <bool> HasContentChanged(RenderingResult renderingResult) { if (File.Exists(renderingResult.FilePath)) { var currentContent = await fileReaderWriter.Read(renderingResult.FilePath); if (currentContent == renderingResult.Content) { return(false); } } return(true); }
public async Task <string> CreateToxicologyAccessionReport(ReportCaseData dataSource, string templateName) { int seriesCount = dataSource.PreviousHistoryChartData.Select(x => x.Name).Distinct().Count(); int xAxisDataCount = dataSource.PreviousHistoryChartData.Select(x => x.DateCollected).Distinct().Count(); //dataSource.ChartData = await this.GenerateChartImageFromXlsxFile("", "", dataSource.PreviousHistoryExcelChartData, seriesCount, xAxisDataCount); Console.Write(dataSource.ToString()); Console.WriteLine(templateName); //string templateName = "ToxicologyAccessionCaseReport"; string filePath = System.Configuration.ConfigurationManager.AppSettings["ReportTemplateLocation"].ToString() + "\\" + templateName + ".trdx"; XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; Telerik.Reporting.Report report = null; using (XmlReader xmlReader = XmlReader.Create(filePath, settings)) { ReportXmlSerializer xmlSerializer = new ReportXmlSerializer(); report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader); } report.DataSource = dataSource; ReportProcessor reportProcessor = new ReportProcessor(); InstanceReportSource instanceReportSource = new InstanceReportSource(); instanceReportSource.ReportDocument = report; RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); //var reportLocation = ConfigurationManager.AppSettings["ReportTempLocation"]; //string reportName = templateName+"_" + Guid.NewGuid().ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".pdf"; //string reportDestination = Path.Combine(reportLocation, reportName); //using (FileStream fs = new FileStream(reportDestination, FileMode.Create)) //{ // fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); //} //string reportUrl = dataSource.ServerUrl + "/" + reportName; ////byte[] bytes = result.DocumentBytes; //string response = Convert.ToBase64String(bytes); return(Convert.ToBase64String(result.DocumentBytes)); }
public static byte[] RenderReportData(byte[] ReportBinaryData, Dictionary <string, object> Parameters, string Output = "PDF") { try { ReportSource instance = RenderReportData(ReportBinaryData, Parameters); ReportProcessor reportprocessor = new ReportProcessor(); RenderingResult result = reportprocessor.RenderReport(Output, instance, null); return(result.DocumentBytes); } catch (Exception ee) { Debug.WriteLine(ee.ToString()); return(null); } }
public async Task <ActionResult> Tooling() { GDFService _svc = new GDFService(); var ret = await _svc.LoginAsync(Session["user"].ToString(), Session["pass"].ToString()); if (!ret) { return(null); } var proj = await _svc.GetProjectAsync(Convert.ToInt32(Session["id"])); var result = await _svc.ExecRenderingAsync( (s, e) => Console.WriteLine("time={0}, status={1}", e.Time, e.Result.RunningStatus), proj ); RenderingResult rendering = new RenderingResult(); List <ToolingInfo_View> toolingInfo_Views = new List <ToolingInfo_View>(); if (result != null) { rendering.Summary = result.Summary; SummaryResult summary = new SummaryResult(); summary = result.Summary; List <ToolingInfo> toolingInfos = new List <ToolingInfo>(summary.Toolings); //Define object summary_view ToolingInfo_View toolingInfo_View = new ToolingInfo_View(); ToolingInfo toolingInfo = new ToolingInfo(); foreach (var i in toolingInfos) { toolingInfo_View.UnusedCount = i.UnusedCount; toolingInfo_View.UsedCount = i.UsedCount; toolingInfo_View.ZeroLifeCount = i.ZeroLifeCount; toolingInfo_Views.Add(toolingInfo_View); } } return(View(toolingInfo_Views)); }
public static void ExportToPDF(Telerik.Reporting.Report reportToExport) { ReportProcessor reportProcessor = new ReportProcessor(); //Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource(); //instanceReportSource.ReportDocument = reportToExport; RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null); string fileName = result.DocumentName + DateTime.Now.Ticks + "." + result.Extension; var directoryInfo = Directory.GetParent(Directory.GetCurrentDirectory()).Parent; string projectPath = directoryInfo.FullName; string folderName = Path.Combine(projectPath, "TestDataSource"); if (!Directory.Exists(folderName)) { Directory.CreateDirectory(folderName); } string filePath = Path.Combine(folderName, fileName); using (FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } //Response.Clear(); //Response.ContentType = result.MimeType; //Response.Cache.SetCacheability(HttpCacheability.Private); //Response.Expires = -1; //Response.Buffer = true; //Response.AddHeader("Content-Disposition", // string.Format("{0};FileName=\"{1}\"", // "attachment", // fileName)); //Response.BinaryWrite(result.DocumentBytes); //Response.End(); }
public ActionResult GenReport(int Id) { DataTable dt = Conexion.Ejecutar_dt(string.Format("EXEC [dbo].[Consulta_Datos_Reporte_NC] @DocEntry = '{0}'", Id)); if (!string.IsNullOrEmpty(dt.Rows[0].ItemArray[9].ToString())) { string RutImg = ConfigurationManager.AppSettings["RutSerFT"].ToString() + ConfigurationManager.AppSettings["IMG"].ToString() + "Logo.png"; Reportes.Report_NC_A4 reportToExport = new Reportes.Report_NC_A4(dt, RutImg); ReportProcessor reportProcessor = new ReportProcessor(); Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource(); instanceReportSource.ReportDocument = reportToExport; RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); string fileName = dt.Rows[0].ItemArray[0].ToString() + "-07-" + dt.Rows[0].ItemArray[10].ToString() + "." + result.Extension; string RutPdf = ConfigurationManager.AppSettings["RutSerFT"].ToString() + ConfigurationManager.AppSettings["REPO"].ToString() + fileName; Response.Clear(); Response.ContentType = result.MimeType; Response.Cache.SetCacheability(HttpCacheability.Private); Response.Expires = -1; Response.Buffer = true; Response.AddHeader("Content-Disposition", string.Format("{0};FileName=\"{1}\"", "attachment", fileName)); Response.BinaryWrite(result.DocumentBytes); if (!System.IO.File.Exists(RutPdf)) { System.IO.File.WriteAllBytes(RutPdf, result.DocumentBytes); } Response.End(); ViewBag.Confirmacion = "PDF generado"; return(File(result.DocumentBytes, "application/pdf")); } ViewBag.Error = "Nota de credito sin Firma digital"; return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Documento electronico sin firma Digital")); }
public async Task <string> CreateToxLabOrderRequisitionReport(ToxLabOrderReportData dataSource, string templateName = "ToxLabOrderRequisitionReport.trdx") { string filePath = System.Configuration.ConfigurationManager.AppSettings["ReportTemplateLocation"].ToString() + "\\" + templateName; XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; Telerik.Reporting.Report report = null; using (XmlReader xmlReader = XmlReader.Create(filePath, settings)) { ReportXmlSerializer xmlSerializer = new ReportXmlSerializer(); report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader); } report.DataSource = dataSource; ReportProcessor reportProcessor = new ReportProcessor(); InstanceReportSource instanceReportSource = new InstanceReportSource(); instanceReportSource.ReportDocument = report; RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); //var reportLocation = ConfigurationManager.AppSettings["ReportTempLocation"]; //string reportName = dataSource.Id + "_ToxLabOrderRequisition_" + Guid.NewGuid().ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".pdf"; //string reportDestination = Path.Combine(dataSource.FolderPath, reportName); //using (FileStream fs = new FileStream(reportDestination, FileMode.Create)) //{ // fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); //} //string reportUrl = dataSource.ServerUrl + "/" + reportName; //byte[] bytes = result.DocumentBytes; //string response = Convert.ToBase64String(bytes); return(Convert.ToBase64String(result.DocumentBytes)); }
protected void Page_Load(object sender, EventArgs e) { ReportProcessor reportProcessor = new ReportProcessor(); // set any deviceInfo settings if necessary System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); Telerik.Reporting.TypeReportSource typeReportSource = new Telerik.Reporting.TypeReportSource(); // reportName is the Assembly Qualified Name of the report typeReportSource.TypeName = "PDF"; RenderingResult result = reportProcessor.RenderReport("PDF", typeReportSource, deviceInfo); string fileName = result.DocumentName + "." + result.Extension; string path = System.IO.Path.GetTempPath(); string filePath = System.IO.Path.Combine(path, fileName); using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } }
public static Stream GetReportStream(IReportDocument report, string filename, out Exception exception, string format) { try { ReportProcessor reportProcessor = new ReportProcessor(); InstanceReportSource instanceReportSource = new InstanceReportSource(); instanceReportSource.ReportDocument = report; RenderingResult renderingResult = reportProcessor.RenderReport(format.ToUpper(), instanceReportSource, null); MemoryStream stream = new MemoryStream(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length); exception = null; return(stream); } catch (Exception ex) { exception = ex; return(null); } }
public static bool SaveReport(IReportDocument report, string filename, out Exception exception, string format) { try { ReportProcessor reportProcessor = new ReportProcessor(); InstanceReportSource instanceReportSource = new InstanceReportSource(); instanceReportSource.ReportDocument = report; RenderingResult renderingResult = reportProcessor.RenderReport(format.ToUpper(), instanceReportSource, null); filename = filename.Replace('\n', ' '); using (FileStream fs = new FileStream(filename, FileMode.Create)) { fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length); } exception = null; return(true); } catch (Exception ex) { exception = ex; return(false); } }
void ExportToPDF(Telerik.Reporting.Report reportToExport) { ReportProcessor reportProcessor = new ReportProcessor(); Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource(); instanceReportSource.ReportDocument = reportToExport; RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); string fileName = result.DocumentName + "." + result.Extension; Response.Clear(); Response.ContentType = result.MimeType; Response.Cache.SetCacheability(HttpCacheability.Private); Response.Expires = -1; Response.Buffer = true; Response.AddHeader("Content-Disposition", string.Format("{0};FileName=\"{1}\"", "attachment", fileName)); Response.BinaryWrite(result.DocumentBytes); Response.End(); }
protected void btnExport_Click(object sender, EventArgs e) { if (!DatosOk()) { return; } string instid = "-1", t_disp_id = "-1"; string informe = tipo_informe; string nombreFichero = string.Empty; string directorio = MapPath("/") + "\\Repo"; ReportProcessor reportProcessor = new ReportProcessor(); RenderingResult renderingResult = null; string nombre = ""; switch (tipo_informe) { case "RptResumenEmpresaInstalacion": if (rcbInstalacion.SelectedValue != RCD_EMPTY) { if (rcbTipoDispositivo.SelectedValue != RCD_EMPTY) { informe = "RptResumenEmpresa"; if (tipo_dispositivo != null) { t_disp_id = tipo_dispositivo.TipoId.ToString(); if (instalacion == null) { nombreFichero = String.Format("EXP{0:0000000}_Instalaciones_{1:0000000}_{2:0000}.pdf", empresa.EmpresaId, t_disp_id, usuario.UsuarioId); } else { instid = instalacion.InstalacionId.ToString(); nombreFichero = String.Format("EXP{0:0000000}_{1:0000000}_{2:0000000}_{3:0000}.pdf", empresa.EmpresaId, instid, t_disp_id, usuario.UsuarioId); } } else { if (instalacion == null) { nombreFichero = String.Format("EXP{0:0000000}_Instalaciones_{1:0000}.pdf", empresa.EmpresaId, usuario.UsuarioId); } else { instid = instalacion.InstalacionId.ToString(); nombreFichero = String.Format("EXP{0:0000000}_{1:0000000}_{2:0000}.pdf", empresa.EmpresaId, instid, usuario.UsuarioId); } } RptResumenEmpresa rptR = new RptResumenEmpresa(desdeFecha, hastaFecha, empresa.EmpresaId, int.Parse(instid), int.Parse(instid), ctx); nombre = String.Format("Resumen Revisiones {0:dd/MM/yyyy} {1:dd/MM/yyyy}", desdeFecha, hastaFecha); renderingResult = reportProcessor.RenderReport("PDF", rptR, null); } else { if (instalacion != null) { instid = instalacion.InstalacionId.ToString(); nombreFichero = String.Format("EXP{0:0000000}_{1:0000000}_{2:0000}.pdf", empresa.EmpresaId, instid, usuario.UsuarioId); } else { nombreFichero = String.Format("EXP{0:0000000}_Instalaciones_{1:0000}.pdf", empresa.EmpresaId, usuario.UsuarioId); } RptResumenEmpresaInstalacion rptR = new RptResumenEmpresaInstalacion(desdeFecha, hastaFecha, empresa.EmpresaId, int.Parse(instid), ctx); nombre = String.Format("Resumen Revisiones {0:dd/MM/yyyy} {1:dd/MM/yyyy}", desdeFecha, hastaFecha); renderingResult = reportProcessor.RenderReport("PDF", rptR, null); } } else if (rcbTipoDispositivo.SelectedValue != RCD_EMPTY) { informe = "RptResumenEmpresaTipoDispositivo"; if (tipo_dispositivo != null) { t_disp_id = tipo_dispositivo.TipoId.ToString(); nombreFichero = String.Format("EXP{0:0000000}_{1:0000000}_{2:0000}.pdf", empresa.EmpresaId, t_disp_id, usuario.UsuarioId); } else { nombreFichero = String.Format("EXP{0:0000000}_{1:0000}.pdf", empresa.EmpresaId, usuario.UsuarioId); } RptResumenEmpresaTipoDispositivo rptR = new RptResumenEmpresaTipoDispositivo(desdeFecha, hastaFecha, empresa.EmpresaId, int.Parse(t_disp_id), ctx); nombre = String.Format("Resumen Revisiones {0:dd/MM/yyyy} {1:dd/MM/yyyy}", desdeFecha, hastaFecha); renderingResult = reportProcessor.RenderReport("PDF", rptR, null); } break; case "RptFacturableEmpresaInstalacion": if (rcbInstalacion.SelectedValue != RCD_EMPTY) { if (rcbTipoDispositivo.SelectedValue != RCD_EMPTY) { informe = "RptFacturableEmpresa"; if (tipo_dispositivo != null) { t_disp_id = tipo_dispositivo.TipoId.ToString(); if (instalacion == null) { nombreFichero = String.Format("EXP{0:0000000}_Instalaciones_{1:0000000}_{2:0000}.pdf", empresa.EmpresaId, t_disp_id, usuario.UsuarioId); } else { instid = instalacion.InstalacionId.ToString(); nombreFichero = String.Format("EXP{0:0000000}_{1:0000000}_{2:0000000}_{3:0000}.pdf", empresa.EmpresaId, instid, t_disp_id, usuario.UsuarioId); } } else { if (instalacion != null) { instid = instalacion.InstalacionId.ToString(); nombreFichero = String.Format("EXP{0:0000000}_{1:0000000}_{2:0000}.pdf", empresa.EmpresaId, instid, usuario.UsuarioId); } else { nombreFichero = String.Format("EXP{0:0000000}_{2:0000}.pdf", empresa.EmpresaId, usuario.UsuarioId); } } RptFacturableEmpresa rptT = new RptFacturableEmpresa(desdeFecha, hastaFecha, empresa.EmpresaId, int.Parse(instid), int.Parse(t_disp_id), ctx); nombre = String.Format("Revisiones facturables {0:dd/MM/yyyy} {1:dd/MM/yyyy}", desdeFecha, hastaFecha); renderingResult = reportProcessor.RenderReport("PDF", rptT, null); } else { if (instalacion != null) { instid = instalacion.InstalacionId.ToString(); nombreFichero = String.Format("EXP{0:0000000}_Instalaciones_{1:0000000}_{2:0000}.pdf", empresa.EmpresaId, instid, usuario.UsuarioId); } else { nombreFichero = String.Format("EXP{0:0000000}_Instalaciones_{1:0000000}_{2:0000}.pdf", empresa.EmpresaId, t_disp_id, usuario.UsuarioId); } RptFacturableEmpresaInstalacion rptF = new RptFacturableEmpresaInstalacion(desdeFecha, hastaFecha, empresa.EmpresaId, int.Parse(instid), ctx); nombre = String.Format("Revisiones facturables {0:dd/MM/yyyy} {1:dd/MM/yyyy}", desdeFecha, hastaFecha); renderingResult = reportProcessor.RenderReport("PDF", rptF, null); } } else if (rcbTipoDispositivo.SelectedValue != RCD_EMPTY) { informe = "RptFacturableEmpresaTipoDispositivo"; if (tipo_dispositivo != null) { t_disp_id = tipo_dispositivo.TipoId.ToString(); nombreFichero = String.Format("EXP{0:0000000}_{1:0000000}_{3:0000}.pdf", empresa.EmpresaId, t_disp_id, usuario.UsuarioId); } else { nombreFichero = String.Format("EXP{0:0000000}_{1:0000}.pdf", empresa.EmpresaId, usuario.UsuarioId); } RptFacturableEmpresaTipoDispositivo rptT = new RptFacturableEmpresaTipoDispositivo(desdeFecha, hastaFecha, empresa.EmpresaId, int.Parse(t_disp_id), ctx); nombre = String.Format("Revisiones facturables {0:dd/MM/yyyy} {1:dd/MM/yyyy}", desdeFecha, hastaFecha); renderingResult = reportProcessor.RenderReport("PDF", rptT, null); } break; } string fichero = String.Format("{0}\\{1}", directorio, nombreFichero); FileStream fs = new FileStream(fichero, FileMode.Create); fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length); fs.Close(); // abrir como documento sobre el repositorio string url = String.Format("DocumentoView.aspx?FileName={0}&EmpresaId={1}&Nombre={2}&InstalacionId={3}&TipoDispositivoId={4}", nombreFichero, empresa.EmpresaId, nombre, instid, t_disp_id); string jCommand = String.Format("parent.openOutSide('{0}', 'DocumentoView');", url); RadAjaxManager1.ResponseScripts.Add(jCommand); }
private void ImprimirXLS(ArrayList ALValorParametrosInternos, Type instance, ArrayList ALValorParametrosConsignacion, Type instance2) { try { //Reporte de Facturas vigentes Telerik.Reporting.Report report1 = (Telerik.Reporting.Report)Activator.CreateInstance(instance); for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++) { report1.ReportParameters[i].AllowNull = true; report1.ReportParameters[i].Value = ALValorParametrosInternos[i]; } report1.ReportParameters[23].Value = 1; report1.ReportParameters[16].Value = 63; report1.ReportParameters[1].Value = "Pendiente por facturar"; //Reporte de Facturas vencidas Telerik.Reporting.Report reportPXFVEN = (Telerik.Reporting.Report)Activator.CreateInstance(instance); for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++) { if (i == 23) { reportPXFVEN.ReportParameters[i].AllowNull = true; reportPXFVEN.ReportParameters[i].Value = 0; } else { reportPXFVEN.ReportParameters[i].AllowNull = true; reportPXFVEN.ReportParameters[i].Value = ALValorParametrosInternos[i]; } } reportPXFVEN.ReportParameters[23].Value = 0; reportPXFVEN.ReportParameters[16].Value = 63; reportPXFVEN.ReportParameters[1].Value = "Pendiente por facturar"; //Reporte de prueba Vigente Telerik.Reporting.Report PruebaVIG = (Telerik.Reporting.Report)Activator.CreateInstance(instance); for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++) { PruebaVIG.ReportParameters[i].AllowNull = true; PruebaVIG.ReportParameters[i].Value = ALValorParametrosInternos[i]; } PruebaVIG.ReportParameters[16].Value = 64; PruebaVIG.ReportParameters[1].Value = "Prueba"; PruebaVIG.ReportParameters[23].Value = 0; //vigente //Reporte de prueba Vencidas Telerik.Reporting.Report PruebaVEN = (Telerik.Reporting.Report)Activator.CreateInstance(instance); for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++) { PruebaVEN.ReportParameters[i].AllowNull = true; PruebaVEN.ReportParameters[i].Value = ALValorParametrosInternos[i]; } PruebaVEN.ReportParameters[16].Value = 64; PruebaVEN.ReportParameters[1].Value = "Prueba"; PruebaVEN.ReportParameters[23].Value = 1; //Vencida //Reporte de No conformes Vigente Telerik.Reporting.Report NCVIG = (Telerik.Reporting.Report)Activator.CreateInstance(instance); for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++) { NCVIG.ReportParameters[i].AllowNull = true; NCVIG.ReportParameters[i].Value = ALValorParametrosInternos[i]; } NCVIG.ReportParameters[16].Value = 65; NCVIG.ReportParameters[1].Value = "Producto no conforme"; NCVIG.ReportParameters[23].Value = 0; //vigente //Reporte de No Conforme Vencidas Telerik.Reporting.Report NCVEN = (Telerik.Reporting.Report)Activator.CreateInstance(instance); for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++) { NCVEN.ReportParameters[i].AllowNull = true; NCVEN.ReportParameters[i].Value = ALValorParametrosInternos[i]; } NCVEN.ReportParameters[16].Value = 65; NCVEN.ReportParameters[1].Value = "Producto no conforme"; NCVEN.ReportParameters[23].Value = 1; //Vencida //Reporte de prueba Vigente Telerik.Reporting.Report RepConsignacion = (Telerik.Reporting.Report)Activator.CreateInstance(instance2); for (int i = 0; i <= ALValorParametrosConsignacion.Count - 1; i++) { RepConsignacion.ReportParameters[i].AllowNull = true; RepConsignacion.ReportParameters[i].Value = ALValorParametrosConsignacion[i]; } var reportBook = new ReportBook(); reportBook.Reports.Add(report1); reportBook.Reports.Add(reportPXFVEN); reportBook.Reports.Add(PruebaVIG); reportBook.Reports.Add(PruebaVEN); reportBook.Reports.Add(NCVIG); reportBook.Reports.Add(NCVEN); reportBook.Reports.Add(RepConsignacion); reportBook.Reports[0].DocumentName = "PXF_VENCIDA"; reportBook.Reports[1].DocumentName = "PXF_VIGENTE"; reportBook.Reports[3].DocumentName = "PRUEBA VENCIDA"; reportBook.Reports[2].DocumentName = "PRUEBA VIGENTE"; reportBook.Reports[5].DocumentName = "NC VENCIDA"; reportBook.Reports[4].DocumentName = "NC VIGENTE"; reportBook.Reports[6].DocumentName = "Consignacion"; ReportProcessor reportProcessor = new ReportProcessor(); RenderingResult result = reportProcessor.RenderReport("XLS", reportBook, null); string ruta = Server.MapPath("Reportes") + "\\" + ALValorParametrosConsignacion[2] + instance.Name + ".xls"; if (File.Exists(ruta)) { File.Delete(ruta); } FileStream fs = new FileStream(ruta, FileMode.Create); fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); fs.Flush(); fs.Close(); // RAM1.ResponseScripts.Add("startDownload('" + instance.Name + ".xls');"); RadAjaxManager1.ResponseScripts.Add("startDownload('" + ALValorParametrosConsignacion[2] + instance.Name + ".xls');"); //Telerik.Reporting.Report report1 = (Telerik.Reporting.Report)Activator.CreateInstance(instance); //for (int i = 0; i <= ALValorParametrosInternos.Count - 1; i++) //{ // report1.ReportParameters[i].AllowNull = true; // report1.ReportParameters[i].Value = ALValorParametrosInternos[i]; //} //ReportProcessor reportProcessor = new ReportProcessor(); //RenderingResult result = reportProcessor.RenderReport("XLS", report1, null); //string ruta = Server.MapPath("Reportes") + "\\" + instance.Name + ".xls"; //if (File.Exists(ruta)) // File.Delete(ruta); //FileStream fs = new FileStream(ruta, FileMode.Create); //fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); //fs.Flush(); //fs.Close(); //RadAjaxManager1.ResponseScripts.Add("startDownload('" + instance.Name + ".xls');"); } catch (Exception ex) { throw ex; } }
protected void CrearInforme(Filtro f, string repositorio) { string consulta = string.Empty; Documento documento = new Documento(); documento.Nombre = f.Nombre; documento.Empresa = usuario.Empresa; documento.Instalacion = usuario.Instalacion; documento.Fecha = DateTime.Now; documento.Comentarios = "Informe generado automáticamente"; documento.Extension = "PDF"; ctx.Add(documento); ctx.SaveChanges(); string directorio = repositorio; string nombreFichero = String.Format("{0:000000000}", documento.DocumentoId) + ".PDF"; string fichero = String.Format("{0}\\{1}", directorio, nombreFichero); ReportProcessor reportProcessor = new ReportProcessor(); RenderingResult renderingResult = null; switch (f.Tipo) { case "Dsipositivo": List <string> dispositivos = new List <string>(); //ConsDisp.AllowPaging = false;// disabling paging //ConsDisp.Rebind(); foreach (GridDataItem item in ConsDisp.MasterTableView.Items) { dispositivos.Add(item["DispositivoId"].Text); } Session["Filtro"] = dispositivos; //ConsDisp.AllowPaging = true;// disabling paging //ConsDisp.Rebind(); consulta = "Consulta dispositivos. " + f.Nombre; RptConsultaDispositivos cd = new RptConsultaDispositivos(dispositivos, consulta); renderingResult = reportProcessor.RenderReport("PDF", cd, null); break; case "Revision": List <string> revisiones = new List <string>(); //ConsRev.AllowPaging = false;// disabling paging //ConsRev.Rebind(); foreach (GridDataItem item in ConsRev.MasterTableView.Items) { revisiones.Add(item["RevisionId"].Text); } Session["Filtro"] = revisiones; //ConsRev.AllowPaging = true;// disabling paging //ConsDisp.Rebind(); consulta = "Consulta revisiones. " + f.Nombre; IList <Revision> lr = new List <Revision>(); foreach (string rid in revisiones) { lr.Add(CntLainsaSci.GetRevision(int.Parse(rid), ctx)); } RptInfConsultaRevision icr = new RptInfConsultaRevision(lr, consulta); renderingResult = reportProcessor.RenderReport("PDF", icr, null); break; } FileStream fs = new FileStream(fichero, FileMode.Create); fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length); fs.Close(); }
/// <exclude /> public static bool GetPreviewInformation(HttpContext context, Guid pageId, Guid templateId, out string imageFilePath, out PlaceholderInformation[] placeholders) { int updateHash = BrowserRender.GetLastCacheUpdateTime(RenderingMode).GetHashCode(); string requestUrl = new UrlBuilder(context.Request.Url.ToString()).ServerUrl + ServiceUrl + $"?p={pageId}&t={templateId}&hash={updateHash}"; RenderingResult result = null; var renderTask = BrowserRender.RenderUrlAsync(context, requestUrl, RenderingMode); renderTask.Wait(10000); if (renderTask.Status == TaskStatus.RanToCompletion) { result = renderTask.Result; } if (result == null) { imageFilePath = null; placeholders = null; return(false); } if (result.Status != RenderingResultStatus.Success) { Log.LogWarning("PageTemplatePreview", "Failed to build preview for page template '{0}'. Reason: {1}; Output:\r\n{2}", templateId, result.Status, result.Output); imageFilePath = null; placeholders = null; return(false); } imageFilePath = result.FilePath; ICollection <string> output = result.Output; const string templateInfoPrefix = "templateInfo:"; var placeholderData = output.FirstOrDefault(l => l.StartsWith(templateInfoPrefix)); var pList = new List <PlaceholderInformation>(); // TODO: use JSON if (placeholderData != null) { foreach (var infoPart in placeholderData.Substring(templateInfoPrefix.Length).Split('|')) { string[] parts = infoPart.Split(','); double left, top, width, height; if (parts.Length != 5 || !double.TryParse(parts[1], out left) || !double.TryParse(parts[2], out top) || !double.TryParse(parts[3], out width) || !double.TryParse(parts[4], out height)) { throw new InvalidOperationException($"Incorrectly serialized template part info: {infoPart}"); } var zoom = 1.0; pList.Add(new PlaceholderInformation { PlaceholderId = parts[0], ClientRectangle = new Rectangle((int)left, (int)top, (int)width, (int)height), ClientRectangleWithZoom = new Rectangle( (int)Math.Round(zoom * left), (int)Math.Round(zoom * top), (int)Math.Round(zoom * width), (int)Math.Round(zoom * height)) }); } } placeholders = pList.ToArray(); return(true); }