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.
Lidarr/src/NzbDrone.Core/Jobs/ScheduledTaskRepository.cs

40 lines
1.1 KiB

using System;
using System.Linq;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.Jobs
{
public interface IScheduledTaskRepository : IBasicRepository<ScheduledTask>
{
ScheduledTask GetDefinition(Type type);
void SetLastExecutionTime(int id, DateTime executionTime);
}
public class ScheduledTaskRepository : BasicRepository<ScheduledTask>, IScheduledTaskRepository
{
public ScheduledTaskRepository(IDatabase database, IEventAggregator eventAggregator)
: base(database, eventAggregator)
{
}
public ScheduledTask GetDefinition(Type type)
{
return Query.Where(c => c.TypeName == type.FullName).Single();
}
public void SetLastExecutionTime(int id, DateTime executionTime)
{
var task = new ScheduledTask
{
Id = id,
LastExecution = executionTime
};
SetFields(task, scheduledTask => scheduledTask.LastExecution);
}
}
}