예제 #1
0
 private static void UpdateCurrentProgramTitle(ref Schedule recNew)
 {
   TvBusinessLayer layer = new TvBusinessLayer();
   IList<Program> programs = layer.GetPrograms(recNew.ReferencedChannel(), recNew.StartTime, recNew.EndTime);
   if (programs != null && programs.Count > 0)
   {
     recNew.ProgramName = programs[0].Title;
   }
 }
예제 #2
0
    public List<Schedule> GetRecordingTimes(Schedule rec, int days)
    {
      TvBusinessLayer layer = new TvBusinessLayer();
      List<Schedule> recordings = new List<Schedule>();

      DateTime dtDay = DateTime.Now;
      if (rec.ScheduleType == (int)ScheduleRecordingType.Once)
      {
        recordings.Add(rec);
        return recordings;
      }

      if (rec.ScheduleType == (int)ScheduleRecordingType.Daily)
      {
        for (int i = 0; i < days; ++i)
        {
          Schedule recNew = rec.Clone();
          recNew.ScheduleType = (int)ScheduleRecordingType.Once;
          recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute,
                                          0);
          if (rec.EndTime.Day > rec.StartTime.Day)
          {
            dtDay = dtDay.AddDays(1);
          }
          recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0);
          if (rec.EndTime.Day > rec.StartTime.Day)
          {
            dtDay = dtDay.AddDays(-1);
          }
          recNew.Series = true;
          if (recNew.StartTime >= DateTime.Now)
          {
            if (rec.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            recordings.Add(recNew);
          }
          dtDay = dtDay.AddDays(1);
        }
        return recordings;
      }

      if (rec.ScheduleType == (int)ScheduleRecordingType.WorkingDays)
      {
        for (int i = 0; i < days; ++i)
        {
          if (WeekEndTool.IsWorkingDay(dtDay.DayOfWeek))
          {
            Schedule recNew = rec.Clone();
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute,
                                            0);
            if (rec.EndTime.Day > rec.StartTime.Day)
            {
              dtDay = dtDay.AddDays(1);
            }
            recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0);
            if (rec.EndTime.Day > rec.StartTime.Day)
            {
              dtDay = dtDay.AddDays(-1);
            }
            recNew.Series = true;
            if (rec.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            if (recNew.StartTime >= DateTime.Now)
            {
              recordings.Add(recNew);
            }
          }
          dtDay = dtDay.AddDays(1);
        }
        return recordings;
      }

      if (rec.ScheduleType == (int)ScheduleRecordingType.Weekends)
      {
        IList<Program> progList = layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName,
                                                              rec.ReferencedChannel());

        foreach (Program prog in progList)
        {
          if ((rec.IsRecordingProgram(prog, false)) &&
              (WeekEndTool.IsWeekend(prog.StartTime.DayOfWeek)))
          {
            Schedule recNew = rec.Clone();
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.StartTime = prog.StartTime;
            recNew.EndTime = prog.EndTime;
            recNew.Series = true;

            if (rec.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            recordings.Add(recNew);
          }
        }
        return recordings;
      }
      if (rec.ScheduleType == (int)ScheduleRecordingType.Weekly)
      {
        for (int i = 0; i < days; ++i)
        {
          if ((dtDay.DayOfWeek == rec.StartTime.DayOfWeek) && (dtDay.Date >= rec.StartTime.Date))
          {
            Schedule recNew = rec.Clone();
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute,
                                            0);
            if (rec.EndTime.Day > rec.StartTime.Day)
            {
              dtDay = dtDay.AddDays(1);
            }
            recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0);
            if (rec.EndTime.Day > rec.StartTime.Day)
            {
              dtDay = dtDay.AddDays(-1);
            }
            recNew.Series = true;
            if (rec.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            if (recNew.StartTime >= DateTime.Now)
            {
              recordings.Add(recNew);
            }
          }
          dtDay = dtDay.AddDays(1);
        }
        return recordings;
      }

      IList<Program> programs;
      if (rec.ScheduleType == (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel)
      {
        //Log.Debug("get {0} {1} EveryTimeOnThisChannel", rec.ProgramName, rec.ReferencedChannel().Name);
        programs = layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName, rec.ReferencedChannel());
        foreach (Program prog in programs)
        {
          // dtDay.DayOfWeek == rec.StartTime.DayOfWeek
          // Log.Debug("BusinessLayer.cs Program prog in programs WeeklyEveryTimeOnThisChannel: {0} {1} prog.StartTime.DayOfWeek == rec.StartTime.DayOfWeek {2} == {3}", rec.ProgramName, rec.ReferencedChannel().Name, prog.StartTime.DayOfWeek, rec.StartTime.DayOfWeek);
          if (prog.StartTime.DayOfWeek == rec.StartTime.DayOfWeek && rec.IsRecordingProgram(prog, false))
          {
            Schedule recNew = rec.Clone();
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.IdChannel = prog.IdChannel;
            recNew.StartTime = prog.StartTime;
            recNew.EndTime = prog.EndTime;
            recNew.Series = true;
            if (rec.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            recordings.Add(recNew);

            //Log.Debug("BusinessLayer.cs Added Recording WeeklyEveryTimeOnThisChannel: {0} {1} prog.StartTime.DayOfWeek == rec.StartTime.DayOfWeek {2} == {3}", rec.ProgramName, rec.ReferencedChannel().Name, prog.StartTime.DayOfWeek, rec.StartTime.DayOfWeek);
          }
        }
        return recordings;
      }

      programs = rec.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnThisChannel
                   ? layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName,
                                                 rec.ReferencedChannel())
                   : layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName, null);
      foreach (Program prog in programs)
      {
        if (rec.IsRecordingProgram(prog, false))
        {
          Schedule recNew = rec.Clone();
          recNew.ScheduleType = (int)ScheduleRecordingType.Once;
          recNew.IdChannel = prog.IdChannel;
          recNew.StartTime = prog.StartTime;
          recNew.EndTime = prog.EndTime;
          recNew.Series = true;
          if (rec.IsSerieIsCanceled(rec.GetSchedStartTimeForProg(prog), prog.IdChannel))
          {
            recNew.Canceled = recNew.StartTime;
          }
          recordings.Add(recNew);
        }
      }
      return recordings;
    }
