Reporting Services系列五:WebService接口

ReportingServices提供WebService接口,基本上所有报表的操作都可以利用它们完成,以下在代码演示如何使用它们进行报表的导出、报表的订阅等。其中报表订阅中的邮件订阅未经过实际测试,其它代码都经过测试,没有发现什么问题。当然方法只是给出个原理,没有什么真正实用价值,有兴趣的人可以根据自己的需求对接口进行包装。

在动手写代码之前,你要添加对此WebService的引用,如图:

//

代码如下:

 

测试代码:


        
private void btExp_Click(object sender, System.EventArgs e)
        
{
            RsWebServiceHelper h
=new RsWebServiceHelper();
            
string[][] pv=new string[4][];
            pv[
0]=new string[2]{"start_time","2007-02-01"};
            pv[
1]=new string[2]{"end_time","2007-03-01"};
            pv[
2]=new string[2]{"note","20"};
            pv[
3]=new string[2]{"RsName","Alarm"};
            
bool rt=h.ExportReport("/pReports/AlarmLevel",pv,"Excel",@"e:\myhuang\rs.xls");
            
if(rt)
            
{
                Response.Write(
"<script language=javascript>window.alert('ok');</script>");
            }

            
else
            
{
                Response.Write(
"<script language=javascript>window.alert('failed');</script>");
            }

        }


        
private void btSubs_Click(object sender, System.EventArgs e)
        
{
            
string[][] pv=new string[4][];
            pv[
0]=new string[2]{"start_time","2007-02-01"};
            pv[
1]=new string[2]{"end_time","2007-03-01"};
            pv[
2]=new string[2]{"note","20"};
            pv[
3]=new string[2]{"RsName","Alarm"};

            RsWebServiceHelper h
=new RsWebServiceHelper();
            
string rtout;
            
bool rt=h.SubscriptionFileShare("/pReports/AlarmLevel",pv,DateTime.Now.AddMinutes(1),"subsnew",@"e:\myhuang\RsShareFolder","EXCEL","myhuang","123",out rtout);
            
if(rt)
            
{
                Response.Write(
"<script language=javascript>window.alert('succeed:"+rtout+"');</script>");
            }

            
else
            
{
                Response.Write(
"<script language=javascript>window.alert('error:"+rtout+"');</script>");
            }

        }

 

posted @ 2007-08-01 22:03  后厂村思维导图馆  阅读(1561)  评论(3编辑  收藏  举报