In this procedure an example of defining an object to encapsulate the files being transferred and attached to other objects within the mobile application is provided. The primary focus of this procedure is on the external data property that references the file. Additionally, the overall architecture and components of the file object are explained during this procedure, including the reasons for their implementation and how they may be used in related functionality.
The sample application to be used in this procedure is Mobile Northwind, which contains the module data structure of Customers -> Orders -> OrderItems. Added to this structure will be a collection property for the Document object that is defined. This will be added as child to the Customer object, making it a sibling of the Orders in the aforementioned module data structure.
This property is always required regardless of where the files are stored, including in a database system or file control system. It is needed during synchronization, as will be apparent in the procedures on this topic.
These attributes are set to reference the property of containing the name of the file as retrieved from the back end system with the File Name attribute set to the string property FileName. We have also defined the file to never be deleted on the client. It is possible to define the file to be deleted only when it was created by the Agentry Client during data synchronization, or to always delete file when the parent object is deleted. Finally, the file has been defined to be read-only, which means users are not able to modify the file on the client device. The File Extension attribute has been left blank, meaning files will keep the extension as returned during synchronization. It is possible specify an extension here, which changes the file extension of all files to the value provided, regardless of the extension of the file when it is downloaded or attached locally.
The settings defined here result in a client device storage location specific to the mobile application and the parent object to which the files are attached. The base path under the Windows 9.x/NT/2000/XP section is set to “Absolute Path.” The Relative Path attribute then contains the full path to the location where the files are to be stored. Other options include the various standard windows lactations, such as My documents, My Pictures, etc. For the Windows CE section, the attribute Use Path is selected, which will replicate the path for Windows desktops on the Windows Mobile devices. The drive letter is removed from the path.
With the complete of this procedure the object to encapsulate the files associated with (or “attached to”) some other object has been defined. The parent object has been defined to contain a collection of these objects, which is to be populated during synchronization and also when files are attached on the client device.
The next area of functionality to implement is the downstream synchronization processing. See the procedure on this topic for guidance on this procedure.