Exemple #1
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)
        {
            IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>();
            Schedule         tvSchedule      = ScheduleFactory.CreateSchedule(channel.ChannelId, title, from, to);

            tvSchedule.PreRecordInterval  = preRecordInterval >= 0 ? preRecordInterval : ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvSchedule.PostRecordInterval = postRecordInterval >= 0 ? postRecordInterval : ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            if (!String.IsNullOrEmpty(directory))
            {
                tvSchedule.Directory = directory;
            }
            if (priority >= 0)
            {
                tvSchedule.Priority = priority;
            }
            tvSchedule.PreRecordInterval  = preRecordInterval;
            tvSchedule.PostRecordInterval = postRecordInterval;
            tvSchedule.ScheduleType       = (int)recordingType;
            tvSchedule.Directory          = directory;
            tvSchedule.Priority           = priority;
            scheduleService.SaveSchedule(tvSchedule);
            ISchedule schedule = tvSchedule.ToSchedule();

            return(Task.FromResult(new AsyncResult <ISchedule>(true, schedule)));
        }
Exemple #2
0
        private static void CancelSingleSchedule(Schedule schedule, Program canceledProgram)
        {
            ICanceledScheduleService canceledScheduleService = GlobalServiceProvider.Instance.Get <ICanceledScheduleService>();

            CanceledSchedule canceledSchedule = CanceledScheduleFactory.CreateCanceledSchedule(schedule.IdSchedule, canceledProgram.IdChannel, canceledProgram.StartTime);

            canceledScheduleService.SaveCanceledSchedule(canceledSchedule);
            StopRecording(schedule);
        }
Exemple #3
0
        private void CancelFullSchedule(Schedule schedule)
        {
            Schedule currentSchedule = schedule;
            Schedule parentSchedule  = null;

            GetParentAndSpawnSchedule(ref currentSchedule, out parentSchedule);
            StopRecording(currentSchedule);
            DeleteEntireOrOnceSchedule(currentSchedule, parentSchedule);
        }
Exemple #4
0
        public override Task <bool> EditScheduleAsync(ISchedule schedule, IChannel channel = null, string title = null, DateTime?from = null, DateTime?to = null, ScheduleRecordingType?recordingType = null, int?preRecordInterval = null, int?postRecordInterval = null, string directory = null, int?priority = null)
        {
            try
            {
                ServiceRegistration.Get <ILogger>().Debug("Editing schedule {0} on channel {1} for {2}, {3} till {4}, type {5}", schedule.ScheduleId, channel.ChannelId, title, from, to, recordingType);
                IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>();
                Schedule         tvSchedule      = scheduleService.GetSchedule(schedule.ScheduleId);

                tvSchedule.IdChannel = channel.ChannelId;
                if (title != null)
                {
                    tvSchedule.ProgramName = title;
                }
                if (from != null)
                {
                    tvSchedule.StartTime = from.Value;
                }
                if (to != null)
                {
                    tvSchedule.EndTime = to.Value;
                }

                if (recordingType != null)
                {
                    ScheduleRecordingType scheduleRecType = recordingType.Value;
                    tvSchedule.ScheduleType = (int)scheduleRecType;
                }

                if (preRecordInterval != null)
                {
                    tvSchedule.PreRecordInterval = preRecordInterval.Value;
                }
                if (postRecordInterval != null)
                {
                    tvSchedule.PostRecordInterval = postRecordInterval.Value;
                }

                if (directory != null)
                {
                    tvSchedule.Directory = directory;
                }
                if (priority != null)
                {
                    tvSchedule.Priority = priority.Value;
                }

                scheduleService.SaveSchedule(tvSchedule);

                return(Task.FromResult(true));
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Warn(String.Format("Failed to edit schedule {0}", schedule.ScheduleId), ex);
                return(Task.FromResult(false));
            }
        }
        public override bool CreateSchedule(IProgram program, ScheduleRecordingType recordingType, out ISchedule schedule)
        {
            IScheduleService scheduleService = GlobalServiceProvider.Instance.Get <IScheduleService>();
            Schedule         tvschedule      = ScheduleFactory.CreateSchedule(program.ChannelId, program.Title, program.StartTime, program.EndTime);

            tvschedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvschedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvschedule.ScheduleType       = (int)recordingType;
            scheduleService.SaveSchedule(tvschedule);
            schedule = tvschedule.ToSchedule();
            return(true);
        }
