private async void OnSyncData(SyncDataEventArgs obj) { if (obj.SyncGpsOnly) //this is called when complete survey { SyncBreadCrumbs(); return; } ToolbarCommand.ImageUri = ProcessingImage; ToolbarCommand.ToolTip = "Sync in progress"; using (var monitor = await GeodatabaseMonitor.CreateAsync(Log, EventAggregator)) { var gdbList = obj.GdbPaths.Select(gdbPath => monitor[gdbPath]).ToList(); await SyncDataAsync(gdbList, obj.SyncDirection); if (obj.RequireFileSync) { FullFileSync(gdbList); } } if (obj.CloseOnCompletion) { EventAggregator.GetEvent <CloseApplicationEvent>().Publish(CloseApplicationEventArgs.Empty); } }
public async void ExecuteManualSync() { try { Log.Debug("Manual Sync Started"); if (_isSynching) { Log.Debug("Already in sync process, skipping manual sync"); } _isSynching = true; //EventAggregator.GetEvent<NotifyEvent>().Publish(new NotifyEventArgs("Manual Sync Started")); using (var gdbMonitor = await GeodatabaseMonitor.CreateAsync(Log, EventAggregator, false)) { await SyncDataAsync(gdbMonitor.BidirectionalGeodatabases, SyncDirection.Upload); await SyncDataAsync(gdbMonitor.BidirectionalGeodatabases, SyncDirection.Download); } _isSynching = false; await DeltasSyncAsync(); DataFileTracker.UpdateLastDownloadSyncDate(); Log.Debug("Manual Sync Completed"); //EventAggregator.GetEvent<TableChangedEvent>().Publish(TableChangedEventArgs.Empty); } catch (Exception e) { Log.Error("Something went wrong....", e); } }
private async Task ContinousSyncAsync(TimeSpan period) { while (!CancellationToken.IsCancellationRequested) { await Task.Delay(period, CancellationToken); if (CancellationToken.IsCancellationRequested) { Log.Info("Sync was cancelled"); return; } if (!_isConnected) { Log.Info("Not connected to server, skipping sync"); continue; } if (!_canStartSync) { Log.Info("Map not loaded, delaying sync"); continue; } if (!_initialDownloadComplete) { Log.Info("Bidirectional sync waiting for completion of download"); continue; } using (var gdbMonitor = await GeodatabaseMonitor.CreateAsync(Log, EventAggregator)) { if (_isSynching) { Log.Debug("Sync in progress - skipping background sync"); continue; } Log.Debug("Background sync beginning"); _isSynching = true; await SyncDataAsync(gdbMonitor.BidirectionalGeodatabases, SyncDirection.Bidirectional); _isSynching = false; Log.Debug("Background sync completed"); FullFileSync(gdbMonitor.BidirectionalGeodatabases); EventAggregator.GetEvent <TableChangedEvent>().Publish(TableChangedEventArgs.Empty); } } }