Replies: 1 comment
-
Depending on your need, you can use a lot of interceptors to fit your needs Before and After a whole sync process using Session Interceptor: var agent = new SyncAgent(clientProvider, serverProvider, options);
var localOrchestrator = agent.LocalOrchestrator;
localOrchestrator.OnSessionBegin(args => Console.WriteLine(args.Message));
localOrchestrator.OnSessionEnd(args => Console.WriteLine(args.SyncResult)); If you need to do something Before and After Reading changes: localOrchestrator.OnDatabaseChangesSelecting(args => {
Console.WriteLine($"Getting changes from local database:");
Console.WriteLine($"Batch directory: {args.BatchDirectory}. Batch size: {args.BatchSize}. Is first sync: {args.IsNew}");
Console.WriteLine($"From: {args.FromTimestamp}. To: {args.ToTimestamp}.");
}
localOrchestrator.OnDatabaseChangesSelected(args =>
{
Console.WriteLine($"Directory: {args.BatchInfo.DirectoryName}. Number of files: {args.BatchInfo.BatchPartsInfo?.Count()} ");
Console.WriteLine($"Total: {args.ChangesSelected.TotalChangesSelected} " +
$"({args.ChangesSelected.TotalChangesSelectedUpdates}/{args.ChangesSelected.TotalChangesSelectedDeletes})");
foreach (var table in args.ChangesSelected.TableChangesSelected)
Console.WriteLine($"Table: {table.TableName}. Total: {table.TotalChanges} ({table.Upserts / table.Deletes}");
}); If you need to do something Before and After Writing changes: localOrchestrator.OnDatabaseChangesApplying(args =>
{
Console.WriteLine($"Directory: {args.ApplyChanges.Changes.DirectoryName}. " +
$"Number of files: {args.ApplyChanges.Changes.BatchPartsInfo?.Count()} ");
Console.WriteLine($"Total: {args.ApplyChanges.Changes.RowsCount} ");
});
localOrchestrator.OnDatabaseChangesApplied(args =>
{
Console.WriteLine($"Applied:{args.ChangesApplied.TotalAppliedChanges}.");
Console.WriteLine($"Failed:{args.ChangesApplied.TotalAppliedChangesFailed}.");
Console.WriteLine($"Conflicts:{args.ChangesApplied.TotalResolvedConflicts}.");
}); You can do it on both side, server or client ( |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In our use case, we have to run some sql commands before the sync starts and then some sql commands after the sync completes.
In the back of my mind, I think I saw some code somewhere that this might be already supported, or there might be an intention to support it. Of course, now that I'm looking for it, I can't find anything.
I can easily handle the pre/post sql commands in my non-DMS code. However, it could be a feature of DMS to support this as part of the sync. I'm on the fence at to which way should be considered "best practice"
Are there good reasons to standardize on keeping pre/post commands outside of DMS? Are there good reasons to support this inside DMS as a feature?
Beta Was this translation helpful? Give feedback.
All reactions