public static byte[] CreateTaxInvoiceReceipt(long paymentId) { byte[] pdf = new byte[0]; using (var idmContainer = new IDMServiceClient()) using (var container = new TransactionModelContainer()) { try { var payment = container.Payments.Where(x => x.Id == paymentId).FirstOrDefault(); if (payment != null) { var response = idmContainer.GetPersonByPartyId(new GetPersonByPartyIdRequest { PartyId = payment.CustomerIdmPartyId }); if (!response.IsSuccessful && response.Result == null) throw new Exception("Customer party not found."); if (string.IsNullOrEmpty(response.Result.CustomerCode)) throw new Exception("Not Customer"); var header = CreateViewPayment(payment, container); header.CustomerCode = response.Result.CustomerCode; TaxInvoice report = new TaxInvoice(); report.DataSource = header; report.PaymentDataSource.DataSource = CreateViewPaymentItems(payment.PaymentItems, container); var reportprocess = new ReportProcessor(); var result = reportprocess.RenderReport("PDF", report, null); pdf = result.DocumentBytes; payment.AddTaxInvoiceReceipt(DateTime.Now, payment.CustomerName, pdf, Convert.ToInt32(payment.Id), payment.PaymentCode); container.SaveChanges(); } else { throw new ArgumentException("PAYMENT_NOT_FOUND"); } } catch (Exception ex) { ErrorLog.Log("System", ex, SystemError.TransactionService); } } return pdf; }
public LienWaiverReportGenerationModel CreateReport(string reportId, ComplianceDocument complianceDocument, bool isCheckForJointVendor, string format = ReportProcessor.FilterPdf, bool shouldLinkToLienWaiver = true) { isLinkToLienWaiverNeeded = shouldLinkToLienWaiver; isJointCheck = isCheckForJointVendor; var lienWaiverReportGenerationModel = GetLienWaiverReportGenerationModel(reportId, complianceDocument); PXReportTools.InitReportParameters(lienWaiverReportGenerationModel.Report, lienWaiverReportGenerationModel.Parameters, Reports.SettingsProvider.Instance.Default); using (var streamManager = new StreamManager()) { var reportNode = ReportProcessor.ProcessReport(lienWaiverReportGenerationModel.Report); ReportProcessor.GetRenderer(format).Render(reportNode, null, streamManager); lienWaiverReportGenerationModel.ReportFileInfo = SaveReportFile(streamManager, complianceDocument, format); } return(lienWaiverReportGenerationModel); }
/// <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); }
public ActionResult Pdf(string reportName, object reportParameters) { var processor = new ReportProcessor(); var deviceInfo = new Hashtable(); var typeReportSource = new Telerik.Reporting.TypeReportSource { TypeName = reportName, Parameters = { } }; var parameters = new RouteValueDictionary(reportParameters); parameters.Keys.ForEach(k => typeReportSource.Parameters.Add(k, parameters[k])); var result = processor.RenderReport("PDF", typeReportSource, deviceInfo); var fileName = string.Format("{0}.{1}", result.DocumentName, result.Extension); return(File(result.DocumentBytes, "application/pdf", fileName)); }
public void TestSimpleConflictException() { var report = new DbReport { Feedbacks = new List <DbReportFeedback> { new DbReportFeedback { FeedbackId = 1, Feedback = new DbFeedback { IsActionable = true } }, new DbReportFeedback { FeedbackId = 2, Feedback = new DbFeedback { IsActionable = true } } }, ConflictExceptions = new List <DbConflictException> { new DbConflictException { IsConflict = false, ConflictExceptionFeedbacks = new List <DbConflictExceptionFeedback> { new DbConflictExceptionFeedback { FeedbackId = 1 }, new DbConflictExceptionFeedback { FeedbackId = 2 }, } } }, RequiredFeedback = 2, RequiredFeedbackConflicted = 4, AllowedFeedback = new List <DbReportAllowedFeedback> { new DbReportAllowedFeedback() } }; ReportProcessor.ProcessReport(report); Assert.AreEqual(false, report.RequiresReview); Assert.AreEqual(false, report.Conflicted); }
private void btnPrintUJ_Click(object sender, EventArgs e) { string iUJID = radGridView2.SelectedRows[0].Cells["UJID"].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; rptUJ rpt = new rptUJ(); rpt.ReportParameters["user"].Value = NBConfig.ValidUserName; rpt.ReportParameters["UJid"].Value = iUJID; IReportDocument iRpt = (IReportDocument)rpt; iRpt.DocumentName = "UJ_" + radGridView2.SelectedRows[0].Cells["NOSJ"].Value.ToString() + " " + radGridView2.SelectedRows[0].Cells["SOPIRName"].Value.ToString(); //// PrinterSettings printerSettings = new PrinterSettings(); try { reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(iRpt, printerSettings); using (sinarekDataSetTableAdapters.uangjalanTableAdapter tbl = new sinarekDataSetTableAdapters.uangjalanTableAdapter()) { tbl.UpdatePrinted(1 , NBConfig.ValidUserName , int.Parse(radGridView2.SelectedRows[0].Cells["logid"].Value.ToString())); } helper.PrintLog(this.GetType().Name, rpt.Name, "Print:" + iUJID); this.vlappenTableAdapter.FillByTanggal(this.sinarekDataSet.vlappen, dtpTanggalLaporan.Value); } catch (Exception ex) { helper.SysLog(this.GetType().Name, this.Text, ex.Message); helper.ErrorMessage(ex.Message); } } }
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."); } } } }
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"); } } }
private void btnPrint_Click(object sender, EventArgs e) { //Print Selected Transaction //string custtypetoid = radGridView1.SelectedRows[0].Cells["custtypetoid"].Value.ToString(); string iLogID = radGridView1.SelectedRows[0].Cells["LogID"].Value.ToString(); //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; rptTM rpt = new rptTM(); rpt.ReportParameters["user"].Value = NBConfig.ValidUserName; rpt.ReportParameters["logid"].Value = lblLogID.Text; //rpt.ReportParameters["custtypetoid"].Value = custtypetoid; IReportDocument iRpt = (IReportDocument)rpt; //// PrinterSettings printerSettings = new PrinterSettings(); //// Adjust the printer settings if necessary... // Print the report using the printer settings. try { reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(iRpt, printerSettings); using (sinarekDataSetTableAdapters.logproductTableAdapter tbl = new sinarekDataSetTableAdapters.logproductTableAdapter()) { tbl.UpdatePrinted(NBConfig.ValidUserName, long.Parse(lblLogID.Text)); } } catch (Exception ex) { MessageBox.Show(ex.Message, "SMS - Error Notofication"); } } }
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(); }
/// <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); } }
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 void TestSimpleReview() { var report = new DbReport { Feedbacks = new List <DbReportFeedback> { new DbReportFeedback { FeedbackId = 1, Feedback = new DbFeedback { IsActionable = true } } }, RequiredFeedback = 2, AllowedFeedback = new List <DbReportAllowedFeedback> { new DbReportAllowedFeedback() } }; ReportProcessor.ProcessReport(report); Assert.AreEqual(true, report.RequiresReview); Assert.AreEqual(false, report.Conflicted); }
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)); }
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)); }
private void OnPrintCommandExecuted(object id) { //Direct to default try { //if (this.Invoice.InvoiceNo == null || this.Invoice.InvoiceNo == string.Empty) //{ // MessageBox.Show("Please save first."); // return; //} SaveOrder(); ReportProcessor reportProcessor = new ReportProcessor(); // reportProcessor.PrintReport(new SunSeven.Reports.ReportModel.rptInvoice(this, this.OrderItems), new PrinterSettings()); // reportProcessor.PrintReport(new SunSeven.Reports.ReportModel.Invoice(this, this.OrderItems), new PrinterSettings()); } catch (Exception e) { MessageBox.Show(e.Message); } }
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 override void OnInitialize(Connector connector) { var batteryProcessor = new BatteryReportProcessor(this); batteryProcessor.BatteryUpdated += OnBatteryUpdated; var errorProcessor = new ErrorReportProcessor(); errorProcessor.ErrorReceived += connector.Reset; Processors = new ReportProcessor[] { batteryProcessor, errorProcessor }; // poll battery status once per minute starting after 3 seconds _batteryTimer = new QueuedTimer( state => connector.IssueReport((byte)ReportSize.Short, DeviceId, (byte)ReportType.Battery), 3000, 60000 ); }
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); } }
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 bool RunReport(string[] args) { try { // read program arguments into Argument Container ArgumentContainer argContainer = new ArgumentContainer(); argContainer.ReadArguments(args); if (argContainer.GetHelp) { Helper.ShowHelpMessage(); } else { string _logFilename = string.Empty; if (argContainer.EnableLog) { _logFilename = "ninja-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".log"; } ReportProcessor reportNinja = new ReportProcessor(_logFilename) { ReportArguments = argContainer, }; reportNinja.Run(); } } catch (Exception ex) { Utility.WriteActivity(string.Format("Exception: {0}", ex.Message)); Utility.WriteActivity(string.Format("Inner Exception: {0}", ex.InnerException)); return(false); } return(true); }
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(); }
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); } }
private void ImprimirTicket(Venta venta) { #region TICKET string textoNumero = Convertir_NumeroLetra.NumeroATexto(venta.MontoTotal.ToString()); // DataTable dt = DatDetalleVenta.ObtenerDatos_Ticket(venta.Id, textoNumero); ParametrosReporte reporte = DatVenta.Consultar_Ticket_Parametro(venta.Id); reporte.LetraNumero = textoNumero; //rptTicket rptTicket = new rptTicket(); ReportTicket rptTicket = new ReportTicket(); rptTicket.tbTicket.DataSource = reporte.lstDetalleVenta; rptTicket.DataSource = reporte; reportViewer1.Report = rptTicket; reportViewer1.RefreshReport(); #endregion try { string impresora = DatBox.Obtener_ImpresoraTicket(serialPC, "TICKET"); TICKET = new PrintDocument(); TICKET.PrinterSettings.PrinterName = impresora; if (TICKET.PrinterSettings.IsValid) { PrinterSettings printerSettings = new PrinterSettings(); printerSettings.PrinterName = impresora; ReportProcessor reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(reportViewer1.ReportSource, printerSettings); } } catch (Exception ex) { MessageBox.Show("Error al imprimir el ticket : " + ex.Message, "Error de impresión", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void Generate_Click(object sender, RoutedEventArgs e) { try { //DataRowView row = (DataRowView)gridContacts.SelectedItem; if (gridContacts.SelectedIndex == -1 || cmbCompanies.SelectedIndex == -1) { MessageBox.Show("Company/Contact Not Selected"); return; } if (cmbTemplateFolders.SelectedIndex == -1 || cmbTemplateFiles.SelectedIndex == -1) { MessageBox.Show("Folder or file is not selected"); return; } if (txtDocumentSerialNumber.Text == "" || !Utility.IsNumber(txtDocumentSerialNumber.Text)) { MessageBox.Show("Please give valid serial number"); return; } string refName = txtRef.Text; //Contact contact = (Contact)gridContacts.SelectedItem; Field field = new Field() { refNo = txtRef.Text, companyName = getCurrentSelectedCompany().companyName, address1 = txtAddress1.Text, address2 = txtAddress2.Text, address3 = txtAddress3.Text, city = txtCity.Text, pincode = txtPincode.Text, phone = txtPhone.Text, date = txtDate.Text, state = getSelectedState().stateName, country = txtCountry.Text, stateCode = txtStateCode.Text, contactName = txtContactName.Text, contactEmail = txtContactEmail.Text, contactPhone = txtContactPhone.Text, gstNo = txtGSTNo.Text, serviceInvoiceNo = txtServiceInvoiceNo.Text, taxInvoiceNo = txtTaxInvoiceNo.Text }; ReportProcessor rp = new ReportProcessor(); string saveFolder = txtDocumentFolderPath.Text + "\\" + getCurrentSelectedCompany().companyName; //rp.GenerateReport(field, txtTemplateFilePath.Text, txtSaveFilePath.Text); //return; if (File.Exists(txtSaveFilePath.Text)) { MessageBox.Show("File Exists previously, either change serial number or delete file from " + txtSaveFilePath.Text); } //Trace.WriteLine("save file path" + txtSaveFilePath.Text); //Trace.WriteLine("Template file path" + txtTemplateFilePath.Text); if (!Directory.Exists(saveFolder)) { Directory.CreateDirectory(saveFolder); } rp.GenerateReport(field, txtTemplateFilePath.Text, txtSaveFilePath.Text); //Trace.WriteLine("Report Generated"); SaveInDb(txtSaveFilePath.Text); if (btnOpenToggle.IsChecked == true) { Process.Start(txtSaveFilePath.Text); } } catch (Exception ex) { MessageBox.Show("Exception in generating report : " + ex.Message); } }
private void SaveNewItem(short StatusID, bool print) { 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 , custtypetoid = -1 , custtypeid = -1; int paid = 0; if (custtype_ != "Botol") { DataRow[] dr = this.sinarekDataSet.custtype.Select("name = '" + custtype_ + "'"); custtypetoid = int.Parse(dr[0]["custtypeid"].ToString()); //dr = this.sinarekDataSet.custtype.Select("name = 'supplier'"); custtypeid = int.Parse(rddSup.Tag.ToString()); } else { custtypetoid = int.Parse(rddSup.Tag.ToString()); } if (chkAntar.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On) { sopirid = int.Parse(rddPelSopir.SelectedValue.ToString()); mobilid = int.Parse(rddPelMobil.SelectedValue.ToString()); kernetid = int.Parse(rddPelKernet.SelectedValue.ToString()); kotaid = int.Parse(rddTujuan.SelectedValue.ToString()); } string[] sep = { "_" }; custid = int.Parse(rddSup.SelectedValue.ToString().Split(sep, StringSplitOptions.RemoveEmptyEntries)[0]); using (sinarekDataSetTableAdapters.logproductTableAdapter tbl = new sinarekDataSetTableAdapters.logproductTableAdapter()) { //Always Create with status created iLogID = tbl.pInsertLogProd(tanggalDateTimePicker.Value , 0 , kernetid , sopirid , mobilid , kotaid , custtypeid , mobil , sopir , keterangan , custid , custtypetoid , custtypetoid , NBConfig.ValidUserName , StatusID, paid, 0).ToString(); } custtypetoid = int.Parse(rddSup.Tag.ToString()); foreach (GridViewRowInfo item in radGridView1.Rows) { using (sinarekDataSetTableAdapters.logdetailTableAdapter tbl = new sinarekDataSetTableAdapters.logdetailTableAdapter()) { try { tbl.pInsertLogOther(int.Parse(iLogID) , item.Cells["keterangan"].Value.ToString() , 0 , int.Parse(item.Cells["custtypeid"].Value.ToString()) , custtypetoid , null , decimal.Parse(item.Cells["quantity"].Value.ToString()) , int.Parse(item.Cells["productid"].Value.ToString()) , int.Parse(item.Cells["status"].Value.ToString()) , decimal.Parse(item.Cells["harga"].Value.ToString()) , NBConfig.ValidUserName); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } MessageBox.Show("Data sudah terinput.", "SMS"); //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; rptSJ rpt = new rptSJ(); rpt.ReportParameters["user"].Value = NBConfig.ValidUserName; rpt.ReportParameters["logid"].Value = iLogID; IReportDocument iRpt = (IReportDocument)rpt; //// PrinterSettings printerSettings = new PrinterSettings(); //// Adjust the printer settings if necessary... // Print the report using the printer settings. reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(iRpt, 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("Transaksi masuk ini dapat dilihat di daftar transaksi yg belum di print."); } }
private void SaveEditItem(short StatusID, bool print) { 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; short custtypetoid = -1 , custtypeid = -1; int paid = 0; DataRow[] dr = this.sinarekDataSet.custtype.Select("name = 'gudang barang'"); custtypetoid = short.Parse(dr[0]["custtypeid"].ToString()); dr = this.sinarekDataSet.custtype.Select("name = 'supplier'"); custtypeid = short.Parse(dr[0]["custtypeid"].ToString()); string[] sep = { "_" }; custid = int.Parse(rddSup.SelectedValue.ToString().Split(sep, StringSplitOptions.RemoveEmptyEntries)[0]); using (sinarekDataSetTableAdapters.logproductTableAdapter tbl = new sinarekDataSetTableAdapters.logproductTableAdapter()) { //Always Create with status created iLogID = tbl.pInsertLogProd(tanggalDateTimePicker.Value , 1 , kernetid , sopirid , mobilid , kotaid , salesid , mobil , sopir , keterangan , custid , custtypetoid , custtypetoid , NBConfig.ValidUserName , StatusID, paid, 0).ToString(); } foreach (GridViewRowInfo item in radGridView1.Rows) { using (sinarekDataSetTableAdapters.logotherTableAdapter tbl = new sinarekDataSetTableAdapters.logotherTableAdapter()) { try { tbl.InsertLogOtherDetail(int.Parse(iLogID) , item.Cells["keterangan"].Value.ToString() , 0 , custtypeid , null , decimal.Parse(item.Cells["quantity"].Value.ToString()) , int.Parse(item.Cells["productid"].Value.ToString()) , decimal.Parse(item.Cells["harga"].Value.ToString()) , NBConfig.ValidUserName); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } MessageBox.Show("Data sudah terinput.", "SMS"); //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; rptSJ rpt = new rptSJ(); rpt.ReportParameters["user"].Value = NBConfig.ValidUserName; rpt.ReportParameters["logid"].Value = iLogID; rpt.ReportParameters["custtypetoid"].Value = 18; IReportDocument iRpt = (IReportDocument)rpt; //// PrinterSettings printerSettings = new PrinterSettings(); //// Adjust the printer settings if necessary... // Print the report using the printer settings. reportProcessor = new ReportProcessor(); reportProcessor.PrintReport(iRpt, printerSettings); } else { MessageBox.Show("Transaksi masuk ini dapat dilihat di daftar transaksi yg belum di print."); } }
protected void RadBtnSaveLetter_Click(object sender, EventArgs e) { //Saving strMagnumID = Request.QueryString["MagnumID"].ToString(); strQuoteAuditID = Request.QueryString["QuoteAuditID"].ToString(); string strQuoteOptionAuditTrailIDO1 = "0"; string strQuoteOptionAuditTrailIDO2 = "0"; string strQuoteOptionAuditTrailIDO3 = "0"; string strQuoteOptionAuditTrailIDO4 = "0"; string strQuoteOptionAuditTrailIDO5 = "0"; string strMessageMain = string.Empty; string strMessage = string.Empty; int intcheckCount = 0; try { Telerik.Web.UI.RadGrid OptionsGrid = (Telerik.Web.UI.RadGrid)RadPanelBar1.FindItemByValue("PanelItem1").FindControl("RadGridOptions"); #region "Get options" foreach (GridDataItem item in OptionsGrid.Items) { if ((item.FindControl("CheckBoxSelect") as System.Web.UI.WebControls.CheckBox).Checked == true) { intcheckCount += 1; #region "Old" //switch (item.Cells[3].Text.Trim()) //{ // case "1": // if (strQuoteOptionAuditTrailIDO1 == "0") // strQuoteOptionAuditTrailIDO1 = item.Cells[2].Text; // else // { // blnContinue = false; // } // break; // case "2": // if (strQuoteOptionAuditTrailIDO2 == "0") // strQuoteOptionAuditTrailIDO2 = item.Cells[2].Text; // else // { // blnContinue = false; // } // break; // case "3": // if (strQuoteOptionAuditTrailIDO3 == "0") // strQuoteOptionAuditTrailIDO3 = item.Cells[2].Text; // else // { // blnContinue = false; // } // break; // case "4": // if (strQuoteOptionAuditTrailIDO4 == "0") // strQuoteOptionAuditTrailIDO4 = item.Cells[2].Text; // else // { // blnContinue = false; // } // break; // case "5": // if (strQuoteOptionAuditTrailIDO5 == "0") // strQuoteOptionAuditTrailIDO5 = item.Cells[2].Text; // else // { // blnContinue = false; // } // break; //} #endregion switch (intcheckCount) { case 1: strQuoteOptionAuditTrailIDO1 = item.Cells[2].Text; break; case 2: strQuoteOptionAuditTrailIDO2 = item.Cells[2].Text; break; case 3: strQuoteOptionAuditTrailIDO3 = item.Cells[2].Text; break; case 4: strQuoteOptionAuditTrailIDO4 = item.Cells[2].Text; break; case 5: strQuoteOptionAuditTrailIDO5 = item.Cells[2].Text; break; } } } #endregion DataSet DS = new DataSet(); #region "SQL" SqlConnection sqlConnectionX; SqlCommand sqlCommandX; SqlParameter sqlParam; SqlDataReader sqlDR; sqlConnectionX = new SqlConnection(ConfigurationManager.AppSettings["SQLConnection"]); sqlConnectionX.Open(); sqlCommandX = new SqlCommand(); sqlCommandX.Connection = sqlConnectionX; sqlCommandX.CommandType = CommandType.StoredProcedure; sqlCommandX.CommandText = "spx_SELECT_QuoteDetailByAuditTrailID_Detailed"; sqlParam = new SqlParameter("QuoteAuditTrailID", strQuoteAuditID); sqlCommandX.Parameters.Add(sqlParam); sqlParam = new SqlParameter("QuoteOption1ID", strQuoteOptionAuditTrailIDO1); sqlCommandX.Parameters.Add(sqlParam); sqlParam = new SqlParameter("QuoteOption2ID", strQuoteOptionAuditTrailIDO2); sqlCommandX.Parameters.Add(sqlParam); sqlParam = new SqlParameter("QuoteOption3ID", strQuoteOptionAuditTrailIDO3); sqlCommandX.Parameters.Add(sqlParam); sqlParam = new SqlParameter("QuoteOption4ID", strQuoteOptionAuditTrailIDO4); sqlCommandX.Parameters.Add(sqlParam); sqlParam = new SqlParameter("QuoteOption5ID", strQuoteOptionAuditTrailIDO5); sqlCommandX.Parameters.Add(sqlParam); sqlDR = sqlCommandX.ExecuteReader(); DataTable dt = new DataTable("Info"); dt.Load(sqlDR); DS.Tables.Add(dt); sqlDR.Close(); sqlCommandX.Cancel(); sqlCommandX.Dispose(); #endregion // Creating and configuring the ObjectDataSource component: var objectDataSource = new Telerik.Reporting.ObjectDataSource(); objectDataSource.DataSource = DS; // GetData returns a DataSet with three tables //objectDataSource.DataMember = "Product"; /// Indicating the exact table to bind to. If the DataMember is not specified the first data table will be used. //objectDataSource.CalculatedFields.Add(new Telerik.Reporting.CalculatedField("FullName", typeof(string), "=Fields.Name + ' ' + Fields.ProductNumber")); // Adding a sample calculated field. // Creating a new report Telerik.Reporting.Report report = new Telerik.Reporting.Report(); //if ((dt.Rows[0][36].ToString() == "ok") && (dt.Rows[0][37].ToString() == "ok")) //{ // report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetter")); //} //if (dt.Rows[0][36].ToString() != "ok") //{ // report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetterDisabilityOnly")); //} //if (dt.Rows[0][37].ToString() != "ok") //{ // report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetterLifeOnly")); //} //Telerik.Reporting.Report report = new Telerik.Reporting.Report(); if (((dt.Rows[0][36].ToString() == "ok") && (dt.Rows[0][37].ToString() == "ok")) || ((dt.Rows[0][72].ToString() != "FDB") && (dt.Rows[0][73].ToString() != "FDB"))) { //Both quoteLife and QuoteDisability were selected if ((dt.Rows[0][42].ToString() == "1") && (dt.Rows[0][43].ToString() == "1")) { report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetter")); } //if only QuoteLife was selected if ((dt.Rows[0][42].ToString() == "1") && (dt.Rows[0][43].ToString() == "0")) { report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetterLifeOnly")); } //if only QuoteDisability was selected if ((dt.Rows[0][42].ToString() == "0") && (dt.Rows[0][43].ToString() == "1")) { //report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetterDisabilityOnly")); report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetterDisOnly")); //report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetter")); //report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetterLifeOnly")); } } else { //2015-10-12 - changed to include if user selects ADB or ACDB then show both life and disability //if (dt.Rows[0][36].ToString() != "ok") //{ // report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetterDisabilityOnly")); //} //if (dt.Rows[0][37].ToString() != "ok") //{ // report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetterLifeOnly")); //} if (dt.Rows[0][36].ToString() != "ok") { if (dt.Rows[0][72].ToString() == "FDB") { report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetterDisabilityOnly")); } else { report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetter")); } } if (dt.Rows[0][37].ToString() != "ok") { if (dt.Rows[0][73].ToString() == "FDB") { report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetterLifeOnly")); } else { report = (Telerik.Reporting.Report)Activator.CreateInstance(System.Reflection.Assembly.Load("Report").GetType("Report.QuoteLetter")); } } } DateTime now = DateTime.Now; //Console.WriteLine("Today is " + now.ToString("MMMM dd, yyyy") + "."); report.DocumentName = now.ToString("ddMMhhmm") + "_" + strMagnumID + "_Quote requested"; // Assigning the ObjectDataSource component to the DataSource property of the report. report.DataSource = objectDataSource; // Use the InstanceReportSource to pass the report to the viewer for displaying Telerik.Reporting.InstanceReportSource reportSource = new Telerik.Reporting.InstanceReportSource(); reportSource.ReportDocument = report; string fileName = report.DocumentName + ".PDF"; //string path = System.IO.Path.GetTempPath(); //string strFolder = "~/files/"; //string month = dateTime.ToString("MMMM"); int intMonth = System.DateTime.Now.Month; string strMonth = intMonth.ToString(); if (intMonth < 10) strMonth = "0" + intMonth.ToString(); string path = Server.MapPath("~/files/"); path += now.ToString("yyyy") + "\\" + strMonth; if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } string filePath = System.IO.Path.Combine(path, 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(filePath, FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } #region "Insert File location into DB" sqlCommandX = new SqlCommand(); sqlCommandX.Connection = sqlConnectionX; sqlCommandX.CommandType = CommandType.StoredProcedure; sqlCommandX.CommandText = "spx_INSERT_QuoteFile"; sqlParam = new SqlParameter("QuoteAuditTrailID", strQuoteAuditID); sqlCommandX.Parameters.Add(sqlParam); sqlParam = new SqlParameter("QuoteFile", filePath); sqlCommandX.Parameters.Add(sqlParam); sqlCommandX.ExecuteNonQuery(); sqlDR.Close(); sqlCommandX.Cancel(); sqlCommandX.Dispose(); #endregion sqlConnectionX.Close(); HiddenFieldSavedFileName.Value = filePath; //Color color = (Color)ColorConverter.ConvertFromString("#00CC00"); System.Drawing.Color col = System.Drawing.ColorTranslator.FromHtml("#00CC00"); lblInfo.ForeColor = col; lblInfo.Text = "File saved successfully"; RadBtnEmail.Visible = true; } catch (Exception ex) { lblInfo.ForeColor = System.Drawing.Color.Red; lblInfo.Text = ex.Message; } }
/// <summary> /// Gets the report stream. /// </summary> /// <param name="item">The item.</param> /// <param name="reportName">Name of the report.</param> /// <returns>MemoryStream.</returns> private MemoryStream GetReportStream(IEditableRoot item, string reportName) { var dict = GetReportParametersDict(item); var reportProcessor = new ReportProcessor(); reportProcessor.Error += ReportProcessorError; var reportInfo = new ReportInfo(string.Format(CultureInfo.InvariantCulture, "?<customReport title=\"\" description=\"\" fileName=\"{0}\" />", reportName), dict); var reportSource = TheReportResolver.Resolve(reportInfo.ToString()); Telerik.Reporting.Processing.RenderingResult result; // Mq1ReportResolver changes the principal, so we'll have to restore it later. var user = ApplicationContext.User; try { result = reportProcessor.RenderReport("PDF", reportSource, null); } finally { ApplicationContext.User = user; } return new MemoryStream(result.DocumentBytes); }
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."); } }
public virtual byte[] CreatePayInSlip() { byte[] pdf = new byte[0]; using (var container = new TransactionModelContainer()) { long id = long.Parse(PaymentId); Payment payment = container.Payments.Where(x => x.Id == id).FirstOrDefault(); if (payment != null) { var config = container.Configurations.Where(x => x.Group == "Pay_In").ToList(); PayInSlipReport report = new PayInSlipReport(); report.DataSource = PayInSlipDetail.CreatePayInSlipSource( config.Where(x => x.Name.ToLower() == "companyname").FirstOrDefault().Value1, config.Where(x => x.Name.ToLower() == "companyname").FirstOrDefault().Value2, config.Where(x => x.Name.ToLower() == "companyname").FirstOrDefault().Value3, config.Where(x => x.Name.ToLower() == "taxno").FirstOrDefault().Value1, config.Where(x => x.Name.ToLower() == "accno").FirstOrDefault().Value1, config.Where(x => x.Name.ToLower() == "accno").FirstOrDefault().Value2, config.Where(x => x.Name.ToLower() == "accno").FirstOrDefault().Value3, DateTime.Now.ToString("dd/MM/yyyy"), config.Where(x => x.Name.ToLower() == "servicecode").FirstOrDefault().Value1, payment.CustomerName, payment.PaymentCode, payment.CustomerIdmPartyId.ToString(), payment.RemainingAmount().ToString(ConfigurationManager.Format.Decimal_Format) ); var reportprocess = new ReportProcessor(); var result = reportprocess.RenderReport("PDF", report, null); pdf = result.DocumentBytes; payment.AddPayInSlip(DateTime.Now, payment.CustomerName, pdf, Convert.ToInt32(payment.Id), payment.PaymentCode); container.SaveChanges(); RefreshWhenDomainModelChanged(payment); } else { throw new ArgumentException("PAYMENT_NOT_FOUND"); } } return pdf; }
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); }
public void ReadReport_InvalidPath_ThrowFileNotFoundException() { ReportProcessor processor = new ReportProcessor("ok", "fakefile.sjd"); Assert.ThrowsException <FileNotFoundException>(() => { processor.ReadReport(); }); }
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; }