Executing the example requires the following objects in the repository:
A time series database with the TSDB identifier.
A validation rule with the NEWVALRULE identifier created in the TSDB time series database. (See Creating a Validation Rule).
A workbook with the OBJ123 identifier created using the time series database with the TSDB identifier. The validation rule is applied to the data of this workbook.
Add links to the following system assemblies:
Ms.
Metabase (only for Fore).
Cubes.
Dimensions.
Create a form and add the following components to it:
UiErAnalyzer with the UiErAnalyzer1 identifier. Select the workbook with the OBJ123 identifier in the Object property of the component. If the Active property is set to False, set it to True.
LanerBox with the LanerBox1 identifier.Select the UiErAnalyzer1 object in the Object property of the component.
Button with the Button1 identifier. Below is the function which is executed on clicking the button:
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Mb: IMetabase;
RubrKey: Integer;
ValidObj: IMetabaseObject;
ValidFilter: IValidationFilter;
DateSettings: IValidationDateSettings;
FilterSett: IValidationFilterSettings;
Level: IValidationLevel;
ComparisonValue: IValidationComparisonValue;
ValidExecSett: IValidationExecuteSettings;
Analyzer: IEaxAnalyzer;
ValidExecRun: IValidationExecRun;
DiagRep: IDiagnosticReport;
Begin
Mb := MetabaseClass.Active;
// Get a validation rule
RubrKey := Mb.GetObjectKeyById("TSDB");
ValidObj := Mb.ItemByIdNamespace("NEWVALRULE", RubrKey).Edit;
ValidFilter := ValidObj As IValidationFilter;
// Set start and end dates of rule calculation
DateSettings := ValidFilter.StartDateSettings;
DateSettings.DateOptions := ValidationDateOptions.DependsFromData;
DateSettings := ValidFilter.EndDateSettings;
DateSettings.DateOptions := ValidationDateOptions.DependsFromData;
// Set calendar level to calculate the rule
ValidFilter.Level := DimCalendarLevel.Year;
// Set threshold value for rule exceptions
ValidFilter.ExceptionsLimit := 500000;
// Set parameters for calculation of the rule
FilterSett := ValidFilter.Settings;
// Set the rule type
ValidFilter.Kind := ValidationDetailsKind.Level;
Level := ValidFilter.Details As IValidationLevel;
// Set conditions of the rule
ComparisonValue := Level.ComparisonValue;
ComparisonValue.ComparisonOperator := ValidationComparisonOperator.More;
ComparisonValue.Percentage := False;
ComparisonValue.Value1 := 100;
// Save changes in the rule
ValidObj.Save;
// Execute the rule in the loaded workbook
ValidExecSett := New ValidationExecuteSettings.Create;
Analyzer := UiErAnalyzer1.ErAnalyzer;
ValidExecSett.Laner := Analyzer.Laner;
ValidExecRun := ValidFilter.Execute(ValidExecSett);
DiagRep := New DiagnosticReport.Create;
DiagRep.Run := ValidExecRun;
DiagRep.EaxAnalyzer := Analyzer;
End Sub Button1OnClick;
After executing the example, on clicking the button, values greater than 100 are highlighted in red in the table.
Create a .NET form and add the following components to it:
UiErAnalyzer with the uiErAnalyzerNet1 identifier. Select the workbook with the OBJ123 identifier in the Object property of the component. If the Active property is set to False, set it to True.
LanerBoxNet with the lanerBoxNet1 identifier.Select the uiErAnalyzerNet1 object in the Object property of the component.
Button with the button1 identifier. Below is the function which is executed on clicking the button:
Imports Prognoz.Platform.Interop.Laner;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Drawing;
...
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
Mb: IMetabase;
RubrKey: Uinteger;
ValidObj: IMetabaseObject;
ValidFilter: IValidationFilter;
DateSettings: IValidationDateSettings;
FilterSett: IValidationFilterSettings;
Level: IValidationLevel;
ComparisonValue: IValidationComparisonValue;
ValidExecSett: ValidationExecuteSettings;
Analyzer: EaxAnalyzer;
ValidExecRun: IValidationExecRun;
DiagRep: IDiagnosticReport;
GxColorCls: GxColorClassClass = New GxColorClassClass();
Begin
Mb := Self.Metabase;
// Get a validation rule
RubrKey := Mb.GetObjectKeyById("TSDB");
ValidObj := Mb.ItemByIdNamespace["NEWVALRULE", RubrKey].Edit();
ValidFilter := ValidObj As IValidationFilter;
// Set start and end dates of rule calculation
DateSettings := ValidFilter.StartDateSettings;
DateSettings.DateOptions := ValidationDateOptions.vdoDependsFromData;
DateSettings := ValidFilter.EndDateSettings;
DateSettings.DateOptions := ValidationDateOptions.vdoDependsFromData;
// Set calendar level to calculate the rule
ValidFilter.Level := DimCalendarLevel.dclYear;
// Set threshold value for rule exceptions
ValidFilter.ExceptionsLimit := 500000;
// Set parameters for calculation of the rule
FilterSett := ValidFilter.Settings;
FilterSett.FontColor := GxColorCls.FromName("Red");
// Set the rule type
ValidFilter.Kind := ValidationDetailsKind.vdkLevel;
Level := ValidFilter.Details As IValidationLevel;
// Set conditions of the rule
ComparisonValue := Level.ComparisonValue;
ComparisonValue.ComparisonOperator := ValidationComparisonOperator.vcoMore;
ComparisonValue.Percentage := False;
ComparisonValue.Value1 := 100;
// Save changes in the rule
ValidObj.Save();
// Execute the rule in the loaded workbook
ValidExecSett := New ValidationExecuteSettings.Create();
Analyzer := uiErAnalyzerNet1.ErAnalyzer.ErAnalyzer;
ValidExecSett.Laner := Analyzer.Laner;
ValidExecRun := ValidFilter.Execute(ValidExecSett);
DiagRep := New DiagnosticReport.Create();
DiagRep.Run := ValidExecRun;
DiagRep.EaxAnalyzer := Analyzer;
End Sub;
The result of example execution matches with that of the Fore example.
See also: