Global Event Handlers

The following is set in repository parameters:

NOTE. Only Fore units are used as an event handler.

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:

<font color="#008080">Public</font><font color="#000000">&nbsp;</font><font color="#008080">Class</font><font color="#000000">&nbsp;EventsClass:&nbsp;ExpressEvents<br /> &nbsp;&nbsp;&nbsp;&nbsp;param_comment:&nbsp;string;<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Public</font><font color="#000000">&nbsp;</font><font color="#008080">Sub</font><font color="#000000">&nbsp;OnAfterExecuteAnalyzer(Args:&nbsp;IEaxAfterExecuteEventArgs);<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Var</font><font color="#000000">&nbsp;DSSet:&nbsp;IDimSelectionSet;<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Begin</font><font color="#000000"><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DSSet&nbsp;:=&nbsp;args.AnalyzerData.SheetData.Selection;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">//&nbsp;get&nbsp;row-list&nbsp;of selected&nbsp;elements&nbsp;in&nbsp;dimensions&nbsp;of express report<br /> </font><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param_comment&nbsp;:=&nbsp;GetEaXReportParams(DSSet);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008000">//&nbsp;add&nbsp;record&nbsp;to&nbsp;access&nbsp;protocol&nbsp;with&nbsp;required&nbsp;comment<br /> </font><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;args.AnalyzerData.Descriptor.CheckAndAudit(</font><font color="#008000">2</font><font color="#000000">,&nbsp;</font><font color="#800000">&quot;Execute&nbsp;report.&quot;</font><font color="#000000">&nbsp;+&nbsp;param_comment);<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">Sub</font><font color="#000000">&nbsp;OnAfterExecuteAnalyzer;<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Public</font><font color="#000000">&nbsp;</font><font color="#008080">Sub</font><font color="#000000">&nbsp;OnAfterPrintAnalyzer(Args:&nbsp;IEaxAfterPrintEventArgs);<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Var</font><font color="#000000">&nbsp;DSSet:&nbsp;IDimSelectionSet;<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Begin</font><font color="#000000"><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DSSet&nbsp;:=&nbsp;args.AnalyzerData.SheetData.Selection;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param_comment&nbsp;:=&nbsp;GetEaXReportParams(DSSet);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Debug.WriteLine(param_comment);<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">Sub</font><font color="#000000">&nbsp;OnAfterPrintAnalyzer;<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Public</font><font color="#000000">&nbsp;</font><font color="#008080">Sub</font><font color="#000000">&nbsp;OnAfterExportAnalyzer(Args:&nbsp;IEaxAfterExportEventArgs);<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Var</font><font color="#000000">&nbsp;DSSet:&nbsp;IDimSelectionSet;<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Begin</font><font color="#000000"><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DSSet&nbsp;:=&nbsp;args.AnalyzerData.SheetData.Selection;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param_comment&nbsp;:=&nbsp;GetEaXReportParams(DSSet);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Debug.WriteLine(param_comment);<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">Sub</font><font color="#000000">&nbsp;OnAfterExportAnalyzer;<br /> </font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">Class</font><font color="#000000">&nbsp;EventsClass;<br /> </font><font color="#008000">//&nbsp;get&nbsp;row-list&nbsp;of selected&nbsp;elements&nbsp;in&nbsp;dimensions&nbsp;of express-report<br /> </font><font color="#008080">Public</font><font color="#000000">&nbsp;</font><font color="#008080">Function</font><font color="#000000">&nbsp;GetEaXReportParams(ExArDsset:&nbsp;IDimSelectionSet):&nbsp;string;<br /> </font><font color="#008080">Var</font><font color="#000000">&nbsp;ControlStr:&nbsp;string;<br /> &nbsp;&nbsp;&nbsp;&nbsp;i,&nbsp;DimCnt:&nbsp;integer;<br /> &nbsp;&nbsp;&nbsp;&nbsp;DimName:&nbsp;string;<br /> &nbsp;&nbsp;&nbsp;&nbsp;selection:&nbsp;idimselection;<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> &nbsp;&nbsp;&nbsp;&nbsp;dimCnt&nbsp;:=&nbsp;ExArDsset.Count;<br /> &nbsp;&nbsp;&nbsp;&nbsp;ControlStr&nbsp;:=&nbsp;</font><font color="#800000">&quot;Report&nbsp;parameters:&nbsp;&quot;</font><font color="#000000">;<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">For</font><font color="#000000">&nbsp;i&nbsp;:=&nbsp;</font><font color="#008000">0</font><font color="#000000">&nbsp;</font><font color="#008080">To</font><font color="#000000">&nbsp;dimCnt&nbsp;-&nbsp;</font><font color="#008000">1</font><font color="#000000">&nbsp;</font><font color="#008080">Do</font><font color="#000000"><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DimName&nbsp;:=&nbsp;ExArDsset.Item(i).Dimension.Name;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ControlStr&nbsp;:=&nbsp;ControlStr&nbsp;+&nbsp;DimName&nbsp;+&nbsp;</font><font color="#800000">&quot;:&nbsp;&quot;</font><font color="#000000">;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;selection&nbsp;:=&nbsp;ExArDsset.Item(i);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">If</font><font color="#000000">&nbsp;selection.SelectedCount&nbsp;=&nbsp;</font><font color="#008000">0</font><font color="#000000">&nbsp;</font><font color="#008080">Then</font><font color="#000000"><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ControlStr&nbsp;:=&nbsp;ControlStr&nbsp;+&nbsp;</font><font color="#800000">&quot;:&nbsp;&lt;not&nbsp;selected&gt;.&nbsp;&quot;</font><font color="#000000">;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Else</font><font color="#000000"><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ControlStr&nbsp;:=&nbsp;ControlStr&nbsp;+&nbsp;</font><font color="#800000">&quot;:&nbsp;&quot;</font><font color="#000000">&nbsp;+&nbsp;Selection.ToString;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">If</font><font color="#000000">;<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">For</font><font color="#000000">;<br /> &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#008080">Return</font><font color="#000000">&nbsp;ControlStr;<br /> </font><font color="#008080">End</font><font color="#000000">&nbsp;</font><font color="#008080">Function</font><font color="#000000">&nbsp;GetEaXReportParams;</font>

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 after finishing update application from core
            Case MetabaseUpdateCallbackReason.ApplyCoreStart: //actions on calling update application from core
            Case MetabaseUpdateCallbackReason.ApplyUI: //actions on calling update application from interface
            Case MetabaseUpdateCallbackReason.SaveUI: //actions on calling update saving from interface
            Case MetabaseUpdateCallbackReason.SaveCore: //actions on calling update saving from core
            Case MetabaseUpdateCallbackReason.LoadCoreEnd: //actions on finishing reading update from core
        End Select;
        return False//without interrupting  system action
    End Function OnCallback;
End Class UpdateHandlerClass;

The example execution result depends on the specified actions for MetabaseUpdateCallbackReason calculation.

To set up handling options for errors occurring in Foresight Analytics Platform based systems, use the Error Handling tab in the Feedback section of the Parameters dialog box.

To open the Parameters dialog box

Specify the following parameters:

Select an assembly, unit or form, which contains function with appropriate signature, in the drop-down list. The list of selected unit, form or assembly functions satisfying this signature is displayed in the Functions drop-down list.

NOTE. The proper error handler enables the user to handle only the errors occurred in application code. Errors that can appear in the Foresight Analytics Platform core will be displayed in the corresponding window.

See also:

Enhancing Application Functionality