ICubeSerializer.PreCheck

Syntax

PreCheck(CubeObject: 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.

See also:

ICubeSerializer