Progress messages are logged with Logger.Progress

This commit is contained in:
Mark McDowall 2013-09-03 22:01:28 -07:00
parent a7eb331d4e
commit c184ec2d98
20 changed files with 166 additions and 90 deletions

View File

@ -1,6 +1,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using Nancy; using Nancy;
using NLog;
using NzbDrone.Api.Mapping; using NzbDrone.Api.Mapping;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.IndexerSearch;
@ -21,18 +23,21 @@ namespace NzbDrone.Api.Indexers
private readonly IMakeDownloadDecision _downloadDecisionMaker; private readonly IMakeDownloadDecision _downloadDecisionMaker;
private readonly IDownloadService _downloadService; private readonly IDownloadService _downloadService;
private readonly IParsingService _parsingService; private readonly IParsingService _parsingService;
private readonly Logger _logger;
public ReleaseModule(IFetchAndParseRss rssFetcherAndParser, public ReleaseModule(IFetchAndParseRss rssFetcherAndParser,
ISearchForNzb nzbSearchService, ISearchForNzb nzbSearchService,
IMakeDownloadDecision downloadDecisionMaker, IMakeDownloadDecision downloadDecisionMaker,
IDownloadService downloadService, IDownloadService downloadService,
IParsingService parsingService) IParsingService parsingService,
Logger logger)
{ {
_rssFetcherAndParser = rssFetcherAndParser; _rssFetcherAndParser = rssFetcherAndParser;
_nzbSearchService = nzbSearchService; _nzbSearchService = nzbSearchService;
_downloadDecisionMaker = downloadDecisionMaker; _downloadDecisionMaker = downloadDecisionMaker;
_downloadService = downloadService; _downloadService = downloadService;
_parsingService = parsingService; _parsingService = parsingService;
_logger = logger;
GetResourceAll = GetReleases; GetResourceAll = GetReleases;
Post["/"] = x=> DownloadRelease(this.Bind<ReleaseResource>()); Post["/"] = x=> DownloadRelease(this.Bind<ReleaseResource>());
} }
@ -60,6 +65,7 @@ namespace NzbDrone.Api.Indexers
private List<ReleaseResource> GetEpisodeReleases(int episodeId) private List<ReleaseResource> GetEpisodeReleases(int episodeId)
{ {
var decisions = _nzbSearchService.EpisodeSearch(episodeId); var decisions = _nzbSearchService.EpisodeSearch(episodeId);
return MapDecisions(decisions); return MapDecisions(decisions);
} }

View File

@ -9,12 +9,20 @@ namespace NzbDrone.Common.Instrumentation
{ {
public static class LoggerExtensions public static class LoggerExtensions
{ {
public static void Progress(this Logger logger, string message)
{
LogProgressMessage(logger, message, ProcessState.Running);
}
public static void Progress(this Logger logger, string message, params object[] args)
{
var formattedMessage = String.Format(message, args);
Progress(logger, formattedMessage);
}
public static void Complete(this Logger logger, string message) public static void Complete(this Logger logger, string message)
{ {
var logEvent = new LogEventInfo(LogLevel.Info, logger.Name, message); LogProgressMessage(logger, message, ProcessState.Completed);
logEvent.Properties.Add("Status", ProcessState.Completed);
logger.Log(logEvent);
} }
public static void Complete(this Logger logger, string message, params object[] args) public static void Complete(this Logger logger, string message, params object[] args)
@ -25,10 +33,7 @@ namespace NzbDrone.Common.Instrumentation
public static void Failed(this Logger logger, string message) public static void Failed(this Logger logger, string message)
{ {
var logEvent = new LogEventInfo(LogLevel.Info, logger.Name, message); LogProgressMessage(logger, message, ProcessState.Failed);
logEvent.Properties.Add("Status", ProcessState.Failed);
logger.Log(logEvent);
} }
public static void Failed(this Logger logger, string message, params object[] args) public static void Failed(this Logger logger, string message, params object[] args)
@ -36,5 +41,13 @@ namespace NzbDrone.Common.Instrumentation
var formattedMessage = String.Format(message, args); var formattedMessage = String.Format(message, args);
Failed(logger, formattedMessage); Failed(logger, formattedMessage);
} }
private static void LogProgressMessage(Logger logger, string message, ProcessState state)
{
var logEvent = new LogEventInfo(LogLevel.Info, logger.Name, message);
logEvent.Properties.Add("Status", state);
logger.Log(logEvent);
}
} }
} }

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Core.DecisionEngine.Specifications.Search; using NzbDrone.Core.DecisionEngine.Specifications.Search;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser; using NzbDrone.Core.Parser;
@ -12,8 +13,8 @@ namespace NzbDrone.Core.DecisionEngine
{ {
public interface IMakeDownloadDecision public interface IMakeDownloadDecision
{ {
List<DownloadDecision> GetRssDecision(IEnumerable<ReportInfo> reports); List<DownloadDecision> GetRssDecision(List<ReportInfo> reports);
List<DownloadDecision> GetSearchDecision(IEnumerable<ReportInfo> reports, SearchCriteriaBase searchCriteriaBase); List<DownloadDecision> GetSearchDecision(List<ReportInfo> reports, SearchCriteriaBase searchCriteriaBase);
} }
public class DownloadDecisionMaker : IMakeDownloadDecision public class DownloadDecisionMaker : IMakeDownloadDecision
@ -29,18 +30,28 @@ namespace NzbDrone.Core.DecisionEngine
_logger = logger; _logger = logger;
} }
public List<DownloadDecision> GetRssDecision(IEnumerable<ReportInfo> reports) public List<DownloadDecision> GetRssDecision(List<ReportInfo> reports)
{ {
return GetDecisions(reports).ToList(); return GetDecisions(reports).ToList();
} }
public List<DownloadDecision> GetSearchDecision(IEnumerable<ReportInfo> reports, SearchCriteriaBase searchCriteriaBase) public List<DownloadDecision> GetSearchDecision(List<ReportInfo> reports, SearchCriteriaBase searchCriteriaBase)
{ {
return GetDecisions(reports, searchCriteriaBase).ToList(); return GetDecisions(reports, searchCriteriaBase).ToList();
} }
private IEnumerable<DownloadDecision> GetDecisions(IEnumerable<ReportInfo> reports, SearchCriteriaBase searchCriteria = null) private IEnumerable<DownloadDecision> GetDecisions(List<ReportInfo> reports, SearchCriteriaBase searchCriteria = null)
{ {
if (reports.Any())
{
_logger.Progress("Processing {0} reports", reports.Count());
}
else
{
_logger.Progress("No reports found");
}
foreach (var report in reports) foreach (var report in reports)
{ {
DownloadDecision decision = null; DownloadDecision decision = null;

View File

@ -1,4 +1,5 @@
using NLog; using NLog;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
@ -37,7 +38,7 @@ namespace NzbDrone.Core.Download
downloadClient.DownloadNzb(remoteEpisode); downloadClient.DownloadNzb(remoteEpisode);
_logger.Info("Report sent to download client. {0}", downloadTitle); _logger.Progress("Report sent to download client. {0}", downloadTitle);
_messageAggregator.PublishEvent(new EpisodeGrabbedEvent(remoteEpisode)); _messageAggregator.PublishEvent(new EpisodeGrabbedEvent(remoteEpisode));
} }
} }

View File

@ -7,7 +7,7 @@ namespace NzbDrone.Core.IndexerSearch.Definitions
public override string ToString() public override string ToString()
{ {
return string.Format("[{0} : S{1:00}E{2:00} ]", SceneTitle, SeasonNumber, EpisodeNumber); return string.Format("[{0} : S{1:00}E{2:00}]", SceneTitle, SeasonNumber, EpisodeNumber);
} }
} }
} }

View File

