2012-02-12 10:52:51 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Core.Model;
|
2012-02-28 06:52:03 +01:00
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2012-02-12 10:52:51 +01:00
|
|
|
|
using SignalR;
|
|
|
|
|
using SignalR.Hosting.AspNet;
|
|
|
|
|
using SignalR.Hubs;
|
|
|
|
|
using SignalR.Infrastructure;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers
|
|
|
|
|
{
|
|
|
|
|
public class SignalRProvider : Hub
|
|
|
|
|
{
|
2012-02-13 00:37:55 +01:00
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
2012-02-12 10:52:51 +01:00
|
|
|
|
|
2012-10-13 23:15:21 +02:00
|
|
|
|
public virtual void UpdateEpisodeStatus(int episodeId, EpisodeStatusType episodeStatus, QualityModel quality)
|
2012-02-12 10:52:51 +01:00
|
|
|
|
{
|
2012-02-28 06:52:03 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
logger.Trace("Sending Status update to client. EpisodeId: {0}, Status: {1}", episodeId, episodeStatus);
|
2012-02-12 10:52:51 +01:00
|
|
|
|
|
2012-02-28 06:52:03 +01:00
|
|
|
|
GetClients().updatedStatus(new
|
|
|
|
|
{
|
|
|
|
|
EpisodeId = episodeId,
|
|
|
|
|
EpisodeStatus = episodeStatus.ToString(),
|
2012-10-14 02:36:16 +02:00
|
|
|
|
Quality = (quality == null ? String.Empty : quality.Quality.ToString())
|
2012-02-28 06:52:03 +01:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2012-11-21 17:14:57 +01:00
|
|
|
|
logger.TraceException("Error", ex);
|
2012-02-28 06:52:03 +01:00
|
|
|
|
throw;
|
|
|
|
|
}
|
2012-02-12 10:52:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-13 02:07:09 +01:00
|
|
|
|
private dynamic GetClients()
|
2012-02-12 10:52:51 +01:00
|
|
|
|
{
|
2012-02-13 00:37:55 +01:00
|
|
|
|
var connectionManager = AspNetHost.DependencyResolver.Resolve<IConnectionManager>();
|
2012-02-12 10:52:51 +01:00
|
|
|
|
return connectionManager.GetClients<SignalRProvider>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|