我是 SSRS 部署的新手,我一直在四处寻找,但找不到适用于我情况的确切场景。我在 SSRS 2012 的不同子文件夹中部署了多个报告。例如:
- 销售/销售报告1
- 销售/销售报告2
- 财务/finReport1
- 财务/finReport2
- 杂项/杂项报告1
- 杂项/杂项报告2
由于有时 SSRS 不喜欢被覆盖的报告文件,我想在部署任何新报告之前删除实例中的所有报告文件。我可以通过使用 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
问题在于,如果这些文件夹中的任何一个不存在,脚本就会停止。我正在尝试确定处理此问题的最佳方法。最好的方法是清空文件夹并将它们留在那里,还是找到一种方法来忽略错误并继续?
根据答案,我将如何在此脚本中调用它?