Пример #1
0
 public void Handle(DownloadFailedEvent message)
 {
   Execute.ExecuteOnUIThread((Action) (() =>
   {
     if (this.CurrentDataContext == null || !(message.Id == this.CurrentDataContext.StickerProduct.id.ToString()))
       return;
     this.ProgressBar.Visibility = Visibility.Collapsed;
   }));
 }
Пример #2
0
 public void Handle(DownloadFailedEvent message)
 {
     Execute.ExecuteOnUIThread((Action)(() =>
     {
         if (this.CurrentDataContext == null || !(message.Id == this.CurrentDataContext.StickerProduct.id.ToString()))
         {
             return;
         }
         this.UpdateState(false);
     }));
 }
Пример #3
0
        public void Handle(DownloadFailedEvent message)
        {
            var blacklist = new Blacklist
            {
                SeriesId      = message.SeriesId,
                EpisodeIds    = message.EpisodeIds,
                SourceTitle   = message.SourceTitle,
                Quality       = message.Quality,
                Date          = DateTime.UtcNow,
                PublishedDate = DateTime.Parse(message.Data.GetValueOrDefault("publishedDate"))
            };

            _blacklistRepository.Insert(blacklist);
        }
        public void should_skip_redownload_if_event_has_skipredownload_set()
        {
            var failedEvent = new DownloadFailedEvent {
                ArtistId = 1,
                AlbumIds = new List <int> {
                    1
                },
                SkipReDownload = true
            };

            Subject.HandleAsync(failedEvent);

            Mocker.GetMock <IManageCommandQueue>()
            .Verify(x => x.Push(It.IsAny <Command>(), It.IsAny <CommandPriority>(), It.IsAny <CommandTrigger>()),
                    Times.Never());
        }
Пример #5
0
        public void Setup()
        {
            _event = new DownloadFailedEvent
            {
                SeriesId   = 12345,
                EpisodeIds = new List <int> {
                    1
                },
                Quality        = new QualityModel(Quality.Bluray720p),
                SourceTitle    = "series.title.s01e01",
                DownloadClient = "SabnzbdClient",
                DownloadId     = "Sabnzbd_nzo_2dfh73k"
            };

            _event.Data.Add("publishedDate", DateTime.UtcNow.ToString("s") + "Z");
        }
Пример #6
0
 void DownloadFile()
 {
     try
     {
         Thread.Sleep(500);
         Request         = WebRequest.Create(Url) as HttpWebRequest;
         Request.Timeout = 5000;
         Request.AddRange(From, To);
         HttpWebResponse Response = Request.GetResponse() as HttpWebResponse;
         using (Stream ResponseStream = Response.GetResponseStream())
         {
             using (Stream Stream = new FileStream(DownloadPath, FileMode.Create))
             {
                 byte[] Array = new byte[512];
                 int    i     = ResponseStream.Read(Array, 0, Array.Length);
                 while (i > 0)
                 {
                     DownloadedLength += i;
                     Stream.Write(Array, 0, i);
                     i = ResponseStream.Read(Array, 0, Array.Length);
                 }
             }
         }
         Completed = true;
         DownloadCompletedEvent?.Invoke(this);
     }
     catch (ThreadAbortException) { return; }
     catch (Exception ex)
     {
         if (ex.Message.Contains("终止") || ex.Message.Contains("内部"))
         {
             return;
         }
         if (ErrorNum >= 5)
         {
             Failed = true;
             DownloadFailedEvent?.Invoke(this);
             return;
         }
         MessageBox.Show(ex.ToString());
         ErrorNum++;
         DownloadedLength = 0L;
         WorkThread       = new Thread(DownloadFile);
         WorkThread.Start();
     }
 }
