Exemple #1
0
        private UPnPError OnCreateScheduleByTime(DvAction action, IList <object> inParams, out IList <object> outParams, CallContext context)
        {
            outParams = new List <object>();
            IScheduleControlAsync     scheduleControl     = ServiceRegistration.Get <ITvProvider>() as IScheduleControlAsync;
            IChannelAndGroupInfoAsync channelAndGroupInfo = ServiceRegistration.Get <ITvProvider>() as IChannelAndGroupInfoAsync;

            if (scheduleControl == null || channelAndGroupInfo == null)
            {
                return(new UPnPError(500, "IChannelAndGroupInfo or IScheduleControl service not available"));
            }

            int      channelId = (int)inParams[0];
            DateTime startTime = (DateTime)inParams[1];
            DateTime endTime   = (DateTime)inParams[2];
            ScheduleRecordingType recordingType = (ScheduleRecordingType)inParams[3];
            ISchedule             schedule      = null;

            AsyncResult <IChannel> result = channelAndGroupInfo.GetChannelAsync(channelId).Result;

            if (result.Success)
            {
                var scheduleResult = scheduleControl.CreateScheduleByTimeAsync(result.Result, startTime, endTime, recordingType).Result;
                if (scheduleResult.Success)
                {
                    schedule = scheduleResult.Result;
                }
            }

            outParams = new List <object> {
                result.Success, schedule
            };
            return(null);
        }
Exemple #2
0
        protected virtual async Task <RecordingStatus?> CreateOrDeleteScheduleByTimeAsync(IChannel program, DateTime start, DateTime end)
        {
            IScheduleControlAsync scheduleControl = _tvHandler.ScheduleControl;
            RecordingStatus?      newStatus       = null;

            if (scheduleControl != null)
            {
                var result = await scheduleControl.CreateScheduleByTimeAsync(program, start, end, ScheduleRecordingType.Once);

                if (result.Success)
                {
                    newStatus = RecordingStatus.Scheduled;
                }
            }
            return(newStatus);
        }