Beispiel #1
0
        public void Handle(AlbumImportedEvent message)
        {
            if (!message.NewDownload)
            {
                return;
            }

            var downloadMessage = new AlbumDownloadMessage

            {
                Message        = GetAlbumDownloadMessage(message.Artist, message.Album, message.ImportedTracks),
                Artist         = message.Artist,
                Album          = message.Album,
                Release        = message.AlbumRelease,
                DownloadClient = message.DownloadClient,
                DownloadId     = message.DownloadId,
                TrackFiles     = message.ImportedTracks,
                OldFiles       = message.OldFiles,
            };

            foreach (var notification in _notificationFactory.OnReleaseImportEnabled())
            {
                try
                {
                    if (ShouldHandleArtist(notification.Definition, message.Artist))
                    {
                        if (downloadMessage.OldFiles.Empty() || ((NotificationDefinition)notification.Definition).OnUpgrade)
                        {
                            notification.OnReleaseImport(downloadMessage);
                        }
                    }
                }

                catch (Exception ex)
                {
                    _logger.Warn(ex, "Unable to send OnReleaseImport notification to: " + notification.Definition.Name);
                }
            }
        }
Beispiel #2
0
        public void Handle(BookImportedEvent message)
        {
            if (!message.NewDownload)
            {
                return;
            }

            var downloadMessage = new BookDownloadMessage
            {
                Message        = GetBookDownloadMessage(message.Author, message.Book, message.ImportedBooks),
                Author         = message.Author,
                Book           = message.Book,
                DownloadClient = message.DownloadClientInfo?.Name,
                DownloadId     = message.DownloadId,
                BookFiles      = message.ImportedBooks,
                OldFiles       = message.OldFiles,
            };

            foreach (var notification in _notificationFactory.OnReleaseImportEnabled())
            {
                try
                {
                    if (ShouldHandleAuthor(notification.Definition, message.Author))
                    {
                        if (downloadMessage.OldFiles.Empty() || ((NotificationDefinition)notification.Definition).OnUpgrade)
                        {
                            notification.OnReleaseImport(downloadMessage);
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.Warn(ex, "Unable to send OnReleaseImport notification to: " + notification.Definition.Name);
                }
            }
        }