ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / Managing replications / Universal replication
  • Overview
  • Principle of automatic assisted universal replication
  • The steps for implementing an automatic assisted universal replication are as follows:
  • Adapting the application (if necessary)
  • Using non-HFSQL databases
  • Preparing the files required by the assisted universal replication
  • Using replication
  • Direct assisted universal replication
  • Assisted universal replication by replication server
  • Offline mode/Online mode
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
The automatic assisted replication is used to easily implement a replication on an existing application. Very few modifications are required at application level, and the standard replication tools allow the end users to start their own replication of data.
The automatic assisted replication allows you to use all the available replication modes:
  • direct replication,
  • replication by server with immediate or periodic replica.
Remark: The automatic assisted replication is available for the replication of mobile data (Android or iOS). For more details, see Replication of mobile data (Android or iOS).
Principle of automatic assisted universal replication
Regardless of the type of application used, a local database is automatically created when implementing the automatic assisted universal replication. This local database (or subscriber database) contains the data required for the application to operate. Then, the data of the local database is replicated with the data of the master database (database found in the application) according to the selected replication mode.
The synchronization is directly performed by the users with ReplicAdmin and ReplicSynchro. These tools are automatically installed and configured on the end-user computer by the setup program of the application.

The steps for implementing an automatic assisted universal replication are as follows:

  1. Adapting the application if necessary.
  2. Preparing the files required by the replication:
    • Describing the replication with ReplicEdit. This description can be done by the creator of the application (recommended) or by the end user. The replication is described in a ".WER" file.
    • Creating the setup program.
    • Installing the application.
  3. Using the replication.
Remark: Some features are not available in this version. For more details, see the Limitations regarding the assisted universal replication.
Adapting the application (if necessary)
Assisted universal replication can be implemented on applications that use HFSQL Classic, HFSQL Client/Server and OLE DB data files, as well as data files handled by Native Connectors (also called Native Accesses).
The data files in the analysis are in HFSQL Classic format: no modification must be performed. The master files can be configured:
  • when defining the replication with ReplicEdit,
  • when creating the setup,
  • when installing the application.
The data files in the analysis use a connection (HFSQL Client/Server, Native Connectors, OLE DB files, etc.): you must define the connection to the master server in the analysis and associate the files with this connection.
The master server used by the connection can correspond to:
  • the operating server (if it is already known when the application is created). This is the case, for example, of applications developed in the same company that uses them.
  • the local test server. In this case, the operating master server can be configured:
    • when defining the replication with ReplicEdit,
    • when creating the setup,
    • when installing the application.
Caution: Regardless of the format of the data files, to use the automatic assisted universal replication, the information for accessing the files MUST NOT BE modified through programming. YOU MUST NOT USE:
Indeed, the mechanism of automatic assisted replication automatically manages an Online/Offline mode and automatically performs the changes required to access the local database or the central database.

Using non-HFSQL databases

To implement assisted universal replication on different databases (Oracle, etc.), a DateTime item must be created in each file taken into account by the replication. This item will have to be updated by the application when modifying or adding a record.
If the databases use different time zones, we recommend that you use a universal format (GMT date and time for example).
Example: Managing a specific item for the replication between an HFSQL database and a MySQL database:
A trigger is implemented in order to automatically fill the "Itm_DateTime" item found in the MySQL database:
  • Code of the trigger
    ResultatTrigger is boolean
    ResultatTrigger = HDescribeTrigger("*", "HAJOUTE,HMODIFIE,HSUPPRIME,HRAYE,HECRIT", "AjoutDateHeure", hTriggerBefore)
    IF ResultatTrigger = False THEN Error(HErrorInfo())
  • Procedure called by the trigger
    PROCÉDURE AjoutDateHeure()
    TestReplic.Rub_DateHeure = DateSys() + TimeSys()
Preparing the files required by the assisted universal replication
The files required by the automatic assisted universal replication are prepared on the development computer:
The replication file (.WER file) is created using ReplicEdit.
When creating the setup program, you have the ability to configure:
  • Direct replication or replication by server,
  • Using the online mode or the offline mode.
Reminder: To create the setup program, go to the "Project" tab, "Generation" group, expand "Setup procedure" and select "Create setup procedure".
This information can be modified when installing the application.
Using replication

Direct assisted universal replication

The principle for the direct assisted replication is as follows:
During a direct replication, the application is installed on the local computer by the setup program (the setup can be a stand-alone setup or a setup with automatic update).
During this setup, a local database (in HFSQL Classic format) is automatically created. This database is identical to the master database.
If the user cannot access the master database, the application operates in offline mode with the local database (salesperson using a laptop computer for example).
To synchronize, the user starts ReplicSynchro and performs the synchronization of data. In our example, the salesperson can perform a synchronization every evening.
If the local computer can directly access the master database (in our example, the salesperson is visiting the office and he can access the network), the master database can be used directly. This change of mode is performed by ReplicAdmin.
Remark: the principle described here is identical for an application that uses a setup with automatic update.

Assisted universal replication by replication server

During a replication by server, the application is installed on the local computer by the setup program (the setup can be a stand-alone setup or a setup with automatic update).
During this setup, a local database (in HFSQL Classic format) is automatically created. This database is identical to the master database. The replication server can also be installed when the application is installed.
If the user cannot access the master database, the application operates in offline mode with the local database (salesperson using a laptop computer for example).
To synchronize, the user starts ReplicSynchro and performs the synchronization of data. In our example, the salesperson can perform a synchronization every evening.
If the local computer can directly access the master database (in our example, the salesperson is visiting the office and he can access the network), the master database can be used directly. This change of mode is performed by ReplicAdmin.
Remark: the principle described here is identical for an application that uses a setup with automatic update.

Offline mode/Online mode

ReplicAdmin allows you to switch from the offline mode (using the local database) to the online mode (using the master database), and conversely.
When the application is in offline mode configured by ReplicAdmin, the application is always using the local data files. No automatic mechanism is implemented. To use the master database, a synchronization must be performed and ReplicAdmin must be used to switch to the online mode.
When the application is in online mode configured by ReplicAdmin, an automatic control mechanism is implemented. This mechanism is as follows:
  • If the connection to the master database is successfully established when the application is started, the application will be in online mode and it will use the data from the master database.
  • If the connection to the master database fails when the application is started, a message proposes to automatically switch to the offline mode and to use the local data.
Remark: in order to have the most updated local data when switching to the offline mode, an immediate synchronization of the local data can be triggered whenever the application is closed (option in the setup program of the application).
When the application is automatically switched to local mode, during the next application start:
  • If the connection to the master database is successfully established when starting the application, a message proposes to synchronize the local data and to switch back to the online in order to use the network data.
  • If the connection to the master database fails, the application remains in offline mode and it continues to use the local database.
Remark: this mechanism can be used for Windows 32-bit and 64-bit executables.
Related Examples:
WD Universal Replication Training (WINDEV): WD Universal Replication
[ + ] This examples explains how to use the universal replication to synchronize data of different sites.
The universal replication is used to synchronize the data of a site (master site) with the same data of one or more replicated sites (subscriber sites). The data structures are identical on each site but they can be exploited via different data managers. HFSQL Classic and Access will be used in this example.
The example presents the processes that must be included in your applications to allow the user, via a simple action (menu, button, ...), to:
- create a master replica,
- create one or more subscriber replicas,
- see and modify the data of these replicas,
- export the created or modified data to a site (portable replica),
- import the created or modified data into another site...
Minimum version required
  • Version 12
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 07/05/2023

Send a report | Local help