首页 > 解决方案 > 如何通过 .bat 或 .rss 在 SSRS 中创建新文件夹?

问题描述

我有一个脚本,可以将许多 .RDL 文件上传到 SSRS 报告服务器。但是,它不考虑它要进入的文件夹是否丢失。我正在尝试安排它来创建该文件夹,但旧的 vbscript CreateObject 选项不起作用,并且基于报表数据库目录表具有的字段,我认为使用它不是一个选项。

我当前的 .rss,由批处理脚本通过 RS.exe 调用:

Public Sub Main()
    
  Dim region As String = REGION
  Dim fLoc As String = FILELOCATION
  Dim folder As String = PARENTFOLDER
  Dim name As String = RDLNAME
  Dim data As String = DATASOURCE
 

  
  
  Dim parent As String = "/" + folder
  Dim location As String = fLoc + "\" + name + ".rdl"

  Dim overwrite As Boolean = True
  Dim reportContents As Byte() = Nothing
  Dim warnings As Warning() = Nothing

  Dim fullpath As String = parent + "/" + name

  'Common CatalogItem properties
  Dim descprop As New [Property]
  descprop.Name = "Description"
  descprop.Value = ""
  Dim hiddenprop As New [Property]
  hiddenprop.Name = "Hidden"
  hiddenprop.Value = "False"

  Dim props(1) As [Property]
  props(0) = descprop
  props(1) = hiddenprop

  'Read RDL definition from disk
  Try
       Dim stream As FileStream = File.OpenRead(location)
       reportContents = New [Byte](stream.Length-1) {}
       stream.Read(reportContents, 0, CInt(stream.Length))
       stream.Close()

       warnings = RS.CreateReport(name, parent, overwrite, reportContents, props)

       If Not (warnings Is Nothing) Then
           Dim warning As Warning
           For Each warning In warnings
               Console.WriteLine(Warning.Message)
           Next warning
       Else
           Console.WriteLine("Report: {0} published successfully with no warnings", name)
       End If

       'Set report DataSource references
       'Dim dataSources(0) As DataSource
       'Dim dsr0 As New DataSourceReference
       'dsr0.Reference = region + "/MyDataSource"
       'Dim ds0 As New DataSource
       'ds0.Item = CType(dsr0, DataSourceDefinitionOrReference)
       'ds0.Name = data
       'dataSources(0) = ds0

       'RS.SetItemDataSources(fullpath, dataSources)

       'Console.Writeline("Report DataSources set successfully")
       Console.WriteLine("Report: {0} published successfully", name)

   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 + ")")
       Console.WriteLine("Report: {0} published with error", name)
   End Try

结束子

标签: reporting-servicesrss

解决方案


推荐阅读