From 6caae1943051ae52feba69a8bb71ce3fe7f26104 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Tue, 19 Apr 2011 19:17:28 -0700 Subject: [PATCH] Timers are now initialized on startup. --- NzbDrone.Core/CentralDispatch.cs | 9 +++ NzbDrone.Web/Controllers/TimersController.cs | 26 +++++++++ NzbDrone.Web/NzbDrone.Web.csproj | 2 + NzbDrone.Web/Views/Timers/index.cshtml | 59 ++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 NzbDrone.Web/Controllers/TimersController.cs create mode 100644 NzbDrone.Web/Views/Timers/index.cshtml diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index 8fef3ef25..2b0a057d0 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -109,9 +109,12 @@ namespace NzbDrone.Core SetupDefaultQualityProfiles(_kernel.Get()); //Setup the default QualityProfiles on start-up BindIndexers(); + BindTimers(); } } + + private static void BindIndexers() { _kernel.Bind().To().InSingletonScope(); @@ -122,6 +125,12 @@ namespace NzbDrone.Core _kernel.Get().InitializeIndexers(indexers.ToList()); } + private static void BindTimers() + { + _kernel.Bind().To().InTransientScope(); + _kernel.Get().Initialize(); + } + private static void ForceMigration(IRepository repository) { repository.GetPaged(0, 1); diff --git a/NzbDrone.Web/Controllers/TimersController.cs b/NzbDrone.Web/Controllers/TimersController.cs new file mode 100644 index 000000000..0ad3d8ce0 --- /dev/null +++ b/NzbDrone.Web/Controllers/TimersController.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using NzbDrone.Core.Providers.Timers; + +namespace NzbDrone.Web.Controllers +{ + public class TimersController : Controller + { + private readonly TimerProvider _timerProvider; + + public TimersController(TimerProvider timerProvider) + { + _timerProvider = timerProvider; + } + + public ActionResult Index() + { + return View(_timerProvider.All()); + } + + + } +} diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index d42469932..aa28433df 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -202,6 +202,7 @@ + Global.asax @@ -662,6 +663,7 @@ + diff --git a/NzbDrone.Web/Views/Timers/index.cshtml b/NzbDrone.Web/Views/Timers/index.cshtml new file mode 100644 index 000000000..ed84fac0f --- /dev/null +++ b/NzbDrone.Web/Views/Timers/index.cshtml @@ -0,0 +1,59 @@ +@model IEnumerable +@{ + Layout = null; +} + + + + Timers + + + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + + } +
+ + Enable + + TypeName + + Name + + Interval + + LastExecution + + Success +
+ @item.Enable + + @item.TypeName + + @item.Name + + @item.Interval + + @String.Format("{0:g}", item.LastExecution) + + @item.Success +
+ +