private async Task LoadSettings() { RetryButtonIsVisible = false; App.Settings.ConnectionDetails = new ConnectionDetails { PortNo = 8096 }; var doNotShowFirstRun = _applicationSettings.Get(Constants.Settings.DoNotShowFirstRun, false); if (!doNotShowFirstRun) { NavigationService.NavigateTo(Constants.Pages.FirstRun.WelcomeView); return; } SetProgressBar(AppResources.SysTrayLoadingSettings); #if !DEBUG //try //{ // if (!ApplicationManifest.Current.App.Title.ToLower().Contains("beta")) // { // var marketPlace = new MarketplaceInformationService(); // var appInfo = await marketPlace.GetAppInformationAsync(ApplicationManifest.Current.App.ProductId); // if (new Version(appInfo.Entry.Version) > new Version(ApplicationManifest.Current.App.Version) && // MessageBox.Show("There is a newer version, would you like to install it now?", "Update Available", MessageBoxButton.OKCancel) == MessageBoxResult.OK) // { // new MarketplaceDetailService().Show(); // } // } //} //catch (Exception ex) //{ // Log.ErrorException("GetAppInformationAsync()", ex); //} #endif // Get and set the app specific settings _specificSettings = _applicationSettings.Get<SpecificSettings>(Constants.Settings.SpecificSettings); if (_specificSettings != null) SharedUtils.CopyItem(_specificSettings, App.SpecificSettings); SetRunUnderLock(); _uploadSettings = _applicationSettings.Get<UploadSettings>(Constants.Settings.PhotoUploadSettings); if (_uploadSettings != null) SharedUtils.CopyItem(_uploadSettings, App.UploadSettings); _connectionDetails = _applicationSettings.Get<ConnectionDetails>(Constants.Settings.ConnectionSettings); _savedServer = _applicationSettings.Get<ServerInfo>(Constants.Settings.DefaultServerConnection); if (_savedServer != null) { _serverInfo.SetServerInfo(_savedServer); } else { NavigationService.NavigateTo(Constants.Pages.FirstRun.WelcomeView); return; } await ConnectToServer(); }
private async Task ConnectToServer() { RetryButtonIsVisible = false; ConnectionResult result = null; SetProgressBar(AppResources.SysTrayGettingServerDetails); if (_connectionDetails != null && !string.IsNullOrEmpty(_connectionDetails.ServerId)) { result = await ConnectionManager.Connect(_connectionDetails.ServerAddress); var server = result.Servers.FirstOrDefault(x => string.Equals(x.Id, _connectionDetails.ServerId, StringComparison.CurrentCultureIgnoreCase)); if (server != null) { _serverInfo.SetServerInfo(server); _applicationSettings.Set(Constants.Settings.DefaultServerConnection, server); _savedServer = server; _applicationSettings.Remove(Constants.Settings.ConnectionSettings); _connectionDetails = null; } } if (_savedServer != null) { result = await ConnectionManager.Connect(_savedServer); } if (result != null && result.State == ConnectionState.Unavailable && _savedServer != null) { RetryButtonIsVisible = true; return; } // See if we can find and communicate with the server if (result == null || result.State == ConnectionState.Unavailable) { result = await ConnectionManager.Connect(); } Deployment.Current.Dispatcher.BeginInvoke(async () => { await Utils.HandleConnectedState(result, ApiClient, NavigationService, Log); SetProgressBar(); }); }