CHAPTER 8 DEPLOYING REPORTS
Public Sub CreateFolder(ByVal folderName as String, ByVal ParentFolder as String)
Dim extraName As String
Dim newFolder As String
if( folderName.IndexOf("/") <> -1 )
newFolder = folderName.Substring(0, folderName.IndexOf("/"))
extraName = folderName.Substring(folderName.IndexOf("/")+1)
else
newFolder = folderName
extraName = ""
end if
Dim props(0) As [Property]
Dim folderProp As new [Property]()
folderProp.Name = "Folder Name"
folderProp.Value = newFolder
props(0) = folderProp
rs.CreateFolder(newFolder, parentFolder, props)
Console.WriteLine("Folder " + newFolder + " created")
if( extraName <> "" and parentFolder = "/")
CreateFolder(extraName, parentFolder + newFolder)
else if(extraName <> "")
CreateFolder(extraName, parentFolder + "/" + newFolder)
end if
End Sub
Note You can deploy a set of data sources and reports to multiple SSRS servers easily with the rs.exe utility. To
mirror deployment with the same RSS script file, simply rerun the RS command with a different server parameter.
Creating a batch file that calls rs.exe multiple times with different server destinations is an easy way to deploy
projects exactly the same way to several locations.
The only function that gets called more than once is our user defined CreateFolder method. This is a
recursive function that will parse the name of the folder you want to create and build it piece by piece. In
order to cut down on space, there is no error checking here. So, if you run this example more than once,
you will need to clean up the folders that this creates or it will throw an exception due to the fact that the
folder already exists.
From a command prompt, move to the directory where the RDL and RSS file are being stored. Type
the following command in the command prompt, and press Enter to run it. Change the report server
URL to reflect your report server.
rs -i PublishReports.rss -s http://localhost/reportserver
You can see the command and the results in Figure 8-11.