为报告ssrs设置缓存刷新计划

时间:2013-09-10 14:13:07

标签: powershell reporting-services ssrs-2012

我的报告服务器上有很多报告。他们中的大多数都使用共享计划进行缓存刷新计划。是否可以通过编程方式在报表上设置缓存刷新计划? 启用缓存,使用共享计划为缓存设置到期,根据共享计划运行快照,所有工作都可以使用SetExecutionOptions-method和SetCacheOptions-method正常运行。

为报告设置缓存刷新计划但运行不正常。建议?

编辑:我想对所有人做同样的事情,数据集将它们设置为按共享计划刷新。

以下是我正在使用的代码(Powershell V3)

$reportServerURI = "http://localhost/Reportserver"
$ReportPathWildCard = "/SOME/FOLDER/ON/SERVER";
$NameSharedSchedule="NAMEOFSCHEDULE";

# init WS proxy
$reportServerURI2010 = "$reportServerURI/ReportService2010.asmx?WSDL"
$RS = New-WebServiceProxy -Uri $reportServerURI2010 -UseDefaultCredential
$proxyNamespace = $RS.GetType().Namespace
#Get Schedule Reference
$NeverExpireSchedule= $RS.ListSchedules([System.Management.Automation.Language.NullString]::Value) | where {$_.Name -eq "$NameSharedSchedule"}
$NeverExpireScheduleID = $NeverExpireSchedule.scheduleid;
$NeverExpireDescription = $NeverExpireSchedule.Description;
$NeverExpireDefinition = $NeverExpireSchedule.Definition;
Write-Host "Found Shared Schedule: '$NameSharedSchedule' with id $NeverExpireScheduleID and definition $NeverExpireDescription";

$NeverExpireScheduleRef =New-Object("$proxyNamespace.ScheduleReference");
$NeverExpireScheduleRef.ScheduleID=$NeverExpireScheduleID;


#get all needed items
$items = $RS.ListChildren($ReportPathWildCard, $true)  | Where-Object {"Report" -contains $_.TypeName} 
#process all items
foreach ($item in $items) {
    $xpath = $item.path
    $xtype = $item.TypeName
    Write-Host "Processing $xtype $xpath"


    ##SET Refresh

   $r= $RS.SetExecutionOptions( $xpath,"Snapshot",$NeverExpireDefinition) 
}

1 个答案:

答案 0 :(得分:2)

实际上找到了它。不知怎的,我和我的几位同事都忽视了它: CreateCacheRefreshPlan方法是解决方案......

它看起来不太好(但是,嘿,我不是开发人员),其中一半是无耻的剽窃,但它可以做到这一点...... :)

Thnx和kudo给所有发布我需要的花絮的人......

$reportServerURI = "http://localhost/Reportserver"
$ReportPathWildCard = "/";
$NameSharedSchedule="NAME OF SCHEDULE";

# init WS proxy
$reportServerURI2010 = "$reportServerURI/ReportService2010.asmx?WSDL"
$RS = New-WebServiceProxy -Uri $reportServerURI2010 -UseDefaultCredential
$proxyNamespace = $RS.GetType().Namespace
# Get Schedule Reference
$NeverExpireSchedule= $RS.ListSchedules([System.Management.Automation.Language.NullString]::Value) | where {$_.Name -eq "$NameSharedSchedule"}
$NeverExpireScheduleID = $NeverExpireSchedule.scheduleid;
$NeverExpireDescription = $NeverExpireSchedule.Description;
$NeverExpireDefinition = $NeverExpireSchedule.Definition;
#Write-Host "Found Shared Schedule: '$NameSharedSchedule' with id $NeverExpireScheduleID and definition $NeverExpireDescription";

$NeverExpireScheduleRef =New-Object("$proxyNamespace.ScheduleReference");
$NeverExpireScheduleRef.ScheduleID=$NeverExpireScheduleID;



# Wat dingen voorbereiden
#delivery Extension
   #$setting = "Report Server Email"
   $matchdata = $NeverExpireScheduleID
   $description = "Automatisch ingesteld op " + $NameSharedSchedule
   $eventtype = "RefreshCache"
   $parameters

#get all needed items
$items = $RS.ListChildren($ReportPathWildCard, $true)  | Where-Object {"Dataset" -contains $_.TypeName} 
#process all items
foreach ($item in $items) {
    $xpath = $item.path
    $xtype = $item.TypeName
    Write-Host "Processing $xtype $xpath"

    $report = $xpath


    ##SET Cache
    $r= $RS.SetCacheOptions( $xpath,[System.Management.Automation.Language.NullString]::Value, $o) 

  $r= $RS.CreateCacheRefreshPlan(   $report,
                                    $description,
                                    $eventtype,
                                    $matchdata,
                                    $parameters
                                    )

}