BaseMatix: IMatrix;
BaseMatix: Prognoz.Platform.Interop.Matrix.IMatrix;
The BaseMatix property returns source data matrix of proxy object.
To get changed data matrix of proxy object, use IMatrixWritableProxy.ChangeMatrix.
Executing the example requires that the repository contains a cube with the CUBE identifier based on four dictionaries.
Add links to the Cubes, Dimensions, Matrix, Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
CubeInst: ICubeInstance;
DefDest: ICubeInstanceDestination;
SelSet: IDimSelectionSet;
i: integer;
DestExec: ICubeInstanceDestinationExecutor;
Proxy, Mx, BaseMatrix, ChangeMatrix: IMatrix;
Mxe: IMatrixEx;
Wp: IMatrixWritableProxy;
Iter: IMatrixIterator;
Mc: IMatrixCoord;
Begin
MB := MetabaseClass.Active;
CubeInst := MB.ItemById("CUBE").Open(Null) As ICubeInstance;
DefDest := CubeInst.Destinations.DefaultDestination;
SelSet := DefDest.CreateDimSelectionSet;
For i := 0 To SelSet.Count - 1 Do
SelSet.Item(i).SelectAll;
End For;
Debug.WriteLine("---------------Unchanged values of elements-------------------");
DestExec := DefDest.CreateExecutorO(CubeInstanceDestinationExecutorOptions.MatrixProxy);
DestExec.PrepareExecute(SelSet);
DestExec.PerformExecute(False);
Proxy := DestExec.Matrix;
Iter := Proxy.CreateIterator;
Iter.Move(IteratorDirection.First);
i := 0;
While Iter.Valid Do
Debug.WriteLine(i.ToString + " Iter.Value = " + Iter.Value);
Iter.Move(IteratorDirection.Next);
i := i + 1;
End While;
Debug.WriteLine("---------------Add a new value-------------------");
Mx := DefDest.Execute(SelSet, -1);
Mxe := Mx As IMatrixEx;
Wp := Mxe.CreateWritableProxyO(0) As IMatrixWritableProxy;
BaseMatrix := Wp.BaseMatrix;
Mc := BaseMatrix.CreateCoord;
Iter := BaseMatrix.CreateIterator;
Iter.Move(IteratorDirection.First);
Iter.PutCurrentPos(Mc);
Mc.Item(0) := 0;
Mc.Item(1) := 0;
Mc.Item(2) := 0;
Mc.Item(3) := 0;
Iter.Goto(Mc);
If Iter.Valid Then
Debug.WriteLine("Error - value already exists");
Else
Debug.WriteLine("Coord - OK");
End If;
Iter.PutCoord(Mc);
Iter.Value := 100500;
Debug.WriteLine("New value = " + Iter.Value);
Debug.WriteLine("---------------Changed/added values of elements-------------------");
Wp.ApplyChanges;
ChangeMatrix := Wp.ChangeMatrix;
Iter := ChangeMatrix.CreateIterator;
Iter.Move(IteratorDirection.First);
i := 0;
While Iter.Valid Do
Debug.WriteLine(i.ToString + " Iter.Value = " + Iter.Value);
Iter.Move(IteratorDirection.Next);
i := i + 1;
End While;
Debug.WriteLine("---------------Source values-------------------");
Wp.RevertChanges;
Iter := ChangeMatrix.CreateIterator;
Iter.Move(IteratorDirection.First);
i := 0;
While Iter.Valid Do
Debug.WriteLine(i.ToString + " Iter.Value = " + Iter.Value);
Iter.Move(IteratorDirection.Next);
i := i + 1;
End While;
End Sub UserProc;
After executing the example a new element is added to the matrix. The console window displays: unchanged values of elements, added/changed values of elements, source values.
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.ForeSystem;
Imports Prognoz.Platform.Interop.Matrix;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
CubeInst: ICubeInstance;
DefDest: ICubeInstanceDestination;
SelSet: IDimSelectionSet;
i: integer;
DestExec: ICubeInstanceDestinationExecutor;
Proxy, Mx, BaseMatrix, ChangeMatrix: IMatrix;
Mxe: IMatrixEx;
Wp: IMatrixWritableProxy;
Iter: IMatrixIterator;
Mc: IMatrixCoord;
Begin
MB := Params.Metabase;
CubeInst := MB.ItemById["CUBE"].Open(Null) As ICubeInstance;
DefDest := CubeInst.Destinations.DefaultDestination;
SelSet := DefDest.CreateDimSelectionSet();
For i := 0 To SelSet.Count - 1 Do
SelSet.Item[i].SelectAll();
End For;
System.Diagnostics.Debug.WriteLine("---------------Unchanged values of elements-------------------");
DestExec := DefDest.CreateExecutorO(CubeInstanceDestinationExecutorOptions.cideoMatrixProxy As Integer);
DestExec.PrepareExecute(SelSet);
DestExec.PerformExecute(False);
Proxy := DestExec.Matrix;
Iter := Proxy.CreateIterator();
Iter.Move(IteratorDirection.itdFirst);
i := 0;
While Iter.Valid Do
System.Diagnostics.Debug.WriteLine(i.ToString() + " Iter.Value = " + Iter.Value);
Iter.Move(IteratorDirection.itdNext);
i := i + 1;
End While;
System.Diagnostics.Debug.WriteLine("---------------Add a new value-------------------");
Mx := DefDest.Execute(SelSet, uinteger.MaxValue);
Mxe := Mx As IMatrixEx;
Wp := Mxe.CreateWritableProxyO(0) As IMatrixWritableProxy;
BaseMatrix := Wp.BaseMatrix;
Mc := BaseMatrix.CreateCoord();
Iter := BaseMatrix.CreateIterator();
Iter.Move(IteratorDirection.itdFirst);
Iter.PutCurrentPos(Mc);
Mc.Item[0] := 0;
Mc.Item[1] := 0;
Mc.Item[2] := 0;
Mc.Item[3] := 0;
Iter.Goto(Mc);
If Iter.Valid Then
System.Diagnostics.Debug.WriteLine("Error - value already exists");
Else
System.Diagnostics.Debug.WriteLine("Coord - OK");
End If;
Iter.PutCoord(Mc);
Iter.Value := 100500;
System.Diagnostics.Debug.WriteLine("New value = " + Iter.Value);
System.Diagnostics.Debug.WriteLine("---------------Changed values of elements-------------------");
Wp.ApplyChanges();
ChangeMatrix := Wp.ChangeMatrix;
Iter := ChangeMatrix.CreateIterator();
Iter.Move(IteratorDirection.itdFirst);
i := 0;
While Iter.Valid Do
System.Diagnostics.Debug.WriteLine(i.ToString() + " Iter.Value = " + Iter.Value);
Iter.Move(IteratorDirection.itdNext);
i := i + 1;
End While;
System.Diagnostics.Debug.WriteLine("---------------Values of elements after reset-------------------");
Wp.RevertChanges();
Iter := BaseMatrix.CreateIterator();
Iter.Move(IteratorDirection.itdFirst);
i := 0;
While Iter.Valid Do
System.Diagnostics.Debug.WriteLine(i.ToString() + " Iter.Value = " + Iter.Value);
Iter.Move(IteratorDirection.itdNext);
i := i + 1;
End While;
End Sub;
See also: