public bool Render(AspNetCore.ReportingServices.OnDemandReportRendering.Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, ref Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream)
 {
     try
     {
         this.ParseDeviceinfo(deviceInfo);
         Stream     output     = this.CreateFinalOutputStream(report.Name, createAndRegisterStream);
         MainEngine mainEngine = new MainEngine(createAndRegisterStream, this);
         if (report.HasDocumentMap && !this.m_omitDocumentMap)
         {
             this.m_addedDocMap = mainEngine.AddDocumentMap(report.DocumentMap);
             if (this.m_addedDocMap)
             {
                 mainEngine.NextPage();
             }
         }
         using (AspNetCore.ReportingServices.Rendering.SPBProcessing.SPBProcessing sPBProcessing = new AspNetCore.ReportingServices.Rendering.SPBProcessing.SPBProcessing(report, createAndRegisterStream, 1.7976931348623157E+308))
         {
             SPBContext sPBContext = new SPBContext();
             sPBContext.StartPage               = 0;
             sPBContext.EndPage                 = 0;
             sPBContext.MeasureItems            = false;
             sPBContext.AddSecondaryStreamNames = true;
             sPBContext.AddToggledItems         = true;
             sPBContext.AddOriginalValue        = true;
             sPBProcessing.SetContext(sPBContext);
             RPLReport rPLReport = null;
             bool      flag      = true;
             while (!sPBProcessing.Done)
             {
                 sPBProcessing.GetNextPage(out rPLReport);
                 if (rPLReport != null)
                 {
                     if (flag)
                     {
                         flag = false;
                         if (sPBProcessing.Done)
                         {
                             mainEngine.AdjustFirstWorksheetName(report.Name, this.m_addedDocMap);
                         }
                     }
                     else
                     {
                         mainEngine.NextPage();
                     }
                     mainEngine.RenderRPLPage(rPLReport, !this.m_simplePageHeaders, this.m_suppressOutlines);
                     rPLReport.Release();
                     rPLReport = null;
                 }
             }
             mainEngine.Save(output);
         }
         if (report.JobContext != null)
         {
             IJobContext jobContext = report.JobContext;
             lock (jobContext.SyncRoot)
             {
                 if (jobContext.AdditionalInfo.ScalabilityTime == null)
                 {
                     jobContext.AdditionalInfo.ScalabilityTime = new ScaleTimeCategory();
                 }
                 jobContext.AdditionalInfo.ScalabilityTime.Rendering = mainEngine.TotalScaleTimeMs;
                 if (jobContext.AdditionalInfo.EstimatedMemoryUsageKB == null)
                 {
                     jobContext.AdditionalInfo.EstimatedMemoryUsageKB = new EstimatedMemoryUsageKBCategory();
                 }
                 jobContext.AdditionalInfo.EstimatedMemoryUsageKB.Rendering = mainEngine.PeakMemoryUsageKB;
             }
         }
         mainEngine.Dispose();
         return(false);
     }
     catch (ReportRenderingException)
     {
         throw;
     }
     catch (Exception ex2)
     {
         if (AsynchronousExceptionDetection.IsStoppingException(ex2))
         {
             throw;
         }
         throw new ReportRenderingException(ex2, true);
     }
 }
        protected override void Render(AspNetCore.ReportingServices.OnDemandReportRendering.Report report, NameValueCollection deviceInfo, Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream)
        {
            PaginationSettings paginationSettings = new PaginationSettings(report, deviceInfo);
            string             text = paginationSettings.OutputFormat.ToString().ToUpperInvariant();
            bool flag = true;

            if (text == "TIFF")
            {
                text = "TIF";
                flag = false;
            }
            else if (text == "EMFPLUS")
            {
                text = "EMF";
            }
            if (text == "EMF")
            {
                paginationSettings.DynamicImageDpiX = 96;
                paginationSettings.DynamicImageDpiY = 96;
                paginationSettings.DpiX             = this.m_printDpiX;
                paginationSettings.DpiY             = this.m_printDpiY;
                int measureImageDpiX = default(int);
                int measureImageDpiY = default(int);
                ImageWriter.GetScreenDpi(out measureImageDpiX, out measureImageDpiY);
                paginationSettings.MeasureImageDpiX = measureImageDpiX;
                paginationSettings.MeasureImageDpiY = measureImageDpiY;
            }
            else
            {
                paginationSettings.MeasureImageDpiX = paginationSettings.DpiX;
                paginationSettings.MeasureImageDpiY = paginationSettings.DpiY;
            }
            paginationSettings.MeasureTextDpi = paginationSettings.DpiX;
            Stream stream = default(Stream);

            using (HPBProcessing.HPBProcessing hPBProcessing = new HPBProcessing.HPBProcessing(report, paginationSettings, createAndRegisterStream, ref renderProperties))
            {
                hPBProcessing.SetContext(hPBProcessing.PaginationSettings.StartPage, hPBProcessing.PaginationSettings.EndPage);
                using (Renderer renderer = new Renderer(true))
                {
                    stream = createAndRegisterStream(report.Name + (flag ? ('_' + hPBProcessing.PaginationSettings.StartPage.ToString(CultureInfo.InvariantCulture)) : ""), text, null, "image/" + text, !flag, StreamOper.CreateAndRegister);
                    using (ImageWriter imageWriter = new ImageWriter(renderer, stream, false, createAndRegisterStream, paginationSettings.MeasureImageDpiX, paginationSettings.MeasureImageDpiY))
                    {
                        imageWriter.OutputFormat = hPBProcessing.PaginationSettings.OutputFormat;
                        hPBProcessing.PaginationSettings.UseGenericDefault = !imageWriter.IsEmf;
                        imageWriter.BeginReport(hPBProcessing.PaginationSettings.DpiX, hPBProcessing.PaginationSettings.DpiY);
                        int num = hPBProcessing.PaginationSettings.StartPage;
                        while (true)
                        {
                            RPLReport rPLReport = default(RPLReport);
                            hPBProcessing.GetNextPage(out rPLReport);
                            if (rPLReport == null)
                            {
                                break;
                            }
                            if (flag && num > hPBProcessing.PaginationSettings.StartPage)
                            {
                                stream = (imageWriter.OutputStream = createAndRegisterStream(report.Name + '_' + num, text, null, "image/" + text, !flag, StreamOper.CreateForPersistedStreams));
                            }
                            renderer.ProcessPage(rPLReport, num, hPBProcessing.SharedFontCache, hPBProcessing.GlyphCache);
                            rPLReport.Release();
                            rPLReport = null;
                            num++;
                        }
                        imageWriter.EndReport();
                    }
                }
            }
            stream.Flush();
        }
