Solved

push pdf's out to SSRS Report Server

Posted on 2014-03-19
7
4,080 Views
1 Endorsement
Last Modified: 2014-03-27
I have some pdf's that are not part of SSRS, but I would like to display them on the Report Server web site.  I was hoping I could automatically ftp them each night, but so far I haven't been able to properly connect to the report server.  I also know there is an upload button, but can't find a way to automate that either.

Does anyone know if this can be done?
1
Comment
Question by:cindyfiller
  • 5
  • 2
7 Comments
 
LVL 37

Accepted Solution

by:
ValentinoV earned 500 total points
Comment Utility
Yes, it can be done!  More precisely, you can use the RS utility (rs.exe) to automate the deployment of items to the report server.

I've created the RSS script for you here:

'The following global variables need to be passed in through the rs command:
'Dim name As String = "CatalogItem.pdf"
'Dim parent As String = "/Test"

Dim reportFile As String = "scripts\resources\" & name

	
Public Sub Main()
	Console.WriteLine("Running script DeployPDF.rss")

	Dim overwrite As Boolean = True
	Dim fileContent As Byte() = Nothing
	Dim warnings As Warning() = Nothing

	'Common CatalogItem properties
	Dim descprop As New [Property]
	descprop.Name = "Description"
	descprop.Value = ""
	Dim hiddenprop As New [Property]
	hiddenprop.Name = "Hidden"
	hiddenprop.Value = "False"

	'PDF-specific property
	Dim mimeTypeProp As New [Property]
	mimeTypeProp.Name = "MimeType"
	mimeTypeProp.Value = "application/pdf"

	Dim props(2) As [Property]
	props(0) = descprop
	props(1) = hiddenprop
	props(2) = mimeTypeProp
	

	Try
		'Read file from disk
		Dim stream As FileStream = File.OpenRead(reportFile)
		fileContent = New [Byte](stream.Length-1) {}
		stream.Read(fileContent, 0, CInt(stream.Length))
		stream.Close()

		Dim item As CatalogItem 
		item = RS.CreateCatalogItem("Resource", name, parent, overwrite, fileContent, props, warnings)

		If Not (warnings Is Nothing) Then
			Dim warning As Warning
			For Each warning In warnings
				Console.WriteLine("Warning: {0}", Warning.Message)
			Next warning
		Else
			Console.WriteLine("CatalogItem: {0} published successfully with no warnings", name)
		End If

	Catch e As IOException
		Console.WriteLine(e.Message)
	Catch e As SoapException
		Console.WriteLine("Error : " + e.Detail.Item("ErrorCode").InnerText + " (" + e.Detail.Item("Message").InnerText + ")")
	End Try
	Console.WriteLine()
End Sub

Open in new window

Save the above to a file called DeployPDF.rss

You'll need a batch file to call the script, so here it is:

@echo off


::Script Variables
SET REPORTSERVER=http://YourServer/ReportServer

::default location on 32-bit machines -> SET RS="C:\Program Files\Microsoft SQL Server\100\Tools\Binn\RS.EXE"
::default location on 64-bit machines -> SET RS="C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\RS.EXE" 
SET RS="C:\Program Files\Microsoft SQL Server\100\Tools\Binn\RS.EXE"

SET LOGFILE="SSRS_DeployLog.txt"
SET SCRIPTLOCATION=scripts
SET TIMEOUT=60
SET ENDPOINT="Mgmt2010"

::Clear Log file
IF EXIST %logfile% DEL %logfile%

ECHO Starting deployment to %REPORTSERVER%

::Write Log Header
ECHO Starting deployment at %DATE% %TIME% >>%LOGFILE%
ECHO SCRIPTLOCATION = %SCRIPTLOCATION% >>%LOGFILE%
ECHO REPORTSERVER   = %REPORTSERVER% >>%LOGFILE%
ECHO TIMEOUT        = %TIMEOUT% >>%LOGFILE%
ECHO ENDPOINT		= %ENDPOINT% >>%LOGFILE%
ECHO COMPUTERNAME	= %COMPUTERNAME% >>%LOGFILE%
ECHO RS             = %RS% >>%LOGFILE%
ECHO. >>%LOGFILE%

::Run Scripts

ECHO ...deploying catalog items...

%RS% -i "%SCRIPTLOCATION%\DeployPDF.rss" -s %REPORTSERVER% -l %TIMEOUT% -e %ENDPOINT% -v name="SomePDF.pdf" -v parent="/Test" >>%LOGFILE% 2>&1


