Exemple #1
0
        public void Handle(MovieGrabbedEvent message)
        {
            // Don't store grabbed events for clients that don't download IDs
            if (message.DownloadId.IsNullOrWhiteSpace())
            {
                return;
            }

            var history = new DownloadHistory
            {
                EventType        = DownloadHistoryEventType.DownloadGrabbed,
                MovieId          = message.Movie.Movie.Id,
                DownloadId       = message.DownloadId,
                SourceTitle      = message.Movie.Release.Title,
                Date             = DateTime.UtcNow,
                Protocol         = message.Movie.Release.DownloadProtocol,
                IndexerId        = message.Movie.Release.IndexerId,
                DownloadClientId = message.DownloadClientId,
                Release          = message.Movie.Release
            };

            history.Data.Add("Indexer", message.Movie.Release.Indexer);
            history.Data.Add("DownloadClient", message.DownloadClient);
            history.Data.Add("DownloadClientName", message.DownloadClientName);

            history.Data.Add("CustomFormatScore", message.Movie.CustomFormatScore.ToString());
            _repository.Insert(history);
        }
Exemple #2
0
        public void Handle(DownloadIgnoredEvent message)
        {
            var history = new DownloadHistory
            {
                EventType        = DownloadHistoryEventType.DownloadIgnored,
                MovieId          = message.MovieId,
                DownloadId       = message.DownloadId,
                SourceTitle      = message.SourceTitle,
                Date             = DateTime.UtcNow,
                Protocol         = message.DownloadClientInfo.Protocol,
                DownloadClientId = message.DownloadClientInfo.Id
            };

            history.Data.Add("DownloadClient", message.DownloadClientInfo.Type);
            history.Data.Add("DownloadClientName", message.DownloadClientInfo.Name);

            _repository.Insert(history);
        }
Exemple #3
0
        public void Handle(BookImportIncompleteEvent message)
        {
            var history = new DownloadHistory
            {
                EventType        = DownloadHistoryEventType.DownloadImportIncomplete,
                AuthorId         = message.TrackedDownload.RemoteBook?.Author?.Id ?? 0,
                DownloadId       = message.TrackedDownload.DownloadItem.DownloadId,
                SourceTitle      = message.TrackedDownload.DownloadItem.OutputPath.ToString(),
                Date             = DateTime.UtcNow,
                Protocol         = message.TrackedDownload.Protocol,
                DownloadClientId = message.TrackedDownload.DownloadClient
            };

            history.Data.Add("DownloadClient", message.TrackedDownload.DownloadItem.DownloadClientInfo.Type);
            history.Data.Add("DownloadClientName", message.TrackedDownload.DownloadItem.DownloadClientInfo.Name);
            history.Data.Add("StatusMessages", message.TrackedDownload.StatusMessages.ToJson());

            _repository.Insert(history);
        }
Exemple #4
0
        public void Handle(DownloadCompletedEvent message)
        {
            var downloadItem = message.TrackedDownload.DownloadItem;

            var history = new DownloadHistory
            {
                EventType        = DownloadHistoryEventType.DownloadImported,
                MovieId          = message.MovieId,
                DownloadId       = downloadItem.DownloadId,
                SourceTitle      = downloadItem.Title,
                Date             = DateTime.UtcNow,
                Protocol         = message.TrackedDownload.Protocol,
                DownloadClientId = message.TrackedDownload.DownloadClient
            };

            history.Data.Add("DownloadClient", downloadItem.DownloadClientInfo.Type);
            history.Data.Add("DownloadClientName", downloadItem.DownloadClientInfo.Name);

            _repository.Insert(history);
        }
Exemple #5
0
        public void Handle(TrackImportedEvent message)
        {
            if (!message.NewDownload)
            {
                return;
            }

            var downloadId = message.DownloadId;

            // Try to find the downloadId if the user used manual import (from wanted: missing) or the
            // API to import and downloadId wasn't provided.
            if (downloadId.IsNullOrWhiteSpace())
            {
                downloadId = _historyService.FindDownloadId(message);
            }

            if (downloadId.IsNullOrWhiteSpace())
            {
                return;
            }

            var history = new DownloadHistory
            {
                EventType = DownloadHistoryEventType.FileImported,

                AuthorId         = message.ImportedBook.Author.Value.Id,
                DownloadId       = downloadId,
                SourceTitle      = message.BookInfo.Path,
                Date             = DateTime.UtcNow,
                Protocol         = message.DownloadClientInfo.Protocol,
                DownloadClientId = message.DownloadClientInfo.Id
            };

            history.Data.Add("DownloadClient", message.DownloadClientInfo.Type);
            history.Data.Add("DownloadClientName", message.DownloadClientInfo.Name);
            history.Data.Add("SourcePath", message.BookInfo.Path);
            history.Data.Add("DestinationPath", message.ImportedBook.Path);

            _repository.Insert(history);
        }
Exemple #6
0
        public void Handle(DownloadFailedEvent message)
        {
            // Don't track failed download for an unknown download
            if (message.TrackedDownload == null)
            {
                return;
            }

            var history = new DownloadHistory
            {
                EventType        = DownloadHistoryEventType.DownloadFailed,
                MovieId          = message.MovieId,
                DownloadId       = message.DownloadId,
                SourceTitle      = message.SourceTitle,
                Date             = DateTime.UtcNow,
                Protocol         = message.TrackedDownload.Protocol,
                DownloadClientId = message.TrackedDownload.DownloadClient
            };

            history.Data.Add("DownloadClient", message.TrackedDownload.DownloadItem.DownloadClientInfo.Type);
            history.Data.Add("DownloadClientName", message.TrackedDownload.DownloadItem.DownloadClientInfo.Name);

            _repository.Insert(history);
        }