private static void CancelProgram(Program program, Schedule schedule, int dialogId)
    {
      Log.Debug("TVProgammInfo.CancelProgram - programm = {0}", program.ToString());
      Log.Debug("                            - schedule = {0}", schedule.ToString());
      Log.Debug(" ProgramID = {0}            ScheduleID = {1}", program.IdProgram, schedule.IdSchedule);

      bool deleteEntireSched = false;

      if (schedule.ScheduleType == (int)ScheduleRecordingType.Once)
      {
        TVUtil.DeleteRecAndSchedWithPrompt(schedule, program.IdChannel);        
        ResetCurrentScheduleAndProgram(schedule);
        return;
      }

      if ((schedule.ScheduleType == (int)ScheduleRecordingType.Daily)
          || (schedule.ScheduleType == (int)ScheduleRecordingType.Weekends)
          || (schedule.ScheduleType == (int)ScheduleRecordingType.Weekly)
          || (schedule.ScheduleType == (int)ScheduleRecordingType.WorkingDays)
          || (schedule.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnEveryChannel)
          || (schedule.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnThisChannel)
          || (schedule.ScheduleType == (int) ScheduleRecordingType.WeeklyEveryTimeOnThisChannel))          
      {
        GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
        if (dlg == null)
        {
          Log.Error("TVProgramInfo.CancelProgram: ERROR no GUIDialogMenu found !!!!!!!!!!");
          return;
        }

        dlg.Reset();
        dlg.SetHeading(TVUtil.GetDisplayTitle(program));
        if (anyUpcomingEpisodesRecording)
        {
          dlg.AddLocalizedString(981); //Cancel this show
        }
        dlg.AddLocalizedString(982); //Delete this entire schedule
        dlg.DoModal(dialogId);
        if (dlg.SelectedLabel == -1)
        {
          return;
        }

        switch (dlg.SelectedId)
        {
          case 981: //delete specific series

            break;
          case 982: //Delete entire recording
            deleteEntireSched = true;
            break;
        }
                
        if (deleteEntireSched)
        {
          TVUtil.DeleteRecAndEntireSchedWithPrompt(schedule, program.StartTime);
          ResetCurrentScheduleAndProgram(schedule);
        }
        else
        {
          TVUtil.DeleteRecAndSchedWithPrompt(schedule, program);
        }                
      }
    }
Ejemplo n.º 2
0
      public List<Schedule> GetConflictingSchedules(Schedule rec)
      {   
          LogDebug("GetConflictingSchedules: Schedule = " + rec.ToString(), (int)LogSetting.DEBUG);
#if(TV100)
          IList schedulesList = Schedule.ListAll();
          IList cards = Card.ListAll();
#elif(TV101 || TV11 || TV12)
          IList<Schedule> schedulesList = Schedule.ListAll();
          IList<Card> cards = Card.ListAll();
#endif

          List<Schedule> conflicts = new List<Schedule>();
          
          if (cards.Count == 0)
          {
              return conflicts;
          }
          //LogDebug("GetConflictingSchedules: Cards.Count =" + cards.Count.ToString(), (int)LogSetting.DEBUG);

          List<Schedule>[] cardSchedules = new List<Schedule>[cards.Count];
          for (int i = 0; i < cards.Count; i++)
          {
              cardSchedules[i] = new List<Schedule>();
          }

          // GEMX: Assign all already scheduled timers to cards. Assume that even possibly overlapping schedulues are ok to the user,
          // as he decided to keep them before. That's why they are in the db
          foreach (Schedule schedule in schedulesList)
          {

              //huha change 
              if (schedule == rec)
              {
                  continue;
              }
              //end huha 
               
              List<Schedule> episodes = GetRecordingTimes(schedule);
              foreach (Schedule episode in episodes)
              {
                  if (DateTime.Now > episode.EndTime)
                  {
                      continue;
                  }
                  if (episode.IsSerieIsCanceled(episode.StartTime))
                  {
                      continue;
                  }
                  Schedule overlapping;
                  AssignSchedulesToCard(episode, cardSchedules, out overlapping,DEBUG);
              }
          }

          List<Schedule> newEpisodes = GetRecordingTimes(rec);
          foreach (Schedule newEpisode in newEpisodes)
          {
              if (DateTime.Now > newEpisode.EndTime)
              {
                  continue;
              }
              if (newEpisode.IsSerieIsCanceled(newEpisode.StartTime))
              {
                  continue;
              }
              Schedule overlapping=null;
              if (!AssignSchedulesToCard(newEpisode, cardSchedules, out overlapping,DEBUG))
              {
                  LogDebug("GetConflictingSchedules: newEpisode can not be assigned to a card = " + newEpisode.ToString(), (int)LogSetting.DEBUG);
                  if (overlapping != null)
                  {
                      LogDebug("Overlapping schedule is:", (int)LogSetting.DEBUG);
                      outputscheduletoresponse(overlapping, (int)LogSetting.DEBUG);
                      conflicts.Add(overlapping);
                  }
                  else
                  {
                      LogDebug("Overlapping schedule is not defined", (int)LogSetting.DEBUG);
                  }                 
                    
              }

              
          }
          return conflicts;
      }