Syniti Replicate API Overview
  • 24 Apr 2024
  • 3 Minutes to read
  • Contributors
  • Dark
    Light

Syniti Replicate API Overview

  • Dark
    Light

Article Summary

View the API Reference Manual

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.

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.

When building a client application using the Syniti Replicate API, be sure to follow directions below for the AppConfig file.

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.ObjectModel; \\APIs
using HiTSoftware.DBMoto.Common; \\ Type Definition for the APIs
...
public void Run(){   
    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;
     // Set synchronization between metadata and Data Replicator (TCP/IP)
     currentMetadata.IsSynchronized = true;
     currentMetadata.Load(); 
     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.IsSynchronized = true;

should be called before loading the metadata.

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.

AppConfig File References

Add the following references to libraries for the Syniti Replicate API in your AppConfig file <runtime> section. Replace all items in italics with correct pathnames, cultures and version numbers. To get the correct version number for your Syniti Replicateinstallation:

  1. Open the Management Center.

  2. In the main menu bar, from the Help menu, choose Syniti Replicate.

  3. Make a note of the exact version number on the right-hand side of the dialog.

  4. Click OK to close the dialog.

The options for the culture value are en, it or jp.

<runtime>
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
     <dependentAssembly>
         <assemblyIdentity name="APILibrary"  culture="neutral" publicKeyToken="ea88625a625249df"/>
         <codeBase version="7.0.0.0" href="FILE://G:/products/dbmoto/test/sut/APILibrary.dll"/>
     </dependentAssembly>
     <dependentAssembly>
           <assemblyIdentity name="EMUtil.resources"  culture="en" publicKeyToken="ea88625a625249df"/>
           <codeBase version="7.1.0.10" href="FILE://G:/products/dbmoto/test/sut/en/EMUtil.resources.dll"/>
     </dependentAssembly>
     <dependentAssembly>
            <assemblyIdentity name="EMUtil"  culture="neutral" publicKeyToken="ea88625a625249df"/>
            <codeBase version="7.1.0.10" href="FILE://G:/products/dbmoto/test/sut/EMUtil.dll"/>
     </dependentAssembly>
   </assemblyBinding>
 </runtime>

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).


Was this article helpful?