::Finish
ECHO. >>%LOGFILE%
ECHO Finished deployment at %DATE% %TIME% >>%LOGFILE%
ECHO. >>%LOGFILE%

ECHO Deployment finished!  See %LOGFILE% for details.
PAUSE

Open in new window

Save that to a file with a .cmd extension.

Follow these guidelines to set up the folder structure as expected by the script:

1. create a folder called PDFDeploymentProject (can be something else)
2. put the .cmd in this folder
3. create a subfolder called \scripts
4. put the .rss file in \scripts
5. create a subfolder in \scripts called \resources
6. put your .pdf file in \resources

Also note that you'll need to customize the .cmd a bit.  The SET REPORTSERVER = line expects your Report Server URL.

Some additional explanation on this line:

%RS% -i "%SCRIPTLOCATION%\DeployPDF.rss" -s %REPORTSERVER% -l %TIMEOUT% -e %ENDPOINT% -v name="SomePDF.pdf" -v parent="/Test" >>%LOGFILE% 2>&1

Open in new window


The name parameter expects the name of your PDF.
The parent parameter expects the folder on the report server in which the file needs to get deployed.

You can repeat that line multiple times for different PDFs.

More info: ReportingService2010.CreateCatalogItem Method

I know it's a lot of info so if something is not clear let me know!
0
 

Author Comment

by:cindyfiller
Comment Utility
Wow - thank you for the massive response.  You deserve a million points for this.  I may not be able to try it today - but will tomorrow for sure.
0
 
LVL 37

Expert Comment

by:ValentinoV
Comment Utility
You deserve a million points for this.

That would be awesome! ;)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:cindyfiller
Comment Utility
I'm sorry for the long delay in testing this out - I had a critical project that was due.  I have followed your instructions and am getting an error.  I think I changed the specifics that need changing, but I'm not understanding this log well enough to fix it.  

Starting deployment at Thu 03/27/2014  8:55:20.14
SCRIPTLOCATION = scripts
REPORTSERVER   = http://bbre2/ReportServer
TIMEOUT        = 60
ENDPOINT            = "Mgmt2010"
COMPUTERNAME      = BBRE2
RS             = "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\RS.EXE"
 
The specified script failed to compile with the following errors:
E:\Business Intelligence\PDFDeploymentProject> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc.exe" /t:exe /main:MainModule /utf8output /R:"System.dll" /R:"System.Xml.dll" /R:"System.Web.Services.dll" /R:"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\rs.exe" /out:"C:\Documents and Settings\Administrator.UNDALUMNI\Local Settings\Temp\1\z5atsfwx.exe" /debug-  "C:\Documents and Settings\Administrator.UNDALUMNI\Local Settings\Temp\1\z5atsfwx.0.vb" "C:\Documents and Settings\Administrator.UNDALUMNI\Local Settings\Temp\1\z5atsfwx.1.vb"


Microsoft (R) Visual Basic Compiler version 8.0.50727.3053
for Microsoft (R) .NET Framework version 2.0.50727.3649
Copyright (c) Microsoft Corporation.  All rights reserved.

C:\Documents and Settings\Administrator.UNDALUMNI\Local Settings\Temp\1\z5atsfwx.1.vb(44) : error BC30451: Name 'reportFile' is not declared.

        Dim stream As FileStream = File.OpenRead(reportFile)
                                                 ~~~~~~~~~~
 
Finished deployment at Thu 03/27/2014  8:55:22.85
0
 

Author Comment

by:cindyfiller
Comment Utility
BTW, the RSS script I started at the Public Sub Main and did not include this section at the top.  That may be part of the problem.

'The following global variables need to be passed in through the rs command:
'Dim name As String = "CatalogItem.pdf"
'Dim parent As String = "/Test"

Dim reportFile As String = "scripts\resources\" & name
0
 

Author Comment

by:cindyfiller
Comment Utility
I added the dim reporfile as string and THIS NOW WORKS BEAUTIFULLY!

Thank you again for your wonderful code above.  I still wish I could give you the trillion points.
0
 

Author Closing Comment

by:cindyfiller
Comment Utility
This was by far one of the best answers I've ever received. It was above and beyond - provided me with the scripts needed to accomplish this!!!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction As you'll probably know, a data region in a SQL Server Reporting Services report can be linked to only one dataset.  This makes it troublesome when you need to display data from more than one dataset in the same data region.  SQL Serve…
Introduction In the following article I’ll be discussing and demonstrating several different ways of how images can be put on a report. I’m using SQL Server Reporting Services 2008 R2 CTP, more precisely version 10.50.1352.12, but the methods ex…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now