惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CERT Recently Published Vulnerability Notes
D
Docker
GbyAI
GbyAI
博客园 - 三生石上(FineUI控件)
博客园_首页
H
Help Net Security
T
The Exploit Database - CXSecurity.com
Microsoft Security Blog
Microsoft Security Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Privacy & Cybersecurity Law Blog
AWS News Blog
AWS News Blog
Spread Privacy
Spread Privacy
F
Full Disclosure
Blog — PlanetScale
Blog — PlanetScale
Y
Y Combinator Blog
V
Vulnerabilities – Threatpost
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
aimingoo的专栏
aimingoo的专栏
Simon Willison's Weblog
Simon Willison's Weblog
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
S
Security Affairs
T
Tailwind CSS Blog
T
Tor Project blog
W
WeLiveSecurity
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
The Hacker News
The Hacker News
腾讯CDC
M
MIT News - Artificial intelligence
D
DataBreaches.Net
量子位
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
博客园 - 【当耐特】
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
I
InfoQ
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
美团技术团队
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
L
LangChain Blog
A
About on SuperTechFans

博客园 - 小小小程序员

转载 gridview在绑定显示的各种格式 - 小小小程序员 - 博客园 转 ASP.NET 2.0中OWC生成柱状图和饼状图的源代码 - 小小小程序员 同一个ASP站点UTF-8和GB2312的两个子站点乱码的解决方法 转 ASP.NET 页面事件执行顺序 转 用 Javascript 验证表单(form)中的单选(radio)值 转 .net里如何判断中文字符长度 转CSDN Sybase PowerDesigner专区 转 ASP.net中的Server.UrlEncode函数和ASP中的Server.URLEncode函数返回的值竟然不一样!!!! DIV实现下拉菜单 转 .NET 2.0 SqlDependency快速上手指南 使用XMLHTTP 获取服务器数据,实现无刷新效果 转 SQL Server 2005中设置Reporting Services发布web报表的匿名访问 div 属性 OBJECTPROPERTY函数使用 转 数字金额大小写转换之存储过程 转 PowerDesigner教程系列 [转载]ASP.NET 格式化字符串 转 VS.NE类、变量、文件命名规范 转 MVC在Web系统中的模式与应用
转 SqlServer 2005 报表批量自动部署
小小小程序员 · 2007-09-07 · via 博客园 - 小小小程序员

当我们需要把设计好的报表发布到Web服务器上时,如果用VS2005只需要 右击报表工程,单击Deploy就可轻松搞定,如果不用VS2005发布,该怎么办?

解决办法有2种。
1.引用 sqlserver2005 的web服务。根据他提供的方法发布报表
2.用sqlserver2005 的rs.exe 命名发布。

我这里介绍的是根据 rs.exe这个命令来自动发布报表的。脚本已经写好,直接Copy 稍微的改动一下即可!

1.现看看rs.exe参数 都代表什么

RUN --CMD
C:\Documents and Settings\junmy>rs /?
Microsoft (R) Reporting Services RS
版本 
9.00.1399.00 x86
根据指定的报表服务器执行脚本文件内容。
RS -i 输入文件 -s serverURL 
[-u 用户名] [-p 密码]
   
[-l 超时] [-b] [-e 端点] [-v var=value] [-t]

        -i  输入文件    要执行的脚本文件
        -s  serverURL   执行脚本
                        所依据的 URL (包括服务器和 vroot)。
        -u  用户名      用于登录到服务器中的用户名。
        -p  密码        用于登录到服务器中的密码。
        -e  端点        要与脚本一起使用的 Web 服务端点。
                        选项为:
                        Exec2005 - ReportExecution2005 端点
                        Mgmt2005 - ReportService2005 端点
                        Mgmt2000 - (不推荐使用) ReportService 端点
        -l  超时        连接到服务器之前
                        超时的秒数。默认值为 

60 秒,0 表示
                        无限长的超时。
        -b              作为批进行运行,且如果命令失败则回滚
        -v  var
=value   传递给脚本的变量和值
        -t  跟踪        在错误消息中包含跟踪信息

C:\Documents and Settings\junmy>

 

2.拷贝下面脚本保存deployReport.rss 相应路径根据自己的情况改动.

Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing
'目录名
Dim datasourceFolderName As String = "Data Sources"
Dim datasourceFolderPath As String = "/" + datasourceFolderName
'报表目录名  所有发布的报表放在此目录
Dim reportsFolderName As String = "testDeployReports"
Dim reportsFolderPath As String = "/" + reportsFolderName
'设计好的报表 存放的路径
Dim filePath As String = "D:\Project\Reports\"
'链接字符串
Dim connectionString As String = "Data Source=localhost;Initial Catalog=DataBaseName;Connect Timeout=120"Public Sub Main()
    rs.Credentials 
= System.Net.CredentialCache.DefaultCredentials
    
