This document explains one of the Data Synchronization criterias to choose regarding Smart Devices Offline Applications Generation. It establishes that all the synchronization processes are going to be invoked and executed on demand.
When generating Offline Smart Devices applications Genexus generates code to execute the synchronization.
- Scripts to generate the database
- Scripts to initialize the database
- Code to execute on the device the scripts
- Scripts to synch the data of the data bases.
- Web services on the server side
Apart from developing this objects the user has to solve the following problems:
- When is the synchronization going to take place?
- Which data is going to be synchronized?
- How is the synchronization done?
There are two ways to do Manual Synchronization, and they differ of aid the developer receives from GeneXus:
- Using generated programs to Synchronize.
- Manually program and synchronize.
Option 1: Using generated programs to synchronize#
Even though the Data Receive Criteria property or the Send Changes property are manual GeneXus generates programs and scripts to do the synchronization. This programs are generated and are on hold until the smart device application calls them to be executed. The easiest way of calling this programs is using the Synchronization API. You can check out the HowTo: Using the Synchronization API for further reading about the Synchronization API.
Option 2: Manually program and synchronize#
The GeneXus user needs to code all the objects needed for the synchronization and also decides some factors of the synchronization strategy.
What do you have to code:
- Procedures that will be executed offline
- The web services (REST or SOAP) that the server is going to expose
- The consumption of those REST or SOAP services via HttpClient
What this code has to do:
- Insert on the local database the data brought by the invoked services
- Send the local Events registered offline to the server
A generic sample code can be seen here.
In this scenario it is very important to check the network status, this is going to be a key factor to define which is the best moment to do the synchronization. Also, this sample is based on Manual Synchronization.
Lastly, there are some Best Practices for Manual Synchronization to take into consideration for optimal resource usage.
Automatic Offline Data Synchronization