Often you need more information about the replication process or even need to intervene it. dRS allows the registration of a event listener in order to perform such tasks.
When you create the replication session you can pass such a listener instance. The listener will be called for each object which is replicated.
class LogReplicationListener : IReplicationEventListener { public void OnReplicate(IReplicationEvent replicationEvent) { IObjectState stateInDesktop = replicationEvent.StateInProviderA(); if (stateInDesktop.IsNew()) { Console.WriteLine("Object '{0}' is new on desktop database", stateInDesktop.GetObject()); } if (stateInDesktop.WasModified()) { Console.WriteLine("Object '{0}' was modified on desktop database", stateInDesktop.GetObject()); } } }
Private Class LogReplicationListener Implements IReplicationEventListener Public Sub OnReplicate(ByVal replicationEvent As IReplicationEvent) _ Implements IReplicationEventListener.OnReplicate Dim stateInDesktop As IObjectState = replicationEvent.StateInProviderA() If stateInDesktop.IsNew() Then Console.WriteLine("Object '{0}' is new on desktop database", _ stateInDesktop.GetObject()) End If If stateInDesktop.WasModified() Then Console.WriteLine("Object '{0}' was modified on desktop database", _ stateInDesktop.GetObject()) End If End Sub End Class
IReplicationSession replicationSession = Replication.Begin(desktopRelicationPartner,mobileRelicationPartner,new LogReplicationListener());
Dim logReplicationListener As IReplicationEventListener = New LogReplicationListener() Dim replicationSession As IReplicationSession _ = Replication.Begin(dektopReplicationProvider, mobileReplicationProvider, logReplicationListener)