The following is set in repository parameters:
Global handler of report calculation.
Global handler of report calculation with updates.
NOTE. As event handlers, one uses only Fore units, except for the units located in internal structure of business applications, components, data entry forms and containers.
To open the Event Handling tab of the Parameters dialog box:
Go to the object navigator.
Select the Tools > Parameters main menu item.
Go to the Event Handling tab after the Parameters dialog box opens.
NOTE. Event handling can be enabled only in the desktop application.
The event handler sends express report parameters used for calculation and enables the user to perform the action determined by the code on each event occurrence.
To set up express report event handling:
Select the Global Handler of Report Calculation and Express Reports checkboxes.
Select the assembly, unit or form where class implementing express report events are described.
Select a class containing event handlers. The Class drop-down list will display all classes of selected assembly, unit or form.
Handling of events occurred on working with report can be set up for express reports:
OnBeforeExecuteAnalyzer - implements an event occurred before table calculation.
OnAfterExecuteAnalyzer - implements an event, which occurs after table calculation.
OnBeforeExportAnalyzer - implements an event, which occurs before report export.
OnAfterExportAnalyzer - implements an event, which occurs after report export.
OnBeforePrintAnalyzer - implements an event, which occurs before report printing.
OnAfterPrintAnalyzer - implements an event, which occurs after report printing.
To execute the example, create a unit and connect it as event handler for express reports. Connect the Dimensions, Export, Express, Forms, Metabase system assemblies in the unit. Add event handlers:
Public Class EventsClass: ExpressEvents
param_comment: string;
Public Sub OnAfterExecuteAnalyzer(Args: IEaxAfterExecuteEventArgs);
Var DSSet: IDimSelectionSet;
Begin
DSSet := args.AnalyzerData.SheetData.Selection;
// get list string of selected elements in express report dimensions
param_comment := GetEaxReportParams(DSSet);
// add a record to access protocol with required comment
args.AnalyzerData.Descriptor.CheckAndAudit(2, "Report execution." + param_comment);
End Sub OnAfterExecuteAnalyzer;
Public Sub OnAfterPrintAnalyzer(Args: IEaxAfterPrintEventArgs);
Var DSSet: IDimSelectionSet;
Begin
DSSet := args.AnalyzerData.SheetData.Selection;
param_comment := GetEaxReportParams(DSSet);
Debug.WriteLine(param_comment);
End Sub OnAfterPrintAnalyzer;
Public Sub OnAfterExportAnalyzer(Args: IEaxAfterExportEventArgs);
Var DSSet: IDimSelectionSet;
Begin
DSSet := args.AnalyzerData.SheetData.Selection;
param_comment := GetEaxReportParams(DSSet);
Debug.WriteLine(param_comment);
End Sub OnAfterExportAnalyzer;
End Class EventsClass;
// get list string of selected elements in express report dimensions
Public Function GetEaxReportParams(ExArDsset: IDimSelectionSet): string;
Var ControlStr: string;
i, DimCnt: integer;
DimName: string;
selection: idimselection;
Begin
dimCnt := ExArDsset.Count;
ControlStr := "Report parameters: ";
For i := 0 To dimCnt - 1 Do
DimName := ExArDsset.Item(i).Dimension.Name;
ControlStr := ControlStr + DimName + ": ";
selection := ExArDsset.Item(i);
If selection.SelectedCount = 0 Then
ControlStr := ControlStr + ": <not selected>. ";
Else
ControlStr := ControlStr + ": " + Selection.ToString;
End If;
End For;
Return ControlStr;
End Function GetEaxReportParams;
After executing the example, when table update event occurs, the information about selected dimensions is recorded to the access protocol. On printing and export information is selected and displayed in the development console. Example of line:
Note: Report execution. Report parameters: Facts: : CountryFact: : Albania,Belgium,Bosnia and Herzegovina,Croatia,Cyprus,Czech Republic,Grenland,Hungary,Italy,Latvia Factors: : GDP Growth (% yearly)Calendar: : 2005,2006,2007,2008,2009,2010
The update handler generates information about update installation process:
Date and time.
User name.
Workstation name.
Update name.
List of objects and their versions (previous and new).
Messages of each object update.
Update status.
To set up update event handling:
Select the Global Handler of Update Events checkbox.
Select the assembly, unit or form where the class implementing update events is described.
Select the class containing event handlers. The Class drop-down list contains all classes of selected assembly, unit or form.
NOTE. The class must inherit the UpdateCallBack class and contain the method with the following signature:
Function OnCallBack(<param1>: MetabaseUpdateCallbackReason; <param1>: IMetabaseUpdate) : Boolean.
Example of update event handler. Add a link to the Metabase system assembly in the unit. Add an event handler.
Public Class UpdateHandlerClass: UpdateCallBack
Function OnCallback(Reason: MetabaseUpdateCallbackReason; Update: IMetabaseUpdate): Boolean;
Begin
//Check update application modes
Select Case Reason
Case MetabaseUpdateCallbackReason.ApplyCoreEnd: //actions on finishing update application from core
Case MetabaseUpdateCallbackReason.ApplyCoreStart: //actions on update application callback from core
Case MetabaseUpdateCallbackReason.ApplyUI: //actions on update application callback from interface
Case MetabaseUpdateCallbackReason.SaveUI: //actions on update save callback from interface
Case MetabaseUpdateCallbackReason.SaveCore: //actions on update save callback from core
Case MetabaseUpdateCallbackReason.LoadCoreEnd: //actions on update read end from core
End Select;
return False; //without interruption of system action
End Function OnCallback;
End Class UpdateHandlerClass;
The example execution result depends on the specified actions for MetabaseUpdateCallbackReason calculation.
See also: