【问题标题】:Enable Caching for all reports in SSRS Report Server为 SSRS 报表服务器中的所有报表启用缓存
【发布时间】:2012-12-07 22:40:48
【问题描述】:

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

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

任何帮助将不胜感激

谢谢 阿杰

【问题讨论】:

标签: ssrs-2008 reporting-services reportserver ssrs-2012


【解决方案1】:

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

将其保存为 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多