Ejemplo n.º 1
0
        private static byte[] Export(LocalReport report, ExportRDLCCommand reportDefinition, out string mime, out string ext)
        {
            Warning[] warnings;
            byte[]    b;
            string    deviceInfo = null;


            if ((reportDefinition.ReportType == ReportType.PDF))
            {
                deviceInfo = String.Format("<DeviceInfo><OutputFormat>{0}</OutputFormat>", reportDefinition.ReportType);

                if (!String.IsNullOrEmpty(reportDefinition.PageWidth))
                {
                    deviceInfo += String.Format("<PageWidth>{0}</PageWidth>", reportDefinition.PageWidth);
                }

                if (!String.IsNullOrEmpty(reportDefinition.PageHeight))
                {
                    deviceInfo += String.Format("<PageHeight>{0}</PageHeight>", reportDefinition.PageHeight);
                }

                if (!String.IsNullOrEmpty(reportDefinition.MarginTop))
                {
                    deviceInfo += String.Format("<MarginTop>{0}</MarginTop>", reportDefinition.MarginTop);
                }

                if (!String.IsNullOrEmpty(reportDefinition.MarginLeft))
                {
                    deviceInfo += String.Format("<MarginLeft>{0}</MarginLeft>", reportDefinition.MarginLeft);
                }

                if (!String.IsNullOrEmpty(reportDefinition.MarginRight))
                {
                    deviceInfo += String.Format("<MarginRight>{0}</MarginRight>", reportDefinition.MarginRight);
                }

                if (!String.IsNullOrEmpty(reportDefinition.MarginBottom))
                {
                    deviceInfo += String.Format("<MarginBottom>{0}</MarginBottom>", reportDefinition.MarginBottom);
                }



                deviceInfo += "</DeviceInfo>";
            }

            string[] streams  = null;
            string   encoding = null;

            mime = null;
            ext  = null;

            b = report.Render(reportDefinition.ReportType.ToString(), deviceInfo, out mime, out encoding, out ext, out streams, out warnings);

            return(b);
        }
Ejemplo n.º 2
0
        public void ExecuteCommand()
        {
            log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            try
            {
                if (Command != null)
                {
                    Me = (ExportRDLCCommand)Command;
                }

                RenderReport();
            }
            catch (Exception ex)
            {
                Page.DisplayErrorAlert(ex);

                log.Error(ex);
            }
        }
Ejemplo n.º 3
0
        public static byte[] RenderReport(ExportRDLCCommand reportDefinition, Hashtable dataItems, out string mime, out string ext)
        {
            byte[] retVal;

            LocalReport localReport = new LocalReport();

            localReport.DataSources.Clear();
            LoadReportDefinition(localReport, reportDefinition);

            foreach (CodeTorch.Core.ReportDataSource dataSource in reportDefinition.ReportDataSources)
            {
                DataTable data = (DataTable)dataItems[dataSource.Name];

                Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(dataSource.Name, data);
                localReport.DataSources.Add(rds);
            }

            localReport.Refresh();

            retVal = Export(localReport, reportDefinition, out mime, out ext);

            return(retVal);
        }
Ejemplo n.º 4
0
        private static void LoadReportDefinition(LocalReport localReport, ExportRDLCCommand reportDefinition)
        {
            string ConfigResourceDLL = ConfigurationManager.AppSettings["APPBUILDER_CONFIG_DLL_NAMESPACE"];
            string configNamespace   = ConfigurationManager.AppSettings["APPBUILDER_CONFIG_DLL_NAMESPACE"];



            Assembly assembly = Assembly.Load(ConfigResourceDLL);

            string reportPath = GetReportPath(reportDefinition.ReportName, reportDefinition.EnableLocalization, configNamespace);

            Stream stream = assembly.GetManifestResourceStream(reportPath);

            if (stream != null)
            {
                localReport.LoadReportDefinition(stream);
                localReport.EnableHyperlinks = reportDefinition.EnableHyperlinks;
                localReport.DisplayName      = "Export";
            }
            else
            {
                throw new ApplicationException(String.Format("Report {0} could not be found.", reportPath));
            }
        }