push pdf's out to SSRS Report Server

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?
cindyfillerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ValentinoVBI ConsultantCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cindyfillerAuthor Commented:
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
ValentinoVBI ConsultantCommented:
You deserve a million points for this.

That would be awesome! ;)
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

cindyfillerAuthor Commented:
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
cindyfillerAuthor Commented:
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
cindyfillerAuthor Commented:
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
cindyfillerAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSRS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.