本文整理汇总了C#中SchedulerServiceAgent.CreateNewSchedule方法的典型用法代码示例。如果您正苦于以下问题:C# SchedulerServiceAgent.CreateNewSchedule方法的具体用法?C# SchedulerServiceAgent.CreateNewSchedule怎么用?C# SchedulerServiceAgent.CreateNewSchedule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SchedulerServiceAgent
的用法示例。
在下文中一共展示了SchedulerServiceAgent.CreateNewSchedule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoRecordCommand
private IMBotMessage DoRecordCommand(IMBotConversation conversation, IList<string> arguments)
{
if (arguments.Count == 0)
{
return new IMBotMessage("Program number missing.", IMBotMessage.ErrorColor);
}
using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
{
RepeatingType repeatingType = RepeatingType.None;
if (arguments.Count > 1)
{
switch (arguments[1].ToLowerInvariant())
{
case "once": case "o": repeatingType = RepeatingType.Once; break;
case "daily": case "d": repeatingType = RepeatingType.Daily; break;
case "weekly": case "w": repeatingType = RepeatingType.Weekly; break;
case "workingdays": case "wd": repeatingType = RepeatingType.WorkingDays; break;
case "weekends": case "we": repeatingType = RepeatingType.Weekends; break;
case "anytime": case "a": repeatingType = RepeatingType.AnyTime; break;
}
}
int programNumber;
if (repeatingType == RepeatingType.None
|| !int.TryParse(arguments[0], out programNumber))
{
return new IMBotMessage("Please specify program number and once, daily, weekly, workingdays, weekends or anytime.", IMBotMessage.ErrorColor);
}
Session.Programs sessionPrograms = null;
if (conversation.Session.ContainsKey(SessionKey.Programs))
{
sessionPrograms = conversation.Session[SessionKey.Programs] as Session.Programs;
}
IProgramSummary program = null;
Channel channel = null;
if (sessionPrograms != null)
{
program = sessionPrograms.GetProgramAt(programNumber, out channel);
if (program == null)
{
return new IMBotMessage("Bad program number.", IMBotMessage.ErrorColor);
}
}
else
{
return new IMBotMessage("No programs.", IMBotMessage.ErrorColor);
}
Schedule schedule = tvSchedulerAgent.CreateNewSchedule(GetChannelType(conversation), ScheduleType.Recording);
bool newEpisodesOnly = arguments.Count > 2 && arguments[2].Equals("new", StringComparison.CurrentCultureIgnoreCase);
string repeatingText = String.Empty;
if (repeatingType == RepeatingType.Once)
{
schedule.Name = GuideProgram.CreateProgramTitle(program.Title, program.SubTitle, program.EpisodeNumberDisplay);
schedule.Rules.Add(ScheduleRuleType.OnDate, program.StartTime.Date);
schedule.Rules.Add(ScheduleRuleType.AroundTime, new ScheduleTime(program.StartTime.TimeOfDay));
if (!String.IsNullOrEmpty(program.SubTitle))
{
schedule.Rules.Add(ScheduleRuleType.SubTitleEquals, program.SubTitle);
}
else if (!String.IsNullOrEmpty(program.EpisodeNumberDisplay))
{
schedule.Rules.Add(ScheduleRuleType.EpisodeNumberEquals, program.EpisodeNumberDisplay);
}
newEpisodesOnly = false;
}
else if (repeatingType == RepeatingType.AnyTime)
{
schedule.Name = program.Title + " (Any Time)";
repeatingText = " any time";
}
else if (repeatingType == RepeatingType.Weekly)
{
schedule.Name = program.Title + " (Weekly)";
schedule.Rules.Add(ScheduleRuleType.DaysOfWeek, GetDaysOfWeek(program.StartTime));
schedule.Rules.Add(ScheduleRuleType.AroundTime, new ScheduleTime(program.StartTime.TimeOfDay));
repeatingText = " weekly";
}
else if (repeatingType == RepeatingType.WorkingDays)
{
schedule.Name = program.Title + " (Mon-Fri)";
schedule.Rules.Add(ScheduleRuleType.DaysOfWeek, ScheduleDaysOfWeek.WorkingDays);
schedule.Rules.Add(ScheduleRuleType.AroundTime, new ScheduleTime(program.StartTime.TimeOfDay));
repeatingText = " Mon-Fri";
}
else if (repeatingType == RepeatingType.Weekends)
{
schedule.Name = program.Title + " (Sat-Sun)";
schedule.Rules.Add(ScheduleRuleType.DaysOfWeek, ScheduleDaysOfWeek.Weekends);
schedule.Rules.Add(ScheduleRuleType.AroundTime, new ScheduleTime(program.StartTime.TimeOfDay));
repeatingText = " Sat-Sun";
}
else if (repeatingType == RepeatingType.Weekly)
{
//.........这里部分代码省略.........
示例2: CreateManualSchedule
private Schedule CreateManualSchedule(Channel channel, int durationMinutes, out string notifyText)
{
using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
{
Schedule schedule = tvSchedulerAgent.CreateNewSchedule(ChannelType.Television, ScheduleType.Recording);
DateTime startTime = DateTime.Now;
TimeSpan duration = new TimeSpan(0, durationMinutes, 0);
schedule.Rules.Add(ScheduleRuleType.Channels, channel.ChannelId);
schedule.Rules.Add(ScheduleRuleType.ManualSchedule, startTime, new ScheduleTime(duration));
schedule.Name = String.Format(CultureInfo.CurrentCulture, "{0} {1:g}-{2:t}", channel.DisplayName, startTime, startTime.Add(duration));
notifyText = schedule.Name;
return schedule;
}
}