Smart devices such as mobile phones, PDAs, and factory controllers that use the Windows® CE Real Time Operating System (RTOS) can take advantage of applications developed in Visual Studio using the new UODONETCF.dll library released with UniVerse Clients 10.3. This article explores an existing PC-based application written in C# using U2 UO.NET and describes how to migrate the application to a new compact framework application that can run on a smart device. The new smart device application uses the majority of the original application's source code. The article describes how to develop the new application with Microsoft® Visual Studio 2008 C# .NET Compact Framework and the UO.NETCF library. You could also use other languages such as Visual Basic or C++.
The UniObject .NET Compact Framework is a persistent application environment. This means that once a smart device makes a connection to a U2 database, the interaction between that device and the database is no different than the interaction between a terminal and the database. The connection remains valid until the UniObject method CloseSession() is called. The difference between a browser-based or Web services-based application and a UO .NET CF application is that the browser or Web service needs to make a connection to an application and database server for each request.
Below is an example of a use case for a compact framework application. In this scenario, a warehouse employee is conducting an inventory. The employee uses an application on a smart device to confirm that an item has the correct barcode printed on it before the item is counted for the inventory.
| Employee action | Application response |
|---|---|
| The employee logs into the smart device. | A connection is made to the U2 database. |
| The employee scans the bar code of the item. | An item lookup occurs and a image of the item is returned. |
| The employee visually verifies that the returned image matches the actual item. | The stock is counted and the database is updated. |
Overview of UniObject .NET Compact Framework
Figure 1 provides a high level architectural view of an application that uses the UniObject .NET Compact Framework. Following the figure, each part of the architecture is briefly described.
Figure 1. Architecture of applications built on UO .NET Compact Framework
Microsoft Visual Studio 2008 is an Integrated Development Environment (IDE) that helps you develop smart device applications with as much ease as developing desktop applications. Smart device development in Visual Studio includes a set of project types and emulators that target development for Pocket PC, Smartphone, and embedded Windows CE devices.
The .NET Compact Framework uses the Windows CE operating system for core functionality and for several device-specific features. Several types and assemblies, such as those for Windows Forms, graphics, drawing, and Web services, were rebuilt to efficiently run on smart devices, rather than being copied from the full .NET Framework. The .NET Compact Framework provides the following interoperability with Windows CE:
- Compatibility with native security
- Full integration with native setup programs
- Interoperability with native code using COM interop and platform invoke
The .NET Compact Framework Common Language Runtime (CLR) was also rebuilt to allow constrained resources to run on limited memory, and to efficiently use battery power. A platform adaptation layer (not shown in Figure 1) exists between Windows CE and the CLR to map the services and device interfaces required by the CLR and Framework onto Windows CE services and interfaces.
The .NET Compact Framework is composed of a subset of the .NET Framework plus other features designed exclusively for the .NET Compact Framework. It provides the features and ease of use that facilitate bringing native device applications developed for the .NET Framework and desktop applications to smart devices.
The application layer is where your libraries and application objects that you create in Visual Studio 2008 reside. UO.NETCF is the UO .NET Compact Framework library. U2CFdemo is the application that is described in the Analyzing the new UO.NETCF application section of this article. The U2CFdemo application contains the User Interface (UI), Presentation Interface (PI), and the rc2crypt business process.
The Microsoft .NET Framework is a software framework that can be installed on computers running Microsoft Windows operating systems.
UniObjects for .NET framework is an interface to the UniData and UniVerse databases through the Microsoft .NET framework. UniObjects for .NET is a proprietary middleware application program interface (API) designed specifically for software development on the .NET Framework. This interface is managed code written in C# Common Language Runtime (CLR) and designed to be deployed on desktop workstations.
UniObjects for .NET Compact Framework
The UniObjects for .NET Compact Framework is a pared down version of the full UO.NET framework. It is designed to be deployed by smart devices that run the Windows CE operating system.
A deeper look into UniObject .NET Compact Framework
The UniObjects for .NET Compact Framework shares the same source code base with UniObjects for .NET. Both UO.NET and UO.NETCF share the same namespace name, which is IBMU2.UODOTNET. UODOTNET4CF.dll is the assembly name for UO .NETCF. This assembly can be found under the ..\UNIDK\uonet\bin directory after you install the UNIDK components from the UniVerse 10.3 Clients CD.
The UO .NET Compact Framework is a subset of the UO .NET Framework class library. The following classes are not available to the UO .NET Compact Framework:
- Connection pooling. Connection pooling is useful in a three tier environment. However, UO .NETCF uses a client server on-demand connection architecture that cannot take advantage of connection pooling. The result is that initial connections to the U2 database are slow, but then the persistent connection allows for fast transmission of data.
- Tracing and logging. Because this class is not available, your smart device applications should allow for the capture of exceptions. These exceptions will be visible to the smart device. U2 Server side logging can also be used for debugging.
- Performance counters. Because this class is not available, you should add timers to your smart device applications during development and use them to understand performance shortfalls.
- Secure connection. SSLStream is not available as of .NET 3.5 sp1. Therefore, SSL communication is not possible between the smart device and the U2 Server. However, .NET CF does allow you to use the system.security.cryptology namespace that provides cryptographic services. These services include secure encoding and decoding of data as well as many other operations, such as hashing, random number generation, and message authentication. You can use these services to encrypt sensitive Strings (data). The U2 database supports bidirectional understanding of these encrypted strings.
- Configuration files. These are files with the type of .config, which normally are used for client side logging and connection pool settings. You do not need U2 specific configuration files for your smart device applications.
Minimum development tool requirements
There are many types of devices in use today that run Windows CE. These devices vary from embedded controllers in a production line to hand held devices such as mobile phones and PDAs. Visual Studio 2008 includes most of the tools needed to develop and emulate a Windows CE device in the .NET Compact Framework without the need for you to actually have the physical smart device.
The following sections provide details of the minimum requirements necessary to develop an application for a smart device using Microsoft .NET Compact Framework.
Emulated smart device development requirements
- Windows Workstation (XP, 2K3, etc.)
- .NET program using Visual Studio .NET 2008 (The sample in this article uses C#)
- U2 database using UniData 7.2 or UniVerse 10.3
- Microsoft ActiveSync Version 4.5
- .NET Framework 2.0 or later
- UniDK - UniVerse 10.3 clients
- UniDK - UniData 7.2a clients (September 2009)
Physical smart device development requirements
- Windows Workstation (XP, 2K3, etc.)
- .NET program using Visual Studio .NET 2008 (The sample in this article uses C#)
- U2 database using UniData 7.2 or UniVerse 10.3
- Microsoft ActiveSync Version 4.5
- Bluetooth or USB cable for ActiveSync
- Wireless Lan for communication to the DB Server
- NET Framework 2.0 or later
- UniDK - UniVerse 10.3 clients
- UniDK - UniData 7.2a clients (September 2009)
Physical smart device communications requirements
The interfaces described in this section apply only to usage relative to the sample described in this article. There are other interfaces and protocols available for smart devices, but they are not covered in this article.
- USB. This interface is used for synchronization. The Windows CE USB Serial Host Driver provides a simulated Serial interface that is used by Microsoft ActiveSync to communicate with Windows CE or Windows Mobile devices over a USB connection from a computer running the Microsoft Windows host development system. This interface can also be used by the smart device to communicate with the U2 DB Server via the TCP/IP protocol.
- Bluetooth. Bluetooth is a wireless communication technology that allows smart devices within a nearby proximity (approximately 10 meters) to communicate with the Windows host development system. This interface is typically used in conjunction with ActiveSync, which is required by the Visual Studio project when deploying the application.
- Wi-Fi. Wi-Fi is a local area network (LAN) that communicates via radio waves based on IEEE 802.11 standards. This interface can be used by the smart device to communicate with the U2 DB Server via the TCP/IP protocol.
- Mobile Data Plan. Smart devices using Edge, 3G, or GPRS have the ability to communicate over the Internet to a U2 DB Server via the TCP/IP protocol.
Analyzing the original UO.NET donor application
This article uses a UO.NET application as the basis for creating a new UO.NETCF application. The UO.NET application is referred to as the donor application. The Downloads section contains a Visual Studio project file for the donor application.
The donor application was written using Visual Studio 2003. When developing this application, the author did not separate the user interface from the presentation interface, which results in a single large source file. With later versions of Visual Studio, it has become easier to design and separate the logic layers. When designing in Visual Studio it is a good idea to be familiar with the Microsoft patterns and practices for software engineering (see the Resources section for a link).
Figure 2 shows the initial user interface for the donor application. The application has three distinct operation areas that are described in detail below the figure.
Figure 2. The donor application user interface
- Connection group and DBMS type properties
- Enter the host name or the IP address of the U2 DB server (
localhostis for information only). - Select the U2 database type.
- Enter the account name (default is
demofor UniData andHS.SALESfor UniVerse). - Enter a valid username for the U2 DB server.
- Enter a valid password for the username.
- Enter the host name or the IP address of the U2 DB server (
- Data source name and ID
- Enter a valid U2 filename.
- Enter a valid record ID.
- The employee visually verifies the item
- The stock is counted and the database is updated.
Figure 3 shows the user interface after the read operation.
Figure 3. The donor application after the read operation
Analyzing the new UO.NETCF application
This article refers to the new UO.NETCF application that is based on the donor application as the smart device application. The Downloads section contains a Visual Studio project file for the smart device application.
The smart device application uses only a part of the Model-View-Controller (MVC) architectural model. The UO .NETCF project uses a User Interface (UI) layer and a Presentation Layer. Only the presentation and U2 interface logic of the original donor application was copied and placed in the Presentation Layer. There is no mechanism to translate the UI logic in the donor windows application to a smart device. Because of the simplicity of the donor application, it was easy enough to create the UI layer from scratch. The sample code supplied with this article contains comments that describe the code changes that were made between the two frameworks.
Running the smart device application
Figure 4 shows the user interface for the smart device application. With the .NET Framework, group boxes can be used to display a frame around a group of controls. For example, the donor application used two group boxes for connection and U2 database type. However, group boxes are not available as part of the .NET Compact Framework.
The smart device application has six distinct operation areas that are described in detail below the figure.
Figure 4. The smart device application user interface
- Open start menu and application header
- From this application named window (U2U S29 U2CFdemo), you can enter the smart device's menus or exit the application.
- Connection properties
- Enter the host name or the IP address of the U2 DB server (
localhostis for information only and will not work on smart devices). - Select the U2 database type.
- Enter the account name (default is
demofor UniData andHS.SALESfor UniVerse). - Enter a valid username for the U2 DB server.
- Enter a valid password for the username.
- Enter the host name or the IP address of the U2 DB server (
- Data source name and ID
- Enter a valid U2 filename.
- Enter a valid record ID.
- Result data
- Result data for the Read operation and the output of rc2crypt is displayed in this box.
- Status messages
- For each operation (Connect. Disconnect, Update, OpenFile, Read, Insert, Delete, and rc2crypt) a status message is displayed in this box.
- Connect and Operation menus
- To compensate for the limited screen size of the typical smart device, the application uses pop-up menus for the connection and operation method calls.
- Connect menu choices are: Connect, Disconnect, and End.
- Operation menu choices are: Update, OpenFile, Read, Insert, Delete, and rc2crypt.
Figure 5 shows the result data box area of the user interface after the read operation.
Figure 5. Result data box after a record read.
A Business Process is included in the example to demonstrate how to pass information to a business object for data manipulation. The project example collects the data from the file record window and passes it to an encryption object named rc2crypt for processing. The processed file record data is returned and displayed in the result record box as shown in Figure 6.
Figure 6. Returned result after processing by rc2crypt business process
The UniObjects .NET Compact Framework is yet another tool from the U2 development group that enables developers to create applications for smart devices. Application developers should be able to use this library to build and extend their solutions.
| Description | Name | Size | Download method |
|---|---|---|---|
| Donor C# application project1 | uonetfilecs2009.zip | 108KB | HTTP |
| U2 Compact Framework application project2 | U2CFdemo.zip | 108KB | HTTP |
| U2 Compact Framework Power Point slides3 | U2US32s.zip | 1229KB | HTTP |
| U2 Compact Framework XML Query project4 | UODOTNETCF.zip | 108KB | HTTP |
Information about download methods
Notes
- Visual Studio project on how to implement the original donor UO.NET project
- Visual Studio project on how to implement the new UO.NETCF project
- UO.NETCF project using XML query and a DataSet.
- Visual Studio project on how to implement a UO.NETCF project using XML query and a DataSet.
Learn
-
"U2 encryption in an open technology world"
walks you through the four worlds of encryption covering C#, Java®, U2 BASIC, and
OpenSSL shell scripting and demonstrates that encryption of data produced is interchangeable amongst them.
-
"Secure U2 Web services"
shows you how to protect your data when exposed through U2 Web services
-
U2
TechConnect provides links that let you search the
IBM U2
Knowledge base. and access U2 Entitled Documents.
-
Use the
Microsoft patterns
and practices Developer Center to learn about Microsoft patterns and practices for
software engineering.
Get products and technologies
- Download
IBM
UniData product Trials and Demos.
- Download
IBM
UniVerse product eTrials and Demos.
- Download
IBM product evaluation versions
or explore
the online trials in the IBM SOA Sandbox and get your hands on application development tools and middleware products from
DB2®, Lotus®, Rational®, Tivoli®, and
WebSphere®.
Discuss
- Participate in the discussion forum.
-
Check out
developerWorks
blogs and
get involved in the
developerWorks community.
Comments (Undergoing maintenance)







