Question

I have s h*tload of reports on my reportserver. Most of them have a Cache Refresh Plan using a shared schedule. Is it programmatically possible to set a Cache Refresh Plan on a report? Enabling caching, set expiration for a cache using a shared schedule, running snapshots according to a shared schedule all works runs fine using SetExecutionOptions-method and SetCacheOptions-method.

Setting a Cached Refreshplan for a report however does NOT run fine. Suggestions?

edit: I would like to do the same for all, datasets set them to refresh on a shared schedule.

Below is the code I am using (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) 
}
Was it helpful?

Solution

Actually found it. Somehow me ànd several colleagues of mine overlooked it: CreateCacheRefreshPlan Method is the solution...

It does not look nice (but hey, I am not a developer) and half of it are shameless rip-offs but it DOES do the trick.... :)

Thnx and kudo's to all the people who posted the tidbits I needed...

$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
                                    )

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top