private static void CreateClient() { try { _logger.Info("Creating API Client"); var device = new Device { DeviceId = SharedUtils.GetDeviceId(), DeviceName = SharedUtils.GetDeviceName() }; var server = ApplicationSettings.Get <ServerInfo>(Constants.Settings.DefaultServerConnection); if (server == null) { _logger.Info("No server details found"); return; } var serverAddress = server.LastConnectionMode.HasValue && server.LastConnectionMode.Value == ConnectionMode.Manual ? server.ManualAddress : server.RemoteAddress; var client = new ApiClient(MediaBrowserLogger, serverAddress, "Windows Phone 8", device, ApplicationManifest.Current.App.Version, new CryptographyProvider()); client.SetAuthenticationInfo(server.AccessToken, server.UserId); _logger.Info("Client created"); _apiClient = client; } catch (Exception ex) { _logger.FatalException("Error creating ApiClient", ex); } }
public void CheckIfUserSignedIn() { var user = _settingsService.Get <UserDto>(Constants.Settings.SelectedUserSetting); var oldUser = _settingsService.Get <AuthenticationResult>(Constants.Settings.AuthUserSetting); if (user != null) { LoggedInUser = user; } if (oldUser != null) { AuthenticationResult = oldUser; } }
public static T GetS <T>(this IApplicationSettingsServiceHandler handler, string key) { if (!handler.Contains(key)) { return(default(T)); } var json = handler.Get <string>(key); var item = JsonConvert.DeserializeObject <T>(json); return(item); }
private static void CreateClient() { try { _logger.Info("Creating Client"); var device = new Device { DeviceId = SharedUtils.GetDeviceId(), DeviceName = SharedUtils.GetDeviceName() }; var server = ApplicationSettings.Get <ServerInfo>(Constants.Settings.DefaultServerConnection); var auth = ApplicationSettings.Get <AuthenticationResult>(Constants.Settings.AuthUserSetting); if (server == null || auth == null || auth.User == null) { if (server == null) { _logger.Info("No server information!"); } if (auth == null) { _logger.Info("No authentication info"); } if (auth != null && auth.User == null) { _logger.Info("No User info available"); } return; } var serverAddress = server.LastConnectionMode.HasValue && server.LastConnectionMode.Value == ConnectionMode.Manual ? server.ManualAddress : server.RemoteAddress; _logger.Info("LastConnectionMode used: {0}", server.LastConnectionMode.HasValue && server.LastConnectionMode.Value == ConnectionMode.Manual ? ConnectionMode.Manual : ConnectionMode.Remote); var client = new ApiClient(_mbLogger, serverAddress, "Windows Phone 8", device, ApplicationManifest.Current.App.Version, new CryptographyProvider()); client.SetAuthenticationInfo(auth.AccessToken, auth.User.Id); _apiClient = client; } catch (Exception ex) { _logger.FatalException("Error creating ApiClient", ex); } }
public void LoadSettings() { var json = _roamingSettings.Get(Constants.StorageSettings.SettingsFile, string.Empty); if (string.IsNullOrEmpty(json)) { return; } var settings = JsonConvert.DeserializeObject <SettingsService>(json); settings.CopyItem(this); }
private int GetWordsRead() { return(_roamingSettings.Get(SelectedItem.InternalId, 0)); }
private bool FileExistsAsync(string filename) { var fileResponse = _roamingSettings.Get <object>(filename); return(fileResponse != null); }
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(); }