public ReportViewer(InstanceReportSource instanceReportSource) { InitializeComponent(); // Insert code required on object creation below this point. ReportHost.ReportSource = instanceReportSource; }
public void LoadReport(Report report) { var mainReport = new MainReport { CompanyInformationDS = {DataSource = new MiraculousMethods().GetCompanyInformation()}, ReportHoster = {ReportSource = report} }; var instanceReportSource = new InstanceReportSource {ReportDocument = mainReport}; var reportViewer = new ReportViewer { ReportHost = { ReportSource = instanceReportSource } }; reportViewer.ShowDialog(); }
private byte[] GenerateReportByteArray(FaxGenerator.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 btnPrint_Click(object sender, EventArgs e) { //Check if there is at least one rincian //Check nota sequence //Check nilai surat jalan vs nilai uang setoran //Others info connected to this transaction //Print Selected Transaction //Print DialogResult res = MessageBox.Show("Siapkan kertas untuk print.", "SMS - Verification" , MessageBoxButtons.OKCancel , MessageBoxIcon.Question); if (res == System.Windows.Forms.DialogResult.OK) { PrinterSettings printerSettings; ReportProcessor reportProcessor; rptLaporanPenj rpt = new rptLaporanPenj(); rpt.ReportParameters["user"].Value = NBConfig.ValidUserName; rpt.ReportParameters["lappenid"].Value = lappenid_; //rpt.ReportParameters["custtypetoid"].Value = custtypetoid; IReportDocument iRpt = (IReportDocument)rpt; //// PrinterSettings printerSettings = new PrinterSettings(); try { InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = iRpt; reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(reportSource, printerSettings); using (sinarekDataSetTableAdapters.lappenTableAdapter tbl = new sinarekDataSetTableAdapters.lappenTableAdapter()) { tbl.UpdateLapPenj(NBConfig.ValidUserName , 1 , 1 , int.Parse(lappenid_)); } SetFormPrinted(); } catch (Exception ex) { helper.ErrorMessage(ex.Message); } } }
public static InstanceReportSource GetPeakUsage() { //Query Database ProcessedPeaksList searchResults = new ProcessedPeaksList(); PeakUsageReport peakUsageReport = new PeakUsageReport(); peakUsageReport.DataSource = searchResults.processedPeaks; InstanceReportSource IRS = new InstanceReportSource(); IRS.ReportDocument = peakUsageReport; return(IRS); }
public DeliveryReportBook() { var deliverySlipReportSource = new InstanceReportSource { ReportDocument = new DeliverySlip() }; this.ReportSources.Add(deliverySlipReportSource); var deliveryListReportSource = new InstanceReportSource { ReportDocument = new DeliveryList() }; this.ReportSources.Add(deliveryListReportSource); }
private void btnPrint_Click(object sender, EventArgs e) { string iLappenID = radGridView3.SelectedRows[0].Cells["lappenID"].Value.ToString(); //Print DialogResult res = RadMessageBox.Show("Siapkan kertas untuk print.", "SMS - Verification" , MessageBoxButtons.OKCancel , RadMessageIcon.Question , MessageBoxDefaultButton.Button2); if (res == System.Windows.Forms.DialogResult.OK) { PrinterSettings printerSettings; ReportProcessor reportProcessor; rptLaporanUJ rpt = new rptLaporanUJ(); rpt.ReportParameters["user"].Value = NBConfig.ValidUserName; rpt.ReportParameters["lappenid"].Value = iLappenID; rpt.ReportParameters["logid"].Value = radGridView3.SelectedRows[0].Cells["logID"].Value.ToString(); IReportDocument iRpt = (IReportDocument)rpt; iRpt.DocumentName = radGridView3.SelectedRows[0].Cells["NOSJ"].Value.ToString() + " " + radGridView3.SelectedRows[0].Cells["SalesName"].Value.ToString(); //// PrinterSettings printerSettings = new PrinterSettings(); try { InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = iRpt; reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(reportSource, printerSettings); using (sinarekDataSetTableAdapters.lappenTableAdapter tbl = new sinarekDataSetTableAdapters.lappenTableAdapter()) { tbl.UpdateLapPenj(NBConfig.ValidUserName , 1 , 1, int.Parse(iLappenID)); } helper.PrintLog(this.GetType().Name, rpt.Name, "Print:" + iLappenID); this.vlappenTableAdapter.FillByTanggal(this.sinarekDataSet.vlappen, dtpTanggalLaporan.Value, "UJ"); } catch (Exception ex) { helper.SysLog(this.GetType().Name, this.Text, ex.Message); //helper.ErrorMessage(ex.Message); } } }
protected void Page_Load(object sender, EventArgs e) { InstanceReportSource RS = new InstanceReportSource(); var Disbursement = new RDisbursement(); // payout.ReportParameters.Add("CreditMemoType", ReportParameterType.String, "CP"); Disbursement.ReportParameters.Add("AgingStart", ReportParameterType.Integer, 1); //payout.ReportParameters.Add("AgingEnd", ReportParameterType.Integer, 30); RS.ReportDocument = Disbursement; RV_Disbursement.ReportSource = RS; }
public ReportSource Resolve(string reportName) { var objectDataSource = new ObjectDataSource(); objectDataSource.DataSource = GetData(); var report = new Report1(); report.DataSource = objectDataSource;// you can use also GetData() directly since it is a List var reportSource = new InstanceReportSource(); reportSource.ReportDocument = report; return(reportSource); }
private void btnPrintSales_Click(object sender, EventArgs e) { //Print DialogResult res = RadMessageBox.Show("Siapkan kertas untuk print.", "SMS - Verification" , MessageBoxButtons.OKCancel , RadMessageIcon.Question , MessageBoxDefaultButton.Button2); if (res == System.Windows.Forms.DialogResult.OK) { PrinterSettings printerSettings; ReportProcessor reportProcessor; rptLaporanPenjSales rpt = new rptLaporanPenjSales(); rpt.ReportParameters["user"].Value = NBConfig.ValidUserName; rpt.ReportParameters["salesname"].Value = lblSales.Text; rpt.ReportParameters["tanggal"].Value = dtpTanggal.Value; IReportDocument iRpt = (IReportDocument)rpt; //iRpt.DocumentName = radGridView1.SelectedRows[0].Cells["NOSJ"].Value.ToString() + " " // + radGridView1.SelectedRows[0].Cells["SalesName"].Value.ToString(); //// PrinterSettings printerSettings = new PrinterSettings(); try { InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = iRpt; reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(reportSource, printerSettings); //SavedToPDF(iRpt, @"C:\Users\VINA\Documents\Laporan Penjualan"); using (sinarekDataSetTableAdapters.lappenTableAdapter tbl = new sinarekDataSetTableAdapters.lappenTableAdapter()) { tbl.UpdatePrintedSales(NBConfig.ValidUserName , 1 , dtpTanggal.Value , lblSales.Text); } helper.PrintLog(this.GetType().Name, rpt.Name, "PrintSales:" + lblSales.Text + "," + dtpTanggal.Value.ToString("dd MMM yy")); this.vlappenTableAdapter.FillByTanggal(this.sinarekDataSet.vlappen, dtpTanggal.Value, "Penjualan"); } catch (Exception ex) { helper.ErrorMessage(ex.Message); } } }
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)); }
private void btnPrint_Click(object sender, EventArgs e) { DialogResult res = MessageBox.Show("Print Laporan Perhitungan Stock. Siap kan kertas di printer." , "Print Laporan Perhitungan Stock" , MessageBoxButtons.OKCancel , MessageBoxIcon.Question , MessageBoxDefaultButton.Button2 , MessageBoxOptions.DefaultDesktopOnly); if (res == System.Windows.Forms.DialogResult.OK) { rptSisaBarang gj = new rptSisaBarang(); gj.ReportParameters["tanggal"].Value = dtpTanggal.Value; gj.ReportParameters["tipeid"].Value = rddTipe.SelectedValue; gj.ReportParameters["User"].Value = NBConfig.ValidUserName; IReportDocument report1 = (IReportDocument)gj; ////set parameters when necessary //// PrinterSettings PrinterSettings printerSettings = new PrinterSettings(); //// Adjust the printer settings if necessary... try { InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = report1; // Print the report using the printer settings. ReportProcessor reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(reportSource, printerSettings); //print log helper.PrintLog(this.Text, gj.Name, "tanggal:" + dtpTanggal.Value.ToString() + ",tipeid:" + rddTipe.SelectedValue.ToString()); //Process Stock Data Akhir //TODO: For Tipe 1 keep data for BSJ & BJ //TODO: For the rest only keep record with stock with parentid = -1 } catch (Exception ex) { helper.ErrorMessage("Ada masalah untuk print laporan stock. Segera hubungi administrator"); helper.SysLog(this.GetType().Name, this.Text, "ERROR : " + ex.Message + " : " + ex.StackTrace); } } }
protected void DesplegarReporte(DateTime fecha1, DateTime fecha2) { ReporteExameneFechas reporte = new ReporteExameneFechas(); Telerik.Reporting.ObjectDataSource ds = new Telerik.Reporting.ObjectDataSource(); MuestraLaboratorioBll muestras = new MuestraLaboratorioBll(); ds.DataSource = muestras.GetReportMonth(fecha1, fecha2); reporte.DataSource = ds; InstanceReportSource fuente = new InstanceReportSource(); fuente.ReportDocument = reporte; examenesXFechas.ReportSource = fuente; }
/// <summary> /// uses telerik reporting tool and writes data to either pdf or excel file according to selected report format from UI /// </summary> /// <param name="reportToExport">object of the class which prepares report</param> /// <param name="reportFormat">either pdf or excel format</param> /// <param name="varianceReportPath">html to excel template file path</param> /// <param name="baseFileName"></param> /// <param name="currentDateTime"></param> /// <returns></returns> public static string CreateFileUsingTelerik(IReportDocument reportToExport, Enums.DownloadFileType reportFormat, string varianceReportPath, string baseFileName, string currentDateTime) { var instanceReportSource = new InstanceReportSource { ReportDocument = reportToExport }; var result = new ReportProcessor().RenderReport(reportFormat.ToString(), instanceReportSource, null); string fileName = string.Format("{0}{1}.{2}", baseFileName, currentDateTime, result.Extension); string filePath = Path.Combine(varianceReportPath, fileName); using (var fs = new FileStream(filePath, FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } return(fileName); }
private void GemMaterialsReport() { if (this.SelectedTemplate != null) { Report report = new MaterialsReport(); var source = new ObjectDataSource(); source.DataSource = typeof(MainViewModel); source.DataMember = "GetDataSourceReport"; report.DataSource = source; var reportSource = new InstanceReportSource() { ReportDocument = report }; var reportWindow = new I_ReportViewer(this.SelectedTemplate.Name + " Materials Report", reportSource, false, false, true); reportWindow.ShowDialog(); } }
private void btnPrintNama_Click(object sender, EventArgs e) { if (rddMember.SelectedValue != null) { DialogResult res = MessageBox.Show("Print Slip Gaji Untuk " + rddMember.Text + ". Siap kan kertas di printer." , "Print Slip Gaji Per Nama" , MessageBoxButtons.OKCancel , MessageBoxIcon.Question , MessageBoxDefaultButton.Button2 , MessageBoxOptions.DefaultDesktopOnly); if (res == System.Windows.Forms.DialogResult.OK) { //Print Slip Gaji rptGajiMingguanNama gj = new rptGajiMingguanNama(); gj.ReportParameters["GMID"].Value = rddGajiMingguan.SelectedValue; gj.ReportParameters["User"].Value = NBConfig.ValidUserName; gj.ReportParameters["memberid"].Value = rddMember.SelectedValue; IReportDocument report1 = (IReportDocument)gj; ////set parameters when necessary //// PrinterSettings PrinterSettings printerSettings = new PrinterSettings(); //// Adjust the printer settings if necessary... InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = report1; // Print the report using the printer settings. ReportProcessor reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(reportSource, printerSettings); //process printed if (!NBConfig.GetGBIDPrintedStaff()) { using (sinarekDataSetTableAdapters.gajibulananTableAdapter gb = new sinarekDataSetTableAdapters.gajibulananTableAdapter()) { gb.UpdatePrintedStaff(NBConfig.ValidUserName, NBConfig.IGBID); } SetPrintedForms(); helper.NotifMessage("Data Gaji telah terkunci dan tidak dapat di ubah lagi."); } } } }
protected void Page_Load(object sender, EventArgs e) { //try //{ // CheckShamsiDateFunctions(); //} //catch (Exception ex) //{ //} int id; id = Page.Request.QueryString[0].ToSafeInt(); Report report = new ReportShareDiv(); Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource(); sqlDataSource.ConnectionString = "Tarin"; sqlDataSource.SelectCommand = " SELECT Members.Name, Members.Code, Members.Type, Members.ShareAmount, Members.ShareCount, Members.HasPriority, ShareDivisionDetails.MemberId, ShareDivisionDetails.ShareAmount AS SharedAmount, " + " ShareDivisionDetails.ShareDivisionId, ShareDivisions.Type AS Expr2, ShareDivisions.Amount As TotalProfit, ShareDivisions.InsertDateTime,dbo.shamsidate(ShareDivisions.InsertDateTime) as [Date]" + " FROM Members INNER JOIN" + " ShareDivisionDetails ON Members.Id = ShareDivisionDetails.MemberId INNER JOIN" + " ShareDivisions ON ShareDivisionDetails.ShareDivisionId = ShareDivisions.Id" + $" where ShareDivisions.Id ={id} order by cast(Members.Code as bigint)"; sqlDataSource.Parameters.Add("@id", System.Data.DbType.Int32, id); report.DataSource = sqlDataSource; InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = report; ReportViewer1.ReportSource = reportSource; var table1 = report.Items.Find("table1", true)[0]; ((table1 as Telerik.Reporting.Table).DataSource as Telerik.Reporting.SqlDataSource).Parameters[0].Value = id; ReportViewer1.RefreshReport(); }
private void btnPrint_Click(object sender, EventArgs e) { ////On Printing Surat Jalan Make sure after printing surat jalan has been updated too ////printed so the next time surat jalan is printing COPY is appended to the title. DialogResult res = MessageBox.Show("Print Laporan Stock. Siap kan kertas di printer." , "Print Laporan Stock" , MessageBoxButtons.OKCancel , MessageBoxIcon.Question , MessageBoxDefaultButton.Button2 , MessageBoxOptions.DefaultDesktopOnly); if (res == System.Windows.Forms.DialogResult.OK) { rptSisaBarang gj = new rptSisaBarang(); gj.ReportParameters["tanggal"].Value = dtpTanggal.Value; gj.ReportParameters["tipeid"].Value = rddTipe.SelectedValue; gj.ReportParameters["User"].Value = NBConfig.ValidUserName; IReportDocument report1 = (IReportDocument)gj; ////set parameters when necessary //// PrinterSettings PrinterSettings printerSettings = new PrinterSettings(); //// Adjust the printer settings if necessary... try { InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = report1; // Print the report using the printer settings. ReportProcessor reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(reportSource, printerSettings); //print log helper.PrintLog(this.Text, gj.Name, "tanggal:" + dtpTanggal.Value.ToString() + ",tipeid:" + rddTipe.SelectedValue.ToString()); } catch (Exception ex) { MessageBox.Show("Ada masalah untuk print laporan stock. Segera hubungi administrator", "SMS - Error Notification"); } } }
/// <summary> /// Save Report to a file to a specified location /// </summary> /// <param name="rptDoc"></param> /// <param name="Location"></param> internal static void SavedToEXCEL(IReportDocument rptDoc, string Location) { ReportProcessor reportProcessor = new ReportProcessor(); InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = rptDoc; string rptName = string.Empty; Hashtable htbl = new Hashtable(); //set any deviceInfo settings if necessary System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("XLS", reportSource, deviceInfo); string fileName = result.DocumentName + "." + result.Extension; string filePath = System.IO.Path.Combine(Location, fileName); using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } }
private void generateReport() { var trafficAreaIDs = string.Join(",", cblTrafficAreas.Items.Cast <ListItem>().Where(i => i.Selected).Select(i => i.Value)); var jobStateIDs = string.Join(",", cblJobStates.Items.Cast <ListItem>().Where(i => i.Selected).Select(i => i.Value)); var typeName = "Orchestrator.Reports.rptRunOverview, Orchestrator.Reports"; var reportType = Type.GetType(typeName); var report = (IReportDocument)Activator.CreateInstance(reportType); report.ReportParameters.ElementAt(0).Value = dteStartDate.SelectedDate.Value.Date; report.ReportParameters.ElementAt(1).Value = dteEndDate.SelectedDate.Value.Date.AddDays(1); report.ReportParameters.ElementAt(2).Value = trafficAreaIDs; report.ReportParameters.ElementAt(3).Value = jobStateIDs; var reportSource = new InstanceReportSource { ReportDocument = report }; this.rptvRunOverview.ReportSource = reportSource; }
public static ReportSource RenderReportData(byte[] ReportBinaryData, Dictionary <string, object> Parameters) { ReportPackager pack = new ReportPackager(); Telerik.Reporting.Report doc = pack.Unpackage(new MemoryStream(ReportBinaryData)); InstanceReportSource instance = new InstanceReportSource(); instance.ReportDocument = doc; if (Parameters != null) { foreach (KeyValuePair <string, object> kvp in Parameters) { instance.Parameters.Add(new Telerik.Reporting.Parameter(kvp.Key, kvp.Value)); } } return(instance); }
private void btnTotalRincian_Click(object sender, EventArgs e) { DialogResult res = MessageBox.Show("Print Laporan Rincian Total Gaji. Siap kan kertas di printer." , "Print Laporan Rincian Total Gaji" , MessageBoxButtons.OKCancel , MessageBoxIcon.Question , MessageBoxDefaultButton.Button2 , MessageBoxOptions.DefaultDesktopOnly); if (res == System.Windows.Forms.DialogResult.OK) { //Print Rincian Summary Gaji rptGajiTotal gj = new rptGajiTotal(); gj.ReportParameters[0].Value = NBConfig.IGMID; gj.ReportParameters["user"].Value = NBConfig.ValidUserName; IReportDocument report1 = (IReportDocument)gj; ////set parameters when necessary //// PrinterSettings PrinterSettings printerSettings = new PrinterSettings(); //// Adjust the printer settings if necessary... InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = report1; // Print the report using the printer settings. ReportProcessor reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(reportSource, printerSettings); //process printed if (!NBConfig.GetGMIDPrinted()) { using (sinarekDataSetTableAdapters.gajimingguanTableAdapter gm = new sinarekDataSetTableAdapters.gajimingguanTableAdapter()) { gm.UpdatePrinted(NBConfig.ValidUserName, NBConfig.IGMID); } SetPrintedForms(); MessageBox.Show("Data Gaji telah terkunci dan tidak dapat di ubah lagi."); } } }
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)); }
public async Task <string> GenerateExtractionReport(string template, ExtractionData 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); } //ReportPackager reportPackager = new ReportPackager(); //using (var sourceStream = System.IO.File.OpenRead(@"C:\Users\Razz\Documents\Visual Studio 2015\Projects\SampleReports\src\SampleReports\Templates\Report1.trdp")) //{ // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); //} 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 PrintView(List <Test> lstT) { if (lstT.Count > 0) { InitializeComponent(); this.rpvNav.CommandBarElement.Rows[0].Strips[0].ItemsLayout.Children[0].Visibility = Telerik.WinControls.ElementVisibility.Collapsed; CommandBarButton btn = new CommandBarButton(); btn.Click += new EventHandler(btn_Click); btn.DrawText = false; btn.Image = (System.Drawing.Image)Properties.Resources.save; btn.ToolTipText = "Save PDF to a specified location"; this.rpvNav.CommandBarElement.Rows[0].Strips[0].Items.Insert(0, btn); BatchReport report = new BatchReport(); InstanceReportSource rptInstance = new InstanceReportSource(); rptInstance.ReportDocument = report; Test t = new Test(); t.PrepRun = lstT[0].PrepRun; t.DueDate = lstT.Where(te => te.DueDate != null).Select(te => te.DueDate).Min(); report.DataSource = t; report.DocumentMapText = "Prep Benchsheet"; Telerik.Reporting.Table tableItem = report.Items.Find("table1", true)[0] as Telerik.Reporting.Table; tableItem.DataSource = lstT; //Render pdf Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor(); System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); deviceInfo["FontEmbedding"] = "None"; result = reportProcessor.RenderReport("PDF", rptInstance, deviceInfo); MemoryStream msPDF = new MemoryStream(result.DocumentBytes); rpvMain.ViewerMode = FixedDocumentViewerMode.TextSelection; rpvMain.LoadDocument(msPDF); //msPDF.Dispose(); } }
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); } }
private void btnPrintNama_Click(object sender, EventArgs e) { DialogResult res = MessageBox.Show("Print Slip THR. Siap kan kertas di printer." , "Print Slip THR" , MessageBoxButtons.OKCancel , MessageBoxIcon.Question , MessageBoxDefaultButton.Button2 , MessageBoxOptions.DefaultDesktopOnly); if (res == System.Windows.Forms.DialogResult.OK) { //Print Slip Gaji rptGajiTHRNama gj = new rptGajiTHRNama(); gj.ReportParameters["templateid"].Value = (chkBayarOleh.Checked ? -2 : -1); gj.ReportParameters["tipepembayaranid"].Value = 4; gj.ReportParameters["User"].Value = NBConfig.ValidUserName; gj.ReportParameters["memberid"].Value = rddMember.SelectedValue; int tahun = 0; if (dtpTahun.Value == null) { dtpTahun.Value = DateTime.Now; } tahun = dtpTahun.Value.Year; gj.ReportParameters["tahun"].Value = tahun; IReportDocument report1 = (IReportDocument)gj; ////set parameters when necessary //// PrinterSettings PrinterSettings printerSettings = new PrinterSettings(); //// Adjust the printer settings if necessary... InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = report1; // Print the report using the printer settings. ReportProcessor reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(reportSource, printerSettings); } }
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); } }
public void ExportToPDF(Report reportToExport) { var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor(); var instanceReportSource = new InstanceReportSource(); instanceReportSource.ReportDocument = reportToExport; var result = reportProcessor.RenderReport("PDF", instanceReportSource, null); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = result.MimeType; HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Private); HttpContext.Current.Response.Expires = -1; HttpContext.Current.Response.Buffer = true; /* Uncomment to handle the file as attachment * Response.AddHeader("Content-Disposition", * string.Format("{0};FileName=\"{1}\"", * "attachment", * fileName)); */ HttpContext.Current.Response.BinaryWrite(result.DocumentBytes); HttpContext.Current.Response.End(); }
[HttpGet("{reportId}")] //Get /api/design/report/1234567 public async Task Report(string reportId) { #if !APPBOXPRO throw new NotSupportedException(); #else //设置当前用户会话 RuntimeContext.Current.CurrentSession = HttpContext.Session.LoadWebSession(); //判断权限 if (!(RuntimeContext.Current.CurrentSession is IDeveloperSession developerSession)) { throw new Exception("Must login as a Developer"); } var desighHub = developerSession.GetDesignHub(); if (desighHub == null) { throw new Exception("Cannot get DesignContext"); } //TODO: 以下代码与OpenReportModel重复,待优化 var modelNode = desighHub.DesignTree.FindModelNode(ModelType.Report, ulong.Parse(reportId)); if (modelNode == null) { throw new Exception($"Cannot find report model: {reportId}"); } //TODO:直接加载字节流 string json = null; if (modelNode.IsCheckoutByMe) { json = await StagedService.LoadReportCodeAsync(modelNode.Model.Id); } if (json == null) { json = await Store.ModelStore.LoadReportCodeAsync(modelNode.Model.Id); } var report = Parse(json); // //根据推/拉模式获取或生成预览数据源, TODO:暂全部生成测试数据 foreach (var ds in report.DataSources) { var ods = (ObjectDataSource)ds; ods.DataSource = MakePreviewData(ods, 10); } //输出为pdf HttpContext.Response.ContentType = "application/pdf"; var rs = new InstanceReportSource { ReportDocument = report }; var deviceInfo = new Hashtable() { { "OutputFormat", "emf" }, { "ProcessItemActions", false }, { "WriteClientAction", false } }; var renderContext = new Reporting.Processing.RenderingContext() { { "ReportDocumentState", null } }; var processingReports = new Reporting.Processing.ReportProcessor() .ProcessReport(rs, deviceInfo, renderContext); var res = Reporting.Processing.ReportProcessor.RenderReport("IMAGE", processingReports, deviceInfo, renderContext); await HttpContext.Response.Body.WriteAsync(res.DocumentBytes); #endif }
public ReportRecord CreateCoaReport(Sample sample, Identification identification) { ReportRecord rc = new ReportRecord(); DateTime reportDate = DateTime.Now; // Update Timepoint Data List<SampleTest> testsNotOnReport = new List<SampleTest>(); CoaReportModel reportData = new CoaReportModel(); try { /* using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true)) { if (DbConnection.IsConnected()) { using (DbCommand) { // GET User using (UserDAO userDao = new UserDAO()) reportData.User = userDao.GetUser(ref dbConnection, ref dbCommand, identification.UserId); foreach (SampleTest test in sample.SampleTests) { List<TimePoint> timpointsNotOnReport = new List<TimePoint>(); //var isOnReport = Convert.ToBoolean(test.TimePoints.Count(x => x.IsOnReport == true)); //if (!isOnReport) //testsNotOnReport.Add(test); /*foreach (TimePoint timePoint in test.TimePoints) { if (!timePoint.IsOnReport) timpointsNotOnReport.Add(timePoint); if (timePoint.ReportDate.IsNull()) timePoint.ReportDate = reportDate; if ((timePoint.ReportBy == 0 || timePoint.ReportBy.IsNull()) && timePoint.IsOnReport) { timePoint.ReportBy = identification.UserId; timePoint.ReportedByUser = reportData.User.FullName; } UpdateOrderSampleTestTimePointReportData(ref dbConnection, ref dbCommand, (int)timePoint.Id, timePoint.IsOnReport, timePoint.ReportDate, timePoint.ReportBy); if (test.CatalogItem.AnalyteId.IsNotNull() && test.CatalogItem.AnalyteId > 0) { timePoint.ResultDetail.ExpectedAmount = sample.SampleAnalytes.FirstOrDefault(a => a.AnalyteId == test.AnalyteId).Amount; timePoint.ResultDetail.ExpectedUnits = sample.SampleAnalytes.FirstOrDefault(a => a.AnalyteId == test.AnalyteId).AmountUOM; } } foreach (TimePoint removeTimePoint in timpointsNotOnReport) { //test.TimePoints.Remove(removeTimePoint); } } } } else { throw new Exception("Unable to Connect"); } } } catch { throw; } foreach (SampleTest onTest in testsNotOnReport) sample.SampleTests.Remove(onTest); // Create Report try { string customerSql = @" select customers.id, customers.customer_name, customers.accountingid, customers.termid, terms.value as terms, customers.credit_check , customers.web_client, customers.sales_rep_id, (users.firstname + ' ' + users.lastname) as modifieduser, (users2.firstname + ' ' + users2.lastname) as createduser, customers.modified_by, customers.modified_date, customers.created_by, customers.created_date, salesrep.firstname, salesrep.lastname from customers LEFT JOIN [User] as users ON customers.modified_by = users.UserID LEFT JOIN [User] as users2 ON customers.created_by = users2.UserID LEFT JOIN list.terms as terms ON customers.termid = terms.termid LEFT JOIN [User] as salesrep ON customers.sales_rep_id = salesrep.UserID LEFT JOIN orders ON orders.parentid = customers.id where orders.id = "; // Get Customer for Sample using (ClientDAO dao = new ClientDAO()) reportData.Customer = dao.GetClient(0); string getOrderNotesSql = @" SELECT orders_notes.id, orders_notes.parentid,orders_notes.txt,orders_notes.is_show_on_report, orders_notes.html, orders_notes.linked_type, orders_notes.linked_id, orders_notes.isnotify, (users.firstname + ' ' + users.lastname) as modifieduser, orders_notes.modified_by, orders_notes.modified_date, orders_notes.created_by, orders_notes.created_date, (users2.firstname + ' ' + users2.lastname) as createduser FROM orders_notes LEFT JOIN [User] as users ON orders_notes.modified_by = users.UserID LEFT JOIN [User] as users2 ON orders_notes.created_by = users2.UserID WHERE parentid = @ID AND orders_notes.delete_date IS NULL AND orders_notes.linked_id = 0 AND orders_notes.linked_type = '" + EnumNoteLink.None.ToString() + @"' AND orders_notes.is_show_on_report = 1 "; //reportData.ReportNotes = GetSampleNotes(sample.ARLNumber.Value, identification, getOrderNotesSql); string getSampleNotesSql = @" SELECT orders_notes.id, orders_notes.parentid,orders_notes.txt,orders_notes.is_show_on_report, orders_notes.html, orders_notes.linked_type, orders_notes.linked_id, orders_notes.isnotify, (users.firstname + ' ' + users.lastname) as modifieduser, orders_notes.modified_by, orders_notes.modified_date, orders_notes.created_by, orders_notes.created_date, (users2.firstname + ' ' + users2.lastname) as createduser FROM orders_notes LEFT JOIN [User] as users ON orders_notes.modified_by = users.UserID LEFT JOIN [User] as users2 ON orders_notes.created_by = users2.UserID WHERE parentid = @ID AND orders_notes.delete_date IS NULL AND orders_notes.linked_id = " + sample.ARLNumber.Value + @" AND orders_notes.linked_type = '" + EnumNoteLink.Sample.ToString() + @"' AND orders_notes.is_show_on_report = 1 "; foreach (SampleTest test in sample.SampleTests) { string getTestNotesSql = @" SELECT orders_notes.id, orders_notes.parentid,orders_notes.txt,orders_notes.is_show_on_report, orders_notes.html, orders_notes.linked_type, orders_notes.linked_id, orders_notes.isnotify, (users.firstname + ' ' + users.lastname) as modifieduser, orders_notes.modified_by, orders_notes.modified_date, orders_notes.created_by, orders_notes.created_date, (users2.firstname + ' ' + users2.lastname) as createduser FROM orders_notes LEFT JOIN [User] as users ON orders_notes.modified_by = users.UserID LEFT JOIN [User] as users2 ON orders_notes.created_by = users2.UserID WHERE parentid = @ID AND orders_notes.delete_date IS NULL AND orders_notes.linked_id = " + test.SampleTestId.Value + @" AND orders_notes.linked_type = '" + EnumNoteLink.Test.ToString() + @"' AND orders_notes.is_show_on_report = 1 "; //test.ReportNotes = GetSampleNotes(test.ARLNumber.Value, identification, getTestNotesSql); } */ reportData.Sample = sample; if (!string.IsNullOrWhiteSpace(reportData.User.Signature.Signature)) reportData.Signature = Image.FromStream(new MemoryStream(Convert.FromBase64String(Security.AesDecrypt(reportData.User.Signature.Signature, AppVars.dbSettings.BaseKey)))); Reports.Coa report = new Reports.Coa(); //report.ReportData = reportData; ReportProcessor reportProcessor = new ReportProcessor(); InstanceReportSource instanceReportSource = new InstanceReportSource(); instanceReportSource.ReportDocument = report; RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); Byte[] pdfReport = result.DocumentBytes; rc.ReferenceId = sample.ARLNumber; rc.DepartmentId = sample.SampleTests[0].DepartmentId; rc.CreatedBy = identification.UserId; rc.CreatedDate = DateTime.Now; rc.ReportData = pdfReport; rc.ReportType = "PDF"; rc.ReportName = "Certificate of Analysis"; rc.SubjectLine = "Result ARL #" + sample.ARLNumber.ToString() + " Lot: " + sample.LotNumber.ToString() + " Drug: " + sample.Description.ToString(); rc.Id = SaveReport(rc); } catch { throw; } return rc; }
private void SaveNewItem() { short StatusID = 4; string iLogID = string.Empty; string mobil = string.Empty , sopir = string.Empty , keterangan = null; int kernetid = -1 , sopirid = -1 , mobilid = -1 , kotaid = -1 , salesid = -1 , custid = -1 , custtypeid = -1 , transtypeid = -1; int paid = 0; transtypeid = int.Parse(rddTipe.SelectedValue.ToString()); custtypeid = int.Parse(rddPel.Tag.ToString()); kotaid = int.Parse(rddTujuan.SelectedValue.ToString()); salesid = int.Parse(rddSales.SelectedValue.ToString()); if (chkAntar.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On) { sopirid = int.Parse(rddSopir.SelectedValue.ToString()); mobilid = int.Parse(rddMobil.SelectedValue.ToString()); kernetid = int.Parse(rddKernet.SelectedValue.ToString()); } else { sopir = txtSopir.Text; mobil = txtMobil.Text; } switch (rddTipe.Text.ToLower()) { case "pelanggan": case "staff": case "pegawai": case "satpam": case "campuran": custid = int.Parse(rddPel.SelectedValue.ToString()); break; case "sales": custid = int.Parse(rddSales.SelectedValue.ToString()); break; case "contoh": break; } using (sinarekDataSetTableAdapters.logproductTableAdapter tbl = new sinarekDataSetTableAdapters.logproductTableAdapter()) { //Always Create with status created iLogID = tbl.pInsertLogProd(tanggalDateTimePicker.Value , 0 , kernetid , sopirid , mobilid , kotaid , salesid , mobil , sopir , keterangan , custid , custtypeid , transtypeid , NBConfig.ValidUserName , StatusID, paid, 0).ToString(); } foreach (GridViewRowInfo item in radGridView1.Rows) { using (sinarekDataSetTableAdapters.logdetailTableAdapter tbl = new sinarekDataSetTableAdapters.logdetailTableAdapter()) { tbl.pInsertLogDetail(int.Parse(iLogID) , int.Parse(item.Cells["productid"].Value.ToString()) , decimal.Parse(item.Cells["quantity"].Value.ToString()) , transtypeid , int.Parse(item.Cells["custtypeid"].Value.ToString()) , 1 , item.Cells["keterangan"].Value.ToString() , NBConfig.ValidUserName); } } RadMessageBox.Show("Data sudah terinput.", "SMS"); //Print DialogResult res = RadMessageBox.Show("Siapkan kertas untuk print.", "SMS - Verification" , MessageBoxButtons.OKCancel , RadMessageIcon.Question , MessageBoxDefaultButton.Button1); if (res == System.Windows.Forms.DialogResult.OK) { PrinterSettings printerSettings; ReportProcessor reportProcessor; rptSJ rpt = new rptSJ(); rpt.ReportParameters["user"].Value = NBConfig.ValidUserName; rpt.ReportParameters["logid"].Value = iLogID; //rpt.ReportParameters["custtypetoid"].Value = rddTipe.SelectedValue; IReportDocument iRpt = (IReportDocument)rpt; //// PrinterSettings printerSettings = new PrinterSettings(); //// Adjust the printer settings if necessary... InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = iRpt; // Print the report using the printer settings. reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(reportSource, printerSettings); using (sinarekDataSetTableAdapters.logproductTableAdapter tbl = new sinarekDataSetTableAdapters.logproductTableAdapter()) { tbl.UpdatePrinted(NBConfig.ValidUserName, long.Parse(iLogID)); } helper.PrintLog(this.GetType().Name, rpt.Name, this.Text + ":LogID-" + iLogID); } else { MessageBox.Show("Surat Jalan ini dapat dilihat di daftar surat jalan yg belum di print."); } }
private void btnSimpan_Click(object sender, EventArgs e) { if (ValidateFields()) { string UJID; //Create UJ using (sinarekDataSetTableAdapters.uangjalanTableAdapter tbl = new sinarekDataSetTableAdapters.uangjalanTableAdapter()) { UJID = tbl.pInsertUangJalan(-2 , "DALAM KOTA" , "KAS" , rddNama.Text , rddMobil.Text , txtKeterangan.Text , -1 , decimal.Parse(txtJumlah.Text) , 0, NBConfig.ValidUserName).ToString(); } //Print DialogResult res = RadMessageBox.Show("Siapkan kertas untuk print.", "SMS - Verification" , MessageBoxButtons.OKCancel , RadMessageIcon.Question , MessageBoxDefaultButton.Button2); if (res == System.Windows.Forms.DialogResult.OK) { PrinterSettings printerSettings; ReportProcessor reportProcessor; rptUJ rpt = new rptUJ(); rpt.ReportParameters["user"].Value = NBConfig.ValidUserName; rpt.ReportParameters["UJid"].Value = UJID; IReportDocument iRpt = (IReportDocument)rpt; iRpt.DocumentName = "UJ_" + rddNama.Text + "_" + rddMobil.Text; //// PrinterSettings printerSettings = new PrinterSettings(); try { InstanceReportSource reportSource = new InstanceReportSource(); reportSource.ReportDocument = iRpt; reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(reportSource, printerSettings); using (sinarekDataSetTableAdapters.uangjalanTableAdapter tbl = new sinarekDataSetTableAdapters.uangjalanTableAdapter()) { tbl.UpdatePrinted(1 , NBConfig.ValidUserName , int.Parse(UJID)); } helper.PrintLog(this.GetType().Name, rpt.Name, "Print:" + UJID); } catch (Exception ex) { helper.SysLog(this.GetType().Name, this.Text, ex.Message); helper.ErrorMessage(ex.Message); } } this.Close(); } }