Blog Home  Home RSS 2.0 Atom 1.0 CDF  
some thoughts... - September, 2006
IT makes the world go round - and sometimes stops it...
 
 Sunday, September 03, 2006

Brian Welcker has published a coding to programmatically set the page size properties of a linked report.

The feature doing linked reports worked well in Reporting Services 2000, because the linked report got the page settings from the original report but in RS 2005 this feature just was "forgotten", as Brian admits in this article.

The following content is intellectual property of Brian Welcker, the original posting can be found here:

I previously showed how you can programmatically set the page size properties (used by the print control) for a specific report on the server. I created an updated version of this sample that will set the page properties for all linked reports on your report server. It copies the relevant properties from the base report to the linked report. If you are using the rs.exe script host, you can delete the proxy methods at the top as they are handled automatically. This example uses the SQL 2000 RS SOAP endpoint but will work for SQL 2005 RS as well.

Dim rs As New ReportingService.ReportingService
Dim ci(), c As ReportingService.CatalogItem
Dim l As String

rs.Url = "http://localhost/reportserver/reportservice.asmx"
rs.Credentials = System.Net.CredentialCache.DefaultCredentials

ci = rs.ListChildren("/", True)

For Each c In ci
   If c.Type = ReportingService.ItemTypeEnum.LinkedReport Then
      Dim p(5) As ReportingService.Property

      p(0) = New ReportingService.Property
      p(0).Name = "PageHeight"

      p(1) = New ReportingService.Property
      p(1).Name = "PageWidth"

      p(2) = New ReportingService.Property
      p(2).Name = "TopMargin"

      p(3) = New ReportingService.Property
      p(3).Name = "BottomMargin"

      p(4) = New ReportingService.Property
      p(4).Name = "LeftMargin"

      p(5) = New ReportingService.Property
      p(5).Name = "RightMargin"

      l = rs.GetReportLink(c.Path)
      p = rs.GetProperties(l, p)
      rs.SetProperties(c.Path, p)

   End If
Next


If you would like to use the script from above with the rs Utility as a Reporting Services Script File, you will have to do some changes to the coding:

Public Sub Main()
Dim ci() as object
dim c as CatalogItem
Dim l As String

rs.Credentials = System.Net.CredentialCache.DefaultCredentials

ci = rs.ListChildren("/", True)

For Each c In ci
If c.Type = ItemTypeEnum.LinkedReport Then

    try    
        'Console.WriteLine(c.name)
    
        Dim p(5) As [Property]

        p(0) = New [Property]
        p(0).Name = "PageHeight"

        p(1) = New [Property]
        p(1).Name = "PageWidth"

        p(2) = New [Property]
        p(2).Name = "TopMargin"

        p(3) = New [Property]
        p(3).Name = "BottomMargin"

        p(4) = New [Property]
        p(4).Name = "LeftMargin"

        p(5) = New [Property]
        p(5).Name = "RightMargin"

        l = rs.GetReportLink(c.Path)
        p = rs.GetProperties(l, p)
        rs.SetProperties(c.Path, p)
    Catch e As SoapException
        Console.WriteLine("")
        Console.WriteLine("Report Error: " & c.Path & "\" & c.name)
        Console.WriteLine("")
        Console.WriteLine(e.Detail.InnerXml.ToString())
        Console.WriteLine("")
        Console.WriteLine("")
    end try
End If
Next

End Sub


MSDN also includes some more usefull informations about rs.exe, like the ones mentioned below.

This one is from "Scripting Deployment and Administrative Tasks":
"The report server script host tool (rs.exe) can run custom Visual Basic code that you might write to re-create or move existing content from one report server to another. With this approach, you write script in Visual Basic, save it as an .rss file, and use rs.exe to run the script on the target report server. The script you write can call the SOAP interface to the Report Server Web service. Deployment scripts are written using this approach because it allows you to re-create a report server folder namespace and content, and re-create role-based security.
You can also use rs.exe to run custom or generated script that you create in SQL Server Management Studio. For Reporting Services, the script generation feature in Management Studio creates Visual Basic code for a very specific task (for example, creating a role, setting report properties, defining a schedule, and so on). The generated code is incomplete; it captures keyboard strokes and mouse events. To use this code, you must copy it into a larger program that you create."

This one from "Compiling and Running Code Examples":
"Reporting Services provides a scripting utility, the rs utility, which is shipped as a file named rs.exe. You can run any Visual Basic code example that is provided in the Report Server Web service library documentation using the rs utility that is included with Reporting Services.

To run a code example

  1. Using a text editor, create a blank text file named sample with an .rss extension.

  2. Copy and paste the following code into the blank file:

    Public Sub Main()
    ' Your code goes here.
    End Sub

  3. Copy and paste the code example you want to use into the space provided in the previous code sample. Save the file. If you are copying directly from a code example provided in a reference topic, remove any import statements, module declarations and the following line of code:

    Dim rs As New ReportingService2005()

    The ReportingService2005 object is already declared and instantiated within the script environment. Redeclaring the object in your code will cause your script to fail. For more information about properly formed scripts, see Formatting the Reporting Services Script File.

  4. Open a command prompt: On the Start menu, click Run, type cmd in the text box, and then click OK.

  5. Navigate to the directory that contains your Sample.rss file. At the command prompt, type the following command to run the sample script file. Be sure to replace the given server URL with that of the report server and endpoint you are accessing. For example:

    rs –i sample.rss –s http://myserver/reportserver"

Sunday, September 03, 2006 8:02:18 PM (Mitteleuropäische Zeit, UTC+01:00)  #     Author:Markus Fischer   Comments [0]   |  |   | 
Copyright © 2010 Markus Fischer. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: