Console Application

Traditionally, the functionality of any XAF module is performed in the main application. However, experience has shown that large-scale business applications have a number of specific tasks which it is advisable to run in batch mode, automatically, perhaps scheduled. These are the process of import (or export) data, or the generation of huge reports. Absolutely inappropriate to use for such purposes, full-bodied Win or Web application that loads dozens of modules, spends resources on a powerful graphical user interface, while the interaction with the user is minimal or not required.

One of the Xafari component is a mechanism to run particular functions in console mode, loading only the required modules. Of course, these functions must be implemented in a special way.

Xafari module provides infrastructure to implement the functions intended for the run using command line. These functions will be called Commands. The Commands can be exist in any XAF module. Framework also supplies a special RunCmd.exe console utility to execute Commands. In accordance with the wishes of customers, a special attention is given to flexible settings of the authentication system.

To implement the Command, the developer need to add Xafari.dll assembly to the module. Xafari.Commands namespace contains all required classes and interfaces. The image below shows the corresponding class diagram.


Module must implements ICommandEnumerator interface, this is to ensure that the RunCmd will "see" the Comands. Each Command is represented by the individual separate class that implements either ICommand or ICommandExtIO interfaces. The code, which directly determines the useful operation, i.e. provides execution of Command, must be placed in the Execute method. The method receives a collection of key-value pairs representing the parameters of the Command, it also receives a reference to the instance of the XAF application, which invoke the Command. CommandBase and CommandExtIOBase abstract classes provides operations, that are demanded when implementing most Commands. This will significantly simplify the work of the developer.

It is important to correctly configure the RunCmd utility to the needs of specific application. Configuration options are specified in a standard RunCmd.exe.config configuration file. Authentication mechanisms defined for RunCmd.exe, must comply with the authentication mechanism of the main application, it is because the Commands interact with the application database.

To learn more about the Xafari Console Application technology, refer to the following topics:

How to