public async Task InitializeAccountSettingsAsync() { SettingsProvider.AccountModel = new AccountModel(); AccountModel loadedAccountModel = null; var networkConnected = await NetworkUtility.CheckInternetConnectionAsync(); if (networkConnected) { loadedAccountModel = await LoadServerAccountSettingsAsync(); } else if (!networkConnected || loadedAccountModel == null) { loadedAccountModel = LoadLocalAccountSettings(); } if (loadedAccountModel == null) { return; } SettingsProvider.AccountModel = new AccountModel { UserName = loadedAccountModel.UserName, Email = loadedAccountModel.Email, LicenseType = loadedAccountModel.LicenseType, LicenseExpirationDate = loadedAccountModel.LicenseExpirationDate, }; }
public async Task <bool> CheckLicenseAsync() { bool networkConnection = await NetworkUtility.CheckInternetConnectionAsync(); bool tokenExists = await new LocalLicenseValidator().ValidateAsync(); bool licenseStatus = networkConnection ? await new PersonalLicenseValidator().ValidateAsync() : tokenExists; OnLicenseStatusChanced.Invoke(this, new LicenseEventArgs(licenseStatus, tokenExists)); return(licenseStatus); }
public async Task UploadSettingsAsync() { if (await NetworkUtility.CheckInternetConnectionAsync() == false) { return; } var settingsHandler = new SettingsHandler(); string json = settingsHandler.GetSettingsAsJson(); await PostSettingsAsync(json); }
public async Task <bool> CheckLicenseAsync(TokenModel tokenModel = null) { var networkAvailable = await NetworkUtility.CheckInternetConnectionAsync(); if (tokenModel == null) { tokenModel = new TokenModel(); } bool licenceStatus = networkAvailable ? await CheckOnlineLicenseAsync(tokenModel) : CheckLocalLicense(); OnLicenseStatusChanced.Invoke(this, new LicenseEventArgs(licenceStatus)); return(licenceStatus); }
public async Task <bool> CloudSaveExistsAsync() { if (await NetworkUtility.CheckInternetConnectionAsync() == false) { return(false); } HttpResponseMessage httpResponseMessage = await GetSettingsAsync(); if (httpResponseMessage.IsSuccessStatusCode) { return(true); } return(false); }
public async Task DownloadSettingsAsync() { if (await NetworkUtility.CheckInternetConnectionAsync() == false) { return; } HttpResponseMessage httpResponseMessage = await GetSettingsAsync(); if (httpResponseMessage.IsSuccessStatusCode) { var settingsHandler = new SettingsHandler(); string json = await httpResponseMessage.Content.ReadAsStringAsync(); settingsHandler.LoadCloudSettings(json); } }