Client/Server Sample Application Classes

Most of the functionality in the Client/Server sample application is built into classes. Objects based on these classes are created in response to user actions.

CSEngine

When you run the application, an object is created in Csmain.prg based on the CSEngine class in Csprocs.prg:

oEngine = CREATEOBJECT('csengine')

The CSEngine class provides generic environment setup and cleanup and utility method, as well as methods that manage application functionality.

Method Description
DropTable Deletes a table on the back end database.
ExecuteTempSPT Execute SQL pass through commands and manage errors generated by the pass through.
ServerStart Create the business rule object that validates employee salaries.
ServerStop Releases the business rule object.
ServerValidateRow Validates data using the business object.

For information about these and other methods in the CSEngine class, look at the code in Csprocs.prg.

OpenDBC

After creating the oEngine object, code in Csmain.prg creates an object based on the OpenDBC form in Sample.vcx:

oStartForm = CREATEOBJECT('OpenDBC')

The OpenDBC form makes it possible for a user to open the sample database, exclusively or shared, to close the database, and to modify the connection to the back end database. You'll need a connection to a back-end database to upsize the table in this sample and access it as a remote view.

There is also code to create and show this form in the Click event of the Database button on the SampleApp form.

OpenDBC is a modal form. When you choose OK in the OpenDBC form, the following code is executed and program execution is continued.

RELEASE THISFORM
oEngine.Start = .T.

If the OpenDBC form was created in Csmain.prg, the following code executes when OpenDBC is closed, creating an instance of the SampleApp class in Sample.vcx:

IF oEngine.Start
   oCSApp = CREATEOBJECT('SampleApp')
   oCSApp.Show
ENDIF

SampleApp

SampleApp is the main form in the Client/Server sample application. This form contains a page frame with two pages. Controls on the first page make it possible for you to open the table, local view, and remote view; upsize the table; restore the original data in the table; and toggle the views online and offline. Controls on the second page make it possible for you to see and edit data in the selected table or view.

Code in the SampleApp form provides access to more encapsulated functionality by creating two additional objects as needed: Salaryrule and Conflicts.

SalaryRule

SalaryRule is a class in an Automation server. The project for the Automation server is Bizrules.pjx and the class is defined in Bizrules.prg:

DEFINE CLASS salaryrule AS Custom OLEPUBLIC

Code associated with the Click event of the chkRules check box makes a call to the StartServer method of CSEngine. Code in the StartServer method creates an instance of the SalaryRule class:

this.oServer = CREATEOBJECT('Bizrules.SalaryRule')

For more information, see Implementing Business Rules in the Client/Server Sample Application later in this section.

Conflicts

The Conflicts form class displays current value, old value and changed values of fields in a record with a data conflict. An instance of the Conflicts class is created in the ResolveConflicts method of the SampleApp form:

frmConflicts = CREATEOBJECT('Conflicts')
frmConflicts.Show

For more information on conflict resolution, see Managing Data Conflicts in the Client/Server Sample Application later in this section.

See Also

Solutions Samples | Client/Server Sample | Client/Server Sample Application Database | Updating Data in the Client/Server Sample Application | Managing Data Conflicts in the Client/Server Sample Application | Implementing Business Rules in the Client/Server Sample Application