Enable Caching for all reports in SSRS Report Server

旧巷老猫 提交于 2019-12-08 02:43:18

问题


I have more than 100 reports in SSRS report server. I need to enable caching for all of those. Right now I am enabling caching through the report manager for each and every report.

Can we add caching in any of the report servers config files? So that we can enable caching for all reports at a single place.

Any help will be appreciated

Thanks AJ


回答1:


Below is the script that I used to enable caching in minutes on a list of reports.

Save it as setreportscaching.rss and then run it from the command line:

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

It is easy to modify it to loop through files in some folder rather then take csv list of reports. It has some silly piece of diagnostics that can be commented out for speed.

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


来源:https://stackoverflow.com/questions/13772171/enable-caching-for-all-reports-in-ssrs-report-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!