2012-02-12 01:52:51 -08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Core.Model;
|
2012-12-18 17:40:47 -08:00
|
|
|
using NzbDrone.Core.Providers.Hubs;
|
2012-02-12 01:52:51 -08:00
|
|
|
using SignalR;
|
|
|
|
using SignalR.Hubs;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers
|
|
|
|
{
|
2012-12-18 17:40:47 -08:00
|
|
|
public class SignalRProvider
|
2012-02-12 01:52:51 -08:00
|
|
|
{
|
2012-02-12 15:37:55 -08:00
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
2012-02-12 01:52:51 -08:00
|
|
|
|
2012-10-13 14:15:21 -07:00
|
|
|
public virtual void UpdateEpisodeStatus(int episodeId, EpisodeStatusType episodeStatus, QualityModel quality)
|
2012-02-12 01:52:51 -08:00
|
|
|
{
|
2012-02-27 21:52:03 -08:00
|
|
|
try
|
|
|
|
{
|
|
|
|
logger.Trace("Sending Status update to client. EpisodeId: {0}, Status: {1}", episodeId, episodeStatus);
|
2012-02-12 01:52:51 -08:00
|
|
|
|
2012-12-18 17:40:47 -08:00
|
|
|
var context = GlobalHost.ConnectionManager.GetHubContext<EpisodeHub>();
|
|
|
|
context.Clients.updatedStatus(new
|
2012-02-27 21:52:03 -08:00
|
|
|
{
|
|
|
|
EpisodeId = episodeId,
|
|
|
|
EpisodeStatus = episodeStatus.ToString(),
|
2012-10-13 17:36:16 -07:00
|
|
|
Quality = (quality == null ? String.Empty : quality.Quality.ToString())
|
2012-02-27 21:52:03 -08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2012-11-21 08:14:57 -08:00
|
|
|
logger.TraceException("Error", ex);
|
2012-02-27 21:52:03 -08:00
|
|
|
throw;
|
|
|
|
}
|
2012-02-12 01:52:51 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|