GetEstimatedChangesCountAsync Server Scope #615
-
I currently have a webjob that creates a snapshot for a downloadonly scope. Is it was possible to check to see if any changes exist on the server downloadonly tables before a new downloadonly scope snapshot is created? If so, how is this accomplished? I should note this is a multi-scope sync scenario. The snapshot is restricted to download only. The other scope is restricted to true two-way synchronization. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @dotnetninja You can try something like that: Get Estimated changes from a client applicationIf you want to know if any changes, from a client application, (using a var webClientOrchestrator = new WebClientOrchestrator(this.ServiceUri);
var agent = new SyncAgent(client.Provider, webClientOrchestrator, options, "scope1");
// Ensure scope is created locally
var clientScope = await agent.LocalOrchestrator.GetClientScopeAsync();
// get changes from server, without any changes sent from client side
var changes = await webClientOrchestrator.GetEstimatedChangesCountAsync(clientScope); Get Estimated changes from a daemon application running on server sideWell, it's not out of the box, and it could be ... complicated :) If you want to know it, from a daemon, directly from the server side, it's complicated, because you need the last time your client made a sync, and this information is only available from the client database itself. We still have this information in the server database, in the history table. Here is what you can do, from the server side: var serverProvider = new SqlSyncProvider(csServer);
// Remote orchestrator
var remoteOrchestrator = new RemoteOrchestrator(serverProvider, options, setup, "DefaultScope");
// all histories for all client scope
var histories = await remoteOrchestrator.GetServerHistoryScopes();
// get the correct client scope
var clientScopeId = new Guid("B47C21C2-198D-48CB-9568-7CF1A3333288");
// get the correct history
var history = histories.Where(h => h.Id == clientScopeId).FirstOrDefault();
var clientScope = new ScopeInfo();
clientScope.IsNewScope = false;
clientScope.Id = clientScopeId;
clientScope.LastServerSyncTimestamp = history.LastSyncTimestamp;
clientScope.Name = "DefaultScope";
var s = await agent.RemoteOrchestrator.GetEstimatedChangesCountAsync(clientScope); Let me know if it's working for you ? Seb |
Beta Was this translation helpful? Give feedback.
Hey @dotnetninja
You can try something like that:
Get Estimated changes from a client application
If you want to know if any changes, from a client application, (using a
WebClientOrchestrator
) you can do something like that:Get Estimated changes from a daemon application ru…