开发自己的SQL2005报表查看SharePoint WebPart(三)

限时加码!20+主流AI编程工具免费用 购周边加赠Coding Plan Lite,Claude Code、Cursor等即刻畅享,学习进阶更高效! 阅读详情

我们在(一)里完成了web part的实现
在(二)里完成了通过调用SQL2005 reporting services的web service,查询并显示报表
现在,我们要给Web part增加属性来设置报表服务器的地址和报表路径
首先,为了能够在SharePoint中设置属性,需要增加对Microsoft.SharePoint的引用,原来我们的BARreportWebPart是从System.Web.UI.WebControls.WebParts.WebPart继承的,现在要改为从Microsoft.SharePoint.WebPartPages.WebPart继承。否则你在Sharepoint web part属性设置里面看不到你的自定义属性
然后,增加两个字符类型的属性:ReportServerURL,ReportPath。具体的attribute设置请参考
如何给Web part增加自定义属性Creating a Web Part with Custom Properties(http://msdn2.microsoft.com/en-us/library/ms948927.aspx)
这是最后的代码
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint.WebPartPages;

namespace BARreportWebPart
{
    [DefaultProperty("Text"),
     ToolboxData("<{0}:BARreportWebPart runat=server></{0}:BARreportWebPart>"),
     XmlRoot(Namespace = "BARreportWebPart")]

    public class BARreportWebPart : Microsoft.SharePoint.WebPartPages.WebPart//System.Web.UI.WebControls.WebParts.WebPart
    {
        string _reportServerURL="";// = "http://ctc-bar:81/ReportServer/ReportService.asmx";
        string _reportPath = "";// = "/BARreports/EBCdetailList";

        public BARreportWebPart()
        {

        }

        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            if (string.Empty == ReportServerURL.Trim() || null == ReportServerURL
                 || string.Empty == ReportPath.Trim() || null == ReportPath)
            {
                writer.Write("please set the ReportServerURL, ReportPath");
                return;
            }
            string reportServerURL = ReportServerURL;
            string reportPath = ReportPath;

            ReportAdapter rsAdapter = new ReportAdapter(reportServerURL, reportPath);
            ReportingServer.ReportParameter[] parameters = rsAdapter.GetParameters();
            ReportingServer.ParameterValue[] parameterValues = null;
            if (parameters.Length > 0)
            {
                parameterValues = new ReportingServer.ParameterValue[parameters.Length];
                for (int i = 0; i < parameters.Length; i++)
                {
                    parameterValues[i] = new ReportingServer.ParameterValue();
                    parameterValues[i].Name = parameters[i].Name;
                    parameterValues[i].Label = parameters[i].Prompt;
                }
                parameterValues[0].Value = "2007-1-1";
                parameterValues[1].Value = "2007-3-1";
            }
            System.Text.Encoding enc = System.Text.Encoding.UTF8;
            byte[] result = rsAdapter.RenderReport(parameterValues);
            string htmlResult = enc.GetString(result);
            //htmlResult = htmlResult.Replace(reportServerURL.Replace("/ReportService.asmx", "?"), "http://" & Request("SERVER_NAME") & Request("SCRIPT_NAME") & "?Report=");
            //writer.Write(htmlResult);
        }

        // Creates a custom property :
        // This property will be displayed as a text box in the
        // property pane.

        // Create a custom category in the property sheet.
        //[Category("Custom Properties")]
        // Assign the default value.
        [DefaultValue("http://ctc-bar:81/ReportServer/ReportService.asmx")]
        // Property is available in both Personalization
        // and Customization mode.
        [WebPartStorage(Storage.Personal)]
        // The caption that appears in the property sheet.
        [FriendlyNameAttribute("ReportServerURL")]
        // The tool tip that appears when pausing the mouse pointer over
        // the friendly name in the property pane.
        [Description("Report Server URL: (like http://ctc-bar:81/ReportServer/ReportService.asmx )")]
        // Display the property in the property pane.
        [Browsable(true)]
        [XmlElement(ElementName = "ReportServerURL")]
        // The accessor for this property.
        public string ReportServerURL
        {
            get
            {
                return _reportServerURL;
            }
            set
            {
                _reportServerURL = value;
            }
        }

        // Assign the default value.
        [DefaultValue("")]
        // Property is available in both Personalization
        // and Customization mode.
        [WebPartStorage(Storage.Personal)]
        // The caption that appears in the property sheet.
        [FriendlyNameAttribute("ReportPath")]
        // The tool tip that appears when pausing the mouse pointer over
        // the friendly name in the property pane.
        [Description("Report Path")]
        // Display the property in the property pane.
        [Browsable(true)]
        [XmlElement(ElementName = "ReportPath")]
        // The accessor for this property.
        public string ReportPath
        {
            get{
                return _reportPath;
            }
            set {
                _reportPath = value;
            }
        }

     }
}

 


 

保姆级教程:用PCAN-View监控汽车CAN总线,从硬件连接到报文分析(附快捷键大全) 本文提供了一份详细的PCAN-View使用教程,涵盖从硬件连接到报文分析的全流程,特别适合汽车电子工程师和初学者。内容包括硬件准备、软件安装、核心功能操作、高级技巧及故障排查,并附有实用的快捷键大全,帮助用户高效监控和分析CAN总线数据。 阅读详情

相关推荐

别再凭感觉选电容了!手把手教你计算电机控制器里的母线电容(附Excel计算工具)

本文详细解析了电机控制器中母线电容的选型方法,从理论计算到工程实践,帮助工程师避免常见误区。通过精确计算纹波电压、电容容量等关键参数,并结合薄膜电容与电解电容的性能对比,提供实用的选型建议。附带的Excel计算工具可快速完成参数计算,适用于工业伺服驱动和电动车电机控制器设计。

weixin_28720573的博客 449

开发自己的SQL2005报表查看SharePoint WebPart(二)

在(一)中,已经完成了一个sharepoint Web part的开发和部署。但是我们的web part还没有任何功能。现在,我们要开始将SQL reporting的报表显示功能加进来了。访问SQL reporting报表有很多方法,这里我们选用的是调用Web service的方式。在工程中增加对SQL reporting service的引用, http://ctc-bar:81/ReportS

闫炜的专栏 2235

ExpressLRS 915MHz vs 2.4GHz:实测对比与TX12遥控器的最佳搭配方案

本文深入对比了ExpressLRS 915MHz与2.4GHz两种频段在穿透能力、延迟、抗干扰等方面的实测表现,并结合RadioMaster TX12遥控器的硬件特性,提供了从微型花飞到极限远航等不同场景下的最佳搭配方案与EdgeTX系统配置指南,帮助FPV玩家根据核心飞行需求做出精准选择。

milk8的博客 422

开发自己的SQL2005报表查看SharePoint WebPart(一)

 SQL 2005自己提供的报表查看web part功能比较简单,不太适合中国人对报表界面的复杂要求。这个WebPart的主要功能是提供新的参数录入方式,如日期型改用日历来选择。第一步:建立一个新的web part新建一个的dll工程BARreportWebPart将class1.cs重命名为BARreportWebPart。增加对System.web的引用,并将类BARrep

闫炜的专栏 1974

开发自己的SQL2005报表查看SharePoint WebPart

 开发自己的SQL2005报表查看SharePoint WebPart(一)SQL 2005自己提供的报表查看web part功能比较简单,不太适合中国人对报表界面的复杂要求。这个WebPart的主要功能是提供新的参数录入方式,如日期型改用日历来选择。第一步:建立一个新的web part新建一个的dll工程BARreportWebPart将class1.cs重命名为BARrep

neptunelove的专栏 785

开发自己的SQL2005报表查看SharePoint WebPart ()

SQL 2005自己提供的报表查看web part功能比较简单,不太适合中国人对报表界面的复杂要求。这个WebPart的主要功能是提供新的参数录入方式,如日期型改用日历来选择。第一步:建立一个新的web part新建一个的dll工程BARreportWebPart将class1.cs重命名为BARreportWebPart。增加对System.web的引用,并将类BARrepo

开发问题集锦 856

SharePoint中集成SQL reporting services

 安装SQL 2005 Reporting service1 我的SQL server 2005 reporting services和Sahrepoint Portal Server安装在同一台服务器时。在启动reporting services的过程中经历了很多周折。先用reporting service configuration manager设置reporting servi

闫炜的专栏 2209

SharePoint WebPart开发实战(一):定制属性及配置界面

        最近一段时间都在研究SharePoint下的开发,感觉SharePoint中的内容还是比较繁杂的,不知道自己入了门没有?顺手记录下了开发过程中的一些心得和体会,以加深自己的理解和掌握,如有不对的地方,还请各位不吝指正。今天先讲讲SharePoint下Web Part的开发,这应该算是SharePoint下最常见的开发了吧,今天的重点是关于自定义属性及配置界面的实现。一、开发环境

程序人生 7072

SharePoint 集成SqlServer2005报表

