The following is set in repository parameters:
Global handler of report calculation.
Global handler of report calculation with updates.
Global event handler.
NOTE. Only Fore units are used as an event handler.
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:
<font color="#008080">Public</font><font color="#000000"> </font><font color="#008080">Class</font><font color="#000000"> EventsClass: ExpressEvents<br /> param_comment: string;<br /> <br /> </font><font color="#008080">Public</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> OnAfterExecuteAnalyzer(Args: IEaxAfterExecuteEventArgs);<br /> </font><font color="#008080">Var</font><font color="#000000"> DSSet: IDimSelectionSet;<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> DSSet := args.AnalyzerData.SheetData.Selection;<br /> </font><font color="#008000">// get row-list of selected elements in dimensions of express report<br /> </font><font color="#000000"> param_comment := GetEaXReportParams(DSSet);<br /> </font><font color="#008000">// add record to access protocol with required comment<br /> </font><font color="#000000"> args.AnalyzerData.Descriptor.CheckAndAudit(</font><font color="#008000">2</font><font color="#000000">, </font><font color="#800000">"Execute report."</font><font color="#000000"> + param_comment);<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> OnAfterExecuteAnalyzer;<br /> <br /> </font><font color="#008080">Public</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> OnAfterPrintAnalyzer(Args: IEaxAfterPrintEventArgs);<br /> </font><font color="#008080">Var</font><font color="#000000"> DSSet: IDimSelectionSet;<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> DSSet := args.AnalyzerData.SheetData.Selection;<br /> param_comment := GetEaXReportParams(DSSet);<br /> Debug.WriteLine(param_comment);<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> OnAfterPrintAnalyzer;<br /> <br /> </font><font color="#008080">Public</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> OnAfterExportAnalyzer(Args: IEaxAfterExportEventArgs);<br /> </font><font color="#008080">Var</font><font color="#000000"> DSSet: IDimSelectionSet;<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> DSSet := args.AnalyzerData.SheetData.Selection;<br /> param_comment := GetEaXReportParams(DSSet);<br /> Debug.WriteLine(param_comment);<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> OnAfterExportAnalyzer;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Class</font><font color="#000000"> EventsClass;<br /> </font><font color="#008000">// get row-list of selected elements in dimensions of express-report<br /> </font><font color="#008080">Public</font><font color="#000000"> </font><font color="#008080">Function</font><font color="#000000"> GetEaXReportParams(ExArDsset: IDimSelectionSet): string;<br /> </font><font color="#008080">Var</font><font color="#000000"> ControlStr: string;<br /> i, DimCnt: integer;<br /> DimName: string;<br /> selection: idimselection;<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> dimCnt := ExArDsset.Count;<br /> ControlStr := </font><font color="#800000">"Report parameters: "</font><font color="#000000">;<br /> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> dimCnt - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br /> DimName := ExArDsset.Item(i).Dimension.Name;<br /> ControlStr := ControlStr + DimName + </font><font color="#800000">": "</font><font color="#000000">;<br /> selection := ExArDsset.Item(i);<br /> </font><font color="#008080">If</font><font color="#000000"> selection.SelectedCount = </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">Then</font><font color="#000000"><br /> ControlStr := ControlStr + </font><font color="#800000">": <not selected>. "</font><font color="#000000">;<br /> </font><font color="#008080">Else</font><font color="#000000"><br /> ControlStr := ControlStr + </font><font color="#800000">": "</font><font color="#000000"> + Selection.ToString;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">If</font><font color="#000000">;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br /> </font><font color="#008080">Return</font><font color="#000000"> ControlStr;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Function</font><font color="#000000"> 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:
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 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:
Send Error Messages by Email. Specify email address, to which error reports should be sent. Default email client installed in user operating system is used to send email messages
Error Handling. Select one of the available radio buttons:
Default. On working, Foresight Analytics Platform will use the built-in mechanism of error handling: if error occurs, the appropriate window with information about error and ability to send it by the specified email
Use Custom Error Handling. Errors occurring in Foresight Analytics Platform can be handled in the function with the following signature:
Function <function name>(<parameter name>: IException): Boolean
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: