Reporting Services : Web Service
来源:互联网 发布:影楼修图软件 编辑:程序博客网 时间:2024/04/29 13:30
From :http://bidwhome.itpub.net/post/20871/167844
Reporting Services 4: Web Service
图1 报表管理器Report Manager
在上一篇随笔《Reporting Services 3: 报表模型项目》中提到过“由于这种即席报表是由终端用户设计的,终端用户并不负责完成在应用程序中引用该报表的工作,这项工作应该由应用程序自动来完成,在以后的随笔中将介绍如何实现这项工作。”,这篇随笔就要解决这个问题,当然解决的方法就是通过使用Reporting Services提供的Web Service来完成的。其实,我们要做的工作很简单:创建一个Web应用程序,列举由某个用户创建的所有报表(可能存在多个不同的文件夹中),并可以通过报表的链接使用ReportViewer控件显示不同的报表。
1、在Visual Studio 2005中创建一个ASP .NET网站RSWS。
2、在Default.aspx中添加一个TreeView控件用于以目录的形式列举报表,然后添加一个ReportViewer控件用于显示报表。
3、在“解决方案资源管理器”中,为网站RSWS“添加 Web 引用”,如图2所示,在URL列表框中输入报表服务器提供的Web Service的地址http://(ServerName)/ReportServer$(InstanceName)/ReportService.asmx。
图2 添加Reporting Services的Web Service引用(点击小图看大图)
如上图所示,Reporting Services的Web Service的文档也告诉我们:Reporting Services的Web Service允许我们管理报表服务器及其服务器设置、安全、报表、订阅和数据源等的内容。
4、在Default.aspx.cs中添加如下代码:
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> 1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts;10using System.Web.UI.HtmlControls;1112public partial class _Default : System.Web.UI.Page13{1415 ReportingWS.ReportingService rs = new ReportingWS.ReportingService();1617 /**//// <summary>18 /// 为Treeview添加节点19 /// </summary>20 /// <param name="tnc">节点集合</param>21 /// <param name="nodepath">节点对象的路径</param>
22 private void AddNodes(TreeNodeCollection tnc, string nodepath)23 {24 //将节点路径中包含的对象列举出来25 ReportingWS.CatalogItem[] items = rs.ListChildren(nodepath, true);2627 for (int i = 0; i < items.Length; i++)28 {29 //限制为用户waxdolladministrator创建的对象,其中对象又限制为文件夹和报表30 if (items[i].CreatedBy.ToLower() == "waxdolladministrator")31 {32 if (items[i].Type == ReportingWS.ItemTypeEnum.Folder)33 tnc.Add(new TreeNode(items[i].Name, "folder" + items[i].Path, "folder.gif", "", ""));34 else if (items[i].Type == ReportingWS.ItemTypeEnum.Report)35 tnc.Add(new TreeNode(items[i].Name, "report" + items[i].Path, "report.gif", "", ""));36 }37 }3839 items = null;40 }4142 protected void Page_Load(object sender, EventArgs e)43 {44 //设置Web Services客户端身份验证的安全凭据45 rs.Credentials = System.Net.CredentialCache.DefaultCredentials;4647 if (!this.IsPostBack)48 this.AddNodes(this.trvReport.Nodes, "/");49 }5051 protected void trvReport_SelectedNodeChanged(object sender, EventArgs e)52 {53 if (this.trvReport.SelectedNode != null)54 {55 string strType = this.trvReport.SelectedNode.Value.Substring(0, 6);5657 if (strType == "report")58 {59 //选中的节点为报表,则在ReportViewer控件中显示该报表60 this.rvReport.Visible = true;61 //为ReportViewer显示服务器端报表进行的属性设置62 this.rvReport.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;63 this.rvReport.ServerReport.ReportServerUrl = new Uri("http://WAXDOLL/ReportServer$BIServer");64 this.rvReport.ServerReport.ReportPath = this.trvReport.SelectedNode.Value.Substring(6);65 }66 else if (strType == "folder")67 {68 //选中的节点为一个文件夹,如果该文件夹从未展开过,则为其增加节点69 this.rvReport.Visible = false;70 if (this.trvReport.SelectedNode.ChildNodes.Count == 0)71 this.AddNodes(this.trvReport.SelectedNode.ChildNodes, this.trvReport.SelectedNode.Value.Substring(6));72 }7374 }75 }76}
示例的运行结果如图3所示:
图3 示例运行结果
Demo下载
Reporting Services的Web Service提供的功能远远要比这里的示例多得多,需要在以后的学习中继续发掘。
- Reporting Services : Web Service
- Reporting Services- Web Service
- Using Reporting Services SharePoint Web Parts in SQL Server 2000 Reporting Services Service Pack 2
- run report through call reporting services web service
- Web Access Reporting Services
- Reporting Services
- Reporting Services
- Reporting Services
- Reporting services
- Reporting Service 和 SQL Server Integration Services 服务不能启动
- Reporting Service在Web Application中的应用
- Asp.Net Web Form 调用Reporting Service
- 通过程序的方式将Reporting Service 报表转成 PDF--- SQL Server Reporting Services 2005
- Using Reporting Services SharePoint Web Parts in SQL Server
- Reporting Services 中 Web服务URL 与 报表管理器URL
- Reporting Services 中 Web服务URL 与 报表管理器URL
- Reporting Service
- Reporting Service
- SQL Reporting Services 困惑的解决 直接传递参数并用ReportViewer来呈现报表
- Reporting Services : 报表模型项目
- LzmTW.uSystem.uReflection+DatasFunction
- LzmTW.uSystem.uReflection+MemberInfoFunction
- 权威解释----如何选择羽毛球?(摘自《羽毛球竞赛规则问答》北京体育大学出版社
- Reporting Services : Web Service
- java异常处理陋习
- 如何判断一个整数是否为奇数
- 《论语》读书笔记 之一
- RDLC报表(一)(报表定义语言客户端处理)
- RDLC报表(二)
- [Source Code]在程序中取得系统的环境变量
- 严重(同义词:非常的 很 无比的)纪念阿佩生日
- 《论语》读书笔记 之二