ICalculateCubeScheduledTask.SetSelection

Syntax

SetSelection(Value: IDimSelectionSet);

Parameters

Value. The selection of the source cube, according to which data is loaded to the destination cube.

Description

The SetSelection method sets a selection, according to which the data is loaded to a cube on task execution.

Comments

The method is used when task for starting a cube loader is used.

Example

Executing the example requires that the repository contains a cube loader and a scheduled tasks container with the Cube_Load and CUBE_TASK identifiers, respectively.

Sub UserProc;
Var
    MB: IMetabase;
    MObj, Parent: IMetabaseObject;
    Loader: ICubeLoader;
    CrInfo: IMetabaseObjectCreateInfo;
    LoaderTask: ICalculateCubeScheduledTask;
    CubeInst: ICubeInstance;
    Period: IScheduledTaskPeriodDaily;
    Prop: IScheduledTaskProperties;
    DimSS: IDimSelectionSet;
    DimS: IDimSelection;
    d: DateTime;
Begin
    MB := MetabaseClass.Active;
    // Scheduled tasks container
    Parent := MB.ItemById("CUBE_TASK").Bind;
    // Cube loader
    Loader := Mb.ItemById("Cube_Load").Bind As ICubeLoader;
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_TASK_CALCULATECUBE;
    CrInfo.Id := "LoaderTask";
    CrInfo.Name := "Cube loader startup task";
    CrInfo.Parent := Parent;
    CrInfo.Permanent := False;
    MObj := MB.CreateObject(CrInfo).Edit;
    // cube loader startup task
    LoaderTask := MObj As ICalculateCubeScheduledTask;
    // Get selection by which data will be loaded
    CubeInst := (Loader.Destination.Cube As IMetabaseObject).Open(NullAs ICubeInstance;
    DimSS := CubeInst.Destinations.DefaultDestination.CreateDimSelectionSet;
    // All elements in selection
    For Each DimS In DimSS Do
        DimS.SelectAll;
    End For;
    LoaderTask.SourceCube := (Loader As ICubeModel);
    // Set up task properties
    Prop := LoaderTask.Properties;
    Period := Prop.CreatePeriod(ScheduledTaskPeriodType.Daily) As IScheduledTaskPeriodDaily;
    d := DateTime.Now;
    d := d.Compose(d.Year, d.Month, d.Day, 18000000);
    Period.StartDateTime := d;
    Period.EveryDays := 3;
    Prop.Period := Period;
    LoaderTask.SetSelection(DimSS);
    MObj.Save;
End Sub UserProc;

After executing the example the task of starting a cube loader is added to the scheduled tasks container. The task is started daily beginning with the current day at 18:00 with interval of two days.

See also:

ICalculateCubeScheduledTask