/// <summary> /// Carrega a definição para o relatório. /// </summary> /// <param name="localReport"></param> protected virtual void LoadDefinition(Microsoft.Reporting.WebForms.LocalReport localReport) { if (Document is IReportDefinitionContainer) { localReport.LoadReportDefinition(((IReportDefinitionContainer)Document).GetDefinition()); } }
public override void render(string sType, Stream st) { var localReport = new Microsoft.Reporting.WebForms.LocalReport(); //rpt.ReportPath = "Rpt01.rdlc"; localReport.EnableExternalImages = true; for (int i = 0; i < this.ds.Tables.Count; i++) { var o = new Microsoft.Reporting.WebForms.ReportDataSource(this.ds.Tables[i].TableName, this.ds.Tables[i]); localReport.DataSources.Add(o); } //string sReportName = Request.QueryString["ReportName"]; System.IO.MemoryStream ms = new System.IO.MemoryStream(this.output); localReport.LoadReportDefinition(ms); // //MemoryStream ms = new MemoryStream(); //file.PostedFile.InputStream.CopyTo(ms); //var byts = ms.ToArray(); //ms.Dispose(); byte[] bytes = localReport.Render(sType); st.Write(bytes, 0, bytes.Length); }
/// <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 IHttpActionResult PrintPackingListExtend(int id, int template) { Library.DTO.Notification notification; // authentication Module.Framework.BLL fwBll = new Module.Framework.BLL(); if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanPrint)) { return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED))); } //GET DATA BLL.ECommercialInvoiceMng bll = new BLL.ECommercialInvoiceMng(); DTO.ECommercialInvoiceMng.PackingListContainerPrintout dtoPrintout = bll.GetPackingListPrintoutData(id, ControllerContext.GetAuthUserId(), out notification); //CREATE PRINTOUT string printoutFileName = string.Empty; if (dtoPrintout != null && dtoPrintout.PackingListPrintouts != null && dtoPrintout.PackingListDetailPrintouts != null) { string reportName = ""; //int? companyID = fwBll.GetCompanyID(ControllerContext.GetAuthUserId()); switch (template) { case 1: reportName = "PackingListPrint_OrangePine.rdlc"; break; default: reportName = "PackingListPrint.rdlc"; break; } Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + reportName; Microsoft.Reporting.WebForms.ReportDataSource rsInvoice = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoice.Name = "PackingList"; rsInvoice.Value = dtoPrintout.PackingListPrintouts; lr.DataSources.Add(rsInvoice); Microsoft.Reporting.WebForms.ReportDataSource rsInvoiceDetail = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoiceDetail.Name = "PackingListDetail"; rsInvoiceDetail.Value = dtoPrintout.PackingListDetailPrintouts; lr.DataSources.Add(rsInvoiceDetail); printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, "PDF"); } return(Ok(new Library.DTO.ReturnData <string>() { Data = printoutFileName, Message = notification })); }
public static void BindControl(Microsoft.Reporting.WebForms.ReportViewer rv, DataSet data, string name, string virtualRldc) { rv.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); rds.Name = name + "_Table"; rds.Value = data.Tables[0]; Microsoft.Reporting.WebForms.LocalReport r = rv.LocalReport; r.ReportPath = virtualRldc; r.DataSources.Add(rds); }
public static byte[] RenderReport(DataSet data, string name, string type) { Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); rds.Name = name + "_Table"; rds.Value = data.Tables[0]; string virtualRdlc = BuildRDLC(data, name); Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = HttpContext.Current.Server.MapPath(virtualRdlc); lr.DataSources.Add(rds); return(RenderReport(lr, name, type)); }
protected void Page_Load(object sender, EventArgs e) { this.ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; System.Data.DataTable dt = null; Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource("COR_Basic", dt); // rds.Name = "COR_Basic"; // rds.Value = dt; Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.DataSources.Add(rds); lr.ReportPath = "bla.rdlc"; byte[] mybytes = lr.Render("WORD"); }
private void CreatePDFDocument(string strReportPath, Microsoft.Reporting.WebForms.ReportViewer AIMSReport, string strDestinationFilePath) { Microsoft.Reporting.WebForms.Warning[] warnings = null; string[] streamids = null; string mimeType = null; string encoding = null; string extension = null; string deviceInfo = null; byte[] bytes; Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = strReportPath; deviceInfo = "<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>"; bytes = AIMSReport.LocalReport.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); WriteToFile(strDestinationFilePath, bytes); }
public IHttpActionResult PrintCreditNote(int id, string fileTypeID) { Library.DTO.Notification notification; // authentication Module.Framework.BLL fwBll = new Module.Framework.BLL(); if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanPrint)) { return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED))); } //GET DATA BLL.CreditNoteMng bll = new BLL.CreditNoteMng(); DTO.ECommercialInvoiceMng.InvoiceContainerPrintout dtoPrintout = bll.GetCreditNotePrintout(id, ControllerContext.GetAuthUserId(), out notification); //CREATE PRINTOUT string printoutFileName = string.Empty; if (dtoPrintout != null && dtoPrintout.Invoices != null && dtoPrintout.InvoiceDetails != null) { Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + "CreditNotePrint.rdlc"; Microsoft.Reporting.WebForms.ReportDataSource rsInvoice = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoice.Name = "Invoice"; rsInvoice.Value = dtoPrintout.Invoices; lr.DataSources.Add(rsInvoice); Microsoft.Reporting.WebForms.ReportDataSource rsInvoiceDetail = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoiceDetail.Name = "InvoiceDetail"; rsInvoiceDetail.Value = dtoPrintout.InvoiceDetails; lr.DataSources.Add(rsInvoiceDetail); printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, fileTypeID); } return(Ok(new Library.DTO.ReturnData <string>() { Data = printoutFileName, Message = notification })); }
/// <summary> /// Carrega a definição para o relatório. /// </summary> /// <param name="localReport">Relatório local para onde a definição será carregada.</param> /// <param name="report"></param> protected virtual void LoadDefinition(Microsoft.Reporting.WebForms.LocalReport localReport, System.IO.Stream report) { _compatiblesParameters.Clear(); if (Document is IReportDefinitionContainer) { System.Xml.Linq.XElement root = null; root = System.Xml.Linq.XElement.Load(report, System.Xml.Linq.LoadOptions.None); var nameAttribute = root.Attribute("Name"); if (nameAttribute != null && !string.IsNullOrEmpty(nameAttribute.Value) && Document.Title == null) { Document.Title = nameAttribute.Value.GetFormatter(); } var reportDefinition = root.GetDefaultNamespace().NamespaceName; var reportParameters = root.Elements(System.Xml.Linq.XName.Get("ReportParameters", reportDefinition)).FirstOrDefault(); var parameters = new List <string>(); if (reportParameters != null) { foreach (var parameter in reportParameters.Elements(System.Xml.Linq.XName.Get("ReportParameter", reportDefinition))) { var paramenterName = parameter.Attribute("Name"); if (paramenterName != null) { parameters.Add(paramenterName.Value); } } } _compatiblesParameters = parameters; using (var stream = new System.IO.MemoryStream()) { root.Save(stream); stream.Seek(0, System.IO.SeekOrigin.Begin); localReport.LoadReportDefinition(stream); } } else { localReport.LoadReportDefinition(report); } }
public override byte[] export(string fileType) { var rpt = new Microsoft.Reporting.WebForms.LocalReport(); //rpt.ReportPath = "Rpt01.rdlc"; rpt.EnableExternalImages = true; for (int i = 0; i < this.ds.Tables.Count; i++) { var o = new Microsoft.Reporting.WebForms.ReportDataSource(this.ds.Tables[i].TableName, this.ds.Tables[i]); rpt.DataSources.Add(o); } //string sReportName = Request.QueryString["ReportName"]; System.IO.MemoryStream ms = new System.IO.MemoryStream(this.output); rpt.LoadReportDefinition(ms); Byte[] results = rpt.Render(fileType); return(results); }
protected void ReportViewer1_Drillthrough(object sender, Microsoft.Reporting.WebForms.DrillthroughEventArgs e) { Microsoft.Reporting.WebForms.LocalReport lr = e.Report as Microsoft.Reporting.WebForms.LocalReport; if (rptFacade == null) { rptFacade = new ReportViewFacade(this.DataProvider); } RptViewDesignMain rptDesign = rptFacade.GetRptViewDesignMainByReportName(e.ReportPath.ToUpper()); RptViewUserSubscription[] viewerInput = new RptViewUserSubscription[lr.OriginalParametersToDrillthrough.Count]; RptViewDataSource dataSource = (RptViewDataSource)rptFacade.GetRptViewDataSource(designMain.DataSourceID); for (int i = 0; i < lr.OriginalParametersToDrillthrough.Count; i++) { viewerInput[i] = new RptViewUserSubscription(); viewerInput[i].InputName = lr.OriginalParametersToDrillthrough[i].Name; if (dataSource.SourceType == DataSourceType.SQL) { viewerInput[i].InputType = ReportViewerInputType.SqlFilter; viewerInput[i].SqlFilterSequence = i + 1; } else { viewerInput[i].InputType = ReportViewerInputType.DllParameter; } viewerInput[i].InputValue = lr.OriginalParametersToDrillthrough[i].Values[0]; } DataSet dsSource = rptFacade.ExecuteDataSetFromSource(rptDesign.ReportID, viewerInput, Server.MapPath("").ToString().Substring(0, Server.MapPath("").ToString().LastIndexOf("\\"))); lr.DataSources.Clear(); lr.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("MESRPT", dsSource.Tables[0])); }
public IHttpActionResult PrintNewPickingList(int id) { Library.DTO.Notification notification; // authentication Module.Framework.BLL fwBll = new Module.Framework.BLL(); if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), getModuleCode(), Library.DTO.ModuleAction.CanPrint)) { return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED))); } //GET DATA BLL.WarehousePickingListMng bll = new BLL.WarehousePickingListMng(); DTO.WarehousePickingListMng.PickingListContainerPrintout dtoPrintout = bll.GetNewPickingListPrintData(id, ControllerContext.GetAuthUserId(), out notification); //CREATE PRINTOUT Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + "PickingListPrint.rdlc"; Microsoft.Reporting.WebForms.ReportDataSource rsInvoice = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoice.Name = "PickingList"; rsInvoice.Value = dtoPrintout.PickingListPrintouts; lr.DataSources.Add(rsInvoice); Microsoft.Reporting.WebForms.ReportDataSource rsInvoiceDetail = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoiceDetail.Name = "PickingListDetail"; rsInvoiceDetail.Value = dtoPrintout.PickingListDetailPrintouts; lr.DataSources.Add(rsInvoiceDetail); string printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, "PDF"); return(Ok(new Library.DTO.ReturnData <string>() { Data = printoutFileName, Message = notification })); }
public static byte[] RenderReport(Microsoft.Reporting.WebForms.LocalReport lr, string name, string type) { string extension = string.Empty; string mimeType = string.Empty; switch (type) { case "PDF": extension = "pdf"; mimeType = "application/pdf"; break; case "Excel": extension = "xls"; mimeType = "application/vnd.excel"; break; case "Image": extension = "emf"; mimeType = "application/image"; break; default: throw new Exception("Unrecognized type: " + type + ". Type must be PDF, Excel or Image."); } //The DeviceInfo settings should be changed based on the reportType //http://msdn2.microsoft.com/en-us/library/ms155397.aspx System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<DeviceInfo>"); sb.Append("<OutputFormat>"); sb.Append(type); sb.Append("</OutputFormat>"); sb.Append("<PageWidth>11in</PageWidth>"); sb.Append("<PageHeight>8.5in</PageHeight>"); sb.Append("<MarginTop>1in</MarginTop>"); sb.Append("<MarginLeft>1in</MarginLeft>"); sb.Append("<MarginRight>1in</MarginRight>"); sb.Append("<MarginBottom>1in</MarginBottom>"); sb.Append("</DeviceInfo>"); string deviceInfo = sb.ToString(); string encoding; Microsoft.Reporting.WebForms.Warning[] warnings; string[] streams; byte[] result; //Render the report result = lr.Render( type, deviceInfo, out mimeType, out encoding, out extension, out streams, out warnings); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = mimeType; HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + name + "." + extension); HttpContext.Current.Response.BinaryWrite(result); HttpContext.Current.Response.End(); return(result); }
/// <summary> /// Carrega a definição do relatório. /// </summary> /// <param name="localReport"></param> protected override void LoadDefinition(Microsoft.Reporting.WebForms.LocalReport localReport) { if (Document is Colosoft.Reports.IReportDefinitionContainer) { //if (_alteraStatus != null) // _alteraStatus("Carregando definição"); System.Xml.Linq.XElement root = null; using (var stream = ((Colosoft.Reports.IReportDefinitionContainer)Document).GetDefinition()) root = System.Xml.Linq.XElement.Load(stream, System.Xml.Linq.LoadOptions.None); const string reportDefinition = "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"; var codeElement = root.Elements(System.Xml.Linq.XName.Get("Code", reportDefinition)).FirstOrDefault(); const string translateMethodHeader = "Public Function Translate"; const string endMethod = "End Function"; int index = 0; if (codeElement != null && !codeElement.IsEmpty && !string.IsNullOrEmpty(codeElement.Value) && (index = codeElement.Value.IndexOf(translateMethodHeader, StringComparison.InvariantCultureIgnoreCase)) >= 0) { var endIndex = codeElement.Value.IndexOf(endMethod, index, StringComparison.InvariantCultureIgnoreCase); // Alterar o método de tradução codeElement.Value = codeElement.Value.Substring(0, index) + @"Public Function Translate(ByVal instance As Object, ByVal enumTypeName As String) As String return Glass.Relatorios.UI.Web.GlassReportViewer.Translate(instance, enumTypeName) End Function" + codeElement.Value.Substring(endIndex + endMethod.Length); } const string translate2MethodHeader = "Public Function Translate2"; index = 0; if (codeElement != null && !codeElement.IsEmpty && !string.IsNullOrEmpty(codeElement.Value) && (index = codeElement.Value.IndexOf(translate2MethodHeader, StringComparison.InvariantCultureIgnoreCase)) >= 0) { var endIndex = codeElement.Value.IndexOf(endMethod, index, StringComparison.InvariantCultureIgnoreCase); // Alterar o método de tradução codeElement.Value = codeElement.Value.Substring(0, index) + @"Public Function Translate2(ByVal instance As Object, ByVal enumTypeName As String, ByVal groupKey As String) As String return Glass.Relatorios.UI.Web.GlassReportViewer.Translate2(instance, enumTypeName, groupKey) End Function" + codeElement.Value.Substring(endIndex + endMethod.Length); } var codeModules = root.Elements(System.Xml.Linq.XName.Get("CodeModules", reportDefinition)) .FirstOrDefault(); if (codeModules == null) { codeModules = new XElement(XName.Get("CodeModules", reportDefinition)); root.Add(codeModules); } codeModules.Add(new XElement(XName.Get("CodeModule", reportDefinition)) { Value = "Colosoft.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d3b3c440aed9b980" }); codeModules.Add(new XElement(XName.Get("CodeModule", reportDefinition)) { Value = "Colosoft.Reports, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ec8331ec4228d300" }); codeModules.Add(new XElement(XName.Get("CodeModule", reportDefinition)) { Value = "Colosoft.Reports.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b0156e5c4c7a6003" }); codeModules.Add(new XElement(XName.Get("CodeModule", reportDefinition)) { Value = "Glass.Relatorios, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" }); codeModules.Add(new XElement(XName.Get("CodeModule", reportDefinition)) { Value = "Glass.Relatorios.UI.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" }); using (var stream = new System.IO.MemoryStream()) { root.Save(stream); stream.Seek(0, System.IO.SeekOrigin.Begin); localReport.LoadReportDefinition(stream); } } }
protected void Page_Load(object sender, EventArgs e) { // ReportViewer1.ShowExportControls = false // ReportViewer1.ShowFindControls = false // ReportViewer1.ShowPrintButton = false // ReportViewer1.ShowPromptAreaButton = false // ReportViewer1.ShowParameterPrompts = false // ReportViewer1.ShowRefreshButton = false // ReportViewer1.ShowPageNavigationControls = false // ReportViewer1.ShowZoomControl = true // ReportViewer1.ShowToolBar = false // ReportViewer1.ShowDocumentMapButton = false // ReportViewer1.ShowBackButton = false // ReportViewer1.ToolBarItemBorderStyle = BorderStyle.None ReportViewer1.ShowToolBar = false; ReportViewer1.ShowParameterPrompts = true; ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = "GM_Gebaeudestammdaten_Wincasa.rdl"; //rdlc ? ReportViewer1.LocalReport.EnableHyperlinks = true; ReportViewer1.LocalReport.EnableExternalImages = true; ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence); Microsoft.Reporting.WebForms.ReportParameterInfoCollection x = ReportViewer1.LocalReport.GetParameters(); /* parameters.Add(new ParameterValue { Name = "in_stichtag", Value = System.DateTime.Now.ToString("MM'/'dd'/'yyyy") }); parameters.Add(new ParameterValue { Name = "in_mandant", Value = "0" }); // in use parameters.Add(new ParameterValue { Name = "in_sprache", Value = "DE" }); parameters.Add(new ParameterValue { Name = "in_standort", Value = "00000000-0000-0000-0000-000000000000" }); parameters.Add(new ParameterValue { Name = "in_gebaeude", Value = "00000000-0000-0000-0000-000000000000" }); parameters.Add(new ParameterValue { Name = "def_logo", Value = "R0lGODlhswA4AOYAAPzq0tvc3fOZJ/zlyLprCvSnRfKMC6urrfr6+rOztPb29oKDhfa3ZcLDxPKSF7q7vPKJA8vLzOC7jO3t7djd5NLS0/GFAJmam+jo6OHi5PLy8vOhOP768/rWqP716qKipOHh4vz8/Hd4e/3y45SBavjGhuXm5vayXPrctOXs9Md0DP7+/vKPEJGSlPe8cPnLkd7f4M3OzoWGiP78+X+AgvDhznt9f4mKjNzSxYeIioyNkPfAesiUUvWtUeLj5eTn66F5SdjY2tbW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7AmCrhJKrCElAB74XBcw3uZqLCV/wBZv7uaAbuhgYCAA7AA==" }); parameters.Add(new ParameterValue { Name = "def_padding_left", Value = 70 }); parameters.Add(new ParameterValue { Name = "def_padding_right", Value = 0 }); parameters.Add(new ParameterValue { Name = "def_padding_top", Value = 0 }); parameters.Add(new ParameterValue { Name = "def_padding_bottom", Value = 0 }); parameters.Add(new ParameterValue { Name = "def_mime", Value = "image/gif" }); parameters.Add(new ParameterValue { Name = "def_HideLogo", Value = false }); */ foreach (Microsoft.Reporting.WebForms.ReportParameterInfo pi in x) { System.Console.WriteLine(pi.Prompt); } System.Collections.Generic.List<Microsoft.Reporting.WebForms.ReportParameter> parms = new System.Collections.Generic.List<Microsoft.Reporting.WebForms.ReportParameter>(); // Add Parameters of type Microsoft.Reporting.Windows.ReportParameter parms.Add(new Microsoft.Reporting.WebForms.ReportParameter("Test", "Whatever")); parms.Add(new Microsoft.Reporting.WebForms.ReportParameter("CustomerID", new string[] { "14335", "15094" })); // http://forums.asp.net/t/1656685.aspx/1 // Clears the source data (below) before a new request is sent // ReportViewer1.LocalReport.DataSources.Clear(); // ReportViewer1.ShowReportBody = true; ReportViewer1.ServerReport.SetParameters(parms); System.Data.DataTable dt = null; Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource("COR_Basic", dt); // rds.Name = "COR_Basic"; // rds.Value = dt; // https://msdn.microsoft.com/en-US/library/ms251837(v=VS.90).aspx Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.DataSources.Add(rds); lr.ReportPath = "bla.rdlc"; string deviceInfo = null; /* deviceInfo = "<DeviceInfo>" + " <OutputFormat>EMF</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.25in</MarginTop>" + " <MarginLeft>0.25in</MarginLeft>" + " <MarginRight>0.25in</MarginRight>" + " <MarginBottom>0.25in</MarginBottom>" + "</DeviceInfo>"; */ Microsoft.Reporting.WebForms.CreateStreamCallback cb = CreateStream; Microsoft.Reporting.WebForms.Warning[] warnings; //lr.Render("WORD", deviceInfo, cb, out warnings); lr.Render("PDF", deviceInfo, cb, out warnings); }
public string GetPrintoutData(int saleOrderID, string reportName, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification { Type = Library.DTO.NotificationType.Success }; try { using (SaleOrderMngEntities context = CreateContext()) { SaleOrderMng_SaleOrder_ReportView dbItem; dbItem = context.SaleOrderMng_SaleOrder_ReportView .Include("SaleOrderMng_SaleOrderDetail_ReportView.SaleOrderMng_SaleOrderDetailExtend_ReportView") .Include("SaleOrderMng_SaleOrderDetailSparepart_ReportView") .Include("SaleOrderMng_SaleOrderExtend_ReportView") .FirstOrDefault(o => o.SaleOrderID == saleOrderID); var dtoPrintout = converter.DB2DTO_Printout(dbItem); //CREATE PRINTOUT if (reportName == null) { reportName = dtoPrintout.ReportName; } //int? companyID = fwBll.GetCompanyID(ControllerContext.GetAuthUserId()); //switch (companyID) //{ // case 13: // reportName = reportName + "_OrangePine.rdlc"; // break; // default: // reportName = reportName + ".rdlc"; // break; //} reportName = reportName + ".rdlc"; Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + reportName; Microsoft.Reporting.WebForms.ReportDataSource rsInvoice = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoice.Name = "Order"; rsInvoice.Value = dtoPrintout.PIPrintouts; lr.DataSources.Add(rsInvoice); Microsoft.Reporting.WebForms.ReportDataSource rsInvoiceDetail = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoiceDetail.Name = "OrderDetail"; rsInvoiceDetail.Value = dtoPrintout.PIDetailPrintouts; lr.DataSources.Add(rsInvoiceDetail); string printoutFileName = TilsoftService.Helper.PrintoutHelper.BuildPrintoutFile(lr, "PDF"); // // author: TheMy // description: add disclaimer (using iTextSharp) // string finalFile = System.Guid.NewGuid().ToString().Replace("-", "") + ".pdf"; FileInfo fInfo = new FileInfo(FrameworkSetting.Setting.AbsoluteReportFolder + reportName); if (File.Exists(FrameworkSetting.Setting.AbsoluteReportFolder + fInfo.Name.Replace(fInfo.Extension, "") + "_bottom.pdf")) { try { Document document = new Document(); PdfCopy writer = new PdfCopy(document, new FileStream(FrameworkSetting.Setting.AbsoluteReportTmpFolder + finalFile, FileMode.Create)); if (writer == null) { throw new Exception("Can not create Pdf object"); } document.Open(); writer.AddDocument(new PdfReader(FrameworkSetting.Setting.AbsoluteReportTmpFolder + printoutFileName)); writer.AddDocument(new PdfReader(FrameworkSetting.Setting.AbsoluteReportFolder + fInfo.Name.Replace(fInfo.Extension, "") + "_bottom.pdf")); writer.Close(); document.Close(); } catch (Exception ex) { //Library.DTO.notification.Type = Library.DTO.NotificationType.Error; //notification.Message = "Adding general condition failed: " + ex.Message; finalFile = printoutFileName; } } else { finalFile = printoutFileName; } return(finalFile); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message)) { notification.DetailMessage.Add(ex.InnerException.Message); } return(""); } }
public IHttpActionResult PrintPI(int id, string reportName) { Library.DTO.Notification notification; // authentication Module.Framework.BLL fwBll = new Module.Framework.BLL(); if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanPrint)) { return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED))); } //GET DATA BLL.SaleOrderMng bll = new BLL.SaleOrderMng(); DTO.SaleOrderMng.PIContainerPrintout dtoPrintout = bll.GetPrintoutData(id, ControllerContext.GetAuthUserId(), out notification); //CREATE PRINTOUT if (reportName == null) { reportName = dtoPrintout.ReportName; } //int? companyID = fwBll.GetCompanyID(ControllerContext.GetAuthUserId()); //switch (companyID) //{ // case 13: // reportName = reportName + "_OrangePine.rdlc"; // break; // default: // reportName = reportName + ".rdlc"; // break; //} reportName = reportName + ".rdlc"; Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + reportName; Microsoft.Reporting.WebForms.ReportDataSource rsInvoice = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoice.Name = "Order"; rsInvoice.Value = dtoPrintout.PIPrintouts; lr.DataSources.Add(rsInvoice); Microsoft.Reporting.WebForms.ReportDataSource rsInvoiceDetail = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoiceDetail.Name = "OrderDetail"; rsInvoiceDetail.Value = dtoPrintout.PIDetailPrintouts; lr.DataSources.Add(rsInvoiceDetail); string printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, "PDF"); // // author: TheMy // description: add disclaimer (using iTextSharp) // string finalFile = System.Guid.NewGuid().ToString().Replace("-", "") + ".pdf"; FileInfo fInfo = new FileInfo(FrameworkSetting.Setting.AbsoluteReportFolder + reportName); if (File.Exists(FrameworkSetting.Setting.AbsoluteReportFolder + fInfo.Name.Replace(fInfo.Extension, "") + "_bottom.pdf")) { try { Document document = new Document(); PdfCopy writer = new PdfCopy(document, new FileStream(FrameworkSetting.Setting.AbsoluteReportTmpFolder + finalFile, FileMode.Create)); if (writer == null) { throw new Exception("Can not create Pdf object"); } document.Open(); writer.AddDocument(new PdfReader(FrameworkSetting.Setting.AbsoluteReportTmpFolder + printoutFileName)); writer.AddDocument(new PdfReader(FrameworkSetting.Setting.AbsoluteReportFolder + fInfo.Name.Replace(fInfo.Extension, "") + "_bottom.pdf")); writer.Close(); document.Close(); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = "Adding general condition failed: " + ex.Message; finalFile = printoutFileName; } } else { finalFile = printoutFileName; } // // // return(Ok(new Library.DTO.ReturnData <string>() { Data = finalFile, Message = notification })); }
/// <summary> /// Prepara o relatório que será exportado. /// </summary> /// <param name="localReport">Instancia do relatório.</param> /// <param name="culture">Cultura que será usada.</param> /// <returns></returns> protected virtual void PrepareLocalReport(Microsoft.Reporting.WebForms.LocalReport localReport, System.Globalization.CultureInfo culture) { if (Document == null) { throw new InvalidOperationException("Document is null"); } localReport.SubreportProcessing += LocalReportSubreportProcessing; LoadDefinition(localReport); if (Document is ISubreportDefinitionContainer) { foreach (ISubreportDefinition subreport in (ISubreportDefinitionContainer)Document) { LoadSubreportDefinition(localReport, subreport); } } foreach (var dataSource in Document.DataSources) { localReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource.Name, dataSource.Value)); } var reportParameters = new List <Microsoft.Reporting.WebForms.ReportParameter>(); foreach (var parameter in Document.Parameters.Values) { if (_compatiblesParameters.Count > 0 && !_compatiblesParameters.Contains(parameter.Name)) { continue; } if (parameter.Values != null) { var values = new string[parameter.Values.Length]; for (var i = 0; i < parameter.Values.Length; i++) { if (parameter.Values[i] != null) { if (!(parameter.Values[i] is string)) { var converter = System.ComponentModel.TypeDescriptor.GetConverter(parameter.Values[i]); if (culture != null) { values[i] = converter.ConvertToString(null, culture, parameter.Values[i]); } else { values[i] = converter.ConvertToString(parameter.Values[i]); } } else { values[i] = parameter.Values[i] as string; } } } reportParameters.Add(new Microsoft.Reporting.WebForms.ReportParameter(parameter.Name, values)); } else { reportParameters.Add(new Microsoft.Reporting.WebForms.ReportParameter(parameter.Name, (string)null)); } } localReport.SetParameters(reportParameters); if (Document.Title != null) { localReport.DisplayName = Document.Title.FormatOrNull() ?? ""; } }
/// <summary> /// Carrega as definição do subrelatório. /// </summary> /// <param name="localReport"></param> /// <param name="subreport"></param> protected virtual void LoadSubreportDefinition(Microsoft.Reporting.WebForms.LocalReport localReport, ISubreportDefinition subreport) { localReport.LoadSubreportDefinition(subreport.Name, subreport.GetDefinition()); }
public static byte[] RenderReport(DataSet data, string name, string type) { Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); rds.Name = name + "_Table"; rds.Value = data.Tables[0]; string virtualRdlc = BuildRDLC(data, name); Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = HttpContext.Current.Server.MapPath(virtualRdlc); lr.DataSources.Add(rds); return RenderReport(lr, name, type); }
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)); 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 (var dataParameterTemplate in reportDataCommandTemplate.Parameters) { var parameter = (IReportParameter)dataParameterTemplate; if (localReport.IsDrillthroughReport) { parameterValues[parameter.Name] = GetParameterValue(parameter, localReport.OriginalParametersToDrillthrough); } else { parameterValues[parameter.Name] = GetParameterValue(parameter); } } var dataCommandTemplate = reportDataCommandTemplate as ReportDataCommandTemplate; if (dataCommandTemplate != null) { using (IDataConnection connection = SimpleQuery.ConfigurationManagerConnection(dataCommandTemplate.DataSourceName)) { if (connection.State == ConnectionState.Closed) { connection.Open(); } DataTable table = null; Boolean isOlap = ChangeOlapParameter(dataCommandTemplate.DataSourceName, parameterValues); if (reportDataCommandTemplate.Name.Equals("DealerGroupID")) { continue; } if (isOlap) { table = ReportAnalyticsClient.GetReportData <DataTable>(GetParameterList(parameterValues)); } if (table == null) { using (IDataCommand command = connection.CreateCommand(reportDataCommandTemplate, parameterValues.DataParameterValue)) { command.CommandTimeout = 200; using (IDataReader reader = command.ExecuteReader()) { table = (isOlap.Equals(true) ? DataTableMapper.ToOlapDataTable(reader, reportDataCommandTemplate.DataMap, new DataTableCallback()) : DataTableMapper.ToDataTable(reader, reportDataCommandTemplate.DataMap, new DataTableCallback())); } } } localReport.DataSources.Add(new MsReportDataSource(reportDataCommandTemplate.Name, table)); } } } localReport.Refresh(); }
public IHttpActionResult PrintInvoice(int id, string formatFile, string reportName, int invoiceType) { BLL.ECommercialInvoiceMng bll = new BLL.ECommercialInvoiceMng(); Library.DTO.Notification notification; // authentication Module.Framework.BLL fwBll = new Module.Framework.BLL(); if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanPrint)) { return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED))); } //CREATE PRINTOUT string printoutFileName = string.Empty; int? companyID = fwBll.GetCompanyID(ControllerContext.GetAuthUserId()); /* * get report file base on format of report * Excel format is special, we will use one function to get report base on excel * Another format we will use microsoft report tool to create report */ if (formatFile == "Excel") { //switch (companyID) //{ // case 13: // printoutFileName = bll.GetOrangePiePrintout(id, out notification); // break; // default: // break; //} printoutFileName = bll.GetInvoicePrintoutInExcel(id, reportName, invoiceType, out notification); } else { DTO.ECommercialInvoiceMng.InvoiceContainerPrintout dtoPrintout = bll.GetInvoicePrintoutData(id, ControllerContext.GetAuthUserId(), out notification); if (dtoPrintout != null && dtoPrintout.Invoices != null && dtoPrintout.InvoiceDetails != null) { reportName = reportName + ".rdlc"; //switch (companyID) //{ // case 13: // reportName = reportName + "_OrangePine.rdlc"; // break; // default: // reportName = reportName + ".rdlc"; // break; //} Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + reportName; Microsoft.Reporting.WebForms.ReportDataSource rsInvoice = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoice.Name = "Invoice"; rsInvoice.Value = dtoPrintout.Invoices; lr.DataSources.Add(rsInvoice); Microsoft.Reporting.WebForms.ReportDataSource rsInvoiceDetail = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoiceDetail.Name = "InvoiceDetail"; rsInvoiceDetail.Value = dtoPrintout.InvoiceDetails; lr.DataSources.Add(rsInvoiceDetail); printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, formatFile); } } return(Ok(new Library.DTO.ReturnData <string>() { Data = printoutFileName, Message = notification })); }
public IHttpActionResult PrintPackingList(int id, string formatType, string reportName) { Library.DTO.Notification notification = new Library.DTO.Notification(); // authentication Module.Framework.BLL fwBll = new Module.Framework.BLL(); if (!fwBll.CanPerformAction(ControllerContext.GetAuthUserId(), moduleCode, Library.DTO.ModuleAction.CanPrint)) { return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED))); } BLL.ECommercialInvoiceMng bll = new BLL.ECommercialInvoiceMng(); string printoutFileName = string.Empty; if (reportName == "PackingListPrint") { if (formatType == "PDF") { DTO.ECommercialInvoiceMng.PackingListContainerPrintout dtoPrintout = bll.GetPackingListPrintoutData(id, ControllerContext.GetAuthUserId(), out notification); reportName = reportName + ".rdlc"; Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + reportName; Microsoft.Reporting.WebForms.ReportDataSource rsInvoice = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoice.Name = "PackingList"; rsInvoice.Value = dtoPrintout.PackingListPrintouts; lr.DataSources.Add(rsInvoice); Microsoft.Reporting.WebForms.ReportDataSource rsInvoiceDetail = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoiceDetail.Name = "PackingListDetail"; rsInvoiceDetail.Value = dtoPrintout.PackingListDetailPrintouts; lr.DataSources.Add(rsInvoiceDetail); printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, "PDF"); } else { printoutFileName = bll.GetPEUackingListPrintoutData(id, reportName, out notification); } } else { if (reportName == "PackingListPrint_PerCont") { if (formatType == "PDF") { List <DTO.ECommercialInvoiceMng.PackingListContainerPrintout> listDtoPrintout = bll.GetPackingListPrintoutData_PerCont(id, ControllerContext.GetAuthUserId(), out notification); foreach (var dtoPrintout in listDtoPrintout) { //DTO.ECommercialInvoiceMng.PackingListContainerPrintout dtoPrintout = bll.GetPackingListPrintoutData(id, ControllerContext.GetAuthUserId(), out notification); reportName = reportName + ".rdlc"; Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = FrameworkSetting.Setting.AbsoluteReportFolder + reportName; Microsoft.Reporting.WebForms.ReportDataSource rsInvoice = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoice.Name = "PackingList"; rsInvoice.Value = dtoPrintout.PackingListPrintouts; lr.DataSources.Add(rsInvoice); Microsoft.Reporting.WebForms.ReportDataSource rsInvoiceDetail = new Microsoft.Reporting.WebForms.ReportDataSource(); rsInvoiceDetail.Name = "PackingListDetail"; rsInvoiceDetail.Value = dtoPrintout.PackingListDetailPrintouts; lr.DataSources.Add(rsInvoiceDetail); if (printoutFileName != string.Empty) { printoutFileName = printoutFileName + "," + PrintoutHelper.BuildPrintoutFile(lr, "PDF"); } else { printoutFileName = PrintoutHelper.BuildPrintoutFile(lr, "PDF"); } reportName = "PackingListPrint_PerCont"; } } else { printoutFileName = bll.GetEUPackingListPrintoutData_PerCont(id, reportName, out notification); } } else { printoutFileName = bll.GetOrangePiePrintout(id, out notification); } } return(Ok(new Library.DTO.ReturnData <string>() { Data = printoutFileName, Message = notification })); }
public HttpResponseMessage Get() { var dataSet = new Models.DataSetFuncionario(); dataSet.Funcionario.AddFuncionarioRow("André", "Lima", DateTime.Now); var report = new Microsoft.Reporting.WebForms.LocalReport(); report.ReportPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Reports/Contratos/relConfirmacaoPreco.rdlc"); report.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSetFuncionario", (System.Data.DataTable)dataSet.Funcionario)); 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); }