@ -1,4 +1,7 @@
using NzbDrone.Common.Messaging; using System.Linq;
using NLog;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
namespace NzbDrone.Core.IndexerSearch namespace NzbDrone.Core.IndexerSearch
@ -7,17 +10,23 @@ namespace NzbDrone.Core.IndexerSearch
{ {
private readonly ISearchForNzb _nzbSearchService; private readonly ISearchForNzb _nzbSearchService;
private readonly IDownloadApprovedReports _downloadApprovedReports; private readonly IDownloadApprovedReports _downloadApprovedReports;
private readonly Logger _logger;
public EpisodeSearchService(ISearchForNzb nzbSearchService, IDownloadApprovedReports downloadApprovedReports) public EpisodeSearchService(ISearchForNzb nzbSearchService,
IDownloadApprovedReports downloadApprovedReports,
Logger logger)
{ {
_nzbSearchService = nzbSearchService; _nzbSearchService = nzbSearchService;
_downloadApprovedReports = downloadApprovedReports; _downloadApprovedReports = downloadApprovedReports;
_logger = logger;
} }
public void Execute(EpisodeSearchCommand message) public void Execute(EpisodeSearchCommand message)
{ {
var decisions = _nzbSearchService.EpisodeSearch(message.EpisodeId); var decisions = _nzbSearchService.EpisodeSearch(message.EpisodeId);
_downloadApprovedReports.DownloadApproved(decisions); var downloaded = _downloadApprovedReports.DownloadApproved(decisions);
_logger.Complete("Episode search completed. {0} reports downloaded.", downloaded.Count);
} }
} }
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Threading.Tasks; using System.Threading.Tasks;
using NLog; using NLog;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.DataAugmentation.Scene;
using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
@ -129,9 +130,10 @@ namespace NzbDrone.Core.IndexerSearch
private List<DownloadDecision> Dispatch(Func<IIndexer, IEnumerable<ReportInfo>> searchAction, SearchCriteriaBase criteriaBase) private List<DownloadDecision> Dispatch(Func<IIndexer, IEnumerable<ReportInfo>> searchAction, SearchCriteriaBase criteriaBase)
{ {
var indexers = _indexerService.GetAvailableIndexers().ToList(); var indexers = _indexerService.GetAvailableIndexers().ToList();
_logger.Progress("Searching {0} indexers for {1}", indexers.Count, criteriaBase);
var reports = new List<ReportInfo>(); var reports = new List<ReportInfo>();
var taskList = new List<Task>(); var taskList = new List<Task>();
var taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.None); var taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.None);
@ -159,7 +161,7 @@ namespace NzbDrone.Core.IndexerSearch
Task.WaitAll(taskList.ToArray()); Task.WaitAll(taskList.ToArray());
_logger.Debug("Total of {0} reports were found for {1} in {2} indexers", reports.Count, criteriaBase, indexers.Count); _logger.Debug("Total of {0} reports were found for {1} from {2} indexers", reports.Count, criteriaBase, indexers.Count);
return _makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList(); return _makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList();
} }

View File

@ -1,4 +1,6 @@
using NzbDrone.Common.Messaging; using NLog;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
namespace NzbDrone.Core.IndexerSearch namespace NzbDrone.Core.IndexerSearch
@ -7,17 +9,23 @@ namespace NzbDrone.Core.IndexerSearch
{ {
private readonly ISearchForNzb _nzbSearchService; private readonly ISearchForNzb _nzbSearchService;
private readonly IDownloadApprovedReports _downloadApprovedReports; private readonly IDownloadApprovedReports _downloadApprovedReports;
private readonly Logger _logger;
public SeasonSearchService(ISearchForNzb nzbSearchService, IDownloadApprovedReports downloadApprovedReports) public SeasonSearchService(ISearchForNzb nzbSearchService,
IDownloadApprovedReports downloadApprovedReports,
Logger logger)
{ {
_nzbSearchService = nzbSearchService; _nzbSearchService = nzbSearchService;
_downloadApprovedReports = downloadApprovedReports; _downloadApprovedReports = downloadApprovedReports;
_logger = logger;
} }
public void Execute(SeasonSearchCommand message) public void Execute(SeasonSearchCommand message)
{ {
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, message.SeasonNumber); var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, message.SeasonNumber);
_downloadApprovedReports.DownloadApproved(decisions); var downloaded = _downloadApprovedReports.DownloadApproved(decisions);
_logger.Complete("Season search completed. {0} reports downloaded.", downloaded.Count);
} }
} }
} }

View File

@ -1,4 +1,6 @@
using System.Linq; using System.Linq;
using NLog;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
@ -10,14 +12,17 @@ namespace NzbDrone.Core.IndexerSearch
private readonly ISeasonService _seasonService; private readonly ISeasonService _seasonService;
private readonly ISearchForNzb _nzbSearchService; private readonly ISearchForNzb _nzbSearchService;
private readonly IDownloadApprovedReports _downloadApprovedReports; private readonly IDownloadApprovedReports _downloadApprovedReports;
private readonly Logger _logger;
public SeriesSearchService(ISeasonService seasonService, public SeriesSearchService(ISeasonService seasonService,
ISearchForNzb nzbSearchService, ISearchForNzb nzbSearchService,
IDownloadApprovedReports downloadApprovedReports) IDownloadApprovedReports downloadApprovedReports,
Logger logger)
{ {
_seasonService = seasonService; _seasonService = seasonService;
_nzbSearchService = nzbSearchService; _nzbSearchService = nzbSearchService;
_downloadApprovedReports = downloadApprovedReports; _downloadApprovedReports = downloadApprovedReports;
_logger = logger;
} }
public void Execute(SeriesSearchCommand message) public void Execute(SeriesSearchCommand message)
@ -27,11 +32,15 @@ namespace NzbDrone.Core.IndexerSearch
.OrderBy(s => s.SeasonNumber) .OrderBy(s => s.SeasonNumber)
.ToList(); .ToList();
var downloadedCount = 0;
foreach (var season in seasons) foreach (var season in seasons)
{ {
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber); var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber);
_downloadApprovedReports.DownloadApproved(decisions); downloadedCount += _downloadApprovedReports.DownloadApproved(decisions).Count;
} }
_logger.Complete("Series search completed. {0} reports downloaded.", downloadedCount);
} }
} }
} }

View File

@ -48,7 +48,7 @@ namespace NzbDrone.Core.Indexers
var result = Fetch(indexer, searchCriteria, 0).DistinctBy(c => c.NzbUrl).ToList(); var result = Fetch(indexer, searchCriteria, 0).DistinctBy(c => c.NzbUrl).ToList();
_logger.Info("Finished searching {0} on {1}. Found {2}", indexer.Name, searchCriteria, result.Count); _logger.Info("Finished searching {0} for {1}. Found {2}", indexer.Name, searchCriteria, result.Count);
return result; return result;
} }
@ -80,12 +80,10 @@ namespace NzbDrone.Core.Indexers
var result = Fetch(indexer, searchUrls); var result = Fetch(indexer, searchUrls);
_logger.Info("Finished searching {0} on {1}. Found {2}", indexer.Name, searchCriteria, result.Count); _logger.Info("Finished searching {0} for {1}. Found {2}", indexer.Name, searchCriteria, result.Count);
return result; return result;
} }
public IList<ReportInfo> Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria) public IList<ReportInfo> Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria)
{ {
_logger.Debug("Searching for {0}", searchCriteria); _logger.Debug("Searching for {0}", searchCriteria);
@ -93,7 +91,7 @@ namespace NzbDrone.Core.Indexers
var searchUrls = indexer.GetDailyEpisodeSearchUrls(searchCriteria.QueryTitle, searchCriteria.SeriesTvRageId, searchCriteria.Airtime); var searchUrls = indexer.GetDailyEpisodeSearchUrls(searchCriteria.QueryTitle, searchCriteria.SeriesTvRageId, searchCriteria.Airtime);
var result = Fetch(indexer, searchUrls); var result = Fetch(indexer, searchUrls);
_logger.Info("Finished searching {0} on {1}. Found {2}", indexer.Name, searchCriteria, result.Count); _logger.Info("Finished searching {0} for {1}. Found {2}", indexer.Name, searchCriteria, result.Count);
return result; return result;
} }

View File

@ -33,13 +33,13 @@ namespace NzbDrone.Core.Indexers
public void Sync() public void Sync()
{ {
_logger.Info("Starting RSS Sync"); _logger.Progress("Starting RSS Sync");
var reports = _rssFetcherAndParser.Fetch(); var reports = _rssFetcherAndParser.Fetch();
var decisions = _downloadDecisionMaker.GetRssDecision(reports); var decisions = _downloadDecisionMaker.GetRssDecision(reports);
var qualifiedReports = _downloadApprovedReports.DownloadApproved(decisions); var downloaded = _downloadApprovedReports.DownloadApproved(decisions);
_logger.Complete("RSS Sync Completed. Reports found: {0}, Reports downloaded: {1}", reports.Count, qualifiedReports.Count()); _logger.Complete("RSS Sync Completed. Reports found: {0}, Reports downloaded: {1}", reports.Count, downloaded.Count());
} }
public void Execute(RssSyncCommand message) public void Execute(RssSyncCommand message)

View File

