Pro SQL Server 2012 Reporting Services

(sharon) #1
CHAPTER 8  DEPLOYING REPORTS

Allowing Users to Enter a Server Name


When a user types in a server name on the form, the code needs to build the URL that fully identifies the
SSRS 2012 server to deploy the RDL file to.
First, you will create a class-level variable to hold the reference to the report server, much as you did
in the SSRS viewers in Chapter 5. You do this by adding the variable definition private
ReportingService2010 rs; to the class, as is shown in Listing 8-4.


Listing 8-4. Class-level Variable in Context


public partial class Publisher : Form {
private ReportingService2010 rs;
public Publisher()


To build the URL that identifies the server based on the user input, you first instantiate the Report
Server Web service and then set the URL property to reflect the name of the server that the user entered
into the reportServer textbox. We will want to form this URL for the user, so they only need to enter the
server name to connect.
To do this, first create a short function to check the server name that the user enters and then
append the rest of the path name to the Reporting Services Web service to make up the complete URL
necessary to reference the Reporting Services Web service on the desired server. By constructing the
URL based on the user’s input, you can use the report deployment application to deploy the reports on
any SSRS 2012 server where the user has permission to do so. Start by adding the code shown in Listing
8-5 into the Publisher class.


Listing 8-5. Get Report Server URL


private string GetRSURL() {
if (reportServer.Text.StartsWith("Error! Hyperlink reference not valid."))
return reportServer.Text + "/reportserver/ReportService2010.asmx";
else
return "Error! Hyperlink reference not valid." + reportServer.Text +
"/reportserver/ReportService2010.asmx";
}


Populating the TreeView Control With a List of Folders


Now you’ll use the Reporting Services Web service to retrieve a list of objects from the server and use
them to populate the ssrsFolders TreeView control. We’ll do this by placing a call to the ListChildren
method of the Report Server Web service. The ListChildren method takes two parameters:



  • Item: The full path name of the parent folder.

  • Recursive: A Boolean expression that indicates whether to return the entire tree of
    child items below the specified item. The default value is false.

Free download pdf