2013-02-18 10:59:43 +03:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2013-04-24 04:56:00 +03:00
|
|
|
using NzbDrone.Common.Messaging;
|
2013-02-18 10:59:43 +03:00
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
|
2013-03-05 08:37:33 +03:00
|
|
|
namespace NzbDrone.Core.Jobs
|
2013-02-18 10:59:43 +03:00
|
|
|
{
|
2013-05-09 09:38:20 +03:00
|
|
|
public interface IScheduledTaskRepository : IBasicRepository<ScheduledTask>
|
2013-02-18 10:59:43 +03:00
|
|
|
{
|
2013-05-09 09:38:20 +03:00
|
|
|
ScheduledTask GetDefinition(Type type);
|
2013-05-11 02:53:50 +03:00
|
|
|
void SetLastExecutionTime(int id, DateTime executionTime);
|
2013-02-18 10:59:43 +03:00
|
|
|
}
|
|
|
|
|
2013-05-09 09:38:20 +03:00
|
|
|
|
|
|
|
public class ScheduledTaskRepository : BasicRepository<ScheduledTask>, IScheduledTaskRepository
|
2013-02-18 10:59:43 +03:00
|
|
|
{
|
|
|
|
|
2013-05-09 09:38:20 +03:00
|
|
|
public ScheduledTaskRepository(IDatabase database, IMessageAggregator messageAggregator)
|
2013-05-06 00:24:33 +03:00
|
|
|
: base(database, messageAggregator)
|
2013-02-18 10:59:43 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-09 09:38:20 +03:00
|
|
|
public ScheduledTask GetDefinition(Type type)
|
2013-02-18 10:59:43 +03:00
|
|
|
{
|
2013-05-11 02:53:50 +03:00
|
|
|
return Query.Single(c => c.TypeName == type.FullName);
|
2013-02-18 10:59:43 +03:00
|
|
|
}
|
|
|
|
|
2013-05-11 02:53:50 +03:00
|
|
|
public void SetLastExecutionTime(int id, DateTime executionTime)
|
|
|
|
{
|
|
|
|
var task = new ScheduledTask
|
|
|
|
{
|
|
|
|
Id = id,
|
|
|
|
LastExecution = executionTime
|
|
|
|
};
|
|
|
|
|
|
|
|
SetFields(task, scheduledTask => scheduledTask.LastExecution);
|
|
|
|
}
|
2013-02-18 10:59:43 +03:00
|
|
|
}
|
2013-03-25 06:51:32 +03:00
|
|
|
}
|