Update clients when new episode is imported (ready).

pull/19/head
Mark McDowall 13 years ago
parent 8519c3c745
commit c739b3e132

@ -177,6 +177,9 @@
<Reference Include="SignalR.Hosting.AspNet">
<HintPath>..\packages\SignalR.Hosting.AspNet.0.4.0.0\lib\net40\SignalR.Hosting.AspNet.dll</HintPath>
</Reference>
<Reference Include="SignalR.Ninject">
<HintPath>..\packages\SignalR.Ninject.0.4\lib\net40\SignalR.Ninject.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.configuration" />

@ -20,11 +20,13 @@ namespace NzbDrone.Core.Providers
private readonly SeriesProvider _seriesProvider;
private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly DownloadProvider _downloadProvider;
private readonly SignalRProvider _signalRProvider;
[Inject]
public DiskScanProvider(DiskProvider diskProvider, EpisodeProvider episodeProvider,
SeriesProvider seriesProvider, MediaFileProvider mediaFileProvider,
ExternalNotificationProvider externalNotificationProvider, DownloadProvider downloadProvider)
ExternalNotificationProvider externalNotificationProvider, DownloadProvider downloadProvider,
SignalRProvider signalRProvider)
{
_diskProvider = diskProvider;
_episodeProvider = episodeProvider;
@ -32,6 +34,7 @@ namespace NzbDrone.Core.Providers
_mediaFileProvider = mediaFileProvider;
_externalNotificationProvider = externalNotificationProvider;
_downloadProvider = downloadProvider;
_signalRProvider = signalRProvider;
}
public DiskScanProvider()
@ -197,6 +200,9 @@ namespace NzbDrone.Core.Providers
if (newDownload)
{
_externalNotificationProvider.OnDownload(message, series);
foreach(var episode in episodes)
_signalRProvider.UpdateEpisodeStatus(episode.EpisodeId, EpisodeStatusType.Ready);
}
else
{

@ -13,18 +13,18 @@ namespace NzbDrone.Core.Providers
{
public class SignalRProvider : Hub
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public virtual void UpdateEpisodeStatus(int episodeId, EpisodeStatusType episodeStatus)
{
Logger.Trace("Sending Status update to client. EpisodeId: {0}, Status: {1}", episodeId, episodeStatus);
logger.Trace("Sending Status update to client. EpisodeId: {0}, Status: {1}", episodeId, episodeStatus);
GetClients().updatedStatus(episodeId, episodeStatus.ToString());
}
private static dynamic GetClients()
{
IConnectionManager connectionManager = AspNetHost.DependencyResolver.Resolve<IConnectionManager>();
var connectionManager = AspNetHost.DependencyResolver.Resolve<IConnectionManager>();
return connectionManager.GetClients<SignalRProvider>();
}
}

@ -10,6 +10,7 @@
<package id="Ninject" version="2.2.1.4" />
<package id="NLog" version="2.0.0.2000" />
<package id="SignalR.Hosting.AspNet" version="0.4.0.0" />
<package id="SignalR.Ninject" version="0.4" />
<package id="SignalR.Server" version="0.4.0.0" />
<package id="SqlServerCompact" version="4.0.8482.1" />
<package id="twitterizer" version="2.4.0.26532" />

@ -7,7 +7,7 @@
Layout = null;
}
<tr class='@Model.EpisodeId data-row@(ViewData["AltRow"] == null || !(bool)ViewData["AltRow"] ? "" : " alt-row")'>
<tr class='episodeId_@(Model.EpisodeId) data-row@(ViewData["AltRow"] == null || !(bool)ViewData["AltRow"] ? "" : " alt-row")'>
<td>@Html.ActionLink(Model.SeriesTitle, "Details", "Series", new { seriesId = Model.SeriesId }, null)</td>
<td>@Model.EpisodeNumbering</td>
<td>@Model.Title</td>
@ -35,7 +35,7 @@
@*Commands Column*@
<td class="@cellColourClass">
<img src='../../Content/Images/@(Model.Status).png' alt='@Model.Status' title='@Model.Status' class='gridImage' />
<img src='../../Content/Images/@(Model.Status).png' alt='@Model.Status' title='@Model.Status' class='gridImage statusImage' />
@Ajax.ImageActionLink("../../Content/Images/Search.png", new { Alt = "Search", Title = "Search for episode", @class = "gridImage" }, "Search", "Episode", new { episodeId = Model.EpisodeId }, null, null)
</td>
</tr>

Loading…
Cancel
Save