Persistate

Controller classes

Hide Navigation Pane

Controller classes

Previous topic Next topic No directory for this topic  

Controller classes

Previous topic Next topic Topic directory requires JavaScript JavaScript is required for the print function Mail us feedback on this topic!  

Persistate generates one class in the Controller module for every operation group in your definition file.  The class name will be of the format <operation group name>Operations, so the class generated for the operation group Action will be called ActionOperations and be written to file ActionOperations.cs.  note that if the operation group contains no operations which are not marked as user interface operations (see Operation and Operation Group Definition), then no class is generated.

Within each class, Persistate generates one method for each operation in the group which is not defined as a user interface operation.  The method name will be of the format Execute<operation name>, where the operation name is the Pascal case version of the name you give the operation in the definition file.  For example, the method for the operation receive books will be called ExecuteReceiveBooks.  See The ActionOperations controller class for an example of a generated class.

The generated execute methods are the starting points for all the business logic in your application. You implement this logic by writing code in the generated class or other classes in the Controller or Model modules.  Remember, however, that the Model module is also accessible from user interface modules, which have limited capability to make changes to the persistent tree.  It is best, therefore, to code operations which modify the persistent tree in the Controller, though this is not a hard and fast rule.

The execute methods. as generated, are just stubs, which return a 'not implemented' message.  They take a parameter of the type Execution.  This object contains all the context that you need while implementing the operation code.  It has properties for the current Session, user interface (UI), the Target object and TargetCollection, and the Operation being executed.  You can add any number of other formal parameters to an execute method, however you will only be able to supply extra actual parameters when executing the operation programmatically using Operation.Execute.

Operation execute methods are called by the Persistate runtime, or you can call them (indirectly) yourself by using the Operation.Execute method.  Persistate calls an execute method when the operation is requested from the user interface, for example by selecting a menu option or clicking a toolbar button.  If your package is running in Viewer-Server mode, then operation requests in the viewer, even using Operation.Execute, will cause the appropriate  execute method to be called in the server.

Execute methods return an ExecutionResult object.  You use this object to tell Persistate how to complete the execution of the operation.  For example, setting its ResultAction property to ResultAction.Commit causes Persistate to synchronise all changes you have made to persistent storage, whereas ResultAction.Rollback does not synchronise, but rolls back the changes in memory.  You can also set a popup message, status message, exception, and specify a handler to deal with any exception during the synchronisation.  See the API documentation for details.