public void RefreshEpgData(ISchedulerService tvSchedulerAgent, IGuideService tvGuideAgent, IControlService tvControlAgent, bool reloadData, Guid currentChannelGroupId, DateTime guideDateTime, CancellationPendingDelegate cancellationPending) { if (reloadData) { _model.ProgramsByChannel.Clear(); RefreshUpcomingPrograms(tvSchedulerAgent, tvControlAgent); if (cancellationPending != null && cancellationPending()) { return; } } if (guideDateTime != DateTime.MinValue) { SetChannelGroup(currentChannelGroupId); _model.GuideDateTime = guideDateTime; _model.Channels = new List <Channel>(tvSchedulerAgent.GetChannelsInGroup(currentChannelGroupId, true)); if (cancellationPending != null && cancellationPending()) { return; } RefreshChannelsEpgData(tvGuideAgent, _model.Channels, guideDateTime, guideDateTime.AddDays(1), cancellationPending); } else { _model.Channels = new List <Channel>(); } }
public void RefreshChannelsEpgData(List<Channel> channels, DateTime fromDateTime, DateTime toDateTime, CancellationPendingDelegate cancellationPending) { foreach (Channel channel in channels) { if (channel.GuideChannelId.HasValue) { if (_model.ProgramsByChannel.ContainsKey(channel.ChannelId)) { ChannelPrograms channelPrograms = _model.ProgramsByChannel[channel.ChannelId]; if (channelPrograms.LowerBoundTime >= toDateTime || channelPrograms.UpperBoundTime <= fromDateTime) { _model.ProgramsByChannel.Remove(channel.ChannelId); } else if (channelPrograms.LowerBoundTime <= fromDateTime && channelPrograms.UpperBoundTime <= toDateTime) { DateTime newUpperBoundTime = channelPrograms.UpperBoundTime.AddHours(8); if (toDateTime > newUpperBoundTime) { newUpperBoundTime = toDateTime; } MergeExtraPrograms(channel, channelPrograms, channelPrograms.UpperBoundTime, newUpperBoundTime); channelPrograms.UpperBoundTime = newUpperBoundTime; } else if (channelPrograms.LowerBoundTime >= fromDateTime && channelPrograms.UpperBoundTime >= toDateTime) { DateTime newLowerBoundTime = channelPrograms.LowerBoundTime.AddHours(-8); if (fromDateTime < newLowerBoundTime) { newLowerBoundTime = fromDateTime; } MergeExtraPrograms(channel, channelPrograms, newLowerBoundTime, channelPrograms.LowerBoundTime); channelPrograms.LowerBoundTime = newLowerBoundTime; } } if (cancellationPending != null && cancellationPending()) { return; } if (!_model.ProgramsByChannel.ContainsKey(channel.ChannelId)) { _model.ProgramsByChannel[channel.ChannelId] = new ChannelPrograms(fromDateTime, toDateTime, Proxies.GuideService.GetChannelProgramsBetween(channel.GuideChannelId.Value, fromDateTime, toDateTime).Result); } } else { _model.ProgramsByChannel[channel.ChannelId] = new ChannelPrograms(fromDateTime, toDateTime, new GuideProgramSummary[] { }); } if (cancellationPending != null && cancellationPending()) { break; } } }
public void RefreshEpgData(bool reloadData, Guid currentChannelGroupId, DateTime guideDateTime, CancellationPendingDelegate cancellationPending) { if (reloadData) { _model.ProgramsByChannel.Clear(); RefreshUpcomingPrograms(); if (cancellationPending != null && cancellationPending()) { return; } } if (guideDateTime != DateTime.MinValue) { SetChannelGroup(currentChannelGroupId); _model.GuideDateTime = guideDateTime; _model.Channels = new List<Channel>(Proxies.SchedulerService.GetChannelsInGroup(currentChannelGroupId, true).Result); if (cancellationPending != null && cancellationPending()) { return; } RefreshChannelsEpgData(_model.Channels, guideDateTime, guideDateTime.AddDays(1), cancellationPending); } else { _model.Channels = new List<Channel>(); } }
public void RefreshChannelsEpgData(List <Channel> channels, DateTime fromDateTime, DateTime toDateTime, CancellationPendingDelegate cancellationPending) { foreach (Channel channel in channels) { if (channel.GuideChannelId.HasValue) { if (_model.ProgramsByChannel.ContainsKey(channel.ChannelId)) { ChannelPrograms channelPrograms = _model.ProgramsByChannel[channel.ChannelId]; if (channelPrograms.LowerBoundTime >= toDateTime || channelPrograms.UpperBoundTime <= fromDateTime) { _model.ProgramsByChannel.Remove(channel.ChannelId); } else if (channelPrograms.LowerBoundTime <= fromDateTime && channelPrograms.UpperBoundTime <= toDateTime) { DateTime newUpperBoundTime = channelPrograms.UpperBoundTime.AddHours(8); if (toDateTime > newUpperBoundTime) { newUpperBoundTime = toDateTime; } MergeExtraPrograms(channel, channelPrograms, channelPrograms.UpperBoundTime, newUpperBoundTime); channelPrograms.UpperBoundTime = newUpperBoundTime; } else if (channelPrograms.LowerBoundTime >= fromDateTime && channelPrograms.UpperBoundTime >= toDateTime) { DateTime newLowerBoundTime = channelPrograms.LowerBoundTime.AddHours(-8); if (fromDateTime < newLowerBoundTime) { newLowerBoundTime = fromDateTime; } MergeExtraPrograms(channel, channelPrograms, newLowerBoundTime, channelPrograms.LowerBoundTime); channelPrograms.LowerBoundTime = newLowerBoundTime; } } if (cancellationPending != null && cancellationPending()) { return; } if (!_model.ProgramsByChannel.ContainsKey(channel.ChannelId)) { _model.ProgramsByChannel[channel.ChannelId] = new ChannelPrograms(fromDateTime, toDateTime, Proxies.GuideService.GetChannelProgramsBetween(channel.GuideChannelId.Value, fromDateTime, toDateTime).Result); } } else { _model.ProgramsByChannel[channel.ChannelId] = new ChannelPrograms(fromDateTime, toDateTime, new GuideProgramSummary[] { }); } if (cancellationPending != null && cancellationPending()) { break; } } }
public void RefreshEpgData(bool reloadData, Guid currentChannelGroupId, DateTime guideDateTime, CancellationPendingDelegate cancellationPending) { if (reloadData) { _model.ProgramsByChannel.Clear(); RefreshUpcomingPrograms(); if (cancellationPending != null && cancellationPending()) { return; } } if (guideDateTime != DateTime.MinValue) { SetChannelGroup(currentChannelGroupId); _model.GuideDateTime = guideDateTime; _model.Channels = new List <Channel>(Proxies.SchedulerService.GetChannelsInGroup(currentChannelGroupId, true).Result); if (cancellationPending != null && cancellationPending()) { return; } RefreshChannelsEpgData(_model.Channels, guideDateTime, guideDateTime.AddDays(1), cancellationPending); } else { _model.Channels = new List <Channel>(); } }
public void RefreshEpgData(ISchedulerService tvSchedulerAgent, IGuideService tvGuideAgent, IControlService tvControlAgent, bool reloadData, Guid currentChannelGroupId, DateTime guideDateTime, CancellationPendingDelegate cancellationPending) { if (reloadData) { _model.ProgramsByChannel.Clear(); RefreshUpcomingPrograms(tvSchedulerAgent, tvControlAgent); if (cancellationPending != null && cancellationPending()) { return; } } if (guideDateTime != DateTime.MinValue) { SetChannelGroup(currentChannelGroupId); _model.GuideDateTime = guideDateTime; _model.Channels = new List<Channel>(tvSchedulerAgent.GetChannelsInGroup(currentChannelGroupId, true)); if (cancellationPending != null && cancellationPending()) { return; } RefreshChannelsEpgData(tvGuideAgent, _model.Channels, guideDateTime, guideDateTime.AddDays(1), cancellationPending); } else { _model.Channels = new List<Channel>(); } }