2013-02-17 23:59:43 -08:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using NzbDrone.Core.Datastore;
|
2013-09-13 23:36:07 -07:00
|
|
|
using NzbDrone.Core.Messaging.Events;
|
2013-09-10 23:33:47 -07:00
|
|
|
|
2013-02-17 23:59:43 -08:00
|
|
|
|
2013-03-04 21:37:33 -08:00
|
|
|
namespace NzbDrone.Core.Jobs
|
2013-02-17 23:59:43 -08:00
|
|
|
{
|
2013-05-08 23:38:20 -07:00
|
|
|
public interface IScheduledTaskRepository : IBasicRepository<ScheduledTask>
|
2013-02-17 23:59:43 -08:00
|
|
|
{
|
2013-05-08 23:38:20 -07:00
|
|
|
ScheduledTask GetDefinition(Type type);
|
2013-05-10 16:53:50 -07:00
|
|
|
void SetLastExecutionTime(int id, DateTime executionTime);
|
2013-02-17 23:59:43 -08:00
|
|
|
}
|
|
|
|
|
2013-05-08 23:38:20 -07:00
|
|
|
|
|
|
|
public class ScheduledTaskRepository : BasicRepository<ScheduledTask>, IScheduledTaskRepository
|
2013-02-17 23:59:43 -08:00
|
|
|
{
|
|
|
|
|
2013-09-13 23:36:07 -07:00
|
|
|
public ScheduledTaskRepository(IDatabase database, IEventAggregator eventAggregator)
|
|
|
|
: base(database, eventAggregator)
|
2013-02-17 23:59:43 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-08 23:38:20 -07:00
|
|
|
public ScheduledTask GetDefinition(Type type)
|
2013-02-17 23:59:43 -08:00
|
|
|
{
|
2013-05-10 16:53:50 -07:00
|
|
|
return Query.Single(c => c.TypeName == type.FullName);
|
2013-02-17 23:59:43 -08:00
|
|
|
}
|
|
|
|
|
2013-05-10 16:53:50 -07:00
|
|
|
public void SetLastExecutionTime(int id, DateTime executionTime)
|
|
|
|
{
|
|
|
|
var task = new ScheduledTask
|
|
|
|
{
|
|
|
|
Id = id,
|
|
|
|
LastExecution = executionTime
|
|
|
|
};
|
|
|
|
|
|
|
|
SetFields(task, scheduledTask => scheduledTask.LastExecution);
|
|
|
|
}
|
2013-02-17 23:59:43 -08:00
|
|
|
}
|
2013-03-24 20:51:32 -07:00
|
|
|
}
|