Element: Integer;
Element: integer;
The Element property determines selected element.
To get selection, use the IValidationSelectionValue.Selection property.
Executing the example requires a form containing the WorkbookDocumentViewerBox component with the WorkbookDocumentViewerBox1 identifier and the UiErAnalayzer component with the UiErAnalyzer1 identifier. UiErAnalyzer1 is a data source for WorkbookDocumentViewerBox1 and contains a time series database workbook with the TSDB_VALIDATION_PARAMETERS identifier. Time series database parameters:
The mandatory series attribute with the CITY identifier referring to the dictionary.
A validation rule with the VALIDATION_TREND identifier of the Compare Trends type.
Add links to the Cubes, Dimensions, Metabase, Ms, Rds system assemblies.
Sub UserProc;
Var
mb: IMetabase;
FCObj: IMetabaseObject;
FC: IRubricator;
LinkedDict: IMetabaseObjectDescriptor;
Dim: IDimInstance;
DimSel: IDimSelection;
ValidObj: IMetabaseObject;
ValidFilter: IValidationFilter;
Trend: IValidationTrend;
Comparator: IValidationSelectionValueList;
ComparVal: IValidationSelectionValue;
ExecSett: IValidationExecuteSettings;
Analyzer: IEaxAnalyzer;
ExecRun: IValidationExecRun;
DiagRep: IDiagnosticReport;
Begin
mb := MetabaseClass.Active;
// Get time series database
FCObj := mb.ItemById("TSDB_VALIDATION_PARAMETERS").Bind;
FC := FCObj As IRubricator;
//Get dictionary to which the "CITY"nbsp;attribute is referrednbsp;
LinkedDict := FC.Facts.Attributes.FindById("CITY").ValuesObject;
Dim := LinkedDict.Open(Null) As IDimInstance;
DimSel := Dim.CreateSelection;
//Get validation rule
ValidObj := Mb.ItemByIdNamespace("VALIDATION_TREND", FCObj.Key).Edit;
ValidFilter := ValidObj As IValidationFilter;
// Get validation rule parameters
Trend := ValidFilter.Details As IValidationTrend;
// Set comparison expression
Comparator := Trend.SelectionComparatorData;
Comparator.Clear;
ComparVal := Comparator.Add(DimSel);
ComparVal.Element := 1;
Debug.WriteLine(ComparVal.Selection.ToString);
// Clear validation filter
Trend.SelectionFilter.Clear;
// Save validation rule
ValidObj.Save;
// Get rule execution parameters
ExecSett := ValidFilter.CreateExecuteSettings;
Analyzer := UiErAnalyzer1.ErAnalyzer;
ExecSett.Laner := Analyzer.Laner;
// Execute validation rule
ExecRun := ValidFilter.Execute(ExecSett);
DiagRep := New DiagnosticReport.Create;
DiagRep.Run := ExecRun;
DiagRep.EaxAnalyzer := Analyzer;
End Sub UserProc;
After executing the example the series, which trend is used for comparison, is changed for the VALIDATION_TREND validation rule. The compared series is set by the first element of the dictionary used as a base for the CITY mandatory attribute. Name of this element is displayed in the console window. The rule is executed for the workbook displayed in WorkbookDocumentViewerBox1.
The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Rds;
…
Sub UserProc();
Var
mb: IMetabase;
FCObj: IMetabaseObject;
FC: IRubricator;
LinkedDict: IMetabaseObjectDescriptor;
Dim: IDimInstance;
DimSel: IDimSelection;
ValidObj: IMetabaseObject;
ValidFilter: IValidationFilter;
Trend: IValidationTrend;
Comparator: IValidationSelectionValueList;
ComparVal: IValidationSelectionValue;
ExecSett: ValidationExecuteSettings;
Analyzer: EaxAnalyzer;
ExecRun: IValidationExecRun;
DiagRep: IDiagnosticReport;
Begin
mb := Self.Metabase;
// Get time series database
FCObj := mb.ItemById["TSDB_VALIDATION_PARAMETERS"].Bind();
FC := FCObj As IRubricator;
//Get dictionary to which the "CITY"nbsp;attribute is referrednbsp;
LinkedDict := FC.Facts.Attributes.FindById("CITY").ValuesObject;
Dim := LinkedDict.Open(Null) As IDimInstance;
DimSel := Dim.CreateSelection();
//Get validation rule
ValidObj := Mb.ItemByIdNamespace["VALIDATION_TREND", FCObj.Key].Edit();
ValidFilter := ValidObj As IValidationFilter;
// Get validation rule parameters
Trend := ValidFilter.Details As IValidationTrend;
// Set comparison expression
Comparator := Trend.SelectionComparatorData;
Comparator.Clear();
ComparVal := Comparator.Add(DimSel);
ComparVal.Element := 1;
System.Diagnostics.Debug.WriteLine(ComparVal.Selection.ToString("", ",", False));
// Clear validation filter
Trend.SelectionFilter.Clear();
// Save validation rule
ValidObj.Save();
// Get rule execution parameters
ExecSett := ValidFilter.CreateExecuteSettings();
Analyzer := uiErAnalyzerNet1.ErAnalyzer.ErAnalyzer;
ExecSett.Laner := Analyzer.Laner;
// Execute validation rule
ExecRun := ValidFilter.Execute(ExecSett);
DiagRep := New DiagnosticReport.Create();
DiagRep.Run := ExecRun;
DiagRep.EaxAnalyzer := Analyzer;
End Sub UserProc;
See also: