Example #1
0
        private void ProcessUpdate()
        {
            _currentFileIndex++;

            // If we downloaded everything
            if (_currentFileIndex >= _filesToDownload.Count)
            {
                FinishUpdate();
            }
            // Otherwise
            else
            {
                string fileToDownload = _filesToDownload[_currentFileIndex];
                string destPath       = Path.GetTempFileName();
                _downloadDestinations.Add(fileToDownload, destPath);
                _webClient.DownloadFileAsync(new Uri(fileToDownload, UriKind.Relative), destPath);
                FileDownloadStarted?.Invoke(fileToDownload);
            }
        }
Example #2
0
        protected virtual void StartDLJob(FileDownloadInfo info)
        {
            string jobURL = PopDownloadFile();

            if (jobURL == string.Empty)
            {
                lock (DownloadPool)
                    DownloadPool.Remove(info);

                info.Connection.Dispose();
                info = null;
            }
            else
            {
                info.Args.DownloadFileName = jobURL;
                info.Args.Progress         = 0;
                lock (RootDir)
                    info.LocalFile = new FileInfo(Path.Combine(RootDir.FullName, jobURL));
                info.Args.LocalFileName = info.LocalFile.FullName;

                FileDownloadStarted?.Invoke(this, info.Args);

                string uriString = string.Empty;
                lock (UpdateServerURL)
                    uriString = UpdateServerURL + "dl.aspx";

                NameValueCollection data = new NameValueCollection();

                string cryptoFileName = HorizonCrypto.EncryptString(jobURL, CryptoSecret);

                data.Add("Timestamp", HorizonCrypto.TimeStamp());
                data.Add("Data", cryptoFileName);

                info.Connection.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";

                info.Connection.UploadValuesAsync(new Uri(uriString), "POST", data, info);
            }
        }
Example #3
0
 private void RaiseDownloadStarted(FileDownloadStartedArgs e)
 {
     FileDownloadStarted?.Invoke(e);
 }