本文整理汇总了C#中SchedulerServiceAgent.GetChannelByDisplayName方法的典型用法代码示例。如果您正苦于以下问题:C# SchedulerServiceAgent.GetChannelByDisplayName方法的具体用法?C# SchedulerServiceAgent.GetChannelByDisplayName怎么用?C# SchedulerServiceAgent.GetChannelByDisplayName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SchedulerServiceAgent
的用法示例。
在下文中一共展示了SchedulerServiceAgent.GetChannelByDisplayName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureDefaultChannel
private Guid EnsureDefaultChannel(ImportGuideChannel channel, ChannelType channelType, bool updateChannelName)
{
using (GuideServiceAgent guideServiceAgent = new GuideServiceAgent())
{
using (SchedulerServiceAgent schedulerServiceAgent = new SchedulerServiceAgent())
{
Guid guideChannelId = guideServiceAgent.EnsureChannel(channel.ExternalId, channel.ChannelName, channelType);
// If we have exactly one channel, check LCN and DisplayName :
Channel[] channels = schedulerServiceAgent.GetChannelsForGuideChannel(guideChannelId);
if (channels.Length == 1 && updateChannelName)
{
bool needsToBeSaved = false;
if (channels[0].LogicalChannelNumber == null && channel.LogicalChannelNumber.HasValue)
{
channels[0].LogicalChannelNumber = channel.LogicalChannelNumber;
needsToBeSaved = true;
}
if (channels[0].DisplayName != channel.ChannelName)
{
channels[0].DisplayName = channel.ChannelName;
needsToBeSaved = true;
}
if (needsToBeSaved)
{
schedulerServiceAgent.SaveChannel(channels[0]);
}
}
else if(channels.Length == 0)
{
// No channels linked to the GuideChannel. If we have an existing channel with the same name, then link it.
Channel existingChannel = schedulerServiceAgent.GetChannelByDisplayName(channelType, channel.ChannelName);
if (existingChannel != null)
{
existingChannel.LogicalChannelNumber = channel.LogicalChannelNumber;
schedulerServiceAgent.SaveChannel(existingChannel);
}
else
{
schedulerServiceAgent.EnsureDefaultChannel(guideChannelId, channelType, channel.ChannelName, null);
channels = schedulerServiceAgent.GetChannelsForGuideChannel(guideChannelId);
if (channels.Length == 1)
{
channels[0].LogicalChannelNumber = channel.LogicalChannelNumber;
schedulerServiceAgent.SaveChannel(channels[0]);
}
}
}
return guideChannelId;
}
}
}
示例2: EnsureChannelForDvbEpg
private static Channel EnsureChannelForDvbEpg(SchedulerServiceAgent tvSchedulerAgent, TvDatabase.Channel mpChannel,
bool epgSyncAutoCreateChannels, bool epgSyncAutoCreateChannelsWithGroup)
{
ChannelLink channelLink = ChannelLinks.GetChannelLinkForMediaPortalChannel(mpChannel);
ChannelType channelType = mpChannel.IsTv ? ChannelType.Television : ChannelType.Radio;
Channel channel = null;
if (channelLink != null)
{
channel = tvSchedulerAgent.GetChannelById(channelLink.ChannelId);
if (channel == null)
{
channel = tvSchedulerAgent.GetChannelByDisplayName(channelType, channelLink.ChannelName);
}
}
if (channel == null)
{
channel = tvSchedulerAgent.GetChannelByDisplayName(channelType, mpChannel.DisplayName);
}
if (channel == null
&& (epgSyncAutoCreateChannels || epgSyncAutoCreateChannelsWithGroup))
{
string groupName = "DVB-EPG";
if (epgSyncAutoCreateChannelsWithGroup)
{
IList<TvDatabase.GroupMap> groupMaps = mpChannel.ReferringGroupMap();
foreach (TvDatabase.GroupMap groupMap in groupMaps)
{
TvDatabase.ChannelGroup channelGroup = TvDatabase.ChannelGroup.Retrieve(groupMap.IdGroup);
if (channelGroup != null)
{
groupName = channelGroup.GroupName;
break;
}
}
}
Guid channelId = tvSchedulerAgent.EnsureChannel(channelType, mpChannel.DisplayName, groupName);
channel = tvSchedulerAgent.GetChannelById(channelId);
if (!channel.LogicalChannelNumber.HasValue
&& mpChannel.ChannelNumber > 0)
{
channel.LogicalChannelNumber = mpChannel.ChannelNumber;
tvSchedulerAgent.SaveChannel(channel);
}
}
return channel;
}
示例3: DoShowGuideCommand
private IMBotMessage DoShowGuideCommand(IMBotConversation conversation, IList<string> arguments)
{
if (arguments.Count == 0)
{
return new IMBotMessage("Channel name or number missing.", IMBotMessage.ErrorColor);
}
using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
using (GuideServiceAgent tvGuideAgent = new GuideServiceAgent())
{
Channel selectedChannel = null;
ChannelType channelType = GetChannelType(conversation);
int lcn;
if (int.TryParse(arguments[0], out lcn))
{
selectedChannel = tvSchedulerAgent.GetChannelByLogicalChannelNumber(channelType, lcn);
if (selectedChannel == null)
{
return new IMBotMessage("Unknown channel number.", IMBotMessage.ErrorColor);
}
}
else
{
selectedChannel = tvSchedulerAgent.GetChannelByDisplayName(channelType, arguments[0]);
if (selectedChannel == null)
{
return new IMBotMessage("Unknown channel name.", IMBotMessage.ErrorColor);
}
}
if (selectedChannel.GuideChannelId.HasValue)
{
DateTime lowerTime = DateTime.Today;
if (arguments.Count > 1)
{
int dayNumber;
if (!int.TryParse(arguments[1], out dayNumber))
{
return new IMBotMessage("Bad day number, use 0 for today, 1 for tomorrow, etc...", IMBotMessage.ErrorColor);
}
lowerTime = lowerTime.AddDays(dayNumber);
}
DateTime upperTime = lowerTime.AddDays(1);
if (lowerTime.Date == DateTime.Today)
{
lowerTime = DateTime.Now;
}
Dictionary<Guid, UpcomingGuideProgram> upcomingRecordingsById = BuildUpcomingDictionary(
tvSchedulerAgent.GetUpcomingGuidePrograms(ScheduleType.Recording, true));
Dictionary<Guid, UpcomingGuideProgram> upcomingAlertsById = BuildUpcomingDictionary(
tvSchedulerAgent.GetUpcomingGuidePrograms(ScheduleType.Alert, false));
Dictionary<Guid, UpcomingGuideProgram> upcomingSuggestionsById = BuildUpcomingDictionary(
tvSchedulerAgent.GetUpcomingGuidePrograms(ScheduleType.Suggestion, false));
GuideProgramSummary[] programs = tvGuideAgent.GetChannelProgramsBetween(selectedChannel.GuideChannelId.Value, lowerTime, upperTime);
if (programs.Length == 0)
{
return new IMBotMessage(String.Format(CultureInfo.CurrentCulture, "No guide data for {0} on {1}.", selectedChannel.DisplayName, lowerTime.ToLongDateString()),
IMBotMessage.ErrorColor);
}
else
{
StringBuilder replyText = new StringBuilder();
replyText.AppendFormat("{0} on {1}:", lowerTime.ToLongDateString(), selectedChannel.DisplayName);
int index = 0;
foreach (GuideProgramSummary program in programs)
{
replyText.AppendLine();
replyText.AppendFormat("{0,3}» ", ++index);
string appendText = AppendProgramIndicatorsPrefix(replyText,
program.GetUniqueUpcomingProgramId(selectedChannel.ChannelId),
upcomingRecordingsById, upcomingAlertsById, upcomingSuggestionsById);
Utility.AppendProgramDetails(replyText, program);
replyText.Append(appendText);
}
conversation.Session[SessionKey.Programs] = new Session.Programs(selectedChannel, programs);
return new IMBotMessage(replyText.ToString(), true)
{
Footer = "Use 'record', 'cancel', 'uncancel' or 'delete schedule' with <number>."
};
}
}
else
{
return new IMBotMessage("Channel has no guide data.", IMBotMessage.ErrorColor);
}
}
}