/// <summary> /// Updates the settings. /// </summary> /// <returns>Task.</returns> async Task UpdateSettings() { try { IConnectivity _connectivity = Container.Resolve <IConnectivity>(); if (_connectivity.IsConnected) { // update the current settings IDataUpdateService dataUpdateService = Container.Resolve <IDataUpdateService>(); ISettingsService settingsService = Container.Resolve <ISettingsService>(); var initialData = await dataUpdateService.GetInitialData(); await settingsService.UpdateSettings(initialData.Settings); } } catch { // ignore any errors } }
async Task OnCheckForUpdate() { try { Busy = true; // check for an update var initialData = await _dataUpdateService.GetInitialData(); await _settingsService.UpdateSettings(initialData.Settings); GetLatestInformation(); } catch { // ignore this exception } finally { Busy = false; } }
/// <summary> /// Called when logging in online. /// </summary> /// <returns>A bool indicating whether we should attempt offline login or not</returns> async Task <bool> OnlineLogin() { try { Busy = true; // await _accountService.Login("18774", "yakov123"); await _accountService.Login(Username, Password); if (_applicationState.CurrentUser.Username == Username) { // we're logged in _offlineServices.SaveCredentials(Username, Password); _secureAppStorage.Username = Username; var initialData = await _dataUpdateService.GetInitialData(); await _databaseService.WriteCurrentCases(initialData.Cases, Username); await _databaseService.WriteValidatedSessions(initialData.ValidatedSessions, Username); await _settingsService.UpdateSettings(initialData.Settings); await SetCurrentlyActiveSession(); // start the SessionUpdateService _sessionUpdateService.Start(); // and redirect to the start page await _navigationService.NavigateAsync("file:///TabbedNavigationPage?SelectedPage=Cases"); } else { // we're not logged in Message = "There was a problem logging in"; } } catch (CommunicationException communicationException) { Message = communicationException.ErrorMessage; // we got a valid response back, so don't continue return(false); } catch (Exception ex) { #if DEBUG // if in debug, show the message then login offline var pageDialogService = ((Prism.Unity.PrismApplication)(App.Current)).Container.Resolve <Prism.Services.IPageDialogService>(); await pageDialogService.DisplayAlertAsync("Debug", "Unable to login : "******" " + ex.Message, "Continue"); #endif return(true); } finally { Busy = false; } return(false); }