예제 #3
0
 /// <summary>
 /// checks if 2 schedules have a common Transponder
 /// depending on tuningdetails of their respective channels
 /// </summary>
 /// <param name="schedule"></param>
 /// <returns>True if a common transponder exists</returns>
 public bool isSameTransponder(Schedule schedule)
 {
   IList<TuningDetail> tuningList1 = ReferencedChannel().ReferringTuningDetail();
   IList<TuningDetail> tuningList2 = schedule.ReferencedChannel().ReferringTuningDetail();
   foreach (TuningDetail tun1 in tuningList1)
   {
     foreach (TuningDetail tun2 in tuningList2)
     {
       if (tun1.Frequency == tun2.Frequency)
       {
         return true;
       }
     }
   }
   return false;
 }
예제 #4
0
    public static IList<Program> GetProgramsForSchedule(Schedule schedule)
    {
      IList<Program> progs = null;
      switch (schedule.scheduleType)
      {
        case (int)ScheduleRecordingType.Once:
          var prgOnce = Program.RetrieveOnce(schedule.programName, schedule.startTime, schedule.endTime,
                                                 schedule.ReferencedChannel().IdChannel);
          progs = new List<Program>();
          if (prgOnce != null)
          {
            progs.Add(prgOnce);
          }
          break;

        case (int)ScheduleRecordingType.Daily:
          progs = Program.RetrieveDaily(schedule.startTime, schedule.endTime,schedule.ReferencedChannel().IdChannel);
          break;

        case (int)ScheduleRecordingType.EveryTimeOnEveryChannel:
          progs = Program.RetrieveEveryTimeOnEveryChannel(schedule.programName);
          break;

        case (int)ScheduleRecordingType.EveryTimeOnThisChannel:
          progs = Program.RetrieveEveryTimeOnThisChannel(schedule.programName, schedule.ReferencedChannel().IdChannel);
          break;

        case (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel:
          progs = Program.RetrieveWeeklyEveryTimeOnThisChannel(schedule.startTime, schedule.endTime, schedule.programName, schedule.ReferencedChannel().IdChannel);
          break;

        case (int)ScheduleRecordingType.Weekends:
          progs = Program.RetrieveWeekends(schedule.startTime, schedule.endTime, schedule.ReferencedChannel().IdChannel);
          break;

        case (int)ScheduleRecordingType.Weekly:
          progs = Program.RetrieveWeekly(schedule.startTime, schedule.endTime, schedule.ReferencedChannel().IdChannel);
          break;

        case (int)ScheduleRecordingType.WorkingDays:
          progs = Program.RetrieveWorkingDays(schedule.startTime, schedule.endTime, schedule.ReferencedChannel().IdChannel);
          break;
      }

      return progs;
    }
    private void OnQuickRecord()
    {
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      if (dlg == null)
      {
        return;
      }
      dlg.Reset();
      dlg.SetHeading(GUILocalizeStrings.Get(891)); //Select TV Channel
      IList<GroupMap> channels = TVHome.Navigator.CurrentGroup.ReferringGroupMap();
      foreach (GroupMap chan in channels)
      {
        GUIListItem item = new GUIListItem(chan.ReferencedChannel().DisplayName);
        string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, chan.ReferencedChannel().DisplayName);
        if (string.IsNullOrEmpty(strLogo))                      
        {
          strLogo = "defaultVideoBig.png";
        }
        item.ThumbnailImage = strLogo;
        item.IconImageBig = strLogo;
        item.IconImage = strLogo;
        dlg.Add(item);
      }
      dlg.DoModal(GetID);
      if (dlg.SelectedLabel < 0)
      {
        return;
      }

      Channel selectedChannel = (channels[dlg.SelectedLabel]).ReferencedChannel();
      dlg.Reset();
      dlg.SetHeading(616); //select recording type
      for (int i = 611; i <= 615; ++i)
      {
        dlg.Add(GUILocalizeStrings.Get(i));
      }
      dlg.Add(GUILocalizeStrings.Get(WeekEndTool.GetText(DayType.Record_WorkingDays)));
      dlg.Add(GUILocalizeStrings.Get(WeekEndTool.GetText(DayType.Record_WeekendDays)));

      Schedule rec = new Schedule(selectedChannel.IdChannel, "", Schedule.MinSchedule, Schedule.MinSchedule);

      TvBusinessLayer layer = new TvBusinessLayer();
      rec.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value);
      rec.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value);
      rec.ScheduleType = (int)ScheduleRecordingType.Once;

      DateTime dtNow = DateTime.Now;
      int day;
      day = 0;

      dlg.Reset();
      dlg.SetHeading(142); //select time
      dlg.ShowQuickNumbers = false;
      //time
      //int no = 0;
      int hour, minute, steps;
      steps = 15;
      dlg.Add("00:00");
      for (hour = 0; hour <= 23; hour++)
      {
        for (minute = 0; minute < 60; minute += steps)
        {
          if (hour == 0 && minute == 0)
          {
            continue;
          }
          string time;
          if (hour < 10)
          {
            time = "0" + hour;
          }
          else
          {
            time = hour.ToString();
          }
          time += ":";
          if (minute < 10)
          {
            time = time + "0" + minute;
          }
          else
          {
            time += minute.ToString();
          }

          //if (hour < 1) time = String.Format("{0} {1}", minute, GUILocalizeStrings.Get(3004));
          dlg.Add(time);
        }
      }
      // pre-select the current time
      dlg.SelectedLabel = (DateTime.Now.Hour * (60 / steps)) + (Convert.ToInt16(DateTime.Now.Minute / steps));
      dlg.DoModal(GetID);
      if (dlg.SelectedLabel == -1)
      {
        return;
      }

      int mins = (dlg.SelectedLabel) * steps;
      hour = (mins) / 60;
      minute = ((mins) % 60);


      dlg.Reset();
      dlg.SetHeading(180); //select time
      dlg.ShowQuickNumbers = false;
      //duration
      for (float hours = 0.5f; hours <= 24f; hours += 0.5f)
      {
        dlg.Add(String.Format("{0} {1}", hours.ToString("f2"), GUILocalizeStrings.Get(3002)));
      }
      dlg.DoModal(GetID);
      if (dlg.SelectedLabel == -1)
      {
        return;
      }
      int duration = (dlg.SelectedLabel + 1) * 30;


      dtNow = DateTime.Now.AddDays(day);
      rec.StartTime = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, hour, minute, 0, 0);
      rec.EndTime = rec.StartTime.AddMinutes(duration);
      rec.ProgramName = GUILocalizeStrings.Get(413) + " (" + rec.ReferencedChannel().DisplayName + ")";

      rec.Persist();
      TvServer server = new TvServer();
      server.OnNewSchedule();
      GUIWindowManager.ShowPreviousWindow();
    }