@ -3,6 +3,7 @@ using System.IO;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MediaFiles.Commands;
using NzbDrone.Core.MediaFiles.EpisodeImport; using NzbDrone.Core.MediaFiles.EpisodeImport;
@ -52,6 +53,7 @@ namespace NzbDrone.Core.MediaFiles
private void Scan(Series series) private void Scan(Series series)
{ {
_logger.Progress("Starting disk scan for {0}", series.Title);
_messageAggregator.PublishCommand(new CleanMediaFileDb(series.Id)); _messageAggregator.PublishCommand(new CleanMediaFileDb(series.Id));
if (!_diskProvider.FolderExists(series.Path)) if (!_diskProvider.FolderExists(series.Path))
@ -64,6 +66,8 @@ namespace NzbDrone.Core.MediaFiles
var decisions = _importDecisionMaker.GetImportDecisions(mediaFileList, series, false); var decisions = _importDecisionMaker.GetImportDecisions(mediaFileList, series, false);
_importApprovedEpisodes.Import(decisions); _importApprovedEpisodes.Import(decisions);
_logger.Complete("Completed disk scan for {0}", series.Title);
} }
public string[] GetVideoFiles(string path, bool allDirectories = true) public string[] GetVideoFiles(string path, bool allDirectories = true)

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MediaFiles.Commands;
using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.MediaFiles.Events;
@ -67,9 +68,9 @@ namespace NzbDrone.Core.MediaFiles
var series = _seriesService.GetSeries(message.SeriesId); var series = _seriesService.GetSeries(message.SeriesId);
var episodeFiles = _mediaFileService.GetFilesBySeason(message.SeriesId, message.SeasonNumber); var episodeFiles = _mediaFileService.GetFilesBySeason(message.SeriesId, message.SeasonNumber);
_logger.Info("Renaming {0} files for {1} season {2}", episodeFiles.Count, series.Title, message.SeasonNumber); _logger.Progress("Renaming {0} files for {1} season {2}", episodeFiles.Count, series.Title, message.SeasonNumber);
RenameFiles(episodeFiles, series); RenameFiles(episodeFiles, series);
_logger.Debug("Episode Fies renamed for {0} season {1}", series.Title, message.SeasonNumber); _logger.Complete("Episode Fies renamed for {0} season {1}", series.Title, message.SeasonNumber);
} }
public void Execute(RenameSeriesCommand message) public void Execute(RenameSeriesCommand message)
@ -77,9 +78,9 @@ namespace NzbDrone.Core.MediaFiles
var series = _seriesService.GetSeries(message.SeriesId); var series = _seriesService.GetSeries(message.SeriesId);
var episodeFiles = _mediaFileService.GetFilesBySeries(message.SeriesId); var episodeFiles = _mediaFileService.GetFilesBySeries(message.SeriesId);
_logger.Info("Renaming {0} files for {1}", episodeFiles.Count, series.Title); _logger.Progress("Renaming {0} files for {1}", episodeFiles.Count, series.Title);
RenameFiles(episodeFiles, series); RenameFiles(episodeFiles, series);
_logger.Debug("Episode Fies renamed for {0}", series.Title); _logger.Complete("Episode Fies renamed for {0}", series.Title);
} }
} }
} }

View File

@ -56,7 +56,12 @@ namespace NzbDrone.Core.ProgressMessaging
return; return;
} }
var status = logEvent.Properties.ContainsKey("Status") ? (ProcessState)logEvent.Properties["Status"] : ProcessState.Running; if (!logEvent.Properties.ContainsKey("Status"))
{
return;
}
var status = (ProcessState)logEvent.Properties["Status"];
var message = new ProgressMessage(); var message = new ProgressMessage();
message.Time = logEvent.TimeStamp; message.Time = logEvent.TimeStamp;

View File

@ -129,7 +129,7 @@ namespace NzbDrone.Core.Tv
var episode = _episodeRepository.Get(episodeId); var episode = _episodeRepository.Get(episodeId);
_episodeRepository.SetMonitoredFlat(episode, monitored); _episodeRepository.SetMonitoredFlat(episode, monitored);
logger.Info("Monitored flag for Episode:{0} was set to {1}", episodeId, monitored); logger.Debug("Monitored flag for Episode:{0} was set to {1}", episodeId, monitored);
} }
public void SetEpisodeMonitoredBySeason(int seriesId, int seasonNumber, bool monitored) public void SetEpisodeMonitoredBySeason(int seriesId, int seasonNumber, bool monitored)

View File