Exemple #6
0
        private static bool StopRecording(Schedule schedule)
        {
            bool stoppedRec = false;
            bool isRec      = ServiceAgents.Instance.ScheduleServiceAgent.IsScheduleRecording(schedule.IdSchedule);

            if (isRec)
            {
                ServiceAgents.Instance.ControllerServiceAgent.StopRecordingSchedule(schedule.IdSchedule);
                stoppedRec = true;
            }
            return(stoppedRec);
        }
Exemple #7
0
        private bool DeleteSchedule(int idSchedule)
        {
            Schedule schedule = ServiceAgents.Instance.ScheduleServiceAgent.GetSchedule(idSchedule);

            if (schedule == null)
            {
                return(false);
            }

            ServiceAgents.Instance.ScheduleServiceAgent.DeleteSchedule(schedule.IdSchedule);
            return(true);
        }
        public override bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule)
        {
            IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>();
            Schedule         tvSchedule      = ScheduleFactory.CreateSchedule(channel.ChannelId, "Manual", from, to);

            tvSchedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvSchedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvSchedule.ScheduleType       = (int)ScheduleRecordingType.Once;
            scheduleService.SaveSchedule(tvSchedule);
            schedule = tvSchedule.ToSchedule();
            return(true);
        }
Exemple #9
0
        public override Task <AsyncResult <ISchedule> > CreateScheduleByTimeAsync(IChannel channel, string title, DateTime from, DateTime to, ScheduleRecordingType recordingType)
        {
            IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>();
            Schedule         tvSchedule      = ScheduleFactory.CreateSchedule(channel.ChannelId, title, from, to);

            tvSchedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvSchedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvSchedule.ScheduleType       = (int)recordingType;
            scheduleService.SaveSchedule(tvSchedule);
            var schedule = tvSchedule.ToSchedule();

            return(Task.FromResult(new AsyncResult <ISchedule>(true, schedule)));
        }
Exemple #10
0
        public override Task <AsyncResult <ISchedule> > CreateScheduleAsync(IProgram program, ScheduleRecordingType recordingType)
        {
            IScheduleService scheduleService = GlobalServiceProvider.Instance.Get <IScheduleService>();
            Schedule         tvschedule      = ScheduleFactory.CreateSchedule(program.ChannelId, program.Title, program.StartTime, program.EndTime);

            tvschedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvschedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvschedule.ScheduleType       = (int)recordingType;
            scheduleService.SaveSchedule(tvschedule);
            var schedule = tvschedule.ToSchedule();
            var success  = schedule != null;

            return(Task.FromResult(new AsyncResult <ISchedule>(success, schedule)));
        }
        public override bool GetProgramsForSchedule(ISchedule schedule, out IList <IProgram> programs)
        {
            programs = new List <IProgram>();
            Schedule scheduleEntity = ScheduleManagement.GetSchedule(schedule.ScheduleId);

            if (scheduleEntity == null)
            {
                return(false);
            }
            IList <Program> programEntities = ProgramManagement.GetProgramsForSchedule(scheduleEntity);

            programs = programEntities.Select(p => p.ToProgram()).Distinct(ProgramComparer.Instance).ToList();
            return(true);
        }
Exemple #12
0
        private static void GetParentAndSpawnSchedule(ref Schedule schedule, out Schedule parentSchedule)
        {
            parentSchedule = schedule.ParentSchedule;
            if (parentSchedule != null)
            {
                return;
            }

            parentSchedule = schedule;
            Schedule spawn = ServiceAgents.Instance.ScheduleServiceAgent.RetrieveSpawnedSchedule(parentSchedule.IdSchedule, parentSchedule.StartTime);

            if (spawn != null)
            {
                schedule = spawn;
            }
        }
Exemple #13
0
        public override Task <AsyncResult <IList <IProgram> > > GetProgramsForScheduleAsync(ISchedule schedule)
        {
            var      programs       = new List <IProgram>();
            Schedule scheduleEntity = ScheduleManagement.GetSchedule(schedule.ScheduleId);

            if (scheduleEntity == null)
            {
                return(Task.FromResult(new AsyncResult <IList <IProgram> >(false, null)));
            }
            IList <Program> programEntities = ProgramManagement.GetProgramsForSchedule(scheduleEntity);

            programs = programEntities.Select(p => GetProgram(p)).Distinct(ProgramComparer.Instance).ToList();
            var success = programs.Count > 0;

            return(Task.FromResult(new AsyncResult <IList <IProgram> >(success, programs)));
        }
