You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.7 KiB
60 lines
1.7 KiB
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using NLog;
|
|
using NzbDrone.Core.Model.Notification;
|
|
using NzbDrone.Core.Repository;
|
|
using SubSonic.Repository;
|
|
|
|
namespace NzbDrone.Core.Providers.Jobs
|
|
{
|
|
public class DeleteSeriesJob : IJob
|
|
{
|
|
private readonly SeriesProvider _seriesProvider;
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
public DeleteSeriesJob(SeriesProvider seriesProvider)
|
|
{
|
|
_seriesProvider = seriesProvider;
|
|
}
|
|
|
|
public string Name
|
|
{
|
|
get { return "Delete Series"; }
|
|
}
|
|
|
|
public int DefaultInterval
|
|
{
|
|
get { return 0; }
|
|
}
|
|
|
|
public void Start(ProgressNotification notification, int targetId)
|
|
{
|
|
DeleteSeries(notification, targetId);
|
|
}
|
|
|
|
private void DeleteSeries(ProgressNotification notification, int seriesId)
|
|
{
|
|
Logger.Warn("Deleting Series [{0}]", seriesId);
|
|
|
|
try
|
|
{
|
|
var series = _seriesProvider.GetSeries(seriesId);
|
|
|
|
notification.CurrentMessage = String.Format("Beginning Delete of Series: {0}", series.Title);
|
|
|
|
Logger.Debug("Deleting Series from DB {0}", series.Title);
|
|
_seriesProvider.DeleteSeries(seriesId);
|
|
|
|
notification.CurrentMessage = String.Format("Successfully deleted Series: {0}", series.Title);
|
|
Logger.Info("Successfully deleted Series [{0}]", seriesId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Logger.ErrorException("An error has occurred while deleting series: " + seriesId, e);
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
} |