3

我在 SSRS 报表服务器中有 100 多个报表。我需要为所有这些启用缓存。现在,我正在通过报表管理器为每个报表启用缓存。

我们可以在任何报表服务器配置文件中添加缓存吗?这样我们就可以在一个地方为所有报告启用缓存。

任何帮助将不胜感激

谢谢阿杰

4

1 回答 1

2

下面是我用来在几分钟内对报告列表启用缓存的脚本。

将其保存为 setreportscaching.rss,然后从命令行运行它:

rs.exe -i setreportscaching.rss -e Mgmt2010 -t -s http://mySsrsBox:8080/ReportServer -v ReportNamesList="OneReport,AnotherReport,YetAnotherOne" -v CacheTimeMinutes="333" -v TargetFolder="ReportsFolderOnServer"

很容易修改它以循环浏览某个文件夹中的文件,而不是获取 csv 报告列表。它有一些愚蠢的诊断,可以注释掉以提高速度。

Public Sub Main()

    Dim reportNames As String() = Nothing
    Dim reportName As String
    Dim texp As TimeExpiration
    Dim reportPath As String

    Console.WriteLine("Looping through reports: {0}", ReportNamesList)

    reportNames = ReportNamesList.Split(","c)

    For Each reportName In reportNames

        texp = New TimeExpiration()
        texp.Minutes = CacheTimeMinutes

        reportPath = "/" + TargetFolder + "/" + reportName

        'feel free to comment out this diagnostics to speed things up
        Console.WriteLine("Current caching for " + reportName + DisplayReportCachingSettings(reportPath))

        'this call sets desired caching option
        rs.SetCacheOptions(reportPath, true, texp)

        'feel free to comment out this diagnostics to speed things up
        Console.WriteLine("New caching for " + reportName + DisplayReportCachingSettings(reportPath))

    Next

End Sub

Private Function DisplayReportCachingSettings(reportPath as string)

    Dim isCacheSet As Boolean
    Dim expItem As ExpirationDefinition = New ExpirationDefinition()
    Dim theResult As String

    isCacheSet = rs.GetCacheOptions(reportPath, expItem)

    If isCacheSet = false Or expItem is Nothing Then
        theResult = " is not defined."
    Else
        If expItem.GetType.Name = "TimeExpiration" Then
            theResult = " is " + (CType(expItem, TimeExpiration)).Minutes.ToString() + " minutes."
        ElseIf expItem.GetType.Name = "ScheduleExpiration" Then
            theResult = " is a schedule"
        Else
            theResult = " is " + expItem.GetType.Name
        End If
    End If

    DisplayReportCachingSettings = theResult

End Function
于 2013-08-22T12:03:22.160 回答