This article shows how to create a
client application that interacts with the
CarModule.CarData schema server
implementation from
How to implement the operations for a user-defined schema.
In this example you
will learn how to create applications that use your own data model definitions
or connect to your own schema server implementations.

You should know the information in the following articles:
First, we need to add a reference to the CarModule.dll assembly and the
CarModule-CarData.dll schema assembly (generated in
How to create a user model using Data Dictionary).
It is usual to also reference UbisensePlatform.dll,
which contains definitions that you are likely to use. The UbisensePlatform.dll
file can be found in the directory where the Ubisense software was installed,
in the bin folder (C:\Program Files\Ubisense 2.1\bin by default).
A user-defined schema has the same usage as other schemas.
Create a
Ubisense.CarModule.CarData.Schema object and call
ConnectAsClient on it:
|
Create methods with the appropriate signature to be a
valid event handler of the
CarHasProperties relation:
|
Now, subscribe those methods to the appropriate CarHasProperties event. Remember to add an establish handler to ensure your client is always up-to-date with the state of the schema relation:
|
If the schema server is not running, your application's
schema will not be able to connect to it. Add a Ubisense.UBase.MonitorForm
object to your application's Program class, in Program.cs to
diagnose any future problems.
|
Get a
ReadTransaction
object from your CarData instance, and use the
car_
index method to iterate over the elements that match the given parameter, or,
don't use one to iterate over the whole contents of the CarHasProperties
relation:
|
The CarData schema defines 3 operations; you can call them like this:
|
Note that you should normally use a caching client so that you can query the local cache
rather than calling get_car_properties. This is so you have predictable
scalability. Using get_car_properties and an event client is fine if you
only ever need to get the properties for 1 car, but as soon as you expect multiple entries
in your database, don't use a remote operation to query the schema, do use a caching client.
The sample
application uses the generated assemblies to create a cached CarData
schema.
The application
iterates over the schema's CarHasProperties relation and shows the
contents to the user.
Has an interface
that lets you call the get, set and remove operations on a CarData schema
object.
Open the sample application solution and check that the references are correct.
Run the schema server and check that it has connected as a server and is serving.
Run the client application. If a server is not present you should get a monitor form telling you this.
Create some entries
in the CarHasProperties relation by entering a VIN, selecting a model and clicking
on 'Create New'
Select one of the entries from the list view and verify that you get the same data when you click 'Get selected' properties.
Select one of the entries and click on Remove selected. The removed entry should no longer appear in the list view.
See the server's command window and review the history of actions.
With the help of the client application we can test the schema server implementation as well as finding possible errors in the definition of the data model.