AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Administrar bases de datos / HFSQL / Gestión de la replicación / Replicación universal
  • Overview
  • HFSQL Classic database: Setting up programmatic replication
  • Step 1: Programming local access to HFSQL Classic data files
  • Step 2: Replication description
  • Step 3: Programming replication
  • Step 4: Application deployment
  • HFSQL Client/Server database: Setting up programmed replication
  • Step 1: Programming local file access
  • Step 1 bis: Using non-HFSQL databases
  • Step 2: Replication description
  • Step 3: Programming replication
  • Step 4: Application deployment
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Overview
The assisted replication through programming is used to implement a replication on an existing application while controlling the synchronization in the application itself. The user starts the synchronization via the application directly, without using any external application.
The assisted replication through programming allows you to use all the available replication modes:
  • direct replication,
  • replication by server with immediate or periodic replica.
HFSQL Classic database: Setting up programmatic replication
WINDEVWEBDEV - Código ServidorHFSQL Classic

Step 1: Programming local access to HFSQL Classic data files

If an application uses the assisted universal replication, it accesses a local database containing the necessary data only. The main database (master database) is used during the synchronization only.
Therefore, the application must be modified in order to access the local data files. You must program:
WINDEVWEBDEV - Código ServidorHFSQL Classic

Step 2: Replication description

The description of the replication is performed in a ".WER" file created by ReplicEdit. ReplicEdit is used to:
WINDEVWEBDEV - Código ServidorHFSQL Classic

Step 3: Programming replication

The local database is initialized when the first synchronization is performed between the application and the master database. The master database is found in the WER file generated by ReplicEdit.
For a direct assisted replication: Example of code that can be used:
// Initializes the replication by passing the postal code to take into account
IF ReplicInfo("MyReplication", replicInitialized) = False THEN
	ReplicInitialize("MyReplication", 47012)
END

// Starts the synchronization
ReplicSynchronize("MyReplication")
The local database must be initialized once only by ReplicInitialize.
Then, a single data synchronization is required (ReplicSynchronize)
Case of assisted replication with replication server: If you're performing assisted replication with replication server, you need to use the ReplicOpen function before the ReplicInitialize function to specify the replication server parameters.. Example:
// Starts the replication on the replication server
ReplicOpen("MyReplication", "", "ReplicationServer", "Flora", "password")

// Initializes the replication by passing the postal code to take into account
IF ReplicInfo("MyReplication", replicInitialized) = False THEN
	ReplicInitialize("MyReplication", 47012)
END

// Starts the synchronization
ReplicSynchronize("MyReplication")
WINDEVWEBDEV - Código ServidorHFSQL ClassicOLE DB

Step 4: Application deployment

The setup program is prepared like for any standard application.
Important: When creating the installation program, you must not ask to install assisted replication (uncheck the "Install and configure assisted universal replication modules" option)..
Reminder: To create the installation program, under the "Proyecto" pane, in the "Generación" group, pull down "Procedimiento de instalación" and select "Create Installation Procedure".
Direct assisted replication (without replication server) .WER file must be integrated into the files installed by the application. The .WER must contain all the characteristics of the paths to the master data files used by the application. The.WER file cannot be included in the library (WDL file).
If the location of the data files of the master database is unknown when creating the .WER file, it must be specified for each end-user computer installed. This operation can be performed:
  • on the end-user computer directly. To do so, ReplicEdit must be supplied to the user. However, the user will have access to all replication characteristics. This solution may cause security problems.
  • by the developer, once the path of the master database was specified by the end user. Then, the .WER is transmitted to the end user for update.
Assisted replication with replication server If you are using assisted replication with a replication server, the .WER file must be deployed on the replication server, along with all information concerning the master database. For more details, see Server for Assisted Universal Replication.
HFSQL Client/Server database: Setting up programmed replication
WINDEVWEBDEV - Código ServidorHFSQL Client/ServerOLE DBConectores Nativos

Step 1: Programming local file access

If an application uses the assisted universal replication, it accesses a local database containing the necessary data only. The main database (master database) is used during the synchronization only.
Therefore, the application must be modified in order to access the local data files. You must program:
  • the creation (if necessary) of the local files.
  • the access to these local files.
The principle is straightforward:
  • Definition of connections at analysis level Connections must be described at analysis level. Each file is associated with a connection.
  • Configuring connections with ReplicEdit ReplicEdit tool allows you to configure these connections to access master databases.
  • Programming local file access The application code will simply switch each connection to an HFSQL Classic connection, allowing the files to be used locally.
