Example #1
0
 public override bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule)
 {
     TvDatabase.Schedule tvSchedule = _tvBusiness.AddSchedule(channel.ChannelId, "Manual", from, to, (int)ScheduleRecordingType.Once);
     tvSchedule.PreRecordInterval  = Int32.Parse(_tvBusiness.GetSetting("preRecordInterval", "5").Value);
     tvSchedule.PostRecordInterval = Int32.Parse(_tvBusiness.GetSetting("postRecordInterval", "5").Value);
     tvSchedule.Persist();
     _tvControl.OnNewSchedule();
     schedule = tvSchedule.ToSchedule();
     return(true);
 }
Example #2
0
        public override async Task <AsyncResult <ISchedule> > CreateScheduleByTimeAsync(IChannel channel, DateTime from, DateTime to, ScheduleRecordingType recordingType)
        {
            await _initComplete.Task;

            TvDatabase.Schedule tvSchedule = new TvDatabase.Schedule(channel.ChannelId, "Manual", from, to);
            tvSchedule.ScheduleType       = (int)recordingType;
            tvSchedule.PreRecordInterval  = Int32.Parse(_tvBusiness.GetSetting("preRecordInterval", "5").Value);
            tvSchedule.PostRecordInterval = Int32.Parse(_tvBusiness.GetSetting("postRecordInterval", "5").Value);
            tvSchedule.Persist();
            _tvControl.OnNewSchedule();
            var schedule = tvSchedule.ToSchedule();

            return(new AsyncResult <ISchedule>(true, schedule));
        }
Example #3
0
        public static bool CreateProgram(TvDatabase.Program program, int scheduleType, out ISchedule currentSchedule)
        {
            ServiceRegistration.Get <ILogger>().Debug("SlimTvService3.CreateProgram: program = {0}", program.ToString());
            TvDatabase.Schedule schedule;
            TvDatabase.Schedule saveSchedule = null;
            TvBusinessLayer     layer        = new TvBusinessLayer();

            if (IsRecordingProgram(program, out schedule, false)) // check if schedule is already existing
            {
                ServiceRegistration.Get <ILogger>().Debug("SlimTvService3.CreateProgram - series schedule found ID={0}, Type={1}", schedule.IdSchedule, schedule.ScheduleType);
                ServiceRegistration.Get <ILogger>().Debug("                            - schedule= {0}", schedule.ToString());
                if (schedule.IsSerieIsCanceled(schedule.GetSchedStartTimeForProg(program), program.IdChannel))
                {
                    // Delete the cancelled schedule.
                    saveSchedule = schedule;
                    schedule     = new TvDatabase.Schedule(program.IdChannel, program.Title, program.StartTime, program.EndTime)
                    {
                        PreRecordInterval  = saveSchedule.PreRecordInterval,
                        PostRecordInterval = saveSchedule.PostRecordInterval,
                        ScheduleType       = (int)ScheduleRecordingType.Once
                    };
                }
            }
            else
            {
                ServiceRegistration.Get <ILogger>().Debug("SlimTvService3.CreateProgram - no series schedule");
                // No series schedule => create it
                schedule = new TvDatabase.Schedule(program.IdChannel, program.Title, program.StartTime, program.EndTime)
                {
                    PreRecordInterval  = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value),
                    PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value),
                    ScheduleType       = scheduleType
                };
            }

            if (saveSchedule != null)
            {
                ServiceRegistration.Get <ILogger>().Debug("SlimTvService3.CreateProgram - UnCancelSerie at {0}", program.StartTime);
                saveSchedule.UnCancelSerie(program.StartTime, program.IdChannel);
                saveSchedule.Persist();
                currentSchedule = saveSchedule.ToSchedule();
            }
            else
            {
                ServiceRegistration.Get <ILogger>().Debug("SlimTvService3.CreateProgram - create schedule = {0}", schedule.ToString());
                schedule.Persist();
                currentSchedule = schedule.ToSchedule();
            }
            return(currentSchedule != null);
        }
Example #4
0
        public override Task <AsyncResult <ISchedule> > CreateScheduleDetailedAsync(IChannel channel, string title, DateTime from, DateTime to, ScheduleRecordingType recordingType, int preRecordInterval, int postRecordInterval, string directory, int priority)
        {
            TvDatabase.Schedule tvSchedule = _tvBusiness.AddSchedule(channel.ChannelId, title, from, to, (int)recordingType);
            tvSchedule.PreRecordInterval  = preRecordInterval >= 0 ? preRecordInterval : Int32.Parse(_tvBusiness.GetSetting("preRecordInterval", "5").Value);
            tvSchedule.PostRecordInterval = postRecordInterval >= 0 ? postRecordInterval : Int32.Parse(_tvBusiness.GetSetting("postRecordInterval", "5").Value);
            if (!String.IsNullOrEmpty(directory))
            {
                tvSchedule.Directory = directory;
            }
            if (priority >= 0)
            {
                tvSchedule.Priority = priority;
            }
            tvSchedule.Persist();
            _tvControl.OnNewSchedule();
            var schedule = tvSchedule.ToSchedule();

            return(Task.FromResult(new AsyncResult <ISchedule>(true, schedule)));
        }