Exemple #14
0
        public bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule)
        {
#if TVE3
            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();
#else
            IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>();
            Schedule         tvSchedule      = ScheduleFactory.CreateSchedule(channel.ChannelId, "Manual", from, to);
            tvSchedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvSchedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvSchedule.ScheduleType       = (int)ScheduleRecordingType.Once;
            scheduleService.SaveSchedule(tvSchedule);
#endif
            schedule = tvSchedule.ToSchedule();
            return(true);
        }
Exemple #15
0
        public bool CreateSchedule(IProgram program, ScheduleRecordingType recordingType, out ISchedule schedule)
        {
#if TVE3
            TvDatabase.Schedule tvSchedule = _tvBusiness.AddSchedule(program.ChannelId, program.Title, program.StartTime, program.EndTime, (int)recordingType);
            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();
            schedule = tvSchedule.ToSchedule();
            return(true);
#else
            IScheduleService scheduleService = GlobalServiceProvider.Instance.Get <IScheduleService>();
            Schedule         tvschedule      = ScheduleFactory.CreateSchedule(program.ChannelId, program.Title, program.StartTime, program.EndTime);
            tvschedule.PreRecordInterval  = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5);
            tvschedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5);
            tvschedule.ScheduleType       = (int)recordingType;
            scheduleService.SaveSchedule(tvschedule);
            schedule = tvschedule.ToSchedule();
            return(true);
#endif
        }
Exemple #16
0
        public bool GetProgramsForSchedule(ISchedule schedule, out IList <IProgram> programs)
        {
            programs = new List <IProgram>();
#if TVE3
            var tvSchedule = TvDatabase.Schedule.Retrieve(schedule.ScheduleId);
            if (tvSchedule == null)
            {
                return(false);
            }

            programs = TvDatabase.Schedule.GetProgramsForSchedule(tvSchedule).Select(p => p.ToProgram()).ToList();
            return(programs.Count > 0);
#else
            Schedule scheduleEntity = ScheduleManagement.GetSchedule(schedule.ScheduleId);
            if (scheduleEntity == null)
            {
                return(false);
            }
            IList <Program> programEntities = ProgramManagement.GetProgramsForSchedule(scheduleEntity);
            programs = programEntities.Select(p => p.ToProgram()).Distinct(ProgramComparer.Instance).ToList();
            return(true);
#endif
        }
Exemple #17
0
        private bool DeleteEntireOrOnceSchedule(Schedule schedule, Schedule parentSchedule)
        {
            //is the schedule recording, then stop it now.
            bool wasDeleted = false;

            foreach (var currentSchedule in new List <Schedule> {
                schedule, parentSchedule
            })
            {
                try
                {
                    if (currentSchedule != null)
                    {
                        wasDeleted |= DeleteSchedule(currentSchedule.IdSchedule);
                    }
                }
                catch (Exception ex)
                {
                    ServiceRegistration.Get <ILogger>().Error("Error deleting schedule with ID '{0}'", ex,
                                                              currentSchedule != null ? currentSchedule.IdSchedule.ToString() : "<null>");
                }
            }
            return(wasDeleted);
        }
 private bool DeleteEntireOrOnceSchedule(Schedule schedule, Schedule parentSchedule)
 {
   //is the schedule recording, then stop it now.
   bool wasDeleted = false;
   foreach (var currentSchedule in new List<Schedule> { schedule, parentSchedule })
   {
     try
     {
       if (currentSchedule != null)
         wasDeleted |= DeleteSchedule(currentSchedule.IdSchedule);
     }
     catch (Exception ex)
     {
       ServiceRegistration.Get<ILogger>().Error("Error deleting schedule with ID '{0}'", ex,
         currentSchedule != null ? currentSchedule.IdSchedule.ToString() : "<null>");
     }
   }
   return wasDeleted;
 }
 private static bool StopRecording(Schedule schedule)
 {
   bool stoppedRec = false;
   bool isRec = ServiceAgents.Instance.ScheduleServiceAgent.IsScheduleRecording(schedule.IdSchedule);
   if (isRec)
   {
     ServiceAgents.Instance.ControllerServiceAgent.StopRecordingSchedule(schedule.IdSchedule);
     stoppedRec = true;
   }
   return stoppedRec;
 }
    private static void GetParentAndSpawnSchedule(ref Schedule schedule, out Schedule parentSchedule)
    {
      parentSchedule = schedule.ParentSchedule;
      if (parentSchedule != null)
        return;

      parentSchedule = schedule;
      Schedule spawn = ServiceAgents.Instance.ScheduleServiceAgent.RetrieveSpawnedSchedule(parentSchedule.IdSchedule, parentSchedule.StartTime);
      if (spawn != null)
        schedule = spawn;
    }
 private void CancelFullSchedule(Schedule schedule)
 {
   Schedule currentSchedule = schedule;
   Schedule parentSchedule = null;
   GetParentAndSpawnSchedule(ref currentSchedule, out parentSchedule);
   StopRecording(currentSchedule);
   DeleteEntireOrOnceSchedule(currentSchedule, parentSchedule);
 }
    private static void CancelSingleSchedule(Schedule schedule, Program canceledProgram)
    {
      ICanceledScheduleService canceledScheduleService = GlobalServiceProvider.Instance.Get<ICanceledScheduleService>();

      CanceledSchedule canceledSchedule = CanceledScheduleFactory.CreateCanceledSchedule(schedule.IdSchedule, canceledProgram.IdChannel, canceledProgram.StartTime);
      canceledScheduleService.SaveCanceledSchedule(canceledSchedule);
      StopRecording(schedule);
    }
