Global Event Handlers

The following is set in repository parameters:

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:

  1. Go to the object navigator.

  2. Select the Tools > Parameters main menu item.

  3. 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:

  1. Select the Global Handler of Report Calculation and Express Reports checkboxes.

  2. Select the assembly, unit or form where class implementing express report events are described.

  3. 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:

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:

To set up update event handling:

  1. Select the Global Handler of Update Events checkbox.

  2. Select the assembly, unit or form where the class implementing update events is described.

  3. 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:

Application Functionality Enhancement