1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-14 15:03:42 +01:00
Radarr/NzbDrone.Core/Jobs/DeleteSeriesJob.cs

58 lines
1.6 KiB
C#
Raw Normal View History

2011-12-02 02:33:17 +01:00
using System.Linq;
using System;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
2011-12-02 02:33:17 +01:00
using NzbDrone.Core.Providers;
2011-12-02 02:33:17 +01:00
namespace NzbDrone.Core.Jobs
{
public class DeleteSeriesJob : IJob
{
private readonly SeriesProvider _seriesProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public DeleteSeriesJob(SeriesProvider seriesProvider)
{
_seriesProvider = seriesProvider;
}
public string Name
{
get { return "Delete Series"; }
}
public TimeSpan DefaultInterval
{
get { return TimeSpan.FromTicks(0); }
}
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
{
DeleteSeries(notification, targetId);
}
private void DeleteSeries(ProgressNotification notification, int seriesId)
{
Logger.Warn("Deleting Series [{0}]", seriesId);
try
{
var title = _seriesProvider.GetSeries(seriesId).Title;
notification.CurrentMessage = String.Format("Deleting '{0}' from database", title);
_seriesProvider.DeleteSeries(seriesId);
2011-07-06 08:17:21 +02:00
notification.CurrentMessage = String.Format("Successfully deleted '{0}' from database", title);
}
catch (Exception e)
{
Logger.ErrorException("An error has occurred while deleting series: " + seriesId, e);
throw;
}
}
}
}