예제 #1
0
 protected override bool RenderInternal(ref MemoryStream chunk, out string mime)
 {
     mime = null;
     try
     {
         /* this is about rendering:
          * what does the user want us to render ->
          * see if this renderer can do what she asks for */
         if (Outputformat == FileType.ft_html)
         {
             /* expect this to be delivered: */
             mime = SetResultDisposition(ResultFileBasename + ".html", FileType.ft_html);
             if (chunk == null)
             {
                 chunk = new MemoryStream();
             }
             /* employ a html rendering engine */
             var engine = new HtmlTemplateEngine(chunk);
             /* compose the parts */
             if (DoRenderHeaderUsingTemplate)
             {
                 engine.RenderHeader(
                     this,
                     PresentationOptions.HasFlag(ReportPresentationOptions.ShowTitle),
                     PresentationOptions.HasFlag(ReportPresentationOptions.ShowLogo)
                     );
             }
             if (DoRenderMetaUsingTemplate)
             {
                 engine.RenderMetadata(
                     this,
                     PresentationOptions.HasFlag(ReportPresentationOptions.ShowMetadata),
                     PresentationOptions.HasFlag(ReportPresentationOptions.ShowCriteria),
                     PresentationOptions.HasFlag(ReportPresentationOptions.ShowQRCode)
                     );
             }
             /* the actual content (report rendition) */
             RenderBody(engine);
             /* submit everything */
             engine.SubmitToStream(this);
         }
         else if (Outputformat == FileType.ft_pdf)
         {
             /* use TEX to render as a pdf */
         }
         else
         {
             /* cannot render that... */
             throw new NotSupportedException(Outputformat.ToString());
         }
         /* succeeded */
         return(true);
     }
     catch (Exception ex)
     {
         /* some error */
         OnBuiltinReportError(ex.Message, ex);
         return(false);
     }
 }
예제 #2
0
        /// <summary>
        /// Returns the number of logical pages
        /// -!- check if the current version of the report generator still generates the ancient doc and xls file formats,
        /// instead of xlsx/docx... if ever needed; at the moment, no report is using these formats in connection with the RDLC engine
        /// </summary>
        protected int RenderAsMsdbrpt(string resultfilebasename, ref MemoryStream chunk, ref string mime, LocalReport rpt, bool count_pages_only)
        {
            string rpt_format;

            if (Outputformat == FileType.ft_xls)
            {
                rpt_format = "Excel";
                if (resultfilebasename.EndsWith(".xls") == false)
                {
                    resultfilebasename += ".xls";
                }
                mime = SetResultDisposition(resultfilebasename + ".xls", FileType.ft_xls);
                if (chunk == null)
                {
                    chunk = new MemoryStream();
                }
            }
            else if (Outputformat == FileType.ft_doc)
            {
                rpt_format = "Word";
                if (resultfilebasename.EndsWith(".doc") == false)
                {
                    resultfilebasename += ".doc";
                }
                mime = SetResultDisposition(resultfilebasename, FileType.ft_doc);
                if (chunk == null)
                {
                    chunk = new MemoryStream();
                }
            }
            else if (Outputformat == FileType.ft_pdf)
            {
                rpt_format = "PDF";
                if (resultfilebasename.EndsWith(".pdf") == false)
                {
                    resultfilebasename += ".pdf";
                }
                mime = SetResultDisposition(resultfilebasename, FileType.ft_pdf);
                if (chunk == null)
                {
                    chunk = new MemoryStream();
                }
            }
            else
            {
                /* cannot render that... */
                throw new NotSupportedException(Outputformat.ToString());
            }
            /* do it */
            string[]  streams;
            Warning[] warnings;
            string    encoding;
            string    extension;

            /* [pkosec 20140521] set dpi for rdlc (MEA-2014-00207 initiative)
             * [pkosec 20140506] use the default value (null), if DPI has not been set */
            string devinfo = null;

            if (GetDPI != 0)
            {
                devinfo = String.Format("<DeviceInfo><DpiX>{0}</DpiX><DpiY>{0}</DpiY></DeviceInfo>", GetDPI);
            }
            var result = rpt.Render(rpt_format, devinfo, PageCountMode.Actual, out mime, out encoding, out extension, out streams, out warnings);

            foreach (var w in warnings)
            {
                Tracing.WarningCore("Code: {0}, Message: {1}, Objectname: {2}, Objecttype: {3}, Severity: {4}",
                                    w.Code,
                                    w.Message,
                                    w.ObjectName,
                                    w.ObjectType,
                                    w.Severity.ToString()
                                    );
            }
            if (count_pages_only == false)
            {
                chunk = new MemoryStream(result);
            }
            /* [dlatikay 20150424] added value: return the number of pages */
            return(rpt.GetTotalPages());
        }
예제 #3
0
 protected override bool RenderInternal(ref MemoryStream chunk, out string mime)
 {
     mime = null;
     try
     {
         /* this is about rendering:
          * what does the user want us to render ->
          * see if this renderer can do what she asks for */
         if (Outputformat == FileType.ft_html || Outputformat == FileType.ft_pdf)
         {
             /* expect this to be delivered: */
             mime = SetResultDisposition(ResultFileBasename, Outputformat);
             if (chunk == null)
             {
                 chunk = new MemoryStream();
             }
             /* employ a html rendering engine */
             var engine = new HtmlTemplateEngine(chunk);
             /* compose the parts */
             engine.RenderHeader(
                 this,
                 PresentationOptions.HasFlag(ReportPresentationOptions.ShowTitle),
                 PresentationOptions.HasFlag(ReportPresentationOptions.ShowLogo)
                 );
             engine.RenderMetadata(
                 this,
                 PresentationOptions.HasFlag(ReportPresentationOptions.ShowMetadata),
                 PresentationOptions.HasFlag(ReportPresentationOptions.ShowCriteria),
                 PresentationOptions.HasFlag(ReportPresentationOptions.ShowQRCode)
                 );
             /* maybe some charts */
             bool trendline = PresentationOptions.HasFlag(ReportPresentationOptions.Trendline);
             if (Presentation.HasFlag(ReportDefPresentations.Linechart))
             {
                 /* draw data into a line chart */
                 var line = RenderChart(ReportDefPresentations.Linechart);
                 engine.SubmitChart(line);
             }
             if (Presentation.HasFlag(ReportDefPresentations.Barchart))
             {
                 /* draw data into a bar chart */
                 var bar = RenderChart(ReportDefPresentations.Barchart);
                 engine.SubmitChart(bar);
             }
             if (Presentation.HasFlag(ReportDefPresentations.Piechart))
             {
                 /* draw data into a pie chart */
                 var pie = RenderChart(ReportDefPresentations.Piechart);
                 engine.SubmitChart(pie);
             }
             /* maybe some tabular data */
             if (Presentation.HasFlag(ReportDefPresentations.Crosstab))
             {
                 /* make a HTML crosstab out of the data */
                 //engine.SubmitCrosstab(AsCrosstab);
             }
             /* submit everything */
             engine.SubmitToStream(this);
         }
         else
         {
             /* cannot render that... */
             throw new NotSupportedException(Outputformat.ToString());
         }
         /* succeeded */
         return(true);
     }
     catch (Exception ex)
     {
         /* some error */
         OnBuiltinReportError(ex.Message, ex);
         return(false);
     }
 }