Пример #7
0
        public void Handle(DownloadFailedEvent message)
        {
            var history = new History
            {
                EventType   = HistoryEventType.DownloadFailed,
                Date        = DateTime.UtcNow,
                Quality     = message.Quality,
                SourceTitle = message.SourceTitle,
                MovieId     = message.MovieId,
                DownloadId  = message.DownloadId
            };

            history.Data.Add("DownloadClient", message.DownloadClient);
            history.Data.Add("Message", message.Message);

            _historyRepository.Insert(history);
        }
Пример #8
0
 public Blocklist GetBlocklist(DownloadFailedEvent message)
 {
     return(new Blocklist
     {
         ArtistId = message.ArtistId,
         AlbumIds = message.AlbumIds,
         SourceTitle = message.SourceTitle,
         Quality = message.Quality,
         Date = DateTime.UtcNow,
         PublishedDate = DateTime.Parse(message.Data.GetValueOrDefault("publishedDate")),
         Size = long.Parse(message.Data.GetValueOrDefault("size", "0")),
         Indexer = message.Data.GetValueOrDefault("indexer"),
         Protocol = message.Data.GetValueOrDefault("protocol"),
         Message = message.Message,
         TorrentInfoHash = message.Data.GetValueOrDefault("guid")
     });
 }
        public void Setup()
        {
            _event = new DownloadFailedEvent
            {
                MovieId        = 69,
                Quality        = new QualityModel(),
                SourceTitle    = "series.title.s01e01",
                DownloadClient = "SabnzbdClient",
                DownloadId     = "Sabnzbd_nzo_2dfh73k"
            };

            _event.Data.Add("publishedDate", DateTime.UtcNow.ToString("s") + "Z");
            _event.Data.Add("size", "1000");
            _event.Data.Add("indexer", "nzbs.org");
            _event.Data.Add("protocol", "1");
            _event.Data.Add("message", "Marked as failed");
        }
Пример #10
0
        public void Handle(DownloadFailedEvent message)
        {
            var blacklist = new Blacklist
            {
                MovieId         = message.MovieId,
                SourceTitle     = message.SourceTitle,
                Quality         = message.Quality,
                Date            = DateTime.UtcNow,
                PublishedDate   = DateTime.Parse(message.Data.GetValueOrDefault("publishedDate")),
                Size            = long.Parse(message.Data.GetValueOrDefault("size", "0")),
                Indexer         = message.Data.GetValueOrDefault("indexer"),
                Protocol        = (DownloadProtocol)Convert.ToInt32(message.Data.GetValueOrDefault("protocol")),
                Message         = message.Message,
                TorrentInfoHash = message.Data.GetValueOrDefault("torrentInfoHash")
            };

            _blacklistRepository.Insert(blacklist);
        }
Пример #11
0
        public void Handle(DownloadFailedEvent message)
        {
            var history = new MovieHistory
            {
                EventType   = MovieHistoryEventType.DownloadFailed,
                Date        = DateTime.UtcNow,
                Quality     = message.Quality,
                Languages   = message.Languages,
                SourceTitle = message.SourceTitle,
                MovieId     = message.MovieId,
                DownloadId  = message.DownloadId
            };

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

            _historyRepository.Insert(history);
        }
        public void should_skip_redownload_if_redownload_failed_disabled()
        {
            var failedEvent = new DownloadFailedEvent {
                ArtistId = 1,
                AlbumIds = new List <int> {
                    1
                }
            };

            Mocker.GetMock <IConfigService>()
            .Setup(x => x.AutoRedownloadFailed)
            .Returns(false);

            Subject.HandleAsync(failedEvent);

            Mocker.GetMock <IManageCommandQueue>()
            .Verify(x => x.Push(It.IsAny <Command>(), It.IsAny <CommandPriority>(), It.IsAny <CommandTrigger>()),
                    Times.Never());
        }
