Exemplo n.º 1
0
        public void Handle(MovieFileDeletedEvent message)
        {
            var deleteMessage = new MovieFileDeleteMessage();

            deleteMessage.Message   = GetMessage(message.MovieFile.Movie, message.MovieFile.Quality);
            deleteMessage.MovieFile = message.MovieFile;
            deleteMessage.Movie     = message.MovieFile.Movie;
            deleteMessage.Reason    = message.Reason;

            foreach (var notification in _notificationFactory.OnMovieFileDeleteEnabled())
            {
                try
                {
                    if (message.Reason != MediaFiles.DeleteMediaFileReason.Upgrade || ((NotificationDefinition)notification.Definition).OnMovieFileDeleteForUpgrade)
                    {
                        if (ShouldHandleMovie(notification.Definition, message.MovieFile.Movie))
                        {
                            notification.OnMovieFileDelete(deleteMessage);
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.Warn(ex, "Unable to send OnMovieFileDelete notification to: " + notification.Definition.Name);
                }
            }
        }