AsCubeStorage: ICubeInstanceStorage;
The AsCubeStorage method saves factor data of as cube data.
Executing the example requires that the repository contains a time series database with the OBJ_RUBRICATOR identifier.
Sub UserProc;
Var
MB: IMetabase;
RubrInst: IRubricatorInstance;
Cube: ICubeInstance;
Dest: ICubeInstanceDestination;
FactorStorage: IRubricatorFactorStorage;
Storage: ICubeInstanceStorage;
FactorExec: IRubricatorFactorExecutor;
Exec: ICubeInstanceDestinationExecutor;
Matr: IMatrix;
It: IMatrixIterator;
Begin
MB := MetabaseClass.Active;
RubrInst := MB.ItemById("OBJ_RUBRICATOR").Open(Null) As IRubricatorInstance;
Cube := RubrInst As ICubeInstance;
Dest := Cube.Destinations.DefaultDestination;
FactorStorage := Dest.CreateStorage As IRubricatorFactorStorage;
FactorStorage.DataOverwrite := False;
FactorStorage.FactDataId := "OBT";
FactorStorage.FactDataKind := MetaAttributeKind.Value;
FactorStorage.CurrentRevision := FactorStorage.OpenRevision("Revision for saving data");
Storage := FactorStorage.AsCubeStorage;
FactorExec := Dest.CreateExecutor As IRubricatorFactorExecutor;
Exec := FactorExec.AsCubeExecutor;
Exec.PrepareExecute(Null);
Exec.PerformExecute;
FactorStorage.FactDataMatrix := Exec.Matrix;
Matr := FactorStorage.FactDataMatrix;
It := Matr.CreateIterator;
It.Move(IteratorDirection.First);
Debug.WriteLine("-----Data before change-----");
While It.Valid Do
Debug.WriteLine(It.Value);
It.Value := It.Value + 1;
It.ValueFlag := 1;
It.Move(IteratorDirection.Next);
End While;
Storage.SaveMatrix(Matr, 1);
Debug.WriteLine("---- Data after change-----");
It.Move(IteratorDirection.First);
While It.Valid Do
Debug.WriteLine(It.Value);
It.Move(IteratorDirection.Next);
End While;
End Sub UserProc;
After executing the example values of all indicators are increased by one, saved in a new revision and displayed in the console window.
See also: