?
Solved

push pdf's out to SSRS Report Server

Posted on 2014-03-19
7
Medium Priority
?
4,344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 37

Accepted Solution

by:
ValentinoV earned 2000 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Hi All, I am here to write a simple article to move SSRS (SQL Server Reporting Services) reports from one server to another. When I have faced the same issue to move reports those were developed by developer on development server and now need to …
A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_27475269.html?cid=1572#a37227028 (htt…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 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