Esempio n. 3
0
        protected override void Render(AspNetCore.ReportingServices.OnDemandReportRendering.Report report, NameValueCollection deviceInfo, Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream)
        {
            PaginationSettings paginationSettings = new PaginationSettings(report, deviceInfo);

            paginationSettings.UseEmSquare       = true;
            paginationSettings.MeasureTextDpi    = 1000;
            paginationSettings.UseGenericDefault = false;
            if (paginationSettings.DynamicImageDpiX == 96)
            {
                paginationSettings.DynamicImageDpiX = 300;
            }
            if (paginationSettings.DynamicImageDpiY == 96)
            {
                paginationSettings.DynamicImageDpiY = 300;
            }
            BufferedStream bufferedStream = default(BufferedStream);

            using (HPBProcessing.HPBProcessing hPBProcessing = new HPBProcessing.HPBProcessing(report, paginationSettings, createAndRegisterStream, ref renderProperties))
            {
                hPBProcessing.SetContext(hPBProcessing.PaginationSettings.StartPage, hPBProcessing.PaginationSettings.EndPage);
                using (Renderer renderer = new Renderer(true))
                {
                    bufferedStream = new BufferedStream(createAndRegisterStream(report.Name, "pdf", null, "application/pdf", false, StreamOper.CreateAndRegister));
                    using (PDFWriter pDFWriter = new PDFWriter(renderer, bufferedStream, false, createAndRegisterStream, hPBProcessing.PaginationSettings.DpiX, hPBProcessing.PaginationSettings.DpiY))
                    {
                        pDFWriter.HumanReadablePDF = this.m_humanReadablePDF;
                        pDFWriter.PrintOnOpen      = this.m_printOnOpen;
                        pDFWriter.Test             = this.m_test;
                        pDFWriter.EmbedFonts       = this.m_embedFonts;
                        if (report.HasDocumentMap)
                        {
                            DocumentMap documentMap = null;
                            try
                            {
                                documentMap = report.DocumentMap;
                                if (documentMap != null)
                                {
                                    if (documentMap.MoveNext())
                                    {
                                        DocumentMapNode current = documentMap.Current;
                                        PDFRenderer.HandleDocumentMap(documentMap, pDFWriter.DocumentMapRootLabel = new PDFLabel(current.Id, current.Label), 1);
                                    }
                                    if (pDFWriter.DocumentMapRootLabel.Children == null || pDFWriter.DocumentMapRootLabel.Children.Count == 0)
                                    {
                                        pDFWriter.DocumentMapRootLabel = null;
                                    }
                                    else
                                    {
                                        pDFWriter.DocumentMapLabelPoints = new Dictionary <string, PDFPagePoint>();
                                    }
                                }
                            }
                            finally
                            {
                                if (documentMap != null)
                                {
                                    documentMap.Dispose();
                                }
                            }
                        }
                        int num = hPBProcessing.PaginationSettings.StartPage;
                        pDFWriter.BeginReport(hPBProcessing.PaginationSettings.MeasureTextDpi, hPBProcessing.PaginationSettings.MeasureTextDpi);
                        while (true)
                        {
                            RPLReport rPLReport = default(RPLReport);
                            hPBProcessing.GetNextPage(out rPLReport);
                            if (rPLReport == null)
                            {
                                break;
                            }
                            renderer.ProcessPage(rPLReport, num, hPBProcessing.SharedFontCache, hPBProcessing.GlyphCache);
                            rPLReport.Release();
                            rPLReport = null;
                            num++;
                        }
                        pDFWriter.EndReport();
                    }
                }
            }
            bufferedStream.Flush();
        }