Пример #13
0
        public void Handle(DownloadFailedEvent message)
        {
            var downloadFailedMessage = new DownloadFailedMessage
            {
                DownloadId     = message.DownloadId,
                DownloadClient = message.DownloadClient,
                Quality        = message.Quality,
                SourceTitle    = message.SourceTitle,
                Message        = message.Message
            };

            foreach (var notification in _notificationFactory.OnDownloadFailureEnabled())
            {
                if (ShouldHandleArtist(notification.Definition, message.TrackedDownload.RemoteBook.Author))
                {
                    notification.OnDownloadFailure(downloadFailedMessage);
                }
            }
        }
Пример #14
0
        public void Setup()
        {
            _event = new DownloadFailedEvent
            {
                AuthorId = 12345,
                BookIds  = new List <int> {
                    1
                },
                Quality        = new QualityModel(Quality.MP3_320),
                SourceTitle    = "artist.name.album.title",
                DownloadClient = "SabnzbdClient",
                DownloadId     = "Sabnzbd_nzo_2dfh73k"
            };

            _event.Data.Add("publishedDate", DateTime.UtcNow.ToString("s") + "Z");
            _event.Data.Add("size", "1000");
            _event.Data.Add("indexer", "nzbs.org");
            _event.Data.Add("protocol", "1");
            _event.Data.Add("message", "Marked as failed");
        }
Пример #15
0
        public void Handle(DownloadFailedEvent message)
        {
            foreach (var episodeId in message.EpisodeIds)
            {
                var history = new History
                {
                    EventType   = HistoryEventType.DownloadFailed,
                    Date        = DateTime.UtcNow,
                    Quality     = message.Quality,
                    SourceTitle = message.SourceTitle,
                    SeriesId    = message.SeriesId,
                    EpisodeId   = episodeId,
                    DownloadId  = message.DownloadId
                };

                history.Data.Add("DownloadClient", message.DownloadClient);
                history.Data.Add("Message", message.Message);

                _historyRepository.Insert(history);
            }
        }
        public void should_redownload_artist_on_failure()
        {
            // note that artist is set to have 3 albums in setup
            var failedEvent = new DownloadFailedEvent {
                ArtistId = 2,
                AlbumIds = new List <int> {
                    1, 2, 3
                }
            };

            Subject.HandleAsync(failedEvent);

            Mocker.GetMock <IManageCommandQueue>()
            .Verify(x => x.Push(It.Is <ArtistSearchCommand>(c => c.ArtistId == failedEvent.ArtistId),
                                It.IsAny <CommandPriority>(), It.IsAny <CommandTrigger>()),
                    Times.Once());

            Mocker.GetMock <IManageCommandQueue>()
            .Verify(x => x.Push(It.IsAny <AlbumSearchCommand>(), It.IsAny <CommandPriority>(), It.IsAny <CommandTrigger>()),
                    Times.Never());
        }
        public void should_redownload_album_on_failure()
        {
            var failedEvent = new DownloadFailedEvent {
                ArtistId = 1,
                AlbumIds = new List <int> {
                    2
                }
            };

            Subject.HandleAsync(failedEvent);

            Mocker.GetMock <IManageCommandQueue>()
            .Verify(x => x.Push(It.Is <AlbumSearchCommand>(c => c.AlbumIds.Count == 1 &&
                                                           c.AlbumIds[0] == 2),
                                It.IsAny <CommandPriority>(), It.IsAny <CommandTrigger>()),
                    Times.Once());

            Mocker.GetMock <IManageCommandQueue>()
            .Verify(x => x.Push(It.IsAny <ArtistSearchCommand>(), It.IsAny <CommandPriority>(), It.IsAny <CommandTrigger>()),
                    Times.Never());
        }