'创建报表目录
    CreateReportFolder(reportsFolderName)
    
'创建DataSource 目录
    CreateReportFolder(datasourceFolderName)
    
'创建数据源
    CreateDataSource(datasourceFolderPath)
   
    
'部署报表
    DeployRepors(filePath)
End Sub'创建目录
Public Sub CreateReportFolder(ByVal reportFolder As String)Try
        
'Create Reports Folder
        rs.CreateFolder(reportFolder,"/",Nothing)
       
        Console.WriteLine(
"Parent Folder Created:{0}",reportFolder)
    
Catch e As Exception
        Console.WriteLine(e.Message)
    
End TryEnd Sub'部署报表
Public Sub DeployRepors(ByVal filePath As String)Dim tempFileAry As String()
    
Dim reportFilePath as String
    tempFileAry 
= Directory.GetFiles(filepath)
    
For Each reportFilePath In tempFileAry
        
Dim fileName As String
        fileName 
= reportFilePath.Substring(reportFilePath.LastIndexOf("\"+ 1)
        
Dim fileSuffix As String
        fileSuffix 
= fileName.Substring(fileName.LastIndexOf("."+ 1)
        
Select Case fileSuffix
            
Case "rdl","png"
                PublishReport(fileName,fileSuffix)
        
End Select
    
NextEnd Sub
'******************************************************************
'
*****           创建数据源                           **************
'
*******************************************************************
Public Sub CreateDataSource(ByVal sourceFolder As String)Dim name As String = "DetechtionCompany"
   
'Define the data source definition.
    Dim definition As New DataSourceDefinition()
    
Dim dSource As New DataSource()
   
    dsource.Item
=definition
   
    definition.CredentialRetrieval 
= CredentialRetrievalEnum.Integrated
    definition.ConnectString 
=connectionString
    definition.Enabled 
= True
    definition.EnabledSpecified 
= True
    definition.Extension 
= "SQL"
    definition.ImpersonateUser 
= False
    definition.ImpersonateUserSpecified 
= True
    
'Use the default prompt string.
    definition.Prompt = Nothing
    definition.WindowsCredentials 
= true
   
    dsource.Name
=datasourceFolderPathTry
       
        rs.CreateDataSource(name, sourceFolder, 
true, definition, Nothing)
            Console.WriteLine(
"Created DataSource:{0}",name)
    
Catch e As Exception
        Console.WriteLine(e.Message)
    
End TryEnd Sub'******************************************************
'
******* 发布报表 *********
'
*******************************************************

Public Sub PublishReport(ByVal reportName As String,ByVal fileSuffix As String)
     
    
TryDim stream As FileStream = File.OpenRead(filePath + reportName)
        definition
= New [Byte](stream.Length) {}
        stream.Read(definition, 
0CInt(stream.Length))
        stream.Close()
    
Catch e As IOException
        Console.WriteLine(e.Message)
    
End TryTry
      
'**********************   parentPath
      If(fileSuffix="rdl"Then
        warnings 
= rs.CreateReport(reportName,reportsFolderPath, true, definition, Nothing)
         SetReportDataSourceRef(reportName)
        
        
Else If(fileSuffix="png"Then
                rs.CreateResource(reportName,reportsFolderPath,
true,definition,"png",Nothing
      
End If
        
If Not (warnings Is NothingThen
            
Dim warning As Warning
            
For Each warning In warnings
                Console.WriteLine(warning.Message)
            
Next warningElse
            Console.WriteLine(
"Report: {0} published successfully with no warnings", reportName)
        
End IfCatch e As Exception
        Console.WriteLine(e.Message)
    
End Try
End Sub'************************************************************************
'
************* 设置报表数据源      **************************************
'
************************************************************************
Public Sub SetReportDataSourceRef(ByVal reportName As String)
Try
      
Dim reference As DataSourceReference = New DataSourceReference
      
Dim ds As DataSource = New DataSource
      reference.Reference
=datasourceFolderPath+"/DetechtionCompany"
       
Dim dsArray As DataSource()=rs.GetItemDataSources(reportsFolderPath+"/"+reportName)
      
      ds
=dsArray(0)
       ds.Item 
= CType(reference, DataSourceReference)
      rs.SetItemDataSources(reportsFolderPath
+"/"+reportName,dsArray)
     
Catch _exception As Exception
     Console.WriteLine(_exception)
 
End Try
End Sub

3. 新建deploy.dat 批处理文件 运行上面脚本。用到刚刚说的 rs.exe命名 (相应参数上面已经给出)
deploy.bat 内容

rs -i deploy.rss -s http://192.168.0.88/ReportServer -u userName -p password

 双击运行deploy.bat 报表将自动发布到http://192.168.0.88/ReportServer 服务器上。。
有一个小问题,每次部署后数据源都无法获取用户名和密码。不知道各位有方法没有