async Task ExecuteSyncCommandAsync() { if (IsBusy) { return; } if (!CrossConnectivity.Current.IsConnected) { MessagingUtils.SendOfflineMessage(); return; } Logger.Track(EvolveLoggerKeys.ManualSync); SyncText = "Syncing..."; IsBusy = true; try { #if DEBUG await Task.Delay(1000); #endif Settings.HasSyncedData = true; Settings.LastSync = DateTime.UtcNow; OnPropertyChanged("LastSyncDisplay"); await StoreManager.SyncAllAsync(Settings.Current.IsLoggedIn); if (!Settings.Current.IsLoggedIn && FeatureFlags.LoginEnabled) { MessagingService.Current.SendMessage(MessageKeys.Message, new MessagingServiceAlert { Title = $"{EventInfo.EventName} Data Synced", Message = "You now have the latest conference data, however to sync your favorites and feedback you must sign in.", Cancel = "OK" }); } } catch (Exception ex) { ex.Data["method"] = "ExecuteSyncCommandAsync"; MessagingUtils.SendAlert("Unable to sync", "Uh oh, something went wrong with the sync, please try again. \n\n Debug:" + ex.Message); Logger.Report(ex); } finally { SyncText = defaultSyncText; IsBusy = false; } }
public async Task FinishHack() { if (!CrossConnectivity.Current.IsConnected) { MessagingUtils.SendAlert("Offline", "You are currently offline. Please go online in order to unlock this Mini-Hack."); return; } if (!Settings.Current.IsLoggedIn) { queued = true; MessagingService.Current.SendMessage(MessageKeys.NavigateLogin); return; } if (IsBusy) { return; } IsBusy = true; queued = false; try { Logger.Track(EvolveLoggerKeys.FinishMiniHack, "Name", Hack.Name); var mobileClient = DataStore.Azure.StoreManager.MobileService; if (mobileClient == null) { return; } var body = JsonConvert.SerializeObject(Hack.Id); await mobileClient.InvokeApiAsync("CompleteMiniHack", body, HttpMethod.Post, null); Hack.IsCompleted = true; Settings.Current.FinishHack(Hack.Id); } catch (Exception ex) { Logger.Report(ex); } finally { IsBusy = false; } }