@ -30,7 +30,7 @@ namespace NzbDrone.Core.Tv
public void RefreshEpisodeInfo(Series series, IEnumerable<Episode> remoteEpisodes) public void RefreshEpisodeInfo(Series series, IEnumerable<Episode> remoteEpisodes)
{ {
_logger.Info("Starting series info refresh for: {0}", series); _logger.Info("Starting episode info refresh for: {0}", series);
var successCount = 0; var successCount = 0;
var failCount = 0; var failCount = 0;

View File

@ -2,6 +2,7 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using NzbDrone.Core.DataAugmentation.DailySeries; using NzbDrone.Core.DataAugmentation.DailySeries;
using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource;
@ -30,39 +31,9 @@ namespace NzbDrone.Core.Tv
_logger = logger; _logger = logger;
} }
public void Execute(RefreshSeriesCommand message)
{
if (message.SeriesId.HasValue)
{
var series = _seriesService.GetSeries(message.SeriesId.Value);
RefreshSeriesInfo(series);
}
else
{
var allSeries = _seriesService.GetAllSeries().OrderBy(c => c.LastInfoSync).ToList();
foreach (var series in allSeries)
{
try
{
RefreshSeriesInfo(series);
}
catch (Exception e)
{
_logger.ErrorException("Couldn't refresh info for {0}".Inject(series), e);
}
}
}
}
public void HandleAsync(SeriesAddedEvent message)
{
RefreshSeriesInfo(message.Series);
}
private void RefreshSeriesInfo(Series series) private void RefreshSeriesInfo(Series series)
{ {
_logger.Progress("Starting Series Refresh for {0}", series.Title);
var tuple = _seriesInfo.GetSeriesInfo(series.TvdbId); var tuple = _seriesInfo.GetSeriesInfo(series.TvdbId);
var seriesInfo = tuple.Item1; var seriesInfo = tuple.Item1;
@ -96,7 +67,38 @@ namespace NzbDrone.Core.Tv
_seriesService.UpdateSeries(series); _seriesService.UpdateSeries(series);
_refreshEpisodeService.RefreshEpisodeInfo(series, tuple.Item2); _refreshEpisodeService.RefreshEpisodeInfo(series, tuple.Item2);
_logger.Complete("Finished series refresh for {0}", series.Title);
_messageAggregator.PublishEvent(new SeriesUpdatedEvent(series)); _messageAggregator.PublishEvent(new SeriesUpdatedEvent(series));
} }
public void Execute(RefreshSeriesCommand message)
{
if (message.SeriesId.HasValue)
{
var series = _seriesService.GetSeries(message.SeriesId.Value);
RefreshSeriesInfo(series);
}
else
{
var allSeries = _seriesService.GetAllSeries().OrderBy(c => c.LastInfoSync).ToList();
foreach (var series in allSeries)
{
try
{
RefreshSeriesInfo(series);
}
catch (Exception e)
{
_logger.ErrorException("Couldn't refresh info for {0}".Inject(series), e);
}
}
}
}
public void HandleAsync(SeriesAddedEvent message)
{
RefreshSeriesInfo(message.Series);
}
} }
} }

View File

@ -46,12 +46,11 @@ define(
var message = seriesTitle + ' - ' + season + 'x' + FormatHelpers.pad(episode, 2); var message = seriesTitle + ' - ' + season + 'x' + FormatHelpers.pad(episode, 2);
Actioneer.ExecuteCommand({ Actioneer.ExecuteCommand({
command : 'episodeSearch', command : 'episodeSearch',
properties : { properties: {
episodeId: this.model.get('id') episodeId: this.model.get('id')
}, },
errorMessage: 'Search failed for: ' + message, errorMessage: 'Search failed for: ' + message
startMessage: 'Search started for: ' + message
}); });
App.vent.trigger(App.Commands.CloseModalCommand); App.vent.trigger(App.Commands.CloseModalCommand);

View File

@ -17,11 +17,13 @@ define(
collection.signalRconnection.received(function (message) { collection.signalRconnection.received(function (message) {
var type = getMessengerType(message.status); var type = getMessengerType(message.status);
var hideAfter = type === 'info' ? 60 : 5;
Messenger.show({ Messenger.show({
id : message.commandId, id : message.commandId,
message: message.message, message : message.message,
type : type type : type,
hideAfter: hideAfter
}); });
}); });

View File

@ -92,6 +92,10 @@ define(
}, },
_getIconClass: function(element) { _getIconClass: function(element) {
if (!element) {
return '';
}
return element.attr('class').match(/(?:^|\s)icon\-.+?(?:$|\s)/)[0]; return element.attr('class').match(/(?:^|\s)icon\-.+?(?:$|\s)/)[0];
}, },
@ -143,14 +147,16 @@ define(
options.button.removeClass('disable'); options.button.removeClass('disable');
} }
if (options.leaveIcon) { if (options.element) {
options.element.removeClass('icon-spin'); if (options.leaveIcon) {
} options.element.removeClass('icon-spin');
}
else { else {
options.element.addClass(options.iconClass); options.element.addClass(options.iconClass);
options.element.removeClass('icon-nd-spinner'); options.element.removeClass('icon-nd-spinner');
options.element.removeClass('icon-spin'); options.element.removeClass('icon-spin');
}
} }
if (options.always) { if (options.always) {