示例#1
0
        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);
            }
        }
示例#2
0
 private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     log.InfoFormat("Download file completed. Canclled:{0}", _cancelDownload);
     if (_cancelDownload)
     {
         RemoveDownloadedSoftware();
     }
     SoftwareUpdateProgress = SoftwareUpdateProgressEnum.Downloaded;
 }
示例#3
0
 public void Reset(string version, string downloadUrl)
 {
     _version               = version;
     _downloadUrl           = downloadUrl;
     SoftwareUpdateProgress = SoftwareUpdateProgressEnum.NewVersionFound;
 }
示例#4
0
 public SoftwareUpdateWindowModel()
 {
     SoftwareUpdateProgress = SoftwareUpdateProgressEnum.NewVersionFound;
 }