private async Task LoadXmlFromHttpAsync() { _timer.Stop(); UpdateStatusChanged?.Invoke(this, UpdateStatus.InProgress); string url = _configuration["host"]; //string url = "https://raw.githubusercontent.com/kizeevov/PhoneBook/master/PhoneBook/Assets/phonebook.xml"; string xml = await _fileService.TryGetXmlFileAsync(url).ConfigureAwait(false); string xmlFile = await TryReadXmlFromFileAsync(); if (!string.IsNullOrEmpty(xml)) { if (xml == xmlFile) { UpdateStatusChanged?.Invoke(this, UpdateStatus.Actual); return; } _contacts = _xmlPhoneBookParser.Parse(xml).ToList(); UpdateStatusChanged?.Invoke(this, UpdateStatus.Success); await TryWriteXmlToFileAsync(xml); } else { UpdateStatusChanged?.Invoke(this, UpdateStatus.Error); } _timer.Start(); }
protected override async Task ActionAsync(CancellationToken cancel) { var newUpdateStatus = await WasabiClient.CheckUpdatesAsync(cancel).ConfigureAwait(false); if (newUpdateStatus != UpdateStatus) { UpdateStatus = newUpdateStatus; UpdateStatusChanged?.Invoke(this, newUpdateStatus); } }
private async void LoadPhoneBook() { string xml = await TryReadXmlFromFileAsync(); if (string.IsNullOrEmpty(xml)) { await LoadXmlFromHttpAsync(); return; } _contacts = _xmlPhoneBookParser.Parse(xml).ToList(); UpdateStatusChanged?.Invoke(this, UpdateStatus.Success); _timer.Start(); }
public void RaiseUpdateStatusChanged(UpdateStatus newStatus, int progress = -1) { UpdateStatusChanged?.Invoke(newStatus, progress); }
protected virtual void OnUpdateStatusChanged(UpdateStatusChangedEventArgs e) { UpdateStatusChanged?.Invoke(this, e); }
/// <summary> /// Notifies handlers of <see cref="UpdateStatusChanged"/> that <see cref="IsUpdateAvailable"/> has been updated. /// </summary> protected void NotifyUpdateStatusChanged() { UpdateStatusChanged?.Invoke(this, EventArgs.Empty); }
private void OnUpdateStatusChanged() { UpdateStatusChanged?.Invoke(this, new EventArgs()); }
private async Task <bool> TryDownloadNewLauncher(string downloadTargetPath) { var downloadLauncherUrl = Constants.GetLauncherFileDownloadUrl(_settingsProvider.GetCurrentSettings().UpdateChannel); _logger.Write("Downloading new launcher."); try { using (var httpClientWithProgress = new HttpClientDownloadWithProgress(downloadLauncherUrl, downloadTargetPath)) { httpClientWithProgress.ProgressChanged += (size, downloaded, percentage) => UpdateStatusChanged?.Invoke(percentage ?? 50); await httpClientWithProgress.StartDownload(); } return(true); } catch (Exception e) { _logger.Write(e); } return(false); }