public async Task<Poraba> GetData(MobileCredentials mobileCredentials) { var stopwatch = new Stopwatch(); stopwatch.Start(); var serviceClient = new MDFServiceSoapClient(); var result = await serviceClient.MonitorAsync(mobileCredentials.MobileNumber, mobileCredentials.Password); var poraba = new Poraba(result.Body.MonitorResult); stopwatch.Stop(); _tc.TrackMetric("Background Task", stopwatch.ElapsedMilliseconds); return poraba; }
private async Task RefreshData(MobileCredentials mobileCredentials, bool networkPresent) { try { if (networkPresent) { Poraba = await _dataService.GetData(mobileCredentials); CacheData(Poraba); } else // TODO // Really? Poraba = new Poraba(); TileUpdateBackgroundTask.UpdateTile(Poraba.QuotaPerc, Poraba.WorstQuotas, Poraba.ExtraSpent, Poraba.MonetaSpent, Poraba.QuotaDescription, Poraba.LastUpdated); } catch (Exception ex) { TelemetryClient.TrackException(ex); throw; } }
public static async Task LoadCache() { try { var folder = await GetFolder(); var files = await folder.GetFilesAsync(); var jsonFile = files.FirstOrDefault(x => x.Name == storageFile); if (jsonFile != null) { var jsonData = await FileIO.ReadTextAsync(jsonFile); PorabaCache = JsonConvert.DeserializeObject<Poraba>(jsonData); } else { PorabaCache = new Poraba(); } } catch (Exception) { throw; } }
private async void CacheData(Poraba poraba) { var folder = await GetFolder(); var jsonData = JsonConvert.SerializeObject(poraba); var jsonFile = await folder.CreateFileAsync(storageFile, CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(jsonFile, jsonData); }
private async Task RefreshData(MobileCredentials mobileCredentials, bool networkPresent) { ShowAppBar = false; ShowLogin = Visibility.Collapsed; ShowData = Visibility.Collapsed; ShowProgress = Visibility.Visible; try { if (networkPresent) Poraba = await _dataService.GetData(mobileCredentials); else Poraba = new Poraba(); TileUpdateBackgroundTask.UpdateTile(Poraba.QuotaPerc, Poraba.WorstQuotas, Poraba.ExtraSpent, Poraba.MonetaSpent, Poraba.QuotaDescription, Poraba.LastUpdated); } catch (Exception ex) { _tc.TrackException(ex); throw; } finally { ShowProgress = Visibility.Collapsed; ShowData = Visibility.Visible; } }