예제 #6
0
        private void TsCopier(object itemlist, Recording rec, Schedule newSchedule)
        {
            string[] bufferListObject;
              bufferListObject = new string[3];
              List<string[]> _itemlist = (List<string[]>)itemlist;
              bool foundHeader = false;
              bufferListObject = _itemlist[0];
              string targetTs = Path.GetDirectoryName(bufferListObject[2]) + "\\" + Path.GetFileNameWithoutExtension(bufferListObject[2]) + "_buffer.ts";

              try
              {
            Log.Info("TsCopier: targetTs {0}", targetTs);

            using (FileStream writer = new FileStream(targetTs, FileMode.CreateNew, FileAccess.Write))
            {
              for (int i = 0; i < _itemlist.Count; i++)
              {
            bufferListObject = _itemlist[i];

            try
            {
              if (File.Exists(bufferListObject[0]))
              {
                using (FileStream reader = new FileStream(bufferListObject[0], FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                  Log.Info("TsCopier: TSfilename {0}", bufferListObject[0]);
                  Log.Debug("TsCopier: TSfilename filesize {0}", bufferListObject[1]);

                  if (!foundHeader)
                  {
                    byte[] prebuf = new byte[1024 * 1024];
                    int bytesPreRead;
                    bytesPreRead = reader.Read(prebuf, 0, 1024 * 1024);
                    long position = 0;

                    // find TS packet header
                    while (bytesPreRead > 0 && !foundHeader)
                    {
                      for (int x = 0; x < 1024 * 1024 - 376; x++)
                      {
                        if (prebuf[x] == 0x47 && prebuf[x + 188] == 0x47 && prebuf[x + 376] == 0x47)
                        {
                          Log.Debug("TsCopier: TS packet header found at {0} pos in {1}.", x, bufferListObject[0]);
                          position = x;
                          foundHeader = true;
                          break;
                        }
                      }
                      bytesPreRead = reader.Read(prebuf, 0, 1024 * 1024);
                    }

                    reader.Position = position;

                    if (!foundHeader)
                    {
                      Log.Debug("TsCopier: TS packet header not found in {0}.", bufferListObject[0]);
                      break;
                    }
                  }

                  byte[] buf = new byte[1024 * 1024];
                  int bytesRead = reader.Read(buf, 0, 1024 * 1024);
                  while (bytesRead > 0)
                  {
                    if (reader.Position > Convert.ToInt64(bufferListObject[1]))
                      bytesRead -= (int)(reader.Position - Convert.ToInt64(bufferListObject[1]));

                    if (bytesRead <= 0)
                      break;

                    writer.Write(buf, 0, bytesRead);
                    bytesRead = reader.Read(buf, 0, 1024 * 1024);
                    Thread.Sleep(100);
                  }
                  reader.Close();
                }
              }
            }
            catch (Exception ex)
            {
              Log.Error("TsCopier exception: {0}", ex);
            }
              }
              writer.Flush();
              writer.Close();
              Log.Info("TsCopier: Done {0}", targetTs);
            }
              }
              catch (Exception ex)
              {
            Log.Error("TsCopier Exception: {0}", ex);
              }

              try
              {
            Log.Debug("TsCopier: Creating Recording entry for {0}", targetTs);

            RecordingDetail recDetail = new RecordingDetail(newSchedule, newSchedule.ReferencedChannel(), DateTime.Now, false);

            recDetail.Recording = new Recording(recDetail.Schedule.IdChannel, recDetail.Schedule.IdSchedule, false,
                                          rec.StartTime, DateTime.Now, rec.Title + " (from buffer)",
                                          recDetail.Program.Description, recDetail.Program.Genre, targetTs,
                                          recDetail.Schedule.KeepMethod,
                                          recDetail.Schedule.KeepDate, 0, rec.IdServer, recDetail.Program.EpisodeName,
                                          recDetail.Program.SeriesNum, recDetail.Program.EpisodeNum,
                                          recDetail.Program.EpisodePart);

            recDetail.Recording.Persist();

            IUser user = recDetail.User;

            TsBufferExtractor.Controller.Fire(this, new TvServerEventArgs(TvServerEventType.RecordingEnded, new VirtualCard(user), (User)user,
                                                 recDetail.Schedule, recDetail.Recording));

            MatroskaTagInfo info = new MatroskaTagInfo();
            info.title = rec.Title + " (from buffer)";
            info.description = recDetail.Program.Description;
            info.genre = recDetail.Program.Genre;

            info.channelName = recDetail.Schedule.ReferencedChannel().DisplayName;
            info.episodeName = recDetail.Program.EpisodeName;
            info.seriesNum = recDetail.Program.SeriesNum;
            info.episodeNum = recDetail.Program.EpisodeNum;
            info.episodePart = recDetail.Program.EpisodePart;
            info.startTime = rec.StartTime;
            info.endTime = DateTime.Now;

            MatroskaTagHandler.WriteTag(System.IO.Path.ChangeExtension(targetTs, ".xml"), info);
            Log.Info("TsCopier: Finished the job.");
              }
              catch (Exception ex)
              {
            Log.Error("TsCopier Exception: {0}", ex);
              }
        }
예제 #7
0
    private GUIListItem Schedule2ListItem(Schedule schedule)
    {
      GUIListItem item = new GUIListItem();
      if (schedule == null)
      {
        return item;
      }
      item.Label = schedule.ProgramName;

      item.TVTag = schedule;
      string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, schedule.ReferencedChannel().DisplayName);
      if (string.IsNullOrEmpty(strLogo))                    
      {
        strLogo = "defaultVideoBig.png";
      }
      item.PinImage = Thumbs.TvConflictRecordingIcon;
      item.ThumbnailImage = strLogo;
      item.IconImageBig = strLogo;
      item.IconImage = strLogo;
      return item;
    }
