Sql server 2008 r2 实现iRenderingExtension接口时出现问题

Sql server 2008 r2 实现iRenderingExtension接口时出现问题,sql-server-2008-r2,Sql Server 2008 R2,如何实现SQL Server Reporting Services的扩展? 我需要为以下内容实现渲染扩展: 将本地化文本应用于报告 将基于当前区域性的datetime和decimal格式应用于报表 如果已为任何报告分配了任何背景图像,请使用定义的背景图像 我已尝试为SQL Server 2008 R2实现iUnderingInterface。 但在连接到报告服务时,它给了我以下信息: “Microsoft.SqlServer.ReportingServices2010.RSConnection2

如何实现SQL Server Reporting Services的扩展? 我需要为以下内容实现渲染扩展:

  • 将本地化文本应用于报告
  • 将基于当前区域性的datetime和decimal格式应用于报表
  • 如果已为任何报告分配了任何背景图像,请使用定义的背景图像
  • 我已尝试为SQL Server 2008 R2实现iUnderingInterface。 但在连接到报告服务时,它给了我以下信息:

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

    以下是继承IRenderingExtension的renderer类&实现所需的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;
    }
    
    public void GetRenderingResource(Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStreamCallback,System.Collections.Specialized.NameValueCollection deviceInfo)
    {
    //在报表中呈现任何嵌入的资源
    }
    公共无效设置配置(字符串配置)
    {
    //用于从Reporting Services配置文件传递配置
    //此报告服务扩展
    }
    公共字符串本地化名称
    {
    得到
    {
    //一个只读属性,返回
    //这是RS分机
    字符串p_strName=“自定义渲染器”;
    System.Globalization.CultureInfo p_CultureInfo=System.Globalization.CultureInfo.CurrentCulture;
    //确定要返回(显示)的文本
    //CultureInfo类的Name属性
    如果(p_CultureInfo.Name==“zh CHS”)
    {
    p_strName+=“(繁体中文)”;
    }
    else if(p_CultureInfo.Name==“zh CHT”)
    {
    p_strName+=“(简体中文)”;
    }
    else if(p_CultureInfo.Name==“en-US”)
    {
    p_strName+=“(繁体英语)”;
    }
    返回p_strName;
    }
    }
    公共图书馆(
    Microsoft.ReportingServices.OnDemandReportRendering.Report报告,
    System.Collections.Specialized.NameValueCollection reportServerParameters,
    System.Collections.Specialized.NameValueCollection设备信息,
    System.Collections.Specialized.NameValueCollection客户端功能,
    参考System.Collections.Hashtable renderProperties,
    Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream(创建和注册流)
    {
    System.IO.Stream s=createAndRegisterStream(
    报告,姓名,
    “html”,
    System.Text.Encoding.UTF8,
    “文本/html”,
    是的,
    Microsoft.ReportingServices.Interfaces.StreamOper.CreateAndRegister);
    System.IO.StreamWriter sw=新的System.IO.StreamWriter;
    西南书写线(“”);
    sw.WriteLine(“测试IRenderingExtension”);
    西南书写线(“”);
    sw.Close();
    s、 Close();
    返回false;
    }
    公共bool RenderStream(
    字符串streamName,
    Microsoft.ReportingServices.OnDemandReportRendering.Report报告,
    System.Collections.Specialized.NameValueCollection reportServerParameters,
    System.Collections.Specialized.NameValueCollection设备信息,
    System.Collections.Specialized.NameValueCollection客户端功能,
    参考System.Collections.Hashtable renderProperties,
    Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream(创建和注册流)
    {
    返回false;
    }
    
    这可能有助于


    第2点可以通过使用
    =User.Language
    来解决问题现在我正在努力本地化报告中的文本。我该怎么做?你能举个例子来实现渲染方法吗?我想实现我自己的渲染,但是来自SSRS的官方文档帮助不大。当我尝试读取/写入createAndRegisterStream的strem结果时,我总是得到错误“无法访问封闭流”。谢谢