Solved

push pdf's out to SSRS Report Server

Posted on 2014-03-19
7
4,185 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
ID: 39941706
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
ID: 39942597
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
ID: 39942632
You deserve a million points for this.

That would be awesome! ;)
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:cindyfiller
ID: 39958935
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
ID: 39958951
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
ID: 39958986
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
ID: 39958989
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSRS 2012 URL 11 69
Please help| Getting the syntax error in below query. 2 70
Add total to a tablix with ReportItem values 15 65
Need return values from a stored procedure 8 40
Steps to solve SSRS SQL 2008 R2 User Access Control (UAC) Permission Error With the introduction of SQL Server 2008 R2 and Vista (Windows 7 as well) came new enhanced security features. One of the features included was User Access Control (UAC) t…
Introduction Earlier I wrote an article about the new lookup functions (http://www.experts-exchange.com/A_3433.html) that ship with SQL Server 2008 R2.  In this article I’m going to show you another new feature of SSRS 2008 R2, this time in the vis…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

685 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