1、制作报表的过程很简单,在VS2005中创建项目,选择报表服务(安装SqlServer2005后才有这个项目)2、安装SQL 2005的web part,文件地址为C:/Program Files/Microsoft SQL Server/90/Tools/Reporting Services/SharePoint下面,可以找到安装文件RSWebParts.cab。使用命令行安装web part

Li Minghua的专栏 900

开发自己的SQL2005报表查看SharePoint WebPart(四)

  这一节,我们给Web part增加报表查询参数。为了演示,这里只增加两个查询参数:开始时间和结束时间。这两个参数都是日期型的数据,为了方便用户操作,我使用了client端的日历脚本来实现日期输入。与上一节相比,我们需要增加两部分工作第一步:构造日期输入控件我的页面布局大概是这样的:

闫炜的专栏 1616

Sharepoint网站中使用SqlServer的ReportService报表简介

一,准备ReportService报表 1建立含查询参数的存储过程 2.打开你的报表管理器,假设你的Report Service发布在soungcha:8085上,则在IE中输入http://soungcha:8085/reports,会看到报表管理器界面, 新建一个文件夹,如wfreport,用于存放报表,可以此时设置它的权限,例如让internet\zhangsan拥有brows...

digang3207的博客 273

Sharepoint网站中使用SqlServer的ReportService报表简介在Sharepoint网站中使用SqlServer的ReportService报表简介

<br />一,准备ReportService报表<br />1建立含查询参数的存储过程<br />2.打开你的报表管理器,假设你的Report Service发布在soungcha:8085上,则在IE中输入http://soungcha:8085/reports ,会看到报表管理器界面, 新建一个文件夹,如wfreport,用于存放报表,可以此时设置它的权限,例如让internet/zhangsan拥有browser权限<br />3.打开VS2005,新建报表项目,<br /> a.新建共享数据源

狂野之城 1253

What you need to do to using the SharePoint add-in for SQL2005

What you need to do to using the SharePoint add-in for SQL2005: Install ref 1 Install SQL 2005 and reporting service, then patch the sp2 for SQL 2005. Install WSS 3.0 or MOSS 200...

AAA2225596的博客 192

SharePoint 2007图文开发教程【图片更新中】

SharePoint 2007图文开发教程(1)---简介,安装,配置及创建Web应用程序 简介    Microsoft Office SharePoint Server 2007 是一个服务器功能集成套件,它提供全面的内容管理和企业搜索、加速共享业务流程并便利跨界限信息共享以更好地了解业务,从而有助于提高组织的工作效率。 Office SharePoint Server 2007

follow excellence 1730

关于SharePoint部署Webpart的十个必读链接(downmoon)

关于SharePoint部署Webpart的十个必读链接(downmoon) ,一家之言, 呵呵!1、如何编写用于 SharePoint Portal Server 2003 的备份和恢复应用程序http://www.microsoft.com/china/MSDN/library/Office/sharepoint/SharePointBackupRestore.mspx2、面向开发人员的

邀月周记 3349

webpart中访问SQL 2005 Express数据库问题的处理办法

我的WEBPart代码如下:1、WebCustomControl1.cs文件:using System;using System.Collections.Generic;using System.ComponentModel;using System.Text;using System.Web;using System.Web.UI;using System.Web.UI.WebCon

eNet 2710

SharePoint中调试WebPart,用VS2008

在MOSS 2007中调试WebPart是件很容易的事件,具体步骤如下:        1、设置WebPart项目生成输出路径        将要调试的WebPart项目生成输出路径设置为该WebPart将要部署到的调试站点bin目录,通过项目“属性->生成->输出->输出路径”进行设置即可,如下图所示:                 2、附加WSS进程        附加w3wp.exe进程。

yqandxyz的专栏 1856

如何在Sharepoint调试webpart

在MOSS 2007中调试WebPart是件很容易的事件,具体步骤如下: 1、设置WebPart项目生成输出路径 将要调试的WebPart项目生成输出路径设置为该WebPart将要部署到的调试站点bin目录,通过项目“属性->生成->输出->输出路径”进行设置即可,如下图所示: 2、附加WSS进程 附加w3wp.exe进程。在附加进程窗口中,名称为w3wp.exe的进程可能有2...

weixin_34238642的博客 151
上一篇: 开发自己的SQL2005报表查看SharePoint WebPart(二)
下一篇: 在ASP.NET中访问SQL 2005报表服务 (二)
yanwei100
博客等级 码龄24年 9粉丝 71原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值