예제 #8
0
 /// <summary>
 /// checks if 2 schedules have a common Transponder
 /// depending on tuningdetails of their respective channels
 /// </summary>
 /// <param name="schedule"></param>
 /// <returns>True if a common transponder exists</returns>
 public bool isSameTransponder(Schedule schedule1, Schedule schedule2)
 {
   IList<TuningDetail> tuningDetailList1 = schedule1.ReferencedChannel().ReferringTuningDetail();
   IList<TuningDetail> tuningDetailList2 = schedule2.ReferencedChannel().ReferringTuningDetail();
   foreach (TuningDetail td1 in tuningDetailList1)
   {
     IChannel c1 = GetTuningChannel(td1);
     foreach (TuningDetail td2 in tuningDetailList2)
     {
       if (!c1.IsDifferentTransponder(GetTuningChannel(td2)))
       {
         return true;
       }
     }
   }
   return false;
 }
예제 #9
0
    public void SetProperties(Schedule schedule, Program prog)
    {
      GUIPropertyManager.SetProperty("#TV.Scheduled.Title", String.Empty);
      GUIPropertyManager.SetProperty("#TV.Scheduled.Genre", String.Empty);
      GUIPropertyManager.SetProperty("#TV.Scheduled.Time", String.Empty);
      GUIPropertyManager.SetProperty("#TV.Scheduled.Description", String.Empty);
      GUIPropertyManager.SetProperty("#TV.Scheduled.thumb", String.Empty);
      GUIPropertyManager.SetProperty("#TV.Scheduled.Channel", String.Empty);

      string strTime = String.Format("{0} {1} - {2}",
                                     Utils.GetShortDayString(schedule.StartTime),
                                     schedule.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                     schedule.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

      GUIPropertyManager.SetProperty("#TV.Scheduled.Title", prog.Title);
      GUIPropertyManager.SetProperty("#TV.Scheduled.Time", strTime);
      if (prog != null)
      {
        GUIPropertyManager.SetProperty("#TV.Scheduled.Channel", prog.ReferencedChannel().DisplayName);
        GUIPropertyManager.SetProperty("#TV.Scheduled.Description", prog.Description);
        GUIPropertyManager.SetProperty("#TV.Scheduled.Genre", prog.Genre);
      }
      else
      {
        GUIPropertyManager.SetProperty("#TV.Scheduled.Description", String.Empty);
        GUIPropertyManager.SetProperty("#TV.Scheduled.Genre", String.Empty);
      }


      string logo = Utils.GetCoverArt(Thumbs.TVChannel, schedule.ReferencedChannel().DisplayName);
      if (string.IsNullOrEmpty(logo))              
      {
        GUIPropertyManager.SetProperty("#TV.Scheduled.thumb", "defaultVideoBig.png");
      }
      else
      {
        GUIPropertyManager.SetProperty("#TV.Scheduled.thumb", logo);        
      }
    }
예제 #10
0
    private void UpdateDescription()
    {
      TvBusinessLayer layer = new TvBusinessLayer();
      Schedule rec = new Schedule(1, "", Schedule.MinSchedule, Schedule.MinSchedule);
      rec.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value);
      rec.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value);

      SetProperties(rec);
      GUIListItem pItem = GetItem(GetSelectedItemNo());
      if (pItem == null)
      {
        return;
      }
      rec = pItem.TVTag as Schedule;
      if (rec == null)
      {
        return;
      }
      Program prog = rec.ReferencedChannel().GetProgramAt(rec.StartTime.AddMinutes(1));
      SetProperties(rec, prog);
    }
