Overview
The Syniti Replicate API, a .NET object model structure called the DBMoto Object Model (DBOM), provides developers with complete control over creating and running replications programmatically.
Click here to view the API Reference Manual
The code below provides a simple example of how to start the Replication Agent for a replication in the default metadata running on the "local" Syniti Replicate server.
The .NET namespace for the API is HitSoftware.DBMoto.Application. This namespace includes the class DBMotoApplication, the main singleton object of the DBOM, which can be instantiated through the static singleton method Instance DBMotoApplication.Instance.
API Sample Code
Note
The API described here is available in Syniti Replicate version 7.1 and above.
The code below provides a simple example of how to start the Replication Agent for a replication in the default metadata running on the "local" Syniti Replicate server.
The .NET namespace for the API is HitSoftware.DBMoto.Application. This namespace includes the class DBMotoApplication, the main singleton object of the DBOM, which can be instantiated through the static singleton method Instance:
using HiTSoftware.DBMoto.Application;
using HiTSoftware.DBMoto.ObjectModel; //APIs
...
public void Run(){
DBMotoApplication dbmApp;
IServer dbmServer = null;
IMetadata currentMetadata = null;
try
{
// Static singleton constructor
dbmApp = DBMotoApplication.Instance;
// Retrieving the local server from the list available in the DBMotoApplication instance
dbmServer = dbmApp.Servers["local"];
// Connecting to the server agent using anonymous authentication
dbmServer.Connect();
// Define and load the current metadata
currentMetadata = dbmServer.Metadatas.DefaultMetadata;
currentMetadata.Load(true);
if (currentMetadata.IsRunning())
{
Console.WriteLine("Data replicator is running on " + currentMetadata.Name);
Console.WriteLine("Stopping now ...");
// Stopping the Data Replicator after a timeout of 10000 milliseconds
currentMetadata.Server.StopReplicationManager(10000);
}
else
{
Console.WriteLine("Data replicator is stopped");
Console.WriteLine("Starting now (as an application) ...");
// Starting the Data Replicator as an application
currentMetadata.Server.StartReplicationManager(false);
}
}
catch(Exception e)
{
if (currentMetadata != null)
currentMetadata.Unload();
if (dbmServer != null)
dbmServer.Disconnect();
Console.WriteLine(e.Message);
}
}
...The DBMotoApplication object has access to a list of IServer objects, which is the list of server agents configured in the Management Center and stored in the local dbmoto.config file. Syniti Replicate users typically define at least a "local" server in the Management Center. It is therefore possible to get a pointer of the local server by calling:
dbmServer = dbmApp.Servers["local"];With a pointer to the local server, you can connect to the server:
Using anonymous authentication (if allowed by the server agent):
dbmServer.Connect();
Using Syniti Replicate authentication (by passing an application login):
dbmServer.Connect(txtUser.Text.Trim(), txtPassword.Text.Trim(), false);
Using Windows authentication (the Windows domain credentials):
dbmServer.Connect(null, null, true);
The IServer class also contains the list of metadata defined for the server, and identifies the default metadata, which will be used by the Replication Agent:
currentMetadata = dbmServer.Metadatas.DefaultMetadata;For interaction that involves the Replication Agent and the metadata, the metadata should be 'synchronized' with the Replication Agent, meaning that the application using the API should open a TCP/IP connection to the Replication Agent and receive notification from the Replication Agent:
currentMetadata.Load(true);The IsSynchronized property also allows you to receive monitor information via the API including how many records have been processed and the current transaction ID in a running replication.
Use the IServer StartReplicationManager and StopReplicationManager methods to start and stop the Replication Agent.
The simple code sample described above provides an introduction to the Syniti Replicate API. Explore the full capabilities of the API from Visual Studio, or from the Syniti Replicate API Reference Guide.
Object Model Diagram
The diagram below provides a graphical representation of the DBMoto Object Model. Note the one-to-many relations between the parent object and the children; and the one-to-one link from each child class to the parent (for instance, an IMetadata has a pointer to IServer).
.png?sv=2022-11-02&spr=https&st=2026-02-13T06%3A28%3A04Z&se=2026-02-13T06%3A41%3A04Z&sr=c&sp=r&sig=X0qBz7%2BbxMt4mzLKpCCksFZtQDh3NS1Pa9DDJQMLMNA%3D)