Exemple #23
0
        public void Persist()
        {
            DateTime start = DateTime.Now; //DEBUG PERFORMANCE
            
            Log.Debug("Persist Schedule");
            Mediaportal.TV.Server.TVDatabase.Entities.Schedule myschedule = new Mediaportal.TV.Server.TVDatabase.Entities.Schedule();
            myschedule.Canceled = DateTime.ParseExact("2000-01-01_00:00", "yyyy-MM-dd_HH:mm", System.Globalization.CultureInfo.InvariantCulture);
            myschedule.CanceledSchedules = new Mediaportal.TV.Server.TVDatabase.Entities.TrackableCollection<Mediaportal.TV.Server.TVDatabase.Entities.CanceledSchedule>();
            myschedule.ChangeTracker = new Mediaportal.TV.Server.TVDatabase.Entities.ObjectChangeTracker();
            myschedule.Channel = ServiceAgents.Instance.ChannelServiceAgent.GetChannel(this.IdChannel);
            //myschedule.ConflictingSchedules
            //myschedule.Conflicts
            myschedule.Directory = "";
            myschedule.EndTime = EndTime;
            myschedule.IdChannel = IdChannel;
            //myschedule.IdParentSchedule
            //myschedule.IdSchedule
            myschedule.KeepDate = KeepDate;
            myschedule.KeepMethod = KeepMethod;
            myschedule.MaxAirings = MaxAirings;
            myschedule.ParentSchedule = null;
            myschedule.PostRecordInterval = PostRecordInterval;
            myschedule.PreRecordInterval = PreRecordInterval;
            myschedule.Priority = Priority;
            myschedule.ProgramName = ProgramName;
            myschedule.Quality = Quality;
            //myschedule.Recordings = new TVDatabase.Entities.TrackableCollection<Mediaportal.TV.Server.TVDatabase.Entities.Recording>(); BUG
            //myschedule.Schedules = new TVDatabase.Entities.TrackableCollection<Mediaportal.TV.Server.TVDatabase.Entities.Schedule>(); Bug
            myschedule.ScheduleType = 0;
            myschedule.Series = Series;
            myschedule.StartTime = StartTime;
            
            //Log.Debug("before myschedule.IdSchedule=" + myschedule.IdSchedule.ToString());
            
            if (TvWishListSetup.Setup)
            {
                ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(myschedule);
                Log.Debug("Added schedule by Setup: " + myschedule.ProgramName);
            }
            else//Tv server schedules
            {
                try
                {
                    DateTime start2 = DateTime.Now; //DEBUG PERFORMANCE
                    ScheduleManagement.SaveSchedule(myschedule);
                    DateTime end2 = DateTime.Now; //DEBUG PERFORMANCE
                    Log.Debug("IList<Schedule> Persist() time=" + end2.Subtract(start2).TotalSeconds.ToString()); //DEBUG PERFORMANCE
                    //ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(myschedule);

                }
                catch (Exception exc)
                {
                    Log.Debug("Exception=" + exc.Message);
                    return;
                }
                //Log.Debug("Added schedule by Server: " + myschedule.ProgramName);
            }
            IdSchedule = myschedule.IdSchedule;
            //Log.Debug("after myschedule.IdSchedule=" + myschedule.IdSchedule.ToString());
            DateTime end = DateTime.Now; //DEBUG PERFORMANCE
            Log.Debug("IList<Schedule> Persist() total time=" + end.Subtract(start).TotalSeconds.ToString()); //DEBUG PERFORMANCE
        }