public static void imprimirFicha(int _cod_ficha_be, string _nome_impressora) { nome_impressora = _nome_impressora; // Imprimir o BE if (_cod_ficha_be > 0) { using (var relatorio = new Microsoft.Reporting.WebForms.LocalReport()) { relatorio.ReportPath = "Relatorios/Ficha.rdlc"; FichaDAO sr = new FichaDAO(); List <Ficha> sc = new List <Ficha>(); //Ficha sc = new Ficha(); sc = sr.GetFicha(_cod_ficha_be); IEnumerable <Ficha> ie; ie = sc.AsQueryable(); ReportDataSource datasource = new ReportDataSource("Ficha", ie); relatorio.DataSources.Add(datasource); Exportar(relatorio); Imprimir(relatorio); } } }
public static void imprimirEtiqueta(int _cod_ficha_be, string _nome_impressora, int qtdEtiquetas) { impressora_etiqueta = _nome_impressora; // Imprimir o BE if (_cod_ficha_be > 0) { using (var etiqueta = new Microsoft.Reporting.WebForms.LocalReport()) { etiqueta.ReportPath = "Etiqueta/etiqueta.rdlc"; FichaDAO sr = new FichaDAO(); List <Ficha> sc = new List <Ficha>(); //Ficha sc = new Ficha(); sc = sr.GetFicha(_cod_ficha_be); IEnumerable <Ficha> ie; ie = sc.AsQueryable(); ReportDataSource datasource = new ReportDataSource("Ficha", ie); etiqueta.DataSources.Add(datasource); ExportarEtiq(etiqueta); for (int x = 0; x < qtdEtiquetas; x++) { ImprimirEtiq(etiqueta); } } } }
private static void ImprimirEtiq(Microsoft.Reporting.WebForms.LocalReport etiqueta) { using (var pd = new System.Drawing.Printing.PrintDocument()) { //configurar impressora //pd.PrinterSettings.PrinterName = "Microsoft Print to PDF"; pd.PrinterSettings.PrinterName = impressora_etiqueta; var pageSettings = new System.Drawing.Printing.PageSettings(); Margins margins = new Margins(0, 0, 0, 0); var pageSettingsEtiqueta = etiqueta.GetDefaultPageSettings(); pageSettings.PaperSize = pageSettingsEtiqueta.PaperSize; pageSettings.Margins = pageSettingsEtiqueta.Margins; pd.DefaultPageSettings.Margins = margins; //pd.DefaultPageSettings = pageSettings; pd.PrintPage += Pd_PrintPage; _streamAtual = 0; pd.Print(); } }
public ActionResult DownloadAnex(int RntID) { byte[] bytes = null; //if (returnId == null) // returnId = "0"; //int catg = Convert.ToInt32(returnId.Substring(0, 1)); //int RntID = Convert.ToInt32(returnId.Substring(1, returnId.Length - 1)); string DocumetNAme = ""; Microsoft.Reporting.WebForms.LocalReport rpt = new Microsoft.Reporting.WebForms.LocalReport(); var DBvlu = db.AJ_Stud_Admin_Return_Reg_C(RntID); rpt.ReportPath = Server.MapPath(@"~/Reports/Regirstion_Reports/Rdlc_Affi_reg_return_Anax_C.rdlc"); rpt.DataSources.Add(new ReportDataSource("Rdlc_Affi_reg_return_Anax_C", DBvlu)); DocumetNAme = "Annex-C" + "." + "PDF"; rpt.GetDefaultPageSettings(); bytes = rpt.Render("PDF"); // bytes = rpt.Render("PDF"); if (bytes.Length > 0) { Response.Buffer = true; Response.Clear(); Response.AddHeader("content-disposition", "attachment; filename=" + DocumetNAme); Response.OutputStream.Write(bytes, 0, bytes.Length); // create the file Response.Flush(); // send it to the client to download Response.End(); // return View(); } return(RedirectToAction("ReturnStatus", "Registration")); }
/// <summary> /// Adiciona o assembly para o relatório /// </summary> /// <param name="localReport"></param> /// <param name="assembly"></param> private static void AddAssembly(Microsoft.Reporting.WebForms.LocalReport localReport, System.Reflection.Assembly assembly) { var assemblyName = assembly.GetName(); localReport.AddFullTrustModuleInSandboxAppDomain( new System.Security.Policy.StrongName( new System.Security.Permissions.StrongNamePublicKeyBlob(assemblyName.GetPublicKey()), assemblyName.Name, assemblyName.Version)); }
public static void SetReportParameter(Microsoft.Reporting.WebForms.LocalReport localreport, System.Collections.Hashtable Para) { Microsoft.Reporting.WebForms.ReportParameterInfoCollection RPara = localreport.GetParameters(); foreach (Microsoft.Reporting.WebForms.ReportParameterInfo item in RPara) { switch (item.Name) { case "CompanyName": localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysCompany()["CompanyName"].ToString()) }); break; case "CompanyAddress": localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysCompany()["CompanyAddress"].ToString()) }); break; case "CompanyPhone": localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysCompany()["CompanyPhone"].ToString()) }); break; case "CompanyFax": localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysCompany()["CompanyFax"].ToString()) }); break; case "CompanyTaxCode": localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysCompany()["CompanyTaxCode"].ToString()) }); break; case "QDBTC": localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysOption()["QDBTC"].ToString()) }); break; case "DirectorName": localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysOption()["DirectorName"].ToString()) }); break; case "ChiefAccountantName": localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysOption()["ChiefAccountantName"].ToString()) }); break; case "ReportCreatorName": localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysOption()["ReportCreatorName"].ToString()) }); break; case "ReportFontSize": localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysOption()["ReportFontSize"].ToString()) }); break; default: if (Para[item.Name] != null) { localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Para[item.Name].ToString()) }); } break; } } }
byte[] Laboratory(int Inst_ID) { using (UOSEntities db = new UOSEntities()) { Microsoft.Reporting.WebForms.LocalReport rpt = new Microsoft.Reporting.WebForms.LocalReport(); rpt.ReportPath = Server.MapPath(@"~/Aff_Reports/Aff_inst_AJ_Rep_Laboratory_INFO.rdlc"); rpt.DataSources.Add(new ReportDataSource("AJ_Rep_Laboratory_INFO", db.AJ_Rep_Laboratory_INFO(Convert.ToInt32(Inst_ID)))); return(rpt.Render("PDF")); } }
byte[] Download_Rpt_Insitut_info(int Inst_ID) { using (UOSEntities db = new UOSEntities()) { Microsoft.Reporting.WebForms.LocalReport rpt = new Microsoft.Reporting.WebForms.LocalReport(); rpt.ReportPath = Server.MapPath(@"~/Aff_Reports/Rpt_Affi_Instu_Info.rdlc"); rpt.DataSources.Add(new ReportDataSource("AJ_Affi_Ins_Pop_Instu_Info", db.AJ_Affi_Ins_Pop_Instu_Info(Convert.ToInt32(Inst_ID)))); return(rpt.Render("PDF")); } }
byte[] Download_Rpt_Non_Requir_info(int Inst_ID) { using (UOSEntities db = new UOSEntities()) { Microsoft.Reporting.WebForms.LocalReport rpt = new Microsoft.Reporting.WebForms.LocalReport(); rpt.ReportPath = Server.MapPath(@"~/Aff_Reports/Aff_ins_Non_Recuring_INFO.rdlc"); rpt.DataSources.Add(new ReportDataSource("AJ_Rep_Non_Recuring_INFO", db.AJ_Rep_Non_Recuring_INFO(Convert.ToInt32(Inst_ID)))); return(rpt.Render("PDF")); } }
byte[] Download_Rpt_Staff_info(int Inst_ID, int cag) { using (UOSEntities db = new UOSEntities()) { Microsoft.Reporting.WebForms.LocalReport rpt = new Microsoft.Reporting.WebForms.LocalReport(); rpt.ReportPath = Server.MapPath(@"~/Aff_Reports/Aff_Inst_Staff_Info.rdlc"); rpt.DataSources.Add(new ReportDataSource("AJ_Rep_Employee_INFO", db.AJ_Rep_Employee_INFO(Convert.ToInt32(Inst_ID), cag))); return(rpt.Render("PDF")); } }
byte[] Download_Rpt_Libaray_info(int Inst_ID) { using (UOSEntities db = new UOSEntities()) { Microsoft.Reporting.WebForms.LocalReport rpt = new Microsoft.Reporting.WebForms.LocalReport(); rpt.ReportPath = Server.MapPath(@"~/Aff_Reports/Aff_Inst_Library_INFO.rdlc"); rpt.DataSources.Add(new ReportDataSource("AJ_Rep_Library_INFO", db.AJ_Rep_Library_INFO(Convert.ToInt32(Inst_ID)))); rpt.DataSources.Add(new ReportDataSource("Affi_ins_Rep_OtherFacilities_INFO", db.AJ_Affi_ins_Rep_OtherFacilities_INFO(Convert.ToInt32(Inst_ID)))); return(rpt.Render("PDF")); } }
public void SetSubDataSource(object sender, Microsoft.Reporting.WebForms.SubreportProcessingEventArgs e) { try { Microsoft.Reporting.WebForms.LocalReport rptTemp = (Microsoft.Reporting.WebForms.LocalReport)sender; DataTable dtTemp = (DataTable)rptTemp.DataSources[e.ReportPath.Trim()].Value; e.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(e.DataSourceNames[0], dtTemp)); } catch (Exception ex) { Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this); } }
/// <summary> /// Note: SSRS cannot render the report if required parameters are missing. /// This will load any report parameters. /// If any of the parameters were required, but they were not provided, show an error message. /// </summary> /// <param name="report">Instance of the ReportViewer control or equiv object</param> private void CheckReportParameters(WebForms.LocalReport report) { //copy-in any report parameters which were not part of the DB query try { WebForms.ReportParameterInfoCollection rdlParams = report.GetParameters(); foreach (WebForms.ReportParameterInfo rdlParam in rdlParams) { if (this._reportParameters.ContainsKey(rdlParam.Name)) { string val = this._reportParameters[rdlParam.Name].ToString(); if (string.IsNullOrEmpty(val)) { if (rdlParam.Nullable) { val = null; report.SetParameters(new WebForms.ReportParameter(rdlParam.Name, val, false)); } else { ErrorMessages.Add(new ErrorMessage("Erro on Report Parameters.", $"Report Parameter value \"{ rdlParam.Name }\" is required, but was not provided.")); } } else { report.SetParameters(new WebForms.ReportParameter(rdlParam.Name, val)); } } else if (!rdlParam.AllowBlank) { ErrorMessages.Add(new ErrorMessage("Erro on Report Parameters.", $"Report Parameter \"{ rdlParam.Name }\" is required, but was not provided.")); } } if (ErrorMessages.Any()) { OnError?.Invoke(this, new EngineErrorEventArgs(ErrorMessages)); } } catch (WebForms.LocalProcessingException ex) { ErrorMessages.Add(new ErrorMessage(ex.Message, ex.StackTrace)); Exception exIn = ex.InnerException; while (exIn != null) { ErrorMessages.Add(new ErrorMessage(exIn.Message, exIn.StackTrace)); exIn = exIn.InnerException; } OnError?.Invoke(this, new EngineErrorEventArgs(ErrorMessages)); } }
/// <summary> /// Classe para instanciar o relatorio e configurar o servidor. /// Exemplo: http://NomeDoServidor/reportserver /// </summary> /// <param name="reportPath"></param> /// <param name="downloadFileName"></param> /// public WebReportRenderer(string reportPath, string downloadFileName) { if (!downloadFileName.EndsWith(".pdf")) { downloadFileName = downloadFileName + "." + HttpContext.Current.Session["FormatoRelatorioTipoArquivoImpressao"].ToString(); } if (HttpContext.Current == null) throw new InvalidOperationException("Esta classe somente para aplicacoes WEB."); this.downloadFileName = downloadFileName; reportInstance = new Microsoft.Reporting.WebForms.LocalReport(); reportInstance.ReportPath = HttpContext.Current.Server.MapPath(reportPath); }
/// <summary> /// Load the .rdl/.rdlc file into the reporting engine. Also, fix the path for any embedded graphics. /// </summary> /// <param name="report">Instance of the ReportViewer control or equiv object</param> /// <param name="reportFullPath">(file) path to the Reports folder (on the HDD)</param> private void LoadReportDefinitionFile(WebForms.LocalReport report, FileInfo reportFullPath) { string xml = File.ReadAllText(reportFullPath.FullName); if (xml.Contains("<Image")) { report.EnableExternalImages = true; } if (xml.Contains("<Hyperlink")) { report.EnableHyperlinks = true; } report.ReportPath = reportFullPath.FullName; report.SetBasePermissionsForSandboxAppDomain(new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted)); }
private void RetrieveFieldsDetailLocal() { string mlTANGGAL = ""; string mlRECEIVEDCODE = ""; string mlRECEIVEDBY = ""; mlDATATABLE = (DataTable)Session["FormEditReceiptData"]; mlTANGGAL = FormatDateyyyyMMdd(Convert.ToDateTime(mlDATATABLE.Rows[0]["InvPreparedForDate"])); mlRECEIVEDCODE = mlDATATABLE.Rows[0]["InvCodeMess"].ToString(); mlRECEIVEDBY = mlDATATABLE.Rows[0]["InvMessName"].ToString(); if (mlDATATABLE.Rows[0]["InvStatus"].ToString() == "PROCEEDS" && mlDATATABLE.Rows[0]["InvReceiptFlag"].ToString() == "R") { mlSQL2 = "SELECT * FROM INV_DELIVERY " + "WHERE Disabled = 0 AND InvReceiptFlag = 'R' AND InvReceiptCode = '" + mlDATATABLE.Rows[0]["InvReceiptCode"].ToString() + "'" + " AND InvPreparedForDate = '" + mlTANGGAL + "' AND InvCodeMess = '" + mlRECEIVEDCODE + "' AND InvMessName = '" + mlRECEIVEDBY + "' " + "ORDER BY InvPreparedForDate Desc"; mlREADER2 = mlOBJGS.DbRecordset(mlSQL2, "PB", mlCOMPANYID); mlDATATABLE1 = InsertReaderToDatatable(mlDATATABLE1, mlDATAROW, mlREADER2); } ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/pj_delinv/InvReceiptH.rdlc"); Microsoft.Reporting.WebForms.ReportParameter mlRECEIPTCODE = new Microsoft.Reporting.WebForms.ReportParameter("ReceiptCode", mlDATATABLE.Rows[0]["InvReceiptCode"].ToString()); Microsoft.Reporting.WebForms.ReportParameter mlCODEMESS = new Microsoft.Reporting.WebForms.ReportParameter("CodeMess", mlDATATABLE.Rows[0]["InvCodeMess"].ToString()); Microsoft.Reporting.WebForms.ReportParameter mlCOMPNAME = new Microsoft.Reporting.WebForms.ReportParameter("CompanyName", mlCOMPANYNAME); Microsoft.Reporting.WebForms.ReportParameter mlCOMPADDR = new Microsoft.Reporting.WebForms.ReportParameter("CompanyAddress", mlCOMPANYADDRESS); Microsoft.Reporting.WebForms.ReportParameter mlTITLE = new Microsoft.Reporting.WebForms.ReportParameter("Title", "INVOICE / RECEIPT"); //Microsoft.Reporting.WebForms.ReportDataSource mlDATASOURCE = new Microsoft.Reporting.WebForms.ReportDataSource("INV_RECEIPT_DATAH", mlDATATABLE); Microsoft.Reporting.WebForms.ReportDataSource mlDATASOURCE = new Microsoft.Reporting.WebForms.ReportDataSource(); Microsoft.Reporting.WebForms.LocalReport mlREPORTH = new Microsoft.Reporting.WebForms.LocalReport(); mlDATASOURCE.Name = "INV_RECEIPT_DATAH"; mlDATASOURCE.Value = mlDATATABLE; mlREPORTH.ReportEmbeddedResource = "~/pj_delinv/InvReceiptH.rdlc"; mlREPORTH.DataSources.Add(mlDATASOURCE); ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetSubDataSource); ReportViewer1.LocalReport.ReportEmbeddedResource = mlREPORTH.ReportEmbeddedResource; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(mlDATASOURCE); ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { mlRECEIPTCODE, mlCODEMESS, mlCOMPNAME, mlCOMPADDR, mlTITLE }); ReportViewer1.LocalReport.Refresh(); }
public static byte[] GeReportStreamPDF(string reportName, string dataSetName, object dataSet, string reportPath, List <Microsoft.Reporting.WebForms.ReportParameter> parameters = null, Dictionary <string, object> dataSets = null) { Microsoft.Reporting.WebForms.LocalReport report = new Microsoft.Reporting.WebForms.LocalReport(); report.EnableExternalImages = true; report.ReportPath = reportPath + "/" + reportName + ".rdlc"; if (parameters.Count() > 0) { report.SetParameters(parameters); } ReportDataSource rds = new ReportDataSource(); rds.Name = dataSetName; rds.Value = dataSet; report.DataSources.Add(rds); if (dataSets != null) { foreach (KeyValuePair <string, object> kvp in dataSets) { ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = kvp.Key; reportDataSource.Value = kvp.Value; report.DataSources.Add(reportDataSource); } } string deviceInfo = null; // http://msdn2.microsoft.com/en-us/library/ms155397.aspx string mimeType; string encoding; string fileNameExtension; string[] streams; Microsoft.Reporting.WebForms.Warning[] warnings; byte[] renderedBytes = report.Render( "PDF", deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return(renderedBytes); }
private static string CriarDeviceInfo(Microsoft.Reporting.WebForms.LocalReport relatorio) { var pageSettings = relatorio.GetDefaultPageSettings(); return(string.Format( System.Globalization.CultureInfo.InvariantCulture, @"<DeviceInfo> <OutputFormat>EMF</OutputFormat> <PageWidth>{0}in</PageWidth> <PageHeight>{1}in</PageHeight> <MarginTop>{2}in</MarginTop> <MarginLeft>{3}in</MarginLeft> <MarginRight>{4}in</MarginRight> <MarginBottom>{5}in</MarginBottom> </DeviceInfo>", pageSettings.PaperSize.Width / 100m, pageSettings.PaperSize.Height / 100m, pageSettings.Margins.Top / 100m, pageSettings.Margins.Left / 100m, pageSettings.Margins.Right / 100m, pageSettings.Margins.Bottom / 100m)); }
private void Imprimir(Microsoft.Reporting.WebForms.LocalReport relatorio) { using (var pd = new System.Drawing.Printing.PrintDocument()) { //configurar impressora pd.PrinterSettings.PrinterName = "Microsoft Print to PDF"; var pageSettings = new System.Drawing.Printing.PageSettings(); var pageSettingsRelatorio = relatorio.GetDefaultPageSettings(); pageSettings.PaperSize = pageSettingsRelatorio.PaperSize; pageSettings.Margins = pageSettingsRelatorio.Margins; pd.DefaultPageSettings = pageSettings; pd.PrintPage += Pd_PrintPage; _streamAtual = 0; pd.Print(); } }
public static string CreateReceiptPrintout2(DataSet ds, string reportName) { Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.DataSources.Clear(); lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + reportName; //Emnable Image lr.EnableExternalImages = true; // foreach (DataTable dt in ds.Tables) { Microsoft.Reporting.WebForms.ReportDataSource rs = new Microsoft.Reporting.WebForms.ReportDataSource(); rs.Name = dt.TableName; rs.Value = dt; lr.DataSources.Add(rs); } return(BuildPrintoutFile(lr, "PDF")); }
public static string CreateReceiptPrintout(DataTable dtData, DataTable dtDetail, string reportName) { Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + reportName; lr.EnableExternalImages = true; Microsoft.Reporting.WebForms.ReportDataSource rsInvoice = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoice.Name = dtData.TableName; rsInvoice.Value = dtData; lr.DataSources.Add(rsInvoice); Microsoft.Reporting.WebForms.ReportDataSource rsInvoiceDetail = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoiceDetail.Name = dtDetail.TableName; rsInvoiceDetail.Value = dtDetail; lr.DataSources.Add(rsInvoiceDetail); return(BuildPrintoutFile(lr, "PDF")); }
public ActionResult DownloadForm(string appId) { obj = GetData(); Microsoft.Reporting.WebForms.LocalReport rpt = new Microsoft.Reporting.WebForms.LocalReport(); rpt.ReportPath = Server.MapPath(@"~/Aff_Reports/Rep_Affi_Ins_Visting_Member.rdlc"); rpt.DataSources.Add(new ReportDataSource("AJ_Aff_Ins_Vist_Rep_Commety", db.AJ_Aff_Ins_Vist_Rep_Commety(Convert.ToInt32(appId)))); rpt.DataSources.Add(new ReportDataSource("AJ_Aff_Ins_Vist_Rep_MEmBEr_Commety", db.AJ_Aff_Ins_Vist_Rep_MEmBEr_Commety(Convert.ToInt32(obj.Institute_Id)))); byte[] bytes = rpt.Render("PDF"); Response.Buffer = true; Response.Clear(); Response.AddHeader("content-disposition", "attachment; filename= Application" + "." + "PDF"); Response.OutputStream.Write(bytes, 0, bytes.Length); // create the file Response.Flush(); // send it to the client to download Response.End(); //return View(); //return Json("Secuss", JsonRequestBehavior.AllowGet); return(View()); }
protected void generate_report_ServerClick(object sender, EventArgs e) { int briefId = 1; ReportGenerator rg = new ReportGenerator(Server.MapPath("~/download/") + Session.SessionID + ".rdlc"); rg.ChartImagePath = Server.MapPath("~/chart-images/"); string reportPath = rg.Generate(briefId); string fileName = "File_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".docx"; string fullFilePath = Server.MapPath("~/download/") + fileName; string extension = string.Empty; string encoding = string.Empty; string mimeType = string.Empty; string[] streams; MRW.Warning[] warnings; MRW.LocalReport report = new MRW.LocalReport(); report.ReportPath = reportPath; report.SetParameters(GetReportParameters(briefId)); Byte[] mybytes = report.Render("WORDOPENXML", null, out mimeType, out encoding, out extension, out streams, out warnings); using (FileStream fs = File.Create(fullFilePath)) { fs.Write(mybytes, 0, mybytes.Length); } Response.ClearHeaders(); Response.ClearContent(); Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); Response.WriteFile(fullFilePath); Response.Flush(); Response.Close(); Response.End(); }
public static HttpResponseMessage Report(DataTable ds, string dsName, string rdlc) { var report = new Microsoft.Reporting.WebForms.LocalReport(); report.ReportPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Bin/Report/" + rdlc); report.DataSources.Add(new ReportDataSource(dsName, ds)); report.Refresh(); string mimeType = ""; string encoding = ""; string filenameExtension = ""; string[] streams = null; Microsoft.Reporting.WebForms.Warning[] warnings = null; byte[] bytes = report.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streams, out warnings); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new ByteArrayContent(bytes); result.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(mimeType); return(result); }
protected void Button1_Click1(object sender, EventArgs e) { //using (var ds = CriarDataSet()) using (var relatorio = new Microsoft.Reporting.WebForms.LocalReport()) { relatorio.ReportPath = "Relatorios/Ficha.rdlc"; //relatorio.ReportPath = "Relatorios/Report.rdlc"; //relatorio.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("hspmPsDataSet", (DataTable)ds.Item)); FichaDAO sr = new FichaDAO(); List <Ficha> sc = new List <Ficha>(); //Ficha sc = new Ficha(); sc = sr.GetFicha(1);// ficha teste nº 1 IEnumerable <Ficha> ie; ie = sc.AsQueryable(); ReportDataSource datasource = new ReportDataSource("Ficha", ie); relatorio.DataSources.Add(datasource); Exportar(relatorio); Imprimir(relatorio); } }
private void RetrieveFieldsDetailPDF() { string mlTANGGAL = ""; string mlRECEIVEDCODE = ""; string mlRECEIVEDBY = ""; Warning[] warnings; string[] streamIds; string mimeType = string.Empty; string encoding = string.Empty; string extension = string.Empty; string filename = ""; mlDATATABLE = (DataTable)Session["FormEditReceiptData"]; mlTANGGAL = FormatDateyyyyMMdd(Convert.ToDateTime(mlDATATABLE.Rows[0]["InvPreparedForDate"])); mlRECEIVEDCODE = mlDATATABLE.Rows[0]["InvCodeMess"].ToString(); mlRECEIVEDBY = mlDATATABLE.Rows[0]["InvMessName"].ToString(); if (mlDATATABLE.Rows[0]["InvStatus"].ToString() == "PROCEEDS" && mlDATATABLE.Rows[0]["InvReceiptFlag"].ToString() == "R") { mlSQL2 = "SELECT * FROM INV_DELIVERY " + "WHERE Disabled = 0 AND InvReceiptFlag = 'R' AND InvReceiptCode = '" + mlDATATABLE.Rows[0]["InvReceiptCode"].ToString() + "'" + " AND InvPreparedForDate = '" + mlTANGGAL + "' AND InvCodeMess = '" + mlRECEIVEDCODE + "' AND InvMessName = '" + mlRECEIVEDBY + "' " + "ORDER BY InvPreparedForDate Desc"; mlREADER2 = mlOBJGS.DbRecordset(mlSQL2, "PB", mlCOMPANYID); mlDATATABLE1 = InsertReaderToDatatable(mlDATATABLE1, mlDATAROW, mlREADER2); } ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/pj_delinv/InvReceiptH.rdlc"); Microsoft.Reporting.WebForms.ReportParameter mlRECEIPTCODE = new Microsoft.Reporting.WebForms.ReportParameter("ReceiptCode", mlDATATABLE.Rows[0]["InvReceiptCode"].ToString()); Microsoft.Reporting.WebForms.ReportParameter mlCODEMESS = new Microsoft.Reporting.WebForms.ReportParameter("CodeMess", mlDATATABLE.Rows[0]["InvCodeMess"].ToString()); Microsoft.Reporting.WebForms.ReportParameter mlCOMPNAME = new Microsoft.Reporting.WebForms.ReportParameter("CompanyName", mlCOMPANYNAME); Microsoft.Reporting.WebForms.ReportParameter mlCOMPADDR = new Microsoft.Reporting.WebForms.ReportParameter("CompanyAddress", mlCOMPANYADDRESS); Microsoft.Reporting.WebForms.ReportParameter mlTITLE = new Microsoft.Reporting.WebForms.ReportParameter("Title", "INVOICE / RECEIPT"); Microsoft.Reporting.WebForms.ReportDataSource mlDATASOURCE = new Microsoft.Reporting.WebForms.ReportDataSource(); Microsoft.Reporting.WebForms.LocalReport mlREPORTH = new Microsoft.Reporting.WebForms.LocalReport(); mlDATASOURCE.Name = "INV_RECEIPT_DATAH"; mlDATASOURCE.Value = mlDATATABLE; mlREPORTH.ReportEmbeddedResource = "~/pj_delinv/InvReceiptH.rdlc"; mlREPORTH.DataSources.Add(mlDATASOURCE); ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetSubDataSource); ReportViewer1.LocalReport.ReportEmbeddedResource = mlREPORTH.ReportEmbeddedResource; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(mlDATASOURCE); ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { mlRECEIPTCODE, mlCODEMESS, mlCOMPNAME, mlCOMPADDR, mlTITLE }); byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings); filename = "InvReceipt"; extension = "pdf"; // Now that you have all the bytes representing the PDF report, buffer it and send it to the client. Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=" + filename + "." + extension); Response.BinaryWrite(bytes); // create the file Response.Flush(); // send it to the client to download Response.End(); //Body.Size.Width + Report.Margins.Left + Report.Margins.Right <= Report.PageSize.Width }
// metodos para imprimir o BE private static void ExportarEtiq(Microsoft.Reporting.WebForms.LocalReport etiqueta) { Microsoft.Reporting.WebForms.Warning[] warnings; LimparStreams(); etiqueta.Render("image", CriarDeviceInfoEtique(etiqueta), CreateStreamCallback, out warnings); }
public ActionResult DetailsReport() { LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); string deviceInfo = "<DeviceInfo>" + " <OutputFormat>PDF</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>1in</MarginLeft>" + " <MarginRight>1in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; lr.ReportPath = Server.MapPath("~/Rapor/Birim.rdlc"); SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["matbaaConnectionString"].ConnectionString); conn.Open(); SqlDataAdapter adap = new SqlDataAdapter("select * from Birim", conn); DataSet ds = new DataSet(); adap.Fill(ds); conn.Close(); lr.DataSources.Clear(); lr.DataSources.Add( new ReportDataSource("DataSetBirim", ds.Tables[0])); Warning[] warnings; string mimeType; string encoding; string[] streamids; string fne; byte[] bytes = lr.Render("PDF", deviceInfo, out mimeType, out encoding, out fne, out streamids, out warnings); return File(bytes, mimeType); }
private void RetrieveFieldsDetailPDF1() { string mlTANGGAL = ""; string mlRECEIVEDCODE = ""; string mlRECEIVEDBY = ""; Warning[] warnings; string[] streamIds; string mimeType = string.Empty; string encoding = string.Empty; string extension = string.Empty; string filename = ""; string deviceInfo = "<DeviceInfo>" + " <OutputFormat>EMF</OutputFormat>" + " <PageWidth>8.27in</PageWidth>" + " <PageHeight>11.69in</PageHeight>" + " <MarginTop>0.7874in</MarginTop>" + " <MarginLeft>0.98425in</MarginLeft>" + " <MarginRight>0.98425in</MarginRight>" + " <MarginBottom>0.7874in</MarginBottom>" + "</DeviceInfo>"; mlDATATABLE = (DataTable)Session["FormEditReceiptData"]; mlTANGGAL = FormatDateyyyyMMdd(Convert.ToDateTime(mlDATATABLE.Rows[0]["InvPreparedForDate"])); mlRECEIVEDCODE = mlDATATABLE.Rows[0]["InvCodeMess"].ToString(); mlRECEIVEDBY = mlDATATABLE.Rows[0]["InvMessName"].ToString(); if (mlDATATABLE.Rows[0]["InvStatus"].ToString() == "PROCEEDS" && mlDATATABLE.Rows[0]["InvReceiptFlag"].ToString() == "R") { mlSQL2 = "SELECT * FROM INV_DELIVERY " + "WHERE Disabled = 0 AND InvReceiptFlag = 'R' AND InvPreparedForDate = '" + mlTANGGAL + "' AND InvCodeMess = '" + mlRECEIVEDCODE + "' AND InvMessName = '" + mlRECEIVEDBY + "' " + "ORDER BY InvPreparedForDate Desc"; mlREADER2 = mlOBJGS.DbRecordset(mlSQL2, "PB", mlCOMPANYID); mlDATATABLE1 = InsertReaderToDatatable(mlDATATABLE1, mlDATAROW, mlREADER2); } ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/pj_delinv/InvReceiptH.rdlc"); Microsoft.Reporting.WebForms.ReportParameter mlRECEIPTCODE = new Microsoft.Reporting.WebForms.ReportParameter("ReceiptCode", mlDATATABLE.Rows[0]["InvReceiptCode"].ToString()); Microsoft.Reporting.WebForms.ReportParameter mlCODEMESS = new Microsoft.Reporting.WebForms.ReportParameter("CodeMess", mlDATATABLE.Rows[0]["InvCodeMess"].ToString()); Microsoft.Reporting.WebForms.ReportParameter mlCOMPNAME = new Microsoft.Reporting.WebForms.ReportParameter("CompanyName", mlCOMPANYNAME); Microsoft.Reporting.WebForms.ReportParameter mlCOMPADDR = new Microsoft.Reporting.WebForms.ReportParameter("CompanyAddress", mlCOMPANYADDRESS); Microsoft.Reporting.WebForms.ReportParameter mlTITLE = new Microsoft.Reporting.WebForms.ReportParameter("Title", "INVOICE / RECEIPT"); Microsoft.Reporting.WebForms.ReportDataSource mlDATASOURCE = new Microsoft.Reporting.WebForms.ReportDataSource(); Microsoft.Reporting.WebForms.LocalReport mlREPORTH = new Microsoft.Reporting.WebForms.LocalReport(); mlDATASOURCE.Name = "INV_RECEIPT_DATAH"; mlDATASOURCE.Value = mlDATATABLE; mlREPORTH.ReportEmbeddedResource = "~/pj_delinv/InvReceiptH.rdlc"; mlREPORTH.DataSources.Add(mlDATASOURCE); ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetSubDataSource); ReportViewer1.LocalReport.ReportEmbeddedResource = mlREPORTH.ReportEmbeddedResource; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(mlDATASOURCE); ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { mlRECEIPTCODE, mlCODEMESS, mlCOMPNAME, mlCOMPADDR, mlTITLE }); //byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings); byte[] bytes = ReportViewer1.LocalReport.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamIds, out warnings); string path = Server.MapPath("~/pj_delinv/Print_Files"); // Open PDF File in Web Browser filename = "InvReceipt"; extension = "pdf"; FileStream file = new FileStream(path + "/" + filename + "." + extension, FileMode.OpenOrCreate, FileAccess.ReadWrite); file.Write(bytes, 0, bytes.Length); file.Dispose(); WebClient client = new WebClient(); Byte[] buffer = client.DownloadData(path + "/" + filename + "." + extension); if (buffer != null) { Response.ContentType = "application/pdf"; Response.AddHeader("content-length", buffer.Length.ToString()); Response.BinaryWrite(buffer); } }
// metodos para imprimir o BE private static void Exportar(Microsoft.Reporting.WebForms.LocalReport relatorio) { Microsoft.Reporting.WebForms.Warning[] warnings; LimparStreams(); relatorio.Render("image", CriarDeviceInfo(relatorio), CreateStreamCallback, out warnings); }
private void RetrieveFieldsDetailLocal() { string mlCRITERIA = ""; string mlTANGGALFROM = ""; string mlTANGGALTO = ""; mlTANGGALFROM = FormatDateyyyyMMdd(mlTXTTANGGALFROM.Text); mlTANGGALTO = FormatDateyyyyMMdd(mlTXTTANGGALTO.Text); if ((mlTANGGALFROM != "") || (mlTANGGALTO != "")) { mlCRITERIA = "((PROCEEDSDATE BETWEEN '" + mlTANGGALFROM + "' AND '" + mlTANGGALTO + "') OR (DELIVEREDDATE BETWEEN '" + mlTANGGALFROM + "' AND '" + mlTANGGALTO + "') " + "OR (RETURNEDDATE BETWEEN '" + mlTANGGALFROM + "' AND '" + mlTANGGALTO + "') OR (DONEDATE BETWEEN '" + mlTANGGALFROM + "' AND '" + mlTANGGALTO + "')) "; } if (mlDDLREPORTNAME.SelectedItem.Value != "InvDeliverySummary.rdlc") { if (mlDDLBRANCH.SelectedItem.Value != "-- Pilih --") { mlCRITERIA = mlCRITERIA + " AND BRANCH = '" + mlDDLBRANCH.SelectedItem.Value + "'"; } mlSQL2 = "SELECT * FROM INV_DELIVERY_STATUS_BRANCH " + "WHERE " + mlCRITERIA + ""; mlREADER2 = mlOBJGS.DbRecordset(mlSQL2, "PB", mlCOMPANYID); mlDATATABLE = InsertReaderToDatatable(mlDATATABLE, mlDATAROW, mlREADER2); } else { mlSQL2 = "SELECT * FROM INV_DELIVERY_STATUS " + "WHERE " + mlCRITERIA + ""; mlREADER2 = mlOBJGS.DbRecordset(mlSQL2, "PB", mlCOMPANYID); mlDATATABLE = InsertReaderToDatatable(mlDATATABLE, mlDATAROW, mlREADER2); } ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/pj_delinv/" + mlDDLREPORTNAME.SelectedItem.Value + ""); Microsoft.Reporting.WebForms.ReportParameter mlCOMPNAME = new Microsoft.Reporting.WebForms.ReportParameter("CompanyName", mlCOMPANYNAME); Microsoft.Reporting.WebForms.ReportParameter mlCOMPADDR = new Microsoft.Reporting.WebForms.ReportParameter("CompanyAddress", mlCOMPANYADDRESS); Microsoft.Reporting.WebForms.ReportParameter mlTITLE = new Microsoft.Reporting.WebForms.ReportParameter("Title", "REPORTING MONITORING DELIVERY INVOICE"); //Microsoft.Reporting.WebForms.ReportDataSource mlDATASOURCE = new Microsoft.Reporting.WebForms.ReportDataSource("INV_RECEIPT_DATAH", mlDATATABLE); Microsoft.Reporting.WebForms.ReportDataSource mlDATASOURCE = new Microsoft.Reporting.WebForms.ReportDataSource(); Microsoft.Reporting.WebForms.LocalReport mlREPORTH = new Microsoft.Reporting.WebForms.LocalReport(); if (mlDDLREPORTNAME.SelectedItem.Value != "InvDeliverySummary.rdlc") { mlDATASOURCE.Name = "INV_DELIVERY_STATUSBRANCH"; } else { mlDATASOURCE.Name = "INV_DELIVERY_STATUS"; } mlDATASOURCE.Value = mlDATATABLE; mlREPORTH.ReportEmbeddedResource = "~/pj_delinv/" + mlDDLREPORTNAME.SelectedItem.Value + ""; mlREPORTH.DataSources.Add(mlDATASOURCE); //ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetSubDataSource); ReportViewer1.LocalReport.ReportEmbeddedResource = mlREPORTH.ReportEmbeddedResource; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(mlDATASOURCE); ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { mlCOMPNAME, mlCOMPADDR, mlTITLE }); ReportViewer1.LocalReport.Refresh(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string startDate = Convert.ToString(Session["startDate"]); string endDate = Convert.ToString(Session["endDate"]); Int32 rptnameid = Convert.ToInt32(Session["rptname"]); Int32 GantryId = 0; Int32 VehicleClassId = 0; Int32 TransactionCategoryId = 0; if (Session["GantryId"] != null) { GantryId = Convert.ToInt32(Session["GantryId"]); } if (Session["VehicleClassId"] != null) { VehicleClassId = Convert.ToInt32(Session["VehicleClassId"]); } if (Session["TransactionCategoryId"] != null) { VehicleClassId = Convert.ToInt32(Session["TransactionCategoryId"]); } ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; Microsoft.Reporting.WebForms.LocalReport rvReportViewer1 = ReportViewer1.LocalReport; string rptname = ""; if (rptnameid > 0) { VaaaN.MLFF.Libraries.CommonLibrary.CBE.SubmoduleCollection subModules = new VaaaN.MLFF.Libraries.CommonLibrary.CBE.SubmoduleCollection(); subModules = VaaaN.MLFF.Libraries.CommonLibrary.BLL.SubModuleBLL.GetByUserId(Convert.ToInt16(Session["LoggedUserId"]), 7); foreach (VaaaN.MLFF.Libraries.CommonLibrary.CBE.SubmoduleCBE submodule in subModules) { if (submodule.SubModuleId == rptnameid) { rptname = submodule.SubModuleName; break; } } if (rptname != "") { ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.ServerReport.Refresh(); DataSet lds = new DataSet(); switch (rptname) { #region Transaction Details Report case "Transaction Details": { string strQuery = " WHERE 1=1 "; if (startDate != null && endDate != null) { strQuery += " AND TRANSACTION_DATETIME BETWEEN TO_DATE('" + startDate + "','DD/MM/YYYY HH24:MI:SS') AND TO_DATE('" + endDate + "','DD/MM/YYYY HH24:MI:SS')"; } else if (startDate != null) { strQuery += " AND TRANSACTION_DATETIME >= TO_DATE('" + startDate + "','DD/MM/YYYY HH24:MI:SS')"; } else if (endDate != null) { strQuery += " AND TRANSACTION_DATETIME <= TO_DATE('" + endDate + "','DD/MM/YYYY HH24:MI:SS')"; } if (GantryId > 0) { strQuery += " AND T.PLAZA_ID = " + GantryId; } if (VehicleClassId > 0) { strQuery += " AND (CV_CTP.VEHICLE_CLASS_ID = " + VehicleClassId + " OR NFPF.VEHICLE_CLASS_ID = " + VehicleClassId + " OR NFPR.VEHICLE_CLASS_ID = " + VehicleClassId + ")"; } if (TransactionCategoryId == 0) { strQuery += " AND NVL(IS_BALANCE_UPDATED,0) <> 1"; } else if (TransactionCategoryId == 1) { strQuery += " AND T.CT_ENTRY_ID IS NOT NULL "; } else if (TransactionCategoryId == 2) { strQuery += " AND T.NF_ENTRY_ID_FRONT IS NOT NULL "; } else if (TransactionCategoryId == 3) { strQuery += " AND T.NF_ENTRY_ID_REAR IS NOT NULL "; } dt = VaaaN.MLFF.Libraries.CommonLibrary.BLL.TransactionBLL.GetDataTableFilteredRecords(strQuery); rvReportViewer1.ReportPath = Server.MapPath("~/Reports/TranscationReport.rdlc"); rvReportViewer1.DataSources.Add(new ReportDataSource("ReportDataSet", dt)); rvReportViewer1.DataSources.Add(new ReportDataSource("CommonDataSet", CreateCommonDataTable(rptname))); break; } #endregion } ReportViewer1.ShowRefreshButton = false; // Section 2 ReportViewer1.DataBind(); ReportViewer1.LocalReport.Refresh(); ReportViewer1.ServerReport.Refresh(); } } } }
protected void BindLocalReport(MsLocalReport localReport, IReport report) { ILocalReportProcessingLocation location = (ILocalReportProcessingLocation)report.ReportProcessingLocation; localReport.LoadReportDefinition(ReportDefinitionCache.GetReportDefinition(location.File).GetReportStream()); localReport.EnableHyperlinks = true; localReport.EnableExternalImages = true; localReport.SetBasePermissionsForSandboxAppDomain(new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted)); //localReport.ExecuteReportInCurrentAppDomain(AppDomain.CurrentDomain.Evidence); //localReport.AddFullTrustModuleInSandboxAppDomain(new System.Security.Policy.StrongName(new System.Security.Permissions.StrongNamePublicKeyBlob(Nullable),"VB.Reports.App.ReportStyleLibrary.StyleSheet","1.0.0")); //localReport.AddTrustedCodeModuleInCurrentAppDomain(System.Reflection.Assembly.GetAssembly(typeof(VB.Reports.App.ReportStyleLibrary.StyleSheet)).ToString()); if (localReport.IsDrillthroughReport) { localReport.SetParameters(localReport.OriginalParametersToDrillthrough); } else { IList <MsReportParameter> parameters = new List <MsReportParameter>(); foreach (IReportParameter parameter in report.ReportParameters) { parameters.Add(new MsReportParameter(parameter.Name, GetParameterValue(parameter))); } localReport.SetParameters(parameters); } localReport.DataSources.Clear(); foreach (IReportDataCommandTemplate reportDataCommandTemplate in report.ReportDataCommandTemplates) { DictionaryDataParameterValue parameterValues = new DictionaryDataParameterValue(); foreach (IReportParameter parameter in reportDataCommandTemplate.Parameters) { if (localReport.IsDrillthroughReport) { parameterValues[parameter.Name] = GetParameterValue(parameter, localReport.OriginalParametersToDrillthrough); } else { parameterValues[parameter.Name] = GetParameterValue(parameter); } } using (IDataConnection connection = SimpleQuery.ConfigurationManagerConnection(location.DataSourceName)) { if (connection.State == ConnectionState.Closed) { connection.Open(); } using (IDataCommand command = connection.CreateCommand(reportDataCommandTemplate, parameterValues.DataParameterValue)) { command.CommandTimeout = 200; using (IDataReader reader = command.ExecuteReader()) { DataTable table = DataTableMapper.ToDataTable(reader); localReport.DataSources.Add(new MsReportDataSource(reportDataCommandTemplate.Name, table)); } } } } localReport.Refresh(); }
private void RetrieveFieldsDetailPDF1() { string mlTANGGAL = ""; string mlRECEIVEDCODE = ""; string mlRECEIVEDBY = ""; Warning[] warnings; string[] streamIds; string mimeType = string.Empty; string encoding = string.Empty; string extension = string.Empty; string filename = ""; string deviceInfo = "<DeviceInfo>" + " <OutputFormat>EMF</OutputFormat>" + " <PageWidth>8.27in</PageWidth>" + " <PageHeight>11.69in</PageHeight>" + " <MarginTop>0.7874in</MarginTop>" + " <MarginLeft>0.98425in</MarginLeft>" + " <MarginRight>0.98425in</MarginRight>" + " <MarginBottom>0.7874in</MarginBottom>" + "</DeviceInfo>"; mlDATATABLE = (DataTable)Session["FormEditReceiptData"]; mlTANGGAL = FormatDateyyyyMMdd(Convert.ToDateTime(mlDATATABLE.Rows[0]["InvPreparedForDate"])); mlRECEIVEDCODE = mlDATATABLE.Rows[0]["InvCodeMess"].ToString(); mlRECEIVEDBY = mlDATATABLE.Rows[0]["InvMessName"].ToString(); if (mlDATATABLE.Rows[0]["InvStatus"].ToString() == "PROCEEDS" && mlDATATABLE.Rows[0]["InvReceiptFlag"].ToString() == "R") { mlSQL2 = "SELECT * FROM INV_DELIVERY " + "WHERE Disabled = '0' AND InvReceiptFlag = 'R' AND InvReceiptCode = '" + mlDATATABLE.Rows[0]["InvReceiptCode"].ToString() + "'" + " AND InvPreparedForDate = '" + mlTANGGAL + "' AND InvCodeMess = '" + mlRECEIVEDCODE + "' AND InvMessName = '" + mlRECEIVEDBY + "' " + "ORDER BY InvPreparedForDate Desc"; mlREADER2 = mlOBJGS.DbRecordset(mlSQL2, "PB", mlCOMPANYID); mlDATATABLE1 = InsertReaderToDatatable(mlDATATABLE1, mlDATAROW, mlREADER2); } //else //{ // mlDATATABLE1 = mlDATATABLE.Copy(); //} ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/pj_delinv/InvReceiptH.rdlc"); Microsoft.Reporting.WebForms.ReportParameter mlRECEIPTCODE = new Microsoft.Reporting.WebForms.ReportParameter("ReceiptCode", mlDATATABLE.Rows[0]["InvReceiptCode"].ToString()); Microsoft.Reporting.WebForms.ReportParameter mlCODEMESS = new Microsoft.Reporting.WebForms.ReportParameter("CodeMess", mlDATATABLE.Rows[0]["InvCodeMess"].ToString()); Microsoft.Reporting.WebForms.ReportParameter mlCOMPNAME = new Microsoft.Reporting.WebForms.ReportParameter("CompanyName", mlCOMPANYNAME); Microsoft.Reporting.WebForms.ReportParameter mlCOMPADDR = new Microsoft.Reporting.WebForms.ReportParameter("CompanyAddress", mlCOMPANYADDRESS); Microsoft.Reporting.WebForms.ReportParameter mlTITLE = new Microsoft.Reporting.WebForms.ReportParameter("Title", "INVOICE / RECEIPT"); Microsoft.Reporting.WebForms.ReportDataSource mlDATASOURCE = new Microsoft.Reporting.WebForms.ReportDataSource(); Microsoft.Reporting.WebForms.LocalReport mlREPORTH = new Microsoft.Reporting.WebForms.LocalReport(); mlDATASOURCE.Name = "INV_RECEIPT_DATAH"; mlDATASOURCE.Value = mlDATATABLE; mlREPORTH.ReportEmbeddedResource = "~/pj_delinv/InvReceiptH.rdlc"; mlREPORTH.DataSources.Add(mlDATASOURCE); ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetSubDataSource); ReportViewer1.LocalReport.ReportEmbeddedResource = mlREPORTH.ReportEmbeddedResource; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(mlDATASOURCE); ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { mlRECEIPTCODE, mlCODEMESS, mlCOMPNAME, mlCOMPADDR, mlTITLE }); //byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings); byte[] bytes = ReportViewer1.LocalReport.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamIds, out warnings); string path = Server.MapPath("~/pj_delinv/Print_Files"); // Open PDF File in Web Browser filename = "InvReceipt"; extension = "pdf"; FileStream file = new FileStream(path + "/" + filename + "." + extension, FileMode.OpenOrCreate, FileAccess.ReadWrite); file.Write(bytes, 0, bytes.Length); file.Dispose(); WebClient client = new WebClient(); Byte[] buffer = client.DownloadData(path + "/" + filename + "." + extension); if (buffer != null) { Response.ContentType = "application/pdf"; Response.AddHeader("content-length", buffer.Length.ToString()); Response.BinaryWrite(buffer); } }
/// <summary> /// Por padrão, o relatório é gerado em modo retrato. /// </summary> /// <param name="reportPath"></param> /// <param name="downloadFileName"></param> /// <param name="orientacao"></param> public WebReportRenderer(string reportPath, string downloadFileName, Orientacao orientacao, string papel = "A4", string margensVerticais = null, string margensLaterais = null) { if (!downloadFileName.EndsWith(".pdf")) { downloadFileName = downloadFileName + "." + HttpContext.Current.Session["FormatoRelatorioTipoArquivoImpressao"].ToString(); } if (HttpContext.Current == null) throw new InvalidOperationException("Esta classe somente para aplicacoes WEB."); this.downloadFileName = downloadFileName; var altura = ""; var largura = ""; switch (papel) { case "A4": altura = "29.7cm"; largura = "21cm"; break; case "Carta": altura = "27.94cm"; largura = "21.59cm"; break; } deviceInfo = "<DeviceInfo>" + " <OutputFormat>PDF</OutputFormat>"; if (orientacao == Orientacao.Paisagem) deviceInfo += " <PageWidth>" + altura + "</PageWidth>" + " <PageHeight>" + largura + "</PageHeight>"; else deviceInfo += " <PageWidth>" + largura + "</PageWidth>" + " <PageHeight>" + altura + "</PageHeight>"; if (!String.IsNullOrEmpty(margensVerticais)) deviceInfo += " <MarginBottom>" + "0.2cm" + "</MarginBottom>" + " <MarginTop>" + margensVerticais + "</MarginTop>"; else deviceInfo += " <MarginBottom>0.2in</MarginBottom>" + " <MarginTop>0.5in</MarginTop>"; if (!String.IsNullOrEmpty(margensLaterais)) deviceInfo += " <MarginLeft> " + margensLaterais + "</MarginLeft>" + " <MarginRight>" + margensLaterais + "</MarginRight>"; else deviceInfo += " <MarginLeft>0.2in</MarginLeft>" + " <MarginRight>0.2in</MarginRight>"; deviceInfo += " <Language>pt-BR</Language>" + "</DeviceInfo>"; reportInstance = new Microsoft.Reporting.WebForms.LocalReport(); reportInstance.ReportPath = HttpContext.Current.Server.MapPath(reportPath); }
private void RetrieveFieldsDetailPDF() { string mlTANGGAL = ""; string mlRECEIVEDCODE = ""; string mlRECEIVEDBY = ""; Warning[] warnings; string[] streamIds; string mimeType = string.Empty; string encoding = string.Empty; string extension = string.Empty; string filename = ""; mlDATATABLE = (DataTable)Session["FormEditReceiptData"]; mlTANGGAL = FormatDateyyyyMMdd(Convert.ToDateTime(mlDATATABLE.Rows[0]["InvPreparedForDate"])); mlRECEIVEDCODE = mlDATATABLE.Rows[0]["InvCodeMess"].ToString(); mlRECEIVEDBY = mlDATATABLE.Rows[0]["InvMessName"].ToString(); if (mlDATATABLE.Rows[0]["InvStatus"].ToString() == "PROCEEDS" && mlDATATABLE.Rows[0]["InvReceiptFlag"].ToString() == "R") { mlSQL2 = "SELECT * FROM INV_DELIVERY " + "WHERE Disabled = 0 AND InvReceiptFlag = 'R' AND InvPreparedForDate = '" + mlTANGGAL + "' AND InvCodeMess = '" + mlRECEIVEDCODE + "' AND InvMessName = '" + mlRECEIVEDBY + "' " + "ORDER BY InvPreparedForDate Desc"; mlREADER2 = mlOBJGS.DbRecordset(mlSQL2, "PB", mlCOMPANYID); mlDATATABLE1 = InsertReaderToDatatable(mlDATATABLE1, mlDATAROW, mlREADER2); } ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/pj_delinv/InvReceiptH.rdlc"); Microsoft.Reporting.WebForms.ReportParameter mlRECEIPTCODE = new Microsoft.Reporting.WebForms.ReportParameter("ReceiptCode", mlDATATABLE.Rows[0]["InvReceiptCode"].ToString()); Microsoft.Reporting.WebForms.ReportParameter mlCODEMESS = new Microsoft.Reporting.WebForms.ReportParameter("CodeMess", mlDATATABLE.Rows[0]["InvCodeMess"].ToString()); Microsoft.Reporting.WebForms.ReportParameter mlCOMPNAME = new Microsoft.Reporting.WebForms.ReportParameter("CompanyName", mlCOMPANYNAME); Microsoft.Reporting.WebForms.ReportParameter mlCOMPADDR = new Microsoft.Reporting.WebForms.ReportParameter("CompanyAddress", mlCOMPANYADDRESS); Microsoft.Reporting.WebForms.ReportParameter mlTITLE = new Microsoft.Reporting.WebForms.ReportParameter("Title", "INVOICE / RECEIPT"); Microsoft.Reporting.WebForms.ReportDataSource mlDATASOURCE = new Microsoft.Reporting.WebForms.ReportDataSource(); Microsoft.Reporting.WebForms.LocalReport mlREPORTH = new Microsoft.Reporting.WebForms.LocalReport(); mlDATASOURCE.Name = "INV_RECEIPT_DATAH"; mlDATASOURCE.Value = mlDATATABLE; mlREPORTH.ReportEmbeddedResource = "~/pj_delinv/InvReceiptH.rdlc"; mlREPORTH.DataSources.Add(mlDATASOURCE); ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetSubDataSource); ReportViewer1.LocalReport.ReportEmbeddedResource = mlREPORTH.ReportEmbeddedResource; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(mlDATASOURCE); ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { mlRECEIPTCODE, mlCODEMESS, mlCOMPNAME, mlCOMPADDR, mlTITLE }); byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings); filename = "InvReceipt"; extension = "pdf"; // Now that you have all the bytes representing the PDF report, buffer it and send it to the client. Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=" + filename + "." + extension); Response.BinaryWrite(bytes); // create the file Response.Flush(); // send it to the client to download Response.End(); //Body.Size.Width + Report.Margins.Left + Report.Margins.Right <= Report.PageSize.Width }