private void DownloadSoftware() { CancelDownloading(); _cancelDownload = false; SoftwareUpdateProgress = SoftwareUpdateProgressEnum.Downloading; if (null == _webClient) { _webClient = new WebClient(); _webClient.DownloadFileCompleted += Client_DownloadFileCompleted; _webClient.DownloadProgressChanged += Client_DownloadProgressChanged; } int pos = _downloadUrl.LastIndexOf("/"); string fileName = _downloadUrl.Substring(pos + 1); _fullDownloadedFileName = Path.Combine(Utils.GetInstallPackagePath(), fileName); log.InfoFormat("Download install package to: {0}", _fullDownloadedFileName); if (File.Exists(_fullDownloadedFileName)) { File.Delete(_fullDownloadedFileName); } try { _webClient.DownloadFileAsync(new Uri(_downloadUrl), _fullDownloadedFileName, fileName); } catch (Exception ex) { log.InfoFormat("Failed to download install package, err:{0}", ex.Message); } }
private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { log.InfoFormat("Download file completed. Canclled:{0}", _cancelDownload); if (_cancelDownload) { RemoveDownloadedSoftware(); } SoftwareUpdateProgress = SoftwareUpdateProgressEnum.Downloaded; }
public void Reset(string version, string downloadUrl) { _version = version; _downloadUrl = downloadUrl; SoftwareUpdateProgress = SoftwareUpdateProgressEnum.NewVersionFound; }
public SoftwareUpdateWindowModel() { SoftwareUpdateProgress = SoftwareUpdateProgressEnum.NewVersionFound; }