Installation If your application uses data files that require one or more connections (HFSQL Client/Server, native access, OLE DB files, etc.), we recommend that you perform the following operations:
  • in the data model editor: if your files are not associated with connections, create as many test connections as you need. For example, if you are using HFSQL Client/Server data and Oracle data, two test connections must be defined in the analysis.
  • in your code, modify the connections associated with the files: simply modify the parameters of the test connections to manipulate local HFSQL Classic data files. For example, the following code defines a local connection to HFSQL data files:
    HOpenConnection("HF_local", "", "", "", "", hAccessHF7)
    HChangeConnection("*", "HF_local")
WINDEVWEBDEV - Código ServidorHFSQL Client/ServerOLE DBConectores Nativos

Step 1 bis: Using non-HFSQL databases

To implement the assisted universal replication on different databases (Oracle, ...), a DateTime item must be created in each file taken into account by in 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 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
    TriggerResult is boolean
    TriggerResult = HDescribeTrigger("*", "HADD,HMODIFY,HDELETE,HCROSS,HWRITE", "AddDataTime", hTriggerBefore)
    IF TriggerResult = False THEN Error(HErrorInfo())
  • Procedure called by the trigger
    PROCEDURE AddDateTime()
    TestReplic.Itm_DateTime = DateSys()+TimeSys()
WINDEVWEBDEV - Código ServidorHFSQL Client/ServerOLE DBConectores Nativos

Step 2: Replication description

The replication is described by ReplicEdit. This tool is used to:
  • define the files taken into account by the replication, the filters taken into account when updating the data. For more details, see Creating a replication with ReplicEdit.
  • configure the location of the master files. All you have to do is redefine the connections of the analysis. The list of connections is returned by "Replication .. Description of connections" from ReplicEdit. For more details, see Replication options defined in ReplicEdit.
This information is saved in a ".WER" file created by ReplicEdit.
WINDEVWEBDEV - Código ServidorWindowsHFSQL Client/ServerOLE DBConectores Nativos

Step 3: Programming replication

The local database is initialized when the first synchronization is performed between the application and the master database. The connections to the master database are defined in the WER file generated by ReplicEdit.
For a direct assisted replication: Example of code that can be used:
// Initialize the replication by passing the postal code 
// to take into account
IF ReplicInfo("MyReplication", replicInitialized) = False THEN
	ReplicInitialize("MyReplication", 47012)
END

// Starts the synchronization
ReplicSynchronize("MyReplication")
The local database must be initialized once only by ReplicInitialize.
Then, a single data synchronization is required (ReplicSynchronize)
Case of assisted replication with replication server: If you are performing assisted replication with replication server, you need to use the ReplicOpen function before the ReplicInitialize function to specify replication server parameters.
// Starts the replication on the replication server
ReplicOpen("MyReplication", "", "ReplicationServer", "Flora", "password")

// Initialize the replication by passing the postal code 
// to take into account
IF ReplicInfo("MyReplication", replicInitialized) = False THEN
	ReplicInitialize("MyReplication", 47012)
END

// Starts the synchronization
ReplicSynchronize("MyReplication")
WINDEVWEBDEV - Código ServidorHFSQL Client/ServerOLE DBConectores Nativos

Step 4: Application deployment

The setup program is prepared like for any standard application. The .WER file must be included in the list of files installed by the application. The .WER file must contain all the characteristics of the connections to the master databases used by the application.
Important: When creating the installation program, you must not ask to install assisted replication (uncheck the "Install and configure assisted universal replication modules" option)..
Reminder: To create the installation program, under the "Proyecto" pane, in the "Generación" group, pull down "Procedimiento de instalación" and select "Create Installation Procedure".
Direct assisted replication (without replication server) .WER file must be integrated into the files installed by the application. The .WER must contain all the characteristics of the paths to the master data files used by the application. The.WER file cannot be included in the library (WDL file).
If the parameters for connecting to the master databases are unknown when crating the .WER file, they must be specified for each installed end-user computer. This operation can be performed:
  • on the end-user computer directly. To do so, ReplicEdit must be supplied to the user. However, the user will have access to all replication characteristics. This solution may cause security problems.
  • by the developer, once the path of the master database was specified by the end user. Then, the .WER is transmitted to the end user for update.
Assisted replication with replication server If you are running assisted replication with a replication server, the .WER file must be deployed on the replication server, along with all information concerning connections to the master databases. For more details, see Server for Assisted Universal Replication.
Versión mínima requerida
  • Versión 12
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local