2013-02-18 07:59:43 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2013-04-24 01:56:00 +00:00
|
|
|
using NzbDrone.Common.Messaging;
|
2013-02-18 07:59:43 +00:00
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
|
2013-03-05 05:37:33 +00:00
|
|
|
namespace NzbDrone.Core.Jobs
|
2013-02-18 07:59:43 +00:00
|
|
|
{
|
2013-05-09 06:38:20 +00:00
|
|
|
public interface IScheduledTaskRepository : IBasicRepository<ScheduledTask>
|
2013-02-18 07:59:43 +00:00
|
|
|
{
|
2013-05-09 06:38:20 +00:00
|
|
|
IList<ScheduledTask> GetPendingJobs();
|
|
|
|
ScheduledTask GetDefinition(Type type);
|
2013-02-18 07:59:43 +00:00
|
|
|
}
|
|
|
|
|
2013-05-09 06:38:20 +00:00
|
|
|
|
|
|
|
public class ScheduledTaskRepository : BasicRepository<ScheduledTask>, IScheduledTaskRepository
|
2013-02-18 07:59:43 +00:00
|
|
|
{
|
|
|
|
|
2013-05-09 06:38:20 +00:00
|
|
|
public ScheduledTaskRepository(IDatabase database, IMessageAggregator messageAggregator)
|
2013-05-05 21:24:33 +00:00
|
|
|
: base(database, messageAggregator)
|
2013-02-18 07:59:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-09 06:38:20 +00:00
|
|
|
public ScheduledTask GetDefinition(Type type)
|
2013-02-18 07:59:43 +00:00
|
|
|
{
|
2013-05-07 00:39:33 +00:00
|
|
|
return Query.Single(c => c.Name == type.FullName);
|
2013-02-18 07:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-09 06:38:20 +00:00
|
|
|
public IList<ScheduledTask> GetPendingJobs()
|
2013-02-18 07:59:43 +00:00
|
|
|
{
|
2013-05-07 00:39:33 +00:00
|
|
|
return Query.Where(c => c.Interval != 0).ToList().Where(c => c.LastExecution < DateTime.Now.AddMinutes(-c.Interval)).ToList();
|
2013-02-18 07:59:43 +00:00
|
|
|
}
|
|
|
|
}
|
2013-03-25 03:51:32 +00:00
|
|
|
}
|