2011-12-02 02:33:17 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System;
|
2011-06-14 03:23:04 +02:00
|
|
|
|
using Ninject;
|
2011-05-12 04:53:19 +02:00
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
2011-12-02 02:33:17 +01:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2011-05-12 04:53:19 +02:00
|
|
|
|
|
2011-12-02 02:33:17 +01:00
|
|
|
|
namespace NzbDrone.Core.Jobs
|
2011-05-12 04:53:19 +02:00
|
|
|
|
{
|
|
|
|
|
public class DeleteSeriesJob : IJob
|
|
|
|
|
{
|
|
|
|
|
private readonly SeriesProvider _seriesProvider;
|
|
|
|
|
|
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
2011-06-14 03:23:04 +02:00
|
|
|
|
[Inject]
|
2011-05-16 01:35:45 +02:00
|
|
|
|
public DeleteSeriesJob(SeriesProvider seriesProvider)
|
2011-05-12 04:53:19 +02:00
|
|
|
|
{
|
|
|
|
|
_seriesProvider = seriesProvider;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Delete Series"; }
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-15 03:47:23 +01:00
|
|
|
|
public TimeSpan DefaultInterval
|
2011-05-12 04:53:19 +02:00
|
|
|
|
{
|
2012-01-15 03:47:23 +01:00
|
|
|
|
get { return TimeSpan.FromTicks(0); }
|
2011-05-12 04:53:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-22 02:48:37 +02:00
|
|
|
|
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
2011-05-12 04:53:19 +02:00
|
|
|
|
{
|
|
|
|
|
DeleteSeries(notification, targetId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DeleteSeries(ProgressNotification notification, int seriesId)
|
|
|
|
|
{
|
2012-02-25 03:01:53 +01:00
|
|
|
|
Logger.Trace("Deleting Series [{0}]", seriesId);
|
2011-05-12 04:53:19 +02:00
|
|
|
|
|
2012-02-25 03:01:53 +01:00
|
|
|
|
var title = _seriesProvider.GetSeries(seriesId).Title;
|
2011-05-17 09:04:49 +02:00
|
|
|
|
|
2012-02-25 03:01:53 +01:00
|
|
|
|
notification.CurrentMessage = String.Format("Deleting '{0}' from database", title);
|
2011-05-12 04:53:19 +02:00
|
|
|
|
|
2012-02-25 03:01:53 +01:00
|
|
|
|
_seriesProvider.DeleteSeries(seriesId);
|
2011-05-12 04:53:19 +02:00
|
|
|
|
|
2012-02-25 03:01:53 +01:00
|
|
|
|
notification.CurrentMessage = String.Format("Successfully deleted '{0}' from database", title);
|
2011-05-12 04:53:19 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|