AddSelection(Selection: );
AddSelection(Selection: Prognoz.Platform.Interop.Dimensions.);
Selection. Selection of cube dimension elements.
The AddSelection method adds elements to the current selection of cube dimension elements.
To set the specified selection of elements, use the IMobilePublishCube.SetSelection method.
Executing the example requires that the repository contains a mobile application with the MA_PUB identifier. Add links to the Metabase, Mobile, Dimensions, Cubes system assemblies.
Sub UserProc;
Var
mb: IMetabase;
Mobile: IMobileApplication;
Publicator: IMobileApplicationPublicator;
MaPubObs: IMobileApplicationPublishObjects;
i: Integer;
MaPubObj: IMobileApplicationPublishObject;
PubObj: IMobilePublishObject;
CubePubObj: IMobilePublishCube;
s: String;
Cube: ICubeInstance;
DefDest: ICubeInstanceDestination;
SelSet: IDimSelectionSet;
DimSel: IDimSelection;
j: Integer;
res: MobilePublishObjectResult;
Begin
mb := MetabaseClass.Active;
// Get mobile application
Mobile := mb.ItemById("MA_PUB").Bind As IMobileApplication;
// Create a mobile application publisher
Publicator := Mobile.CreatePublicator;
// Get mobile application objects
MaPubObs := Publicator.Items;
For i := 0 To MaPubObs.Count - 1 Do
MaPubObj := MaPubObs.Item(i);
// Select cubes among the objects
If MaPubObj.Type = MobilePublishObjectType.Cube Then
PubObj := MaPubObj.PublishObject;
CubePubObj := PubObj As IMobilePublishCube;
// Display data on the cube in the console window
s := PubObj.Object.Name + " (" + PubObj.Object.Id + ")";
Debug.WriteLine("Cube: " + s).
Cube := PubObj.Object.Open(Null) As ICubeInstance;
DefDest := Cube.Destinations.DefaultDestination;
// Get an empty selection
SelSet := DefDest.CreateDimSelectionSet;
// Select the first dimension elements
For j := 0 To SelSet.Count - 1 Do
DimSel := SelSet.Item(j);
DimSel.SelectElement(0, False);
End For;
// Add elements to the current selection
CubePubObj.AddSelection(SelSet);
// Define publishing path
PubObj.ExportPath := "C:\" + PubObj.Object.Id + ".zip";
// Publish cube
res := PubObj.Publish;
// Display the result in the console window
If (res As integer) = 0 Then
Debug.WriteLine("Publishing was successful").
Debug.WriteLine(" Publishing path: " + PubObj.ExportPath);
Else
Debug.WriteLine("Error occurred on publishing").
End If;
End If;
End For;
End Sub UserProc;
Example execution result: elements are added to the selection of dimensions elements for all cubes from the mobile application; the cubes are published and the publishing results are displayed in the console window.
Executing the example requires that the repository contains a mobile application with the MA_PUB identifier.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Mobile;
Imports Prognoz.Platform.Interop.Dimensions;
…
[STAThread]
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
Mobile: IMobileApplication;
Publicator: IMobileApplicationPublicator;
MaPubObs: IMobileApplicationPublishObjects;
i: Integer;
MaPubObj: IMobileApplicationPublishObject;
PubObj: IMobilePublishObject;
CubePubObj: IMobilePublishCube;
s: String;
Cube: ICubeInstance;
DefDest: ICubeInstanceDestination;
SelSet: IDimSelectionSet;
DimSel: IDimSelection;
j: Integer;
res: MobilePublishObjectResult;
Begin
mb := Params.Metabase;
// Get the mobile application
Mobile := mb.ItemById["MA_PUB"].Bind() As IMobileApplication;
// Create a mobile application publicator
Publicator := Mobile.CreatePublicator();
// Get the mobile application objects
MaPubObs := Publicator.Items;
For i := 0 To MaPubObs.Count - 1 Do
MaPubObj := MaPubObs.Item[i];
// Select cubes among the objects
If MaPubObj.Type = MobilePublishObjectType.mpotCube Then
PubObj := MaPubObj.PublishObject;
CubePubObj := PubObj As IMobilePublishCube;
// Display data on the cube in the console window
s := PubObj.Object.Name + " (" + PubObj.Object.Id + ")";
System.Diagnostics.Debug.WriteLine("Cube: " + s).
Cube := PubObj.Object.Open(Null) As ICubeInstance;
DefDest := Cube.Destinations.DefaultDestination;
// Get an empty selection
SelSet := DefDest.CreateDimSelectionSet();
// Select the first dimension elements
For j := 0 To SelSet.Count - 1 Do
DimSel := SelSet.Item[j];
DimSel.SelectElement(0, False);
End For;
// Add elements to the current selection
CubePubObj.AddSelection(SelSet);
// Define the publishing path
PubObj.ExportPath := "C:\" + PubObj.Object.Id + ".zip";
// Publish cube
res := PubObj.Publish(Null);
// Display the result in the console window
If (res As integer) = 0 Then
System.Diagnostics.Debug.WriteLine("Publishing was successful").
System.Diagnostics.Debug.WriteLine(" Publishing path: " + PubObj.ExportPath).
Else
System.Diagnostics.Debug.WriteLine("Error occurred on publishing").
End If;
End If;
End For;
End Sub;
Example execution result: elements are added to the selection of dimensions elements for all cubes from the mobile application; the cubes are published and the publishing results are displayed in the console window.
See also: