ICubeSerializer.PreCheck

Fore Syntax

PreCheck(CubeObject: IMetabaseObjectDescriptor);

Fore.NET Syntax

PreCheck(CubeObject: Prognoz.Platform.Interop.Metabase.IMetabaseObjectDescriptor);

Parameters

CubeObject. A cube, for which data export permissions must be checked.

Description

The PreCheck method checks export permissions of the specified user. If the user does not have permissions, an exception is thrown.

Example

Executing the example requires that the repository contains a cube with the Cube_1 identifier.

Sub TestUserRight;
Var
    MB: IMetabase;
    Des: IMetabaseObjectDescriptor;
    CubInst: ICubeInstance;
    CubeDist: ICubeInstanceDestination;
    CubS: ICubeSerializer;
    CubSIns: ICubeSerialInstance;
    DimSS: IDimSelectionSet;
    DimS: IDimSelection;
Begin
    MB := MetabaseClass.Active;
    CubS := New CubeSerializer.Create As ICubeSerializer;
    Des := MB.ItemById("Cube_1");
    Try
        CubS.PreCheck(Des);
        CubInst := Des.Open(NullAs ICubeInstance;
        CubeDist := CubInst.Destinations.DefaultDestination;
        CubSIns := CubS.SaveToFile("c:\cub.ppcube", CubInst);
        DimSS := CubeDist.CreateDimSelectionSet;
        For Each DimS In DimSS Do
            DimS.SelectAll;
        End For;
        CubSIns.Save(CubeDist, DimSS, 0);
    Except On Exp: Exception Do
        If Exp.MessageID = 5651 Then
            Debug.WriteLine("Operation has been prohibited because of restricted permissions of the user");
        End If;
    End Try;
End Sub TestUserRight;

After executing the example, the cube with all data is saved to the cub.ppcube file. Permissions of the current user to export this cube are checked on saving. If the user does not have permissions, an exception is thrown, and an appropriate message is displayed.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Metabase;

Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Des: IMetabaseObjectDescriptor;
    CubInst: ICubeInstance;
    CubeDist: ICubeInstanceDestination;
    CubS: CubeSerializer = New CubeSerializerClass();
    CubSIns: ICubeSerialInstance;
    DimSS: IDimSelectionSet;
    DimS: IDimSelection;
Begin
    MB := Params.Metabase;
    Des := MB.ItemById["Cube_1"];
    Try
        CubS.PreCheck(Des);
        CubInst := Des.Open(NullAs ICubeInstance;
        CubeDist := CubInst.Destinations.DefaultDestination;
        CubSIns := CubS.SaveToFile("c:\cub.ppcube", CubInst);
        DimSS := CubeDist.CreateDimSelectionSet();
        For Each DimS In DimSS Do
            DimS.SelectAll();
        End For;
        CubSIns.Save(CubeDist, DimSS, 0);
    Except On Exp: System.Exception Do
        System.Diagnostics.Debug.WriteLine(Exp.Message);
    End Try;
End Sub;

See also:

ICubeSerializer