public PendingQueueViewModel(ILocationSyncManager syncManager) { this.Load = ReactiveCommand.CreateFromTask(async() => { this.Items.Clear(); var gps = await syncManager.GetPendingGpsEvents(); foreach (var item in gps) { this.Items.Add(new CommandItem { Text = $"GPS Lat: {item.Latitude} - Long: {item.Longitude}", Detail = item.DateCreated.LocalDateTime.ToLongDateString() }); } var geofences = await syncManager.GetPendingGeofenceEvents(); foreach (var geofence in geofences) { this.Items.Add(new CommandItem { Text = $"Geofence {geofence.Identifier} (Entered: {geofence.Entered})", Detail = geofence.DateCreated.LocalDateTime.ToLongDateString() }); } this.RaisePropertyChanged(nameof(this.Items)); }); this.BindBusyCommand(this.Load); }
public SyncGeofenceJob(ILocationSyncManager syncManager, IRepository repository, IGeofenceSyncDelegate?geofences = null) { this.syncManager = syncManager; this.repository = repository; this.geofences = geofences; }
public SyncGpsJob(ILocationSyncManager syncManager, IRepository repository, IGpsSyncDelegate?gps = null) { this.syncManager = syncManager; this.repository = repository; this.gps = gps; }
public static async Task <bool> Process <T>(ILocationSyncManager syncManager, JobInfo jobInfo, IRepository repository, Func <IEnumerable <T>, CancellationToken, Task> process, CancellationToken cancelToken) where T : LocationEvent { if (!syncManager.IsSyncEnabled) { return(false); } var config = jobInfo.GetSyncConfig(); var events = await repository.GetAll <T>(); var list = config.SortMostRecentFirst ? events.OrderByDescending(x => x.DateCreated) : events.OrderBy(x => x.DateCreated); //if (config.ExpirationTime != null) //{ // // TODO: if expired, delete it - could also let processor deal with this // //list = list.Where(x => x.DateCreated.Add(expiryTime) > DateTime.UtcNow); //} foreach (var batch in list.Page(config.BatchSize)) { var batchProcessed = false; // configure how aggressive this need to be? while (!cancelToken.IsCancellationRequested && !batchProcessed) { try { await process(batch, cancelToken); batchProcessed = true; foreach (var e in batch) { await repository.Remove <T>(e.Id); } } catch (Exception ex) { await Task.Delay(1000); // TODO: retry time Log.Write(ex); } } } return(events.Any()); }
public ActionsViewModel(SampleSqliteConnection conn, LocationSyncDelegates syncDelegate, ILocationSyncManager syncManager, IDialogs dialogs) { this.conn = conn; this.syncDelegate = syncDelegate; this.syncManager = syncManager; this.dialogs = dialogs; this.ProcessGeofences = this.ProcessCommand(LocationSyncType.Geofence); this.ClearGeofences = this.ClearCommand(LocationSyncType.Geofence); this.ProcessGps = this.ProcessCommand(LocationSyncType.GPS); this.ClearGps = this.ClearCommand(LocationSyncType.GPS); }