Пример #1
0
        private void RemoveCompletedDownloads()
        {
            var trackedDownloads = _trackedDownloadService.GetTrackedDownloads()
                                   .Where(t => !t.DownloadItem.Removed && t.DownloadItem.CanBeRemoved && t.State == TrackedDownloadState.Imported)
                                   .ToList();

            foreach (var trackedDownload in trackedDownloads)
            {
                _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload));
            }
        }
        public void Execute(ProcessMonitoredDownloadsCommand message)
        {
            var enableCompletedDownloadHandling = _configService.EnableCompletedDownloadHandling;
            var trackedDownloads = _trackedDownloadService.GetTrackedDownloads();

            foreach (var trackedDownload in trackedDownloads)
            {
                if (trackedDownload.State == TrackedDownloadState.DownloadFailedPending)
                {
                    _failedDownloadService.ProcessFailed(trackedDownload);
                }

                if (enableCompletedDownloadHandling && trackedDownload.State == TrackedDownloadState.ImportPending)
                {
                    _completedDownloadService.Import(trackedDownload);
                }
            }

            if (enableCompletedDownloadHandling && _configService.RemoveCompletedDownloads)
            {
                // Remove tracked downloads that are now complete
                RemoveCompletedDownloads(trackedDownloads);
            }

            _eventAggregator.PublishEvent(new DownloadsProcessedEvent());
        }
Пример #3
0
        public void Handle(DownloadsProcessedEvent message)
        {
            var trackedDownloads = _trackedDownloadService.GetTrackedDownloads().Where(t => t.IsTrackable && DownloadIsTrackable(t)).ToList();

            _eventAggregator.PublishEvent(new TrackedDownloadRefreshedEvent(trackedDownloads));
        }