如何利用RS.exe部署Reporting Services
2005-06-21 15:12
169 查看
一、 [/b]Rs.exe[/b]介绍[/b]
[/b]rs 实用工具是一个脚本宿主,可用来处理您在输入文件中提供的脚本。您可以通过定义脚本来管理报表服务器,将报表服务器数据库内容复制到其他数据库,以及发布报表等。必须采用 Microsoft Visual Basic® .NET 代码来编写脚本,并使用 .rss 文件扩展名将其存储为 Unicode 文本文件或 UTF-8 文本文件。
Rs命令说明:
RS -i inputfile -s serverURL [-u username] [-p password] [-l timeout] [-b] [-v var=value] [-t]
[/b] -i inputfile 要执行的脚本文件
-s serverURL 执行脚本所依据的URL <包括服务器和vroot>
-u username 用于登录到服务器中的用户名
-p password 用于登录到服务器中的用户名
-l timeout 连接到服务器之前超时的秒数。默认值为60秒,0表示无限长的超时
-b 作为批进行运行,且如果命令失败则回滚。
-v var=value 传递给脚本的变量和指
-t trace 在出错消息中包含跟踪信息。
二、 [/b]Rs[/b]脚本实例[/b]
[/b]Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing
Dim parentPath As String = "/" + parentFolder // parentFolder 由命令行输入的
Dim filePath As String = "C:/Inetpub/wwwroot/Setup/ReportSystem/" //.rss文件所存放的路径
Public Sub Main()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim name As String
'创建父文件夹
Try
rs.CreateFolder(parentFolder, "/", Nothing)
Console.WriteLine("Parent folder created: {0}", parentFolder)
Catch e As Exception
Console.WriteLine(e.Message)
End Try
'创建数据源
CreateSampleDataSource()
'报表的发布
PublishReport("AcademeBonus")
PublishReport("AcademeProject") //要发布的报表名称(如果有多个可以继续添加)
End Sub
'创建数据源
Public Sub CreateSampleDataSource()
Dim name As String = "ChdSrInforSys" //数据源名称
Dim parent As String = "/" + parentFolder
'Define the data source definition.
Dim definition As New DataSourceDefinition()
definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated
//数据库连接字符串
definition.ConnectString = "data source=(local);initial catalog=ChdSrInforSys;uid=sa;" 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 = False
Try
rs.CreateDataSource(name, parent, False, definition, Nothing) //调用rs内部命令
Catch e As Exception
Console.WriteLine(e.Message)
End Try
End Sub
‘报表的发布
Public Sub PublishReport(ByVal reportName As String)
Try
Dim stream As FileStream = File.OpenRead(filePath + reportName + ".rdl")
definition = New [Byte](stream.Length) {}
stream.Read(definition, 0, CInt(stream.Length))
stream.Close()
Catch e As IOException
Console.WriteLine(e.Message)
End Try
Try
warnings = rs.CreateReport(reportName, parentPath, False, definition, Nothing)
If Not (warnings Is Nothing) Then
Dim warning As Warning
For Each warning In warnings
Console.WriteLine(warning.Message)
Next warning
Else
Console.WriteLine("Report: {0} published successfully with no warnings", reportName)
End If
Catch e As Exception
Console.WriteLine(e.Message)
End Try
End Sub
[/b]rs 实用工具是一个脚本宿主,可用来处理您在输入文件中提供的脚本。您可以通过定义脚本来管理报表服务器,将报表服务器数据库内容复制到其他数据库,以及发布报表等。必须采用 Microsoft Visual Basic® .NET 代码来编写脚本,并使用 .rss 文件扩展名将其存储为 Unicode 文本文件或 UTF-8 文本文件。
Rs命令说明:
RS -i inputfile -s serverURL [-u username] [-p password] [-l timeout] [-b] [-v var=value] [-t]
[/b] -i inputfile 要执行的脚本文件
-s serverURL 执行脚本所依据的URL <包括服务器和vroot>
-u username 用于登录到服务器中的用户名
-p password 用于登录到服务器中的用户名
-l timeout 连接到服务器之前超时的秒数。默认值为60秒,0表示无限长的超时
-b 作为批进行运行,且如果命令失败则回滚。
-v var=value 传递给脚本的变量和指
-t trace 在出错消息中包含跟踪信息。
二、 [/b]Rs[/b]脚本实例[/b]
[/b]Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing
Dim parentPath As String = "/" + parentFolder // parentFolder 由命令行输入的
Dim filePath As String = "C:/Inetpub/wwwroot/Setup/ReportSystem/" //.rss文件所存放的路径
Public Sub Main()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim name As String
'创建父文件夹
Try
rs.CreateFolder(parentFolder, "/", Nothing)
Console.WriteLine("Parent folder created: {0}", parentFolder)
Catch e As Exception
Console.WriteLine(e.Message)
End Try
'创建数据源
CreateSampleDataSource()
'报表的发布
PublishReport("AcademeBonus")
PublishReport("AcademeProject") //要发布的报表名称(如果有多个可以继续添加)
End Sub
'创建数据源
Public Sub CreateSampleDataSource()
Dim name As String = "ChdSrInforSys" //数据源名称
Dim parent As String = "/" + parentFolder
'Define the data source definition.
Dim definition As New DataSourceDefinition()
definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated
//数据库连接字符串
definition.ConnectString = "data source=(local);initial catalog=ChdSrInforSys;uid=sa;" 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 = False
Try
rs.CreateDataSource(name, parent, False, definition, Nothing) //调用rs内部命令
Catch e As Exception
Console.WriteLine(e.Message)
End Try
End Sub
‘报表的发布
Public Sub PublishReport(ByVal reportName As String)
Try
Dim stream As FileStream = File.OpenRead(filePath + reportName + ".rdl")
definition = New [Byte](stream.Length) {}
stream.Read(definition, 0, CInt(stream.Length))
stream.Close()
Catch e As IOException
Console.WriteLine(e.Message)
End Try
Try
warnings = rs.CreateReport(reportName, parentPath, False, definition, Nothing)
If Not (warnings Is Nothing) Then
Dim warning As Warning
For Each warning In warnings
Console.WriteLine(warning.Message)
Next warning
Else
Console.WriteLine("Report: {0} published successfully with no warnings", reportName)
End If
Catch e As Exception
Console.WriteLine(e.Message)
End Try
End Sub
相关文章推荐
- 二十、MDT 2013 Update 1批量部署-如何利用WSUS补丁服务器安装补丁
- 如何利用MFC编写的.exe调用C#编写的dll动态库
- 不使用GACUtil.exe,如何部署和卸载程序集到GAC中
- vista如何利用“shutdown.exe”设置自动关机命令
- 如何利用VS2010安装和部署应用程序
- 不使用GACUtil.exe,如何部署和卸载程序集到GAC中
- 小胖说事21------如何利用开发者账号重签ipa文件,并部署到IOS设备做测试(ipa重新签名)
- 如何利用xml文件部署jsp项目
- 如何利用VS2010安装和部署应用程序
- Tomcat 7下如何利用 catalina.properties 部署公用类
- Python 3.6如何快速的利用Pyinstaller把.py文件打包成.exe的应用程序
- 如何利用VS2010安装和部署应用程序
- 如何利用开发者账号重签ipa文件,并部署到IOS设备做测试
- 利用winrar制作exe程序,如何配置解压后自动运行
- 如何利用Oracle VM Templates 在几分钟内部署Oracle Real Application Clusters (RAC)
- 在开测试环境下,如何利用makecert.exe命令创建各种certificate
- 如何利用kickstart实现Linux快速部署(kickstart启动过程演示)
- Tomcat 7下如何利用 catalina.properties 部署公用类
- 如何利用Helm在Kubernetes上快速部署Cloud Foundry?
- 教你如何利用php.exe运行php文件