Пример #18
0
        public void Handle(DownloadFailedEvent message)
        {
            foreach (var bookId in message.BookIds)
            {
                var history = new EntityHistory
                {
                    EventType   = EntityHistoryEventType.DownloadFailed,
                    Date        = DateTime.UtcNow,
                    Quality     = message.Quality,
                    SourceTitle = message.SourceTitle,
                    AuthorId    = message.AuthorId,
                    BookId      = bookId,
                    DownloadId  = message.DownloadId
                };

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

                _historyRepository.Insert(history);
            }
        }
        public void should_redownload_book_on_failure()
        {
            var failedEvent = new DownloadFailedEvent
            {
                AuthorId = 1,
                BookIds  = new List <int> {
                    2
                }
            };

            Subject.Handle(failedEvent);

            Mocker.GetMock <IManageCommandQueue>()
            .Verify(x => x.Push(It.Is <BookSearchCommand>(c => c.BookIds.Count == 1 &&
                                                          c.BookIds[0] == 2),
                                It.IsAny <CommandPriority>(),
                                It.IsAny <CommandTrigger>()),
                    Times.Once());

            Mocker.GetMock <IManageCommandQueue>()
            .Verify(x => x.Push(It.IsAny <AuthorSearchCommand>(), It.IsAny <CommandPriority>(), It.IsAny <CommandTrigger>()),
                    Times.Never());
        }
        public void should_redownload_author_on_failure()
        {
            // note that author is set to have 3 books in setup
            var failedEvent = new DownloadFailedEvent
            {
                AuthorId = 2,
                BookIds  = new List <int> {
                    1, 2, 3
                }
            };

            Subject.Handle(failedEvent);

            Mocker.GetMock <IManageCommandQueue>()
            .Verify(x => x.Push(It.Is <AuthorSearchCommand>(c => c.AuthorId == failedEvent.AuthorId),
                                It.IsAny <CommandPriority>(),
                                It.IsAny <CommandTrigger>()),
                    Times.Once());

            Mocker.GetMock <IManageCommandQueue>()
            .Verify(x => x.Push(It.IsAny <BookSearchCommand>(), It.IsAny <CommandPriority>(), It.IsAny <CommandTrigger>()),
                    Times.Never());
        }
Пример #21
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);
        }
Пример #22
0
        public void Handle(DownloadFailedEvent message)
        {
            foreach (var episodeId in message.EpisodeIds)
            {
                var history = new EpisodeHistory
                {
                    EventType   = EpisodeHistoryEventType.DownloadFailed,
                    Date        = DateTime.UtcNow,
                    Quality     = message.Quality,
                    SourceTitle = message.SourceTitle,
                    SeriesId    = message.SeriesId,
                    EpisodeId   = episodeId,
                    DownloadId  = message.DownloadId,
                    Language    = message.Language
                };

                history.Data.Add("DownloadClient", message.DownloadClient);
                history.Data.Add("DownloadClientName", message.TrackedDownload?.DownloadItem.DownloadClientInfo.Name);
                history.Data.Add("Message", message.Message);
                history.Data.Add("ReleaseGroup", message.TrackedDownload?.RemoteEpisode?.ParsedEpisodeInfo?.ReleaseGroup);

                _historyRepository.Insert(history);
            }
        }
Пример #23
0
        public void Handle(DownloadFailedEvent message)
        {
            var blocklist = new Blocklist
            {
                MovieId         = message.MovieId,
                SourceTitle     = message.SourceTitle,
                Quality         = message.Quality,
                Date            = DateTime.UtcNow,
                PublishedDate   = DateTime.Parse(message.Data.GetValueOrDefault("publishedDate")),
                Size            = long.Parse(message.Data.GetValueOrDefault("size", "0")),
                Indexer         = message.Data.GetValueOrDefault("indexer"),
                Protocol        = (DownloadProtocol)Convert.ToInt32(message.Data.GetValueOrDefault("protocol")),
                Message         = message.Message,
                TorrentInfoHash = message.Data.GetValueOrDefault("torrentInfoHash"),
                Languages       = message.Languages
            };

            if (Enum.TryParse(message.Data.GetValueOrDefault("indexerFlags"), true, out IndexerFlags flags))
            {
                blocklist.IndexerFlags = flags;
            }

            _blocklistRepository.Insert(blocklist);
        }