コード例 #1
0
        public static bool IsRecordingProgram(TvDatabase.Program program, out TvDatabase.Schedule recordingSchedule, bool filterCanceledRecordings)
        {
            recordingSchedule = null;

            IList <TvDatabase.Schedule> schedules = TvDatabase.Schedule.ListAll();

            foreach (TvDatabase.Schedule schedule in schedules)
            {
                if (schedule.Canceled != TvDatabase.Schedule.MinSchedule || (filterCanceledRecordings && schedule.IsSerieIsCanceled(schedule.GetSchedStartTimeForProg(program), program.IdChannel)))
                {
                    continue;
                }
                if (schedule.IsManual && schedule.IdChannel == program.IdChannel && schedule.EndTime >= program.EndTime)
                {
                    TvDatabase.Schedule manual = schedule.Clone();
                    manual.ProgramName = program.Title;
                    manual.EndTime     = program.EndTime;
                    manual.StartTime   = program.StartTime;
                    if (manual.IsRecordingProgram(program, filterCanceledRecordings))
                    {
                        recordingSchedule = schedule;
                        return(true);
                    }
                }
                else if (schedule.IsRecordingProgram(program, filterCanceledRecordings))
                {
                    recordingSchedule = schedule;
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
    private void CheckEpsiodesForRecording(Schedule schedule, TvDatabase.Program program)
    {
      if (!schedule.DoesUseEpisodeManagement)
        return;

      //check how many episodes we got
      while (true)
      {
        IList<Recording> recordings = Recording.ListAll();

        List<Recording> episodes = GetEpisodes(program.Title, recordings);
        if (episodes.Count <= schedule.MaxAirings)
          return;

        Recording oldestEpisode = GetOldestEpisode(episodes);
        if (oldestEpisode == null)
          return;
        Log.Write("diskmanagement:   Delete episode {0} {1} {2} {3}",
                  oldestEpisode.ReferencedChannel(),
                  oldestEpisode.Title,
                  oldestEpisode.StartTime.ToLongDateString(),
                  oldestEpisode.StartTime.ToLongTimeString());

        // Delete the file from disk and the recording entry from the database.        
        bool result = RecordingFileHandler.DeleteRecordingOnDisk(oldestEpisode.FileName);
        if (result)
        {
          oldestEpisode.Delete();
        }
      }
    }
コード例 #3
0
    public void OnScheduleEnded(string recordingFilename, Schedule recording, TvDatabase.Program program)
    {
      Log.Write("diskmanagement: recording {0} ended. type:{1} max episodes:{2}",
                program.Title, (ScheduleRecordingType)recording.ScheduleType, recording.MaxAirings);

      CheckEpsiodesForRecording(recording, program);
    }
コード例 #4
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);
        }
コード例 #5
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="schedule">Schedule of this recording</param>
        /// <param name="channel">Channel on which the recording is done</param>
        /// <param name="endTime">Date/Time the recording should start without pre-record interval</param>
        /// <param name="endTime">Date/Time the recording should stop with post record interval</param>
        /// <param name="isSerie">Is serie recording</param>
        ///
        ///
        public RecordingDetail(Schedule schedule, Channel channel, DateTime endTime, bool isSerie)
        {
            _user = UserFactory.CreateSchedulerUser(schedule.IdSchedule);

            /*User.Name = string.Format("scheduler{0}", schedule.IdSchedule);
             * User.CardId = -1;
             * User.SubChannel = -1;
             * User.IsAdmin = true;
             * User.Priority = UserFactory.SCHEDULER_PRIORITY;*/

            _schedule = schedule;
            _channel  = channel;
            _endTime  = endTime;
            _program  = null;
            _isSerie  = isSerie;

            DateTime startTime = DateTime.MinValue;

            if (isSerie)
            {
                DateTime now = DateTime.Now.AddMinutes(schedule.PreRecordInterval);
                startTime = new DateTime(now.Year, now.Month, now.Day, schedule.StartTime.Hour, schedule.StartTime.Minute, 0);
            }
            else
            {
                startTime = schedule.StartTime;
            }

            _program = schedule.ReferencedChannel().GetProgramAt(startTime);

            //no program? then treat this as a manual recording
            if (_program == null)
            {
                _program = new TvDatabase.Program(0, DateTime.Now, endTime, "manual", "", "",
                                                  TvDatabase.Program.ProgramState.None,
                                                  System.Data.SqlTypes.SqlDateTime.MinValue.Value, string.Empty, string.Empty,
                                                  string.Empty, string.Empty, -1, string.Empty, 0);
            }
        }
コード例 #6
0
    /// <summary>
    /// constructor
    /// </summary>
    /// <param name="schedule">Schedule of this recording</param>
    /// <param name="channel">Channel on which the recording is done</param>
    /// <param name="endTime">Date/Time the recording should start without pre-record interval</param>
    /// <param name="endTime">Date/Time the recording should stop with post record interval</param>
    /// <param name="isSerie">Is serie recording</param>
    /// 
    /// 
    public RecordingDetail(Schedule schedule, Channel channel, DateTime endTime, bool isSerie)
    {
      _user = UserFactory.CreateSchedulerUser(schedule.IdSchedule);
      /*User.Name = string.Format("scheduler{0}", schedule.IdSchedule);
      User.CardId = -1;
      User.SubChannel = -1;
      User.IsAdmin = true;
      User.Priority = UserFactory.SCHEDULER_PRIORITY;*/

      _schedule = schedule;
      _channel = channel;
      _endTime = endTime;
      _program = null;
      _isSerie = isSerie;

      DateTime startTime = DateTime.MinValue;

      if (isSerie)
      {
        DateTime now = DateTime.Now.AddMinutes(schedule.PreRecordInterval);
        startTime = new DateTime(now.Year, now.Month, now.Day, schedule.StartTime.Hour, schedule.StartTime.Minute, 0);
      }
      else
      {
        startTime = schedule.StartTime;
      }

      _program = schedule.ReferencedChannel().GetProgramAt(startTime);

      //no program? then treat this as a manual recording
      if (_program == null)
      {
        _program = new TvDatabase.Program(0, DateTime.Now, endTime, "manual", "", "",
                                          TvDatabase.Program.ProgramState.None,
                                          System.Data.SqlTypes.SqlDateTime.MinValue.Value, string.Empty, string.Empty,
                                          string.Empty, string.Empty, -1, string.Empty, 0);
      }
    }