/// <summary> /// Executes the specified param. /// </summary> /// <param name="param">The param.</param> /// <param name="result">The result.</param> /// <returns></returns> public OpResult Execute(string param) { List <ScheduleEvent> events; StringBuilder sb = new StringBuilder(); OpResult opResult = new OpResult(); if (m_eventSchedule == null) { opResult.StatusCode = OpStatusCode.Exception; opResult.StatusText = m_exception; return(opResult); } try { if (param.Equals("recorded", StringComparison.InvariantCultureIgnoreCase)) { events = m_eventSchedule.GetScheduleEvents(DateTime.MinValue, DateTime.MaxValue, ScheduleEventStates.HasOccurred) as List <ScheduleEvent>; } else if (param.Equals("recording", StringComparison.InvariantCultureIgnoreCase)) { events = m_eventSchedule.GetScheduleEvents(DateTime.MinValue, DateTime.MaxValue, ScheduleEventStates.IsOccurring) as List <ScheduleEvent>; } else if (param.Equals("scheduled", StringComparison.InvariantCultureIgnoreCase)) { events = m_eventSchedule.GetScheduleEvents(DateTime.Now, DateTime.Now.AddDays(7), ScheduleEventStates.WillOccur) as List <ScheduleEvent>; } else { opResult.StatusCode = OpStatusCode.BadRequest; return(opResult); } events.Sort(CompareScheduleEvents); foreach (ScheduleEvent item in events) { opResult.AppendFormat("{0}={1} ({2}-{3})", item.Id, item.GetExtendedProperty("Title"), item.StartTime.ToLocalTime().ToString("g"), item.EndTime.ToLocalTime().ToShortTimeString() ); } opResult.StatusCode = OpStatusCode.Ok; } catch (Exception ex) { opResult.StatusCode = OpStatusCode.Exception; opResult.StatusText = ex.Message; } return(opResult); }
public static bool CacheUpcomingScheduleEvents(int maxDaysInAdvance) { if (!EventScheduleExists) { return(false); } _cachedScheduleEvents = es.GetScheduleEvents(DateTime.Now, DateTime.Now.AddDays(maxDaysInAdvance), Microsoft.MediaCenter.TV.Scheduling.ScheduleEventStates.All); return(true); }
private void FindOnGoingRecordings() { DateTime now = DateTime.Now; ICollection <ScheduleEvent> scheduledEventsLast24h = eventSchedule.GetScheduleEvents(now.AddDays(-1.0), now, ScheduleEventStates.IsOccurring); foreach (ScheduleEvent scheduleEvent in scheduledEventsLast24h) { onGoingRecordings.Add(RecordingFactory.CreateFromScheduleEvent(scheduleEvent)); } }