예제 #11
0
    private void SetProperties(Schedule rec)
    {
      string strTime = String.Format("{0} {1} - {2}",
                                     Utils.GetShortDayString(rec.StartTime),
                                     rec.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                     rec.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

      GUIPropertyManager.SetProperty("#TV.RecordedTV.Title", rec.ProgramName);
      GUIPropertyManager.SetProperty("#TV.RecordedTV.Genre", "");
      GUIPropertyManager.SetProperty("#TV.RecordedTV.Time", strTime);
      GUIPropertyManager.SetProperty("#TV.RecordedTV.Description", "");
      string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, rec.ReferencedChannel().DisplayName);
      if (string.IsNullOrEmpty(strLogo))                    
      {
        GUIPropertyManager.SetProperty("#TV.RecordedTV.thumb", "defaultVideoBig.png");
      }
      else
      {
        GUIPropertyManager.SetProperty("#TV.RecordedTV.thumb", strLogo);
      }
    }
예제 #12
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);
      }
    }
예제 #13
0
 private RecordingDetail CreateNewRecordingDetail(Schedule schedule, DateTime currentTime)
 {
   RecordingDetail newRecording = null;
   DateTime start = new DateTime(currentTime.Year, currentTime.Month, currentTime.Day, schedule.StartTime.Hour,
                                 schedule.StartTime.Minute, schedule.StartTime.Second);
   DateTime end = new DateTime(currentTime.Year, currentTime.Month, currentTime.Day, schedule.EndTime.Hour,
                               schedule.EndTime.Minute, schedule.EndTime.Second);
   if (start > end)
     end = end.AddDays(1);
   if (currentTime >= start.AddMinutes(-schedule.PreRecordInterval) &&
       currentTime <= end.AddMinutes(schedule.PostRecordInterval))
   {
     if (!schedule.IsSerieIsCanceled(start))
     {
       VirtualCard vCard = null;
       bool isRecordingSchedule = IsRecordingSchedule(schedule.IdSchedule, out vCard);
       if (!isRecordingSchedule)
       {
         newRecording = new RecordingDetail(schedule, schedule.ReferencedChannel(), end, true);
       }
     }
   }
   return newRecording;
 }
