public bool GetChannel(IProgram program, out IChannel channel) { channel = null; Program indexProgram = program as Program; if (indexProgram == null) return false; if (!CheckConnection(indexProgram.ServerIndex)) return false; try { WebChannelBasic tvChannel = TvServer(indexProgram.ServerIndex).GetChannelBasicById(indexProgram.ChannelId); if (tvChannel != null) { channel = new Channel { ChannelId = tvChannel.Id, Name = tvChannel.Title, ServerIndex = indexProgram.ServerIndex }; return true; } } catch (Exception ex) { ServiceRegistration.Get<ILogger>().Error(ex.Message); } return false; }
public bool GetChannel(int channelId, out IChannel channel) { if (_channelCache.TryGetValue(channelId, out channel)) return true; // TODO: lookup by ID cannot guess which server might be adressed, so we force the first one. int serverIndex = 0; if (!CheckConnection(serverIndex)) return false; try { WebChannelBasic webChannel = TvServer(serverIndex).GetChannelBasicById(channelId); channel = new Channel { ChannelId = webChannel.Id, Name = webChannel.Title, ServerIndex = serverIndex }; _channelCache[channelId] = channel; return true; } catch (Exception ex) { ServiceRegistration.Get<ILogger>().Error(ex.Message); return false; } }