コード例 #1
0
        private void OnProgressChanged(object sender, FileDownloadingProgressArguments e)
        {
            var progressArgs = new CourseDownloadingProgressArguments
            {
                CurrentAction  = Properties.Resources.Downloading,
                ClipName       = e.FileName,
                CourseProgress = _totalCourseDownloadingProgessRatio,
                ClipProgress   = e.Percentage
            };

            _courseDownloadingProgress.Report(progressArgs);
        }
コード例 #2
0
        private async Task DownloadCourse(RpcData rpcData)
        {
            string destinationFolder = _configProvider.DownloadsPath;

            var course = rpcData.Payload.Course;

            _timeoutBetweenClipDownloadingTimer.Elapsed += OnTimerElapsed;

            var courseDirectory = CreateCourseDirectory(GetBaseCourseDirectoryName(destinationFolder, course.Title));

            try
            {
                var moduleCounter = 0;
                foreach (var module in course.Modules)
                {
                    ++moduleCounter;
                    await DownloadModule(rpcData, courseDirectory, moduleCounter, module);
                }

                _lastFinishedMessageComposer.SetState(1);
            }
            catch (OperationCanceledException)
            {
                _lastFinishedMessageComposer.SetState(2);
            }
            catch (Exception ex)
            {
                _lastFinishedMessageComposer.SetState(3);
            }
            finally
            {
                var progressArgs = new CourseDownloadingProgressArguments
                {
                    ClipName       = string.Empty,
                    CourseProgress = 0,
                    ClipProgress   = 0
                };
                _timeoutBetweenClipDownloadingTimer.Elapsed -= OnTimerElapsed;
                _courseDownloadingProgress.Report(progressArgs);
                if (_timeoutBetweenClipDownloadingTimer != null)
                {
                    _timeoutBetweenClipDownloadingTimer.Enabled = false;
                }
                _timeoutProgress.Report(0);
            }
        }
コード例 #3
0
        private async Task DownloadCourse(Course course)
        {
            string destinationFolder = _configProvider.DownloadsPath;

            _timeoutBetweenClipDownloadingTimer.Elapsed += OnTimerElapsed;

            var courseDirectory = CreateCourseDirectory(GetBaseCourseDirectoryName(destinationFolder, course.Title));

            try
            {
                var moduleCounter = 0;
                foreach (var module in course.Modules)
                {
                    ++moduleCounter;
                    await DownloadModule(course, courseDirectory, moduleCounter, module);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                var progressArgs = new CourseDownloadingProgressArguments
                {
                    ClipName       = string.Empty,
                    CourseProgress = 0,
                    ClipProgress   = 0
                };
                _timeoutBetweenClipDownloadingTimer.Elapsed -= OnTimerElapsed;
                _courseDownloadingProgress.Report(progressArgs);
                if (_timeoutBetweenClipDownloadingTimer != null)
                {
                    _timeoutBetweenClipDownloadingTimer.Enabled = false;
                }
                _timeoutProgress.Report(0);
            }
        }