Timers are now initialized on startup.

This commit is contained in:
kay.one 2011-04-19 19:17:28 -07:00
parent 38712c7e5f
commit 6caae19430
4 changed files with 96 additions and 0 deletions

View File

@ -109,9 +109,12 @@ namespace NzbDrone.Core
SetupDefaultQualityProfiles(_kernel.Get<IRepository>()); //Setup the default QualityProfiles on start-up SetupDefaultQualityProfiles(_kernel.Get<IRepository>()); //Setup the default QualityProfiles on start-up
BindIndexers(); BindIndexers();
BindTimers();
} }
} }
private static void BindIndexers() private static void BindIndexers()
{ {
_kernel.Bind<IndexerProviderBase>().To<NzbsOrgProvider>().InSingletonScope(); _kernel.Bind<IndexerProviderBase>().To<NzbsOrgProvider>().InSingletonScope();
@ -122,6 +125,12 @@ namespace NzbDrone.Core
_kernel.Get<IndexerProvider>().InitializeIndexers(indexers.ToList()); _kernel.Get<IndexerProvider>().InitializeIndexers(indexers.ToList());
} }
private static void BindTimers()
{
_kernel.Bind<ITimer>().To<RssSyncTimer>().InTransientScope();
_kernel.Get<TimerProvider>().Initialize();
}
private static void ForceMigration(IRepository repository) private static void ForceMigration(IRepository repository)
{ {
repository.GetPaged<Series>(0, 1); repository.GetPaged<Series>(0, 1);

View File

@ -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());
}
}
}

View File

@ -202,6 +202,7 @@
<Compile Include="Controllers\SeriesController.cs" /> <Compile Include="Controllers\SeriesController.cs" />
<Compile Include="Controllers\SettingsController.cs" /> <Compile Include="Controllers\SettingsController.cs" />
<Compile Include="Controllers\SharedController.cs" /> <Compile Include="Controllers\SharedController.cs" />
<Compile Include="Controllers\TimersController.cs" />
<Compile Include="Controllers\UpcomingController.cs" /> <Compile Include="Controllers\UpcomingController.cs" />
<Compile Include="Global.asax.cs"> <Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon> <DependentUpon>Global.asax</DependentUpon>
@ -662,6 +663,7 @@
<Content Include="Scripts\jquery.validate.unobtrusive.min.js" /> <Content Include="Scripts\jquery.validate.unobtrusive.min.js" />
<Content Include="Views\Web.config" /> <Content Include="Views\Web.config" />
<Content Include="Views\Settings\Indexers.cshtml" /> <Content Include="Views\Settings\Indexers.cshtml" />
<Content Include="Views\Timers\index.cshtml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="App_Data\" /> <Folder Include="App_Data\" />

View File

@ -0,0 +1,59 @@
@model IEnumerable<NzbDrone.Core.Repository.TimerSetting>
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Timers</title>
</head>
<body>
<table>
<tr>
<th>
</th>
<th>
Enable
</th>
<th>
TypeName
</th>
<th>
Name
</th>
<th>
Interval
</th>
<th>
LastExecution
</th>
<th>
Success
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@item.Enable
</td>
<td>
@item.TypeName
</td>
<td>
@item.Name
</td>
<td>
@item.Interval
</td>
<td>
@String.Format("{0:g}", item.LastExecution)
</td>
<td>
@item.Success
</td>
</tr>
}
</table>
</body>
</html>