Evaluate(Value: IOrmRecord): IOrmCondition;
Evaluate(Value: Prognoz.Platform.Interop.Orm.IOrmRecord): Prognoz.Platform.Interop.Orm.IOrmCondition;
Value. Checked record.
The Evaluate method checks if collection conditions are fulfilled for the specified record.
If all the conditions are fulfilled for the specified record, the method returns Null. If a condition is not fulfilled, the method returns this condition.
Executing the example requires that the repository contains a dictionary with the Evaluate identifier containing a logical attribute with the IS_ACTUAL identifier.
Add links to the Dimension, Metabase and Orm system assemblies.
Sub Evaluate;
Var
MB: IMetabase;
pDim: IDimInstance;
pDimModel: IDimensionModel;
pManager: IDimOrmManager;
pClass: IDimOrmClass;
Conds: IOrmConditions;
pCond: IDimOrmCondition;
pCondition, pCond_1: IOrmCondition;
pDimElement: IDimElement;
pDimElements: IDimElementArray;
i, ArttrInd: Integer;
Record: IOrmRecord;
Begin
MB := MetabaseClass.Active;
// Get dictionary
pDim := MB.ItemById("DICT").Open(Null) As IDimInstance;
// Get dictionary structure
pDimModel := pDim.Dimension;
// Create an object that is used to work with conditions
pManager := New DimOrmManager.Create;
// Create a class that is used to work with conditions
pClass := pManager.CreateClass(pDimModel);
// Create a condition
pCond := pClass.CreateCondition;
Conds := pCond.Conditions;
pCondition := Conds.Add;
pCondition.AttributeName := "IS_ACTUAL";
pCondition.Value := True;
// Get dictionary elements
pDimElements := pDim.Elements.Elements;
// Check whether each element complies with condition
pDimElement := pDim.NewElement;
For i := 0 To pDimElements.Count - 1 Do
pDimElement.Element := pDimElements.Element(i);
Record := pDimElement As IOrmRecord;
// Perform check
pCond_1 := Conds.Evaluate(Record);
// If element does not comply with condition,
//display its name
If pCond_1 <> Null Then
ArttrInd := Record.FindAttribute("NAME");
Debug.WriteLine(Record.AttributeValue(ArttrInd));
End If;
End For;
End Sub Evaluate;
After executing the example the console window displays names of the elements, which do not comply with the condition: the IS_ACTUAL attribute must be set to True.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Orm;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
pDim: IDimInstance;
pDimModel: IDimensionModel;
pManager: IDimOrmManager;
pClass: IDimOrmClass;
Conds: IOrmConditions;
pCond: IDimOrmCondition;
pCondition, pCond_1: IOrmCondition;
pDimElement: IDimElement;
pDimElements: IDimElementArray;
i, ArttrInd: Integer;
Record: IOrmRecord;
Begin
MB := Params.Metabase;
// Get dictionary
pDim := MB.ItemById["DICT"].Open(Null) As IDimInstance;
// Get dictionary structure
pDimModel := pDim.Dimension;
// Create an object that is used to work with conditions
pManager := New DimOrmManager.Create();
// Create a class that is used to work with conditions
pClass := pManager.CreateClass(pDimModel);
// Create a condition
pCond := pClass.CreateCondition();
Conds := pCond.Conditions;
pCondition := Conds.Add();
pCondition.AttributeName := "IS_ACTUAL";
pCondition.Value := True;
// Get dictionary elements
pDimElements := pDim.Elements.Elements;
// Check if each element complies with condition
pDimElement := pDim.NewElement();
For i := 0 To pDimElements.Count - 1 Do
pDimElement.Element := pDimElements.Element[i];
Record := pDimElement As IOrmRecord;
// Perform check
pCond_1 := Conds.Evaluate(Record);
// If element does not comply with condition,
//display its name
If pCond_1 <> Null Then
ArttrInd := Record.FindAttribute("NAME");
System.Diagnostics.Debug.WriteLine(Record.AttributeValue[ArttrInd]);
End If;
End For;
End Sub;
See also: