2012-02-12 09:52:51 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using NLog;
|
2013-02-24 19:18:48 +00:00
|
|
|
|
using NzbDrone.Common.Eventing;
|
|
|
|
|
using NzbDrone.Core.Download;
|
2013-02-19 06:01:03 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2012-02-12 09:52:51 +00:00
|
|
|
|
using NzbDrone.Core.Model;
|
2012-12-19 01:40:47 +00:00
|
|
|
|
using NzbDrone.Core.Providers.Hubs;
|
2012-02-12 09:52:51 +00:00
|
|
|
|
using SignalR;
|
|
|
|
|
using SignalR.Hubs;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers
|
|
|
|
|
{
|
2013-02-24 19:18:48 +00:00
|
|
|
|
public class SignalRProvider : IHandle<EpisodeGrabbedEvent>
|
2012-02-12 09:52:51 +00:00
|
|
|
|
{
|
2012-02-12 23:37:55 +00:00
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
2012-02-12 09:52:51 +00:00
|
|
|
|
|
2012-10-13 21:15:21 +00:00
|
|
|
|
public virtual void UpdateEpisodeStatus(int episodeId, EpisodeStatusType episodeStatus, QualityModel quality)
|
2012-02-12 09:52:51 +00:00
|
|
|
|
{
|
2012-02-28 05:52:03 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
logger.Trace("Sending Status update to client. EpisodeId: {0}, Status: {1}", episodeId, episodeStatus);
|
2012-02-12 09:52:51 +00:00
|
|
|
|
|
2012-12-19 01:40:47 +00:00
|
|
|
|
var context = GlobalHost.ConnectionManager.GetHubContext<EpisodeHub>();
|
|
|
|
|
context.Clients.updatedStatus(new
|
2012-02-28 05:52:03 +00:00
|
|
|
|
{
|
2013-02-24 19:18:48 +00:00
|
|
|
|
EpisodeId = episodeId,
|
|
|
|
|
EpisodeStatus = episodeStatus.ToString(),
|
|
|
|
|
Quality = (quality == null ? String.Empty : quality.Quality.ToString())
|
2012-02-28 05:52:03 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2012-11-21 16:14:57 +00:00
|
|
|
|
logger.TraceException("Error", ex);
|
2012-02-28 05:52:03 +00:00
|
|
|
|
throw;
|
|
|
|
|
}
|
2012-02-12 09:52:51 +00:00
|
|
|
|
}
|
2013-02-24 19:18:48 +00:00
|
|
|
|
|
|
|
|
|
public void Handle(EpisodeGrabbedEvent message)
|
|
|
|
|
{
|
|
|
|
|
foreach (var episode in message.ParseResult.Episodes)
|
|
|
|
|
{
|
|
|
|
|
UpdateEpisodeStatus(episode.OID, EpisodeStatusType.Downloading, message.ParseResult.Quality);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-02-12 09:52:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|