I'm new to SSRS deployment, and I've been searching around but can't quite find the exact scenario that applies to my situation. I have several reports deployed across different subfolders in SSRS 2012. For example:
- Sales/salesReport1
- Sales/salesReport2
- Finance/finReport1
- Finance/finReport2
- Misc/miscReport1
- Misc/miscReport2
Due to the fact that sometimes SSRS doesn't like an overwritten report file, I would like to delete all the report files in the instance before deploying any new reports. I can successfully remove the folders and their contents by calling this script using rs.exe:
Public Sub Main()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim bh As New BatchHeader()
bh.BatchID = rs.CreateBatch()
rs.BatchHeaderValue = bh
'Delete all reports from Main Folder and sub folders.Note:The Folders will be deleted also.
'If do not want to delete the folder, we could use rs.CreateFolder(“Folder name”, “/Main Folder”, “nothing”) to create a new one with nothing.
rs.DeleteItem("/Sales")
rs.DeleteItem("/Finance")
rs.DeleteItem("/Misc")
'Delete all reports from a sub folder, and delete the sub folder
'rs.DeleteItem("/Main Folder/Sub Folder ")
rs.BatchHeaderValue = bh
' Delete folders using batch header.
Try
rs.ExecuteBatch()
Console.WriteLine("Folders deleted successfully.")
Catch e As SoapException
Console.WriteLine(e.Detail.InnerXml.ToString())
Finally
rs.BatchHeaderValue = Nothing
End Try
End Sub 'Main
The issue lies in the fact that if any of those folders doesn't exist, the script will stop. I'm trying to determine the best way to handle this. Would the best way be to empty the folders and leave them there, or to find a way to ignore the errors and continue?
Depending on the answer, how would I invoke that in this script?