Move(FromIndex: Integer; ToIndex: Integer);
Move(FromIndex: integer; ToIndex: integer);
FromIndex. Index of validation rule position from which validation rule must be moved.
ToIndex. Index of the position, to which validation rule must be moved.
The Move method moves validation chain elements.
The method is executed only if the collection contains more than one validation rule.
Executing the example requires that the repository contains a regular report with the REG_REPORT_VALIDATIONS identifier, for which time series database is a data source. The report contains two validation rules.
Add links to the Drawing, Express, Laner, Metabase, Ms, Pivot, Report, Tab system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Validation: IValidationFilter;
Report: IPrxReport;
DataArea: IEaxDataArea;
AreaSlice: IEaxDataAreaSlice;
EaxValidations: IEaxDataAreaValidations;
EaxValidation, EaxValidation1: IEaxDataAreaValidation;
i, k, m, index: integer;
Grid: IEaxGrid;
DiagReport: IDiagnosticReport;
Chain: IEaxDataAreaValidationChain;
ValidationLink: IEaxDataAreaValidationLink;
Validations: IEaxDataAreaValidations;
ValidationsCount: Integer;
LinkSource: IEaxDataAreaValidation;
Id: String;
ValidFilterSetting: IValidationFilterSettings;
TabCellStyle: ITabCellStyle;
Color: IGxColor;
Brush: IGxSolidBrush;
DataAreaValidation: IEaxDataAreaValidation;
Level: IValidationLevel;
Begin
// Get repository
MB := MetabaseClass.Active;
// Get regular report
Report := MB.ItemById("REG_REPORT_VALIDATIONS").Edit As IPrxReport;
// Get analytical data area
DataArea := Report.DataArea;
// Get data slice
AreaSlice := DataArea.Slices.Item(0);
For i := 0 To AreaSlice.Views.Count - 1 Do
If Areaslice.Views.Item(i) Is IEaxGrid Then
// Get data table
Grid := AreaSlice.Views.Item(i) As IEaxGrid;
// Create diagnostic report
DiagReport := New DiagnosticReport.Create;
{Link validation chain of diagnostic report with collection
regular report validation rules}
DiagReport.Grid := Grid;
Break;
End If;
End For;
// Get validation chain
Chain := DiagReport.Chain;
// Get validation collection in chain
Validations := Chain.Validations;
// Get and display to the console number of validations in chain
ValidationsCount := Validations.Count;
Debug.WriteLine("Number of validations in chain = " + ValidationsCount.ToString);
// Display to the console alice parent object identifier
For k := 0 To Chain.Count - 1 Do
ValidationLink := Chain.Item(k);
If ValidationLink.Enabled = False Then
ValidationLink.Enabled := True;
End If;
LinkSource := ValidationLink.Source;
Id := LinkSource.Id;
Debug.WriteLine("Slice parent object identifier - " + Id);
End For;
// Move elements of validation chain
Chain.Move(1, 0);
// Get collection of validation rules
EaxValidations := AreaSlice.Validations;
// Clear collection of validation rules
EaxValidations.Clear;
// Create validation rules
EaxValidation := EaxValidations.Create;
// Add new validation rule
EaxValidation1 := EaxValidations.Add(EaxValidation);
// Display to the console index of validation rule
For m := 0 To EaxValidations.Count - 1 Do
DataAreaValidation := EaxValidations.Item(m);
Index := EaxValidations.IndexOf(DataAreaValidation);
Debug.WriteLine("Index of validation rule = " + Index.ToString);
End For;
// If rule is found by the 1 key, it will be deleted
If EaxValidations.FindByKey(1) <> Null Then
EaxValidations.RemoveByKey(1);
End If;
// Get filter
Validation := EaxValidation.Filter As IValidationFilter;
If Validation <> Null Then
// To calculate validation, use date of data start/end
Validation.StartDateSettings.DateOptions := ValidationDateOptions.DependsFromData;
Validation.EndDateSettings.DateOptions := ValidationDateOptions.DependsFromData;
// Get filter settings
ValidFilterSetting := Validation.Settings;
// Validation type - comparison with number
Validation.Kind := ValidationDetailsKind.Level;
// Get settings of validation type
Level := Validation.Details As IValidationLevel;
// Comparison operator - bigger than the specified number
Level.ComparisonValue.ComparisonOperator := ValidationComparisonOperator.More;
// Set number for comparison
Level.ComparisonValue.Value1 := 0;
// Get cell style
TabCellStyle := ValidFilterSetting.CellStyle.TabStyle;
// Change background color of cells that satisfy validation rule
Color := New GxColor.CreateRGB(120, 0, 120);
Brush := New GxSolidBrush.Create(Color);
TabCellStyle.BackgroundBrush := Brush;
// Change text of cells that satisfy validation rule
TabCellStyle.Text := "Text";
End If;
// Update report and save changes
Report.Recalc;
(Report As IMetabaseObject).Save;
End Sub UserProc;
After executing the example:
The console window displays the number of validations in chain.
The console window displays identifier of slice data source parent object.
Validation chain element is moved.
The console window displays validation rule index.
If the rule with key 1 is found, it is removed.
A validation rule with parameters is created, by which table is formatted.
The requirements and result of the Fore.NET Example execution match with those in the Fore Example.
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Laner;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Pivot;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Tab;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Validation: IValidationFilter;
Report: IPrxReport;
DataArea: IEaxDataArea;
AreaSlice: IEaxDataAreaSlice;
EaxValidations: IEaxDataAreaValidations;
EaxValidation, EaxValidation1: IEaxDataAreaValidation;
i, k, m, index: integer;
Grid: EaxGrid;
DiagReport: IDiagnosticReport = New DiagnosticReportClass();
Chain: IEaxDataAreaValidationChain;
ValidationLink: IEaxDataAreaValidationLink;
Validations: IEaxDataAreaValidations;
ValidationsCount: Integer;
LinkSource: IEaxDataAreaValidation;
Id: String;
ValidFilterSetting: IValidationFilterSettings;
TabCellStyle: ITabCellStyle;
Color: GxColor = New GxColorClass_2();
Brush: GxSolidBrush = New GxSolidBrushClass();
DataAreaValidation: IEaxDataAreaValidation;
level: IValidationLevel;
Begin
// Get repository
MB := Params.Metabase;
// Get regular report
Report := MB.ItemById["REG_REPORT_VALIDATIONS"].Edit() As IPrxReport;
// Get analytical data area
DataArea := Report.DataArea;
// Get data slice
AreaSlice := DataArea.Slices.Item[0];
For i := 0 To AreaSlice.Views.Count - 1 Do
If Areaslice.Views.Item[i] Is IEaxGrid Then
// Get data table
Grid := AreaSlice.Views.Item[i] As EaxGrid;
{Link validation chain of diagnostic report with collection
regular report validation rules}
DiagReport.Grid := Grid;
Break;
End If;
End For;
// Get validation chain
Chain := DiagReport.Chain;
// Get validation collection in chain
Validations := Chain.Validations;
// Get and display to the console number of validations in chain
ValidationsCount := Validations.Count;
System.Diagnostics.Debug.WriteLine
("Number of validations in chain = " + ValidationsCount.ToString());
// Display to the console alice parent object identifier
For k := 0 To Chain.Count - 1 Do
ValidationLink := Chain.Item[k];
If ValidationLink.Enabled = False Then
ValidationLink.Enabled := True;
End If;
LinkSource := ValidationLink.Source;
Id := LinkSource.Id;
System.Diagnostics.Debug.WriteLine
("Slice parent object identifier - " + Id);
End For;
// Move elements of validation chain
Chain.Move(1, 0);
// Get collection of validation rules
EaxValidations := AreaSlice.Validations;
// Clear collection of validation rules
EaxValidations.Clear();
// Create validation rules
EaxValidation := EaxValidations.Create();
// Add new validation rule
EaxValidation1 := EaxValidations.Add(EaxValidation);
// Display to the console index of validation rule
For m := 0 To EaxValidations.Count - 1 Do
DataAreaValidation := EaxValidations.Item[m];
Index := EaxValidations.IndexOf(DataAreaValidation);
System.Diagnostics.Debug.WriteLine
("Validation rule index = " + Index.ToString());
End For;
// If rule is found by the 1 key, it will be deleted
If EaxValidations.FindByKey(1) <> Null Then
EaxValidations.RemoveByKey(1);
End If;
// Get filter
Validation := EaxValidation.Filter As IValidationFilter;
If Validation <> Null Then
// To calculate validation, use date of data start/end
Validation.StartDateSettings.DateOptions := ValidationDateOptions.vdoDependsFromData;
Validation.EndDateSettings.DateOptions := ValidationDateOptions.vdoDependsFromData;
// Get filter settings
ValidFilterSetting := Validation.Settings;
// Validation type - comparison with number
Validation.Kind := ValidationDetailsKind.vdkLevel;
// Get settings of validation type
Level := Validation.Details As IValidationLevel;
// Comparison operator - bigger than the specified number
Level.ComparisonValue.ComparisonOperator := ValidationComparisonOperator.vcoMore;
// Set number for comparison
Level.ComparisonValue.Value1 := 0;
// Get cell style
TabCellStyle := ValidFilterSetting.CellStyle.TabStyle;
// Change background color of cells that satisfy validation rule
Color.CreateRGB(120, 0, 120);
Brush.Create(Color);
TabCellStyle.BackgroundBrush := Brush;
// Change text of cells that satisfy validation rule
TabCellStyle.Text := "Text";
End If;
// Update report and save changes
Report.Recalc();
(Report As IMetabaseObject).Save();
End Sub;
See also: