예제 #1
0
        public void DownloadFilesOnSpecificDirectory(string downloadLink, string directoryPath)
        {
            _ChangeStatusForCurrentProgramInDownloadingStatus(Constants.StatusDownloading);

            try
            {
                using (var client = _webClient)
                {
                    client.DownloadProgressChanged += _WebClient_DownloadProgressChanged;
                    client.DownloadFileCompleted += webClient_OnFinish;
                    client.DownloadFileAsync(new Uri(downloadLink),
                        directoryPath);
                }
            }
            catch (Exception e)
            {
                var decisionsArgs = new DecisionsArgsBuilder().Build(e, _stopButton);
                var status= new DecisionsFactory().GetDecisionBasedOnArgs(decisionsArgs)
                    .TriggerDecision(decisionsArgs);
                _ChangeStatusForCurrentProgramInDownloadingStatus(status);
            }
        }
예제 #2
0
        private void webClient_OnFinish(object sender, AsyncCompletedEventArgs e)
        {
            var decisionsArgsBuilder = new DecisionsArgsBuilder();

            _webClient.Dispose();

            var newStatus = new DecisionsFactory().GetDecisionBasedOnArgs(decisionsArgsBuilder.Build(e))
                .TriggerDecision(decisionsArgsBuilder
                .Build(e,_downloadProgressBar, UtilClass.CreateDirectoryPathWithProgramFile(_currentDirectoryPath,
                _currentProgramInDownloading.DownloadLink),_downloadablePrograms,_downloadProgressLabel));

            _ChangeStatusForCurrentProgramInDownloadingStatus(newStatus);

            if (_downloadablePrograms.Count <= 0) return;
            _DownloadFile();
        }