SetSelection(Value: IDimSelectionSet);
SetSelection(Value: Prognoz.Platform.Interop.Dimensions.IDimSelectionSet);
Value. The cube selection, according to which data cache is updated.
The SetSelection method sets the selection, according to which data cache is updated for the cube on executing the task.
Executing the example requires a cube with the CUBE_ID identifier with the enabled data caching and also a scheduled tasks container with the SCHEDULED_TASK_CONTAINER identifier.
Sub UserProc;
Var
Metabase: IMetabase;
ScheduledTask: ICubeCacheUpdateScheduledTask;
CrInfo: IMetabaseObjectCreateInfo;
CubIn: ICubeInstance;
CubInDes: ICubeInstanceDestination;
DimS: IDimSelection;
DimSS: IDimSelectionSet;
Properties: IScheduledTaskProperties;
Period: IScheduledTaskPeriodMonthly;
i: Integer;
Begin
Metabase := MetabaseClass.Active;
CrInfo := Metabase.CreateCreateInfo;
CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_TASK_UPDATE_CUBE_CACHE;
CrInfo.Parent := Metabase.ItemById("SCHEDULED_TASK_CONTAINER");
ScheduledTask := Metabase.CreateObject(CrInfo).Edit As ICubeCacheUpdateScheduledTask;
CubIn := Metabase.ItemById("CUBE_ID").Open(Null) As ICubeInstance;
CubInDes := CubIn.Destinations.DefaultDestination;
DimSS := CubInDes.CreateDimSelectionSet;
For Each DimS In DimSS Do
DimS.SelectAll;
End For;
ScheduledTask.SourceCube := CubIn.Cube;
ScheduledTask.DestKey := CubInDes.Key;
ScheduledTask.SetSelection(DimSS);
//Set task execution period
Properties := ScheduledTask.Properties;
Period := Properties.CreatePeriod(ScheduledTaskPeriodType.Monthly) As IScheduledTaskPeriodMonthly;
Period.DayOfWeek := CalendarDayOfWeek.Monday;
Period.WeekOfMonth := CalendarWeekOfMonth.Third;
For i := 1 To 12 Do
Period.Months(i As CalendarMonth) := True;
End For;
Period.StartTime := DateTime.ComposeTimeOfDay(12, 0, 0, 0);
Properties.Period := Period;
(ScheduledTask As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the task of cache update for the CUBE_ID cube by the specified display version and specified selection is created in the SCHEDULED_TASK_CONTAINER scheduled tasks container. The task will be executed monthly on Monday of the third week of the month at 12:00.
Executing the example requires a cube with the CUBE_ID identifier with the enabled data caching and also a scheduled tasks container with the SCHEDULED_TASK_CONTAINER identifier.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.KeFore;
Imports System;
Public Sub Main(Params: StartParams);
Var
Metabase: IMetabase;
ScheduledTask: ICubeCacheUpdateScheduledTask;
CrInfo: IMetabaseObjectCreateInfo;
CubIn: ICubeInstance;
CubInDes: ICubeInstanceDestination;
DimS: IDimSelection;
DimSS: IDimSelectionSet;
Properties: IScheduledTaskProperties;
Period: IScheduledTaskPeriodMonthly;
i: Integer;
Begin
Metabse := Params.Metabase;
CrInfo := Metabase.CreateCreateInfo();
CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_TASK_UPDATE_CUBE_CACHE As Int32;
CrInfo.Parent := Metabase.ItemById["SCHEDULED_TASK_CONTAINER"];
ScheduledTask := Metabase.CreateObject(CrInfo).Edit() As ICubeCacheUpdateScheduledTask;
CubIn := Metabase.ItemById["CUBE_ID"].Open(Null) As ICubeInstance;
CubInDes := CubIn.Destinations.DefaultDestination;
DimSS := CubInDes.CreateDimSelectionSet();
For Each DimS In DimSS Do
DimS.SelectAll();
End For;
ScheduledTask.SourceCube := CubIn.Cube;
ScheduledTask.DestKey := CubInDes.Key;
ScheduledTask.SetSelection(DimSS);
//Set task execution period
Properties := ScheduledTask.Properties;
Period := Properties.CreatePeriod(ScheduledTaskPeriodType.stptMonthly) As IScheduledTaskPeriodMonthly;
Period.DayOfWeek := CalendarDayOfWeek.dowMonday;
Period.WeekOfMonth := CalendarWeekOfMonth.womThird;
For i := 1 To 12 Do
Period.Months[i As CalendarMonth] := True;
End For;
Period.StartTime := DateTime.Now;
Properties.Period := Period;
(ScheduledTask As IMetabaseObject).Save();
End Sub;
After executing the example the task of cache updating is created for the CUBE_ID cube by the specified display version and specified selection is created in the SCHEDULED_TASK_CONTAINER scheduled tasks container. The task will be executed monthly on Monday of the third week of the month in time when it was created.
See also: