コード例 #1
0
 public override void Render(HtmlTextWriter outputWriter)
 {
     m_encoding   = outputWriter.Encoding;
     m_mainStream = Utility.CreateBufferedStream(outputWriter);
     if (!m_onlyVisibleStyles)
     {
         string    styleStreamName = HTML5Renderer.GetStyleStreamName(m_rplReport.ReportName, m_pageNum);
         Stream    stream          = m_createAndRegisterStreamCallback(styleStreamName, "css", Encoding.UTF8, "text/css", willSeek: false, StreamOper.CreateAndRegister);
         ROMReport rOMReport       = m_report as ROMReport;
         if (rOMReport != null)
         {
             HTMLStyleRenderer hTMLStyleRenderer = new HTMLStyleRenderer(rOMReport.Report, m_createAndRegisterStreamCallback, m_deviceInfo, this);
             hTMLStyleRenderer.Render(stream);
         }
         stream.Flush();
         m_styleStream = stream;
     }
     else if (!m_useInlineStyle)
     {
         string     styleStreamName2 = HTML5Renderer.GetStyleStreamName(m_rplReport.ReportName, m_pageNum);
         StreamOper operation        = StreamOper.CreateOnly;
         if (m_deviceInfo.StyleStream)
         {
             operation = StreamOper.CreateAndRegister;
         }
         Stream stream2 = m_createAndRegisterStreamCallback(styleStreamName2, "css", Encoding.UTF8, "text/css", willSeek: false, operation);
         m_styleStream = new BufferedStream(stream2);
     }
     if (!m_deviceInfo.HTMLFragment)
     {
         WriteStream(HTMLElements.HtmlStandardsDocType);
         Stream mainStream = m_mainStream;
         Stream stream3    = m_mainStream = new BufferedStream(m_createAndRegisterStreamCallback("BODY", "html", null, null, willSeek: true, StreamOper.CreateOnly));
         RenderHtmlBody();
         RenderSecondaryStreamSpanTagsForJavascriptFunctions();
         WriteStream(HTMLElements.m_closeBody);
         m_mainStream = mainStream;
         stream3.Flush();
         WriteStream(HTMLElements.m_openHtml);
         WriteStreamLineBreak();
         WriteStream(HTMLElements.m_openHead);
         WriteStream(HTMLElements.m_openTitle);
         WriteStream(HttpUtility.HtmlEncode(m_rplReport.ReportName));
         WriteStream(HTMLElements.m_closeTitle);
         WriteStreamLineBreak();
         WriteStreamCR("<META http-equiv=\"Content-Type\" content=\"text/html; charset=" + outputWriter.Encoding.BodyName + "\"/>");
         WriteStreamCR("<META http-equiv=\"Content-Style-Type\" content=\"text/css\"/>");
         WriteStreamCR("<META http-equiv=\"Content-Script-Type\" content=\"text/javascript\"/>");
         if (!m_isMHTML)
         {
             WriteStreamCR(HTMLElements.EdgeContentType);
         }
         RenderHead();
         RenderFinalScript();
         WriteStream(HTMLElements.m_closeHead);
         WriteStream(HTMLElements.m_openBody);
         if (m_deviceInfo.AllowScript)
         {
             StringBuilder stringBuilder = new StringBuilder();
             if (base.NeedResizeImages)
             {
                 stringBuilder.Append(m_deviceInfo.JavascriptPrefixId);
                 stringBuilder.Append("ResizeImages();");
             }
             if (m_deviceInfo.NavigationId != null)
             {
                 stringBuilder.Append(m_deviceInfo.JavascriptPrefixId);
                 stringBuilder.Append("GoToBookmark(");
                 stringBuilder.Append(m_deviceInfo.NavigationId);
                 stringBuilder.Append(");");
             }
             if (m_report.SortItem != null)
             {
                 stringBuilder.Append(m_deviceInfo.JavascriptPrefixId);
                 stringBuilder.Append("GoToSortItem();");
             }
             if (m_report.ShowHideToggle != null)
             {
                 stringBuilder.Append(m_deviceInfo.JavascriptPrefixId);
                 stringBuilder.Append("GoToShowHideToggle();");
             }
             if (m_emitImageConsolidationScaling)
             {
                 stringBuilder.Append("Microsoft_ReportingServices_HTMLRenderer_ScaleImageConsolidation('");
                 stringBuilder.Append(m_deviceInfo.HtmlPrefixId);
                 stringBuilder.Append("');");
                 stringBuilder.Append("Microsoft_ReportingServices_HTMLRenderer_ScaleImageForFit('");
                 stringBuilder.Append(m_deviceInfo.HtmlPrefixId);
                 stringBuilder.Append("');");
             }
             bool hasFixedHeader = HasFixedHeader;
             if (m_deviceInfo.IsBrowserGeckoEngine && hasFixedHeader)
             {
                 stringBuilder.Append(m_deviceInfo.JavascriptPrefixId + "CreateFixedHeaders();");
             }
             if (m_needsCanGrowFalseScript)
             {
                 stringBuilder.Append("Microsoft_ReportingServices_HTMLRenderer_GrowTablixTextBoxes();");
             }
             if (m_needsFitVertTextScript)
             {
                 stringBuilder.Append("Microsoft_ReportingServices_HTMLRenderer_FitVertText('");
                 stringBuilder.Append(m_deviceInfo.HtmlPrefixId);
                 stringBuilder.Append("'");
                 stringBuilder.Append(",");
                 stringBuilder.Append("'");
                 stringBuilder.Append(m_deviceInfo.HtmlPrefixId);
                 stringBuilder.Append("oReportDiv");
                 stringBuilder.Append("');");
             }
             if (m_needsGrowRectangleScript)
             {
                 stringBuilder.Append("Microsoft_ReportingServices_HTMLRenderer_GrowRectangles('");
                 stringBuilder.Append(m_deviceInfo.HtmlPrefixId);
                 stringBuilder.Append("'");
                 stringBuilder.Append(",");
                 stringBuilder.Append("'");
                 stringBuilder.Append(m_deviceInfo.HtmlPrefixId);
                 stringBuilder.Append("oReportDiv");
                 stringBuilder.Append("');");
             }
             if (stringBuilder.Length > 0)
             {
                 WriteStream(string.Concat(" onload=\"", stringBuilder, "\""));
             }
             if (hasFixedHeader && !m_isMHTML && m_hasOnePage)
             {
                 WriteStream(" onscroll=\"" + m_deviceInfo.JavascriptPrefixId + "CreateFixedHeaders()\"");
                 WriteStream(" onresize=\"" + m_deviceInfo.JavascriptPrefixId + "CreateFixedHeaders()\" ");
             }
         }
         RenderBodyTagStyle();
         WriteStream(HTMLElements.m_closeBracket);
         m_mainStream.Flush();
         stream3.Seek(0L, SeekOrigin.Begin);
         Utility.CopyStream(stream3, m_mainStream);
         stream3.Close();
         stream3 = null;
         WriteStream(HTMLElements.m_closeHtml);
         m_mainStream.Flush();
     }
     else
     {
         Stream mainStream2 = m_mainStream;
         Stream stream4     = m_mainStream = new BufferedStream(m_createAndRegisterStreamCallback("BODY", "html", null, null, willSeek: true, StreamOper.CreateOnly));
         RenderHtmlBody();
         RenderFinalScript();
         stream4.Flush();
         m_mainStream = mainStream2;
         RenderHead();
         stream4.Seek(0L, SeekOrigin.Begin);
         Utility.CopyStream(stream4, m_mainStream);
         m_mainStream.Flush();
     }
 }
コード例 #2
0
        protected override bool InternalRenderStream(string streamName, Microsoft.ReportingServices.OnDemandReportRendering.Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, ref Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream)
        {
            if (streamName == null || streamName.Length <= 0)
            {
                return(false);
            }
            if (Microsoft.ReportingServices.Rendering.SPBProcessing.SPBProcessing.RenderSecondaryStream(report, createAndRegisterStream, streamName))
            {
                return(true);
            }
            char c = '_';

            char[] separator = new char[1]
            {
                c
            };
            string[] array = streamName.Split(separator);
            if (array.Length < 2)
            {
                return(false);
            }
            string text = report.Name + c + "style";

            if (streamName.StartsWith(text, StringComparison.Ordinal))
            {
                DeviceInfo deviceInfo2 = null;
                try
                {
                    deviceInfo2 = new ServerDeviceInfo();
                    deviceInfo2.ParseDeviceInfo(deviceInfo, clientCapabilities);
                }
                catch (ArgumentOutOfRangeException innerException)
                {
                    throw new ReportRenderingException(RenderRes.rrInvalidDeviceInfo, innerException);
                }
                if (streamName.Length > text.Length && deviceInfo2.Section == 0)
                {
                    int    result = 0;
                    string s      = streamName.Substring(text.Length + 1);
                    if (int.TryParse(s, out result))
                    {
                        deviceInfo2.Section = result;
                    }
                }
                if (!deviceInfo2.OnlyVisibleStyles || deviceInfo2.Section == 0)
                {
                    Stream            stream            = createAndRegisterStream(streamName, "css", Encoding.UTF8, "text/css", willSeek: false, StreamOper.CreateAndRegister);
                    HTMLStyleRenderer hTMLStyleRenderer = new HTMLStyleRenderer(report, createAndRegisterStream, deviceInfo2, null);
                    hTMLStyleRenderer.Render(stream);
                    stream.Flush();
                }
                else
                {
                    Html5ServerRenderer html5ServerRenderer = null;
                    try
                    {
                        html5ServerRenderer = CreateRenderer(report, reportServerParameters, deviceInfo2, deviceInfo, clientCapabilities, createAndRegisterStream, ref renderProperties, 0);
                        html5ServerRenderer.RenderStylesOnly(streamName);
                        html5ServerRenderer.UpdateRenderProperties(ref renderProperties);
                    }
                    catch (InvalidSectionException innerException2)
                    {
                        throw new ReportRenderingException(innerException2);
                    }
                    finally
                    {
                        html5ServerRenderer?.Dispose();
                    }
                }
                return(true);
            }
            return(false);
        }