예제 #14
0
 private RecordingDetail IsTimeToRecordOnce(Schedule schedule, DateTime currentTime, out bool isTimeToRecord)
 {
   isTimeToRecord = false;
   RecordingDetail newRecording = null;
   if (currentTime >= schedule.StartTime.AddMinutes(-schedule.PreRecordInterval) &&
       currentTime <= schedule.EndTime.AddMinutes(schedule.PostRecordInterval))
   {
     VirtualCard vCard = null;
     bool isRecordingSchedule = IsRecordingSchedule(schedule.IdSchedule, out vCard);
     if (!isRecordingSchedule)
     {
       newRecording = new RecordingDetail(schedule, schedule.ReferencedChannel(), schedule.EndTime, schedule.Series);
       isTimeToRecord = true;
     }
   }
   return newRecording;
 }
예제 #15
0
    private bool IsTimeToRecordEveryTimeOnThisChannel(Schedule schedule, DateTime currentTime)
    {
      bool isTimeToRecord = false;
      TvDatabase.Program current =
        schedule.ReferencedChannel().GetProgramAt(currentTime.AddMinutes(schedule.PreRecordInterval),
                                                  schedule.ProgramName);

      if (current != null)
      {
        if (currentTime >= current.StartTime.AddMinutes(-schedule.PreRecordInterval) &&
            currentTime <= current.EndTime.AddMinutes(schedule.PostRecordInterval))
        {
          if (!schedule.IsSerieIsCanceled(current.StartTime))
          {
            bool createSpawnedOnceSchedule = CreateSpawnedOnceSchedule(schedule, current);
            if (createSpawnedOnceSchedule)
            {
              ResetTimer(); //lets process the spawned once schedule at once.
            }
          }
        }
      }

      return isTimeToRecord;
    }