实现IRenderingExtesion接口的问题

时间:2011-03-05 04:51:08

标签: sql-server-2008-r2

如何为SQL Server Reporting Services实施EXTENSIONS? 我需要为以下事情实现渲染扩展:

  1. 将本地化文本应用于报告。
  2. 根据当前文化将日期时间和小数格式应用于报告。
  3. 如果已分配任何报告,则使用已定义的背景图像。
  4. 我尝试为SQL Server 2008 R2实现IRenderingInterface。 但它在连接到报告服务时让我关注:

    “Microsoft.SqlServer.ReportingServices2010.RSConnection2010 + MissingEndpointException:尝试连接到报表服务器失败。请检查您的连接信息,并且报表服务器是兼容版本.---> System.InvalidOperationException:客户端找到响应内容类型'',但预期'text / xml'。“

    以下是继承IRenderingExtension& amp;的渲染器类。实现所需的Render和RenderStream方法以及LocalizedName属性:

    public void GetRenderingResource(Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStreamCallback, System.Collections.Specialized.NameValueCollection deviceInfo)
    {
      //Render any Embedded Resource in the Report
    }
    
    public void SetConfiguration(string configuration)
    {
      //Used to pass configuration from Reporting Services Config File
      //to this Reporting Serivces Extension
    }
    
    public string LocalizedName
    {
      get
      {
        //A Read only properties which return the name of
        //this RS extension
        string p_strName = "Custom Renderer";
    
        System.Globalization.CultureInfo p_CultureInfo = System.Globalization.CultureInfo.CurrentCulture;
    
        //Determine the text to be returned (displayed) by
        // the Name property of CultureInfo class
        if (p_CultureInfo.Name == "zh-CHS")
        {
          p_strName += " (Traditional Chinese)";
        }
        else if (p_CultureInfo.Name == "zh-CHT")
        {
          p_strName += " (Simplified Chinese)";
        }
        else if (p_CultureInfo.Name == "en-US")
        {
          p_strName += "(Traditional English)";
        }
        return p_strName;
      }
    }
    
    public bool Render(
        Microsoft.ReportingServices.OnDemandReportRendering.Report report,
        System.Collections.Specialized.NameValueCollection reportServerParameters,
        System.Collections.Specialized.NameValueCollection deviceInfo,
        System.Collections.Specialized.NameValueCollection clientCapabilities,
        ref System.Collections.Hashtable renderProperties,
        Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStream)
    {
      System.IO.Stream s = createAndRegisterStream(
          report.Name,
          "html",
          System.Text.Encoding.UTF8,
          "text/html",
          true,
          Microsoft.ReportingServices.Interfaces.StreamOper.CreateAndRegister);
      System.IO.StreamWriter sw = new System.IO.StreamWriter(s);
    
      sw.WriteLine("<html><body>");
      sw.WriteLine("Testing IRenderingExtension.");
      sw.WriteLine("</body></html>");
      sw.Close();
      s.Close();
      return false;
    }
    
    public bool RenderStream(
        string streamName,
        Microsoft.ReportingServices.OnDemandReportRendering.Report report,
        System.Collections.Specialized.NameValueCollection reportServerParameters,
        System.Collections.Specialized.NameValueCollection deviceInfo,
        System.Collections.Specialized.NameValueCollection clientCapabilities,
        ref System.Collections.Hashtable renderProperties,
        Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStream)
    {
      return false;
    }
    

1 个答案:

答案 0 :(得分:0)

这可能会有所帮助......

使用Report Language field

中的=User.Language可以涵盖第2点