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); TvDatabase.Schedule tvSchedule = TvDatabase.Schedule.Retrieve(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; } tvSchedule.Persist(); _tvControl.OnNewSchedule(); // I don't think this is needed, but doesn't hurt either 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 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); }
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)); }
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); }
public bool AddScheduleAdvanced(int idChannel, string programName, DateTime startTime, DateTime endTime, int scheduleType, int preRecordInterval, int postRecordInterval, string directory, int keepMethod) { if (!ConnectToDatabase()) return false; Schedule sched = new Schedule(idChannel, programName, startTime, endTime); // using negative numbers instead of null because non-primitive types (which a Nullable<int> is) and SOAP don't mix easily sched.PreRecordInterval = preRecordInterval < 0 ? Int32.Parse(GetSetting("preRecordInterval", "5").Value) : preRecordInterval; sched.PostRecordInterval = postRecordInterval < 0 ? Int32.Parse(GetSetting("postRecordInterval", "5").Value) : postRecordInterval; sched.ScheduleType = scheduleType; sched.Directory = directory; sched.KeepMethod = keepMethod; sched.Persist(); RemoteControl.Instance.OnNewSchedule(); return true; }
public bool AddSchedule(int channelId, String programName, DateTime startTime, DateTime endTime, int scheduleType, Int32 priority, Int32 keepmethod, DateTime keepdate, Int32 preRecordInterval, Int32 postRecordInterval) { try { TvBusinessLayer layer = new TvBusinessLayer(); TvDatabase.Schedule s = new TvDatabase.Schedule(channelId, programName, startTime, endTime); if (scheduleType < 0) { s.ScheduleType = (int)TvDatabase.ScheduleRecordingType.Once; } else { s.ScheduleType = scheduleType; } if (priority != -1) { s.Priority = priority; } if (keepmethod != -1) { s.KeepMethod = keepmethod; s.KeepDate = keepdate; } if ((preRecordInterval < 0) && (postRecordInterval < 0)) { //Use the settings from Mediaportal s.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value); s.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value); } else { // Use the settings from XBMC s.PreRecordInterval = preRecordInterval; s.PostRecordInterval = postRecordInterval; } s.Persist(); RemoteControl.Instance.OnNewSchedule(); return true; } catch { return false; } }
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))); }
public static void StartRecordingSchedule(Channel channel, bool manual) { TvBusinessLayer layer = new TvBusinessLayer(); TvServer server = new TvServer(); if (manual) // until manual stop { Schedule newSchedule = new Schedule(channel.IdChannel, GUILocalizeStrings.Get(413) + " (" + channel.DisplayName + ")", DateTime.Now, DateTime.Now.AddDays(1)); newSchedule.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value); newSchedule.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value); newSchedule.Persist(); server.OnNewSchedule(); } else // current program { // lets find any canceled episodes that match this one we want to create, if found uncancel it. Schedule existingParentSchedule = Schedule.RetrieveSeries(channel.IdChannel, channel.CurrentProgram.Title, channel.CurrentProgram.StartTime, channel.CurrentProgram.EndTime); if (existingParentSchedule != null) { foreach (CanceledSchedule cancelSched in existingParentSchedule.ReferringCanceledSchedule()) { if (cancelSched.CancelDateTime == channel.CurrentProgram.StartTime) { existingParentSchedule.UnCancelSerie(channel.CurrentProgram.StartTime, channel.CurrentProgram.IdChannel); server.OnNewSchedule(); return; } } } // ok, no existing schedule found with matching canceled schedules found. proceeding to add the schedule normally Schedule newSchedule = new Schedule(channel.IdChannel, channel.CurrentProgram.Title, channel.CurrentProgram.StartTime, channel.CurrentProgram.EndTime); newSchedule.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value); newSchedule.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value); newSchedule.Persist(); server.OnNewSchedule(); } GUIMessage msgManualRecord = new GUIMessage(GUIMessage.MessageType.GUI_MSG_MANUAL_RECORDING_STARTED, 0, 0, 0, 0, 0, null); GUIWindowManager.SendMessage(msgManualRecord); }
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(); }
public bool AddSchedule(int idChannel,string programName,DateTime startTime,DateTime endTime,int scheduleType) { if (!ConnectToDatabase()) return false; Schedule sched = new Schedule(idChannel, programName, startTime, endTime); sched.PreRecordInterval = Int32.Parse(GetSetting("preRecordInterval", "5").Value); sched.PostRecordInterval = Int32.Parse(GetSetting("postRecordInterval", "5").Value); sched.ScheduleType = scheduleType; sched.Persist(); RemoteControl.Instance.OnNewSchedule(); return true; }
public static void OnSetQuality(Schedule rec) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(882); dlg.ShowQuickNumbers = true; dlg.AddLocalizedString(968); dlg.AddLocalizedString(965); dlg.AddLocalizedString(966); dlg.AddLocalizedString(967); VIDEOENCODER_BITRATE_MODE _newBitRate = rec.BitRateMode; switch (_newBitRate) { case VIDEOENCODER_BITRATE_MODE.NotSet: dlg.SelectedLabel = 0; break; case VIDEOENCODER_BITRATE_MODE.ConstantBitRate: dlg.SelectedLabel = 1; break; case VIDEOENCODER_BITRATE_MODE.VariableBitRateAverage: dlg.SelectedLabel = 2; break; case VIDEOENCODER_BITRATE_MODE.VariableBitRatePeak: dlg.SelectedLabel = 3; break; } dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedLabel) { case 0: // Not Set _newBitRate = VIDEOENCODER_BITRATE_MODE.NotSet; break; case 1: // CBR _newBitRate = VIDEOENCODER_BITRATE_MODE.ConstantBitRate; break; case 2: // VBR _newBitRate = VIDEOENCODER_BITRATE_MODE.VariableBitRateAverage; break; case 3: // VBR Peak _newBitRate = VIDEOENCODER_BITRATE_MODE.VariableBitRatePeak; break; } rec.BitRateMode = _newBitRate; rec.Persist(); dlg.Reset(); dlg.SetHeading(882); dlg.ShowQuickNumbers = true; dlg.AddLocalizedString(968); dlg.AddLocalizedString(886); //Default dlg.AddLocalizedString(993); // Custom dlg.AddLocalizedString(893); //Portable dlg.AddLocalizedString(883); //Low dlg.AddLocalizedString(884); //Medium dlg.AddLocalizedString(885); //High QualityType _newQuality = rec.QualityType; switch (_newQuality) { case QualityType.NotSet: dlg.SelectedLabel = 0; break; case QualityType.Default: dlg.SelectedLabel = 1; break; case QualityType.Custom: dlg.SelectedLabel = 2; break; case QualityType.Portable: dlg.SelectedLabel = 3; break; case QualityType.Low: dlg.SelectedLabel = 4; break; case QualityType.Medium: dlg.SelectedLabel = 5; break; case QualityType.High: dlg.SelectedLabel = 6; break; } dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedLabel) { case 0: // Not Set _newQuality = QualityType.NotSet; break; case 1: // Default _newQuality = QualityType.Default; break; case 2: // Custom _newQuality = QualityType.Custom; break; case 3: // Protable _newQuality = QualityType.Portable; break; case 4: // Low _newQuality = QualityType.Low; break; case 5: // Medium _newQuality = QualityType.Medium; break; case 6: // High _newQuality = QualityType.High; break; } rec.QualityType = _newQuality; rec.Persist(); } TvServer server = new TvServer(); server.OnNewSchedule(); }
private void ChangeType(Schedule rec) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(GUILocalizeStrings.Get(616)); //616=Select Recording type //611=Record once //612=Record everytime on this channel //613=Record everytime on every channel //614=Record every week at this time //615=Record every day at this time 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))); dlg.Add(GUILocalizeStrings.Get(990000));// 990000=Weekly everytime on this channel switch ((ScheduleRecordingType)rec.ScheduleType) { case ScheduleRecordingType.Once: dlg.SelectedLabel = 0; break; case ScheduleRecordingType.EveryTimeOnThisChannel: dlg.SelectedLabel = 1; break; case ScheduleRecordingType.EveryTimeOnEveryChannel: dlg.SelectedLabel = 2; break; case ScheduleRecordingType.Weekly: dlg.SelectedLabel = 3; break; case ScheduleRecordingType.Daily: dlg.SelectedLabel = 4; break; case ScheduleRecordingType.WorkingDays: dlg.SelectedLabel = 5; break; case ScheduleRecordingType.Weekends: dlg.SelectedLabel = 6; break; case ScheduleRecordingType.WeeklyEveryTimeOnThisChannel: dlg.SelectedLabel = 7; break; } dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedLabel) { case 0: //once rec.ScheduleType = (int)ScheduleRecordingType.Once; rec.Canceled = Schedule.MinSchedule; break; case 1: //everytime, this channel rec.ScheduleType = (int)ScheduleRecordingType.EveryTimeOnThisChannel; rec.Canceled = Schedule.MinSchedule; break; case 2: //everytime, all channels rec.ScheduleType = (int)ScheduleRecordingType.EveryTimeOnEveryChannel; rec.Canceled = Schedule.MinSchedule; break; case 3: //weekly rec.ScheduleType = (int)ScheduleRecordingType.Weekly; rec.Canceled = Schedule.MinSchedule; break; case 4: //daily rec.ScheduleType = (int)ScheduleRecordingType.Daily; rec.Canceled = Schedule.MinSchedule; break; case 5: //WorkingDays rec.ScheduleType = (int)ScheduleRecordingType.WorkingDays; rec.Canceled = Schedule.MinSchedule; break; case 6: //Weekends rec.ScheduleType = (int)ScheduleRecordingType.Weekends; rec.Canceled = Schedule.MinSchedule; break; case 7://weekly everytime, this channel rec.ScheduleType = (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel; rec.Canceled = Schedule.MinSchedule; break; } rec.Persist(); TvServer server = new TvServer(); server.OnNewSchedule(); LoadDirectory(); } }
private bool CreateSpawnedOnceSchedule(Schedule schedule, TvDatabase.Program current) { bool isSpawnedOnceScheduleCreated = false; Schedule dbSchedule = Schedule.RetrieveOnce(current.IdChannel, current.Title, current.StartTime, current.EndTime); if (dbSchedule == null) // not created yet { Schedule once = Schedule.RetrieveOnce(current.IdChannel, current.Title, current.StartTime, current.EndTime); if (once == null) // make sure that we DO NOT create multiple once recordings. { Schedule newSchedule = new Schedule(schedule); newSchedule.IdChannel = current.IdChannel; newSchedule.StartTime = current.StartTime; newSchedule.EndTime = current.EndTime; newSchedule.ScheduleType = 0; // type Once newSchedule.Series = true; newSchedule.IdParentSchedule = schedule.IdSchedule; newSchedule.Persist(); isSpawnedOnceScheduleCreated = true; // 'once typed' created schedule will be used instead at next call of IsTimeToRecord() } } return isSpawnedOnceScheduleCreated; }
private void InitiateBufferFilesCopyProcess(Recording rec) { if (_tsBufferExtractorSetup == "A" && _snapshotBufferPosition == -2) { Log.Info("TsBufferExtractor: there is no program information, skip the ts buffer copy."); return; } string recordingFilename = rec.FileName; IUser u = _tvEvent.Card.User; long bufferId = 0; Int64 currentPosition = -1; var layer = new TvBusinessLayer(); Int64 maximumFileSize = Int64.Parse(layer.GetSetting("timeshiftMaxFileSize", "30").Value) * 1000 * 1000; int maxFiles = Convert.ToInt16(layer.GetSetting("timeshiftMaxFiles", "30").Value); List<string[]> itemlist = new List<string[]>(); if (RemoteControl.Instance.TimeShiftGetCurrentFilePosition(ref u, ref currentPosition, ref bufferId)) { string currentFile = RemoteControl.Instance.TimeShiftFileName(ref u) + bufferId.ToString() + ".ts"; if (_snapshotBufferPosition == -2) { _snapshotBufferId = bufferId + 1; Log.Debug("TsBufferExtractor: snapshotBufferPosition was overwritten, the new _snapshotBufferId {0}", _snapshotBufferId); } Log.Info("TsBufferExtractor: current TS Position {0}, TS bufferId {1}, snapshotBufferId {2}, recording file {3}", currentPosition, bufferId, _snapshotBufferId, recordingFilename); if (_snapshotBufferId < bufferId) { Log.Debug("TsBufferExtractor: snapshotBufferId {0}, bufferId {1}", _snapshotBufferId, bufferId); string nextFile; for (long i = _snapshotBufferId; i < bufferId; i++) { nextFile = RemoteControl.Instance.TimeShiftFileName(ref u) + i + ".ts"; Log.Debug("TsBufferExtractor: nextFile {0}", nextFile); itemlist.Add(new[] { nextFile, string.Format("{0}", maximumFileSize), recordingFilename }); } } else if (_snapshotBufferId > bufferId) { { string nextFile; for (long i = _snapshotBufferId; i <= maxFiles; i++) { nextFile = RemoteControl.Instance.TimeShiftFileName(ref u) + i + ".ts"; Log.Debug("TsBufferExtractor: nextFile {0}", nextFile); itemlist.Add(new[] { nextFile, string.Format("{0}", maximumFileSize), recordingFilename }); } if (1 < _bufferId) { for (long i = 1; i < _bufferId; i++) { nextFile = RemoteControl.Instance.TimeShiftFileName(ref u) + i + ".ts"; Log.Debug("TsBufferExtractor: nextFile {0}", nextFile); itemlist.Add(new[] { nextFile, string.Format("{0}", maximumFileSize), recordingFilename }); } } } } itemlist.Add(new[] { currentFile, string.Format("{0}", currentPosition), recordingFilename }); Log.Debug("TsBufferExtractor: currentFile {0}", currentFile); try { Schedule newSchedule = new Schedule(rec.IdChannel, rec.Title, rec.StartTime, DateTime.Now); newSchedule.PreRecordInterval = 0; newSchedule.PostRecordInterval = 0; newSchedule.Persist(); Copyer Copy = new Copyer(); Copy.CopyTimeShiftFile(itemlist, rec, newSchedule); } catch (Exception ex) { Log.Error("TsBufferExtractor.CopyTimeShiftFile exception : {0}", ex); } } _snapshotBufferPosition = -1; _snapshotBufferFile = string.Empty; _snapshotBufferId = 0; }
private static bool AssignSchedulesToCard(Schedule schedule, List<Schedule>[] cardSchedules, out List<Schedule> overlappingSchedules) { overlappingSchedules = new List<Schedule>(); Log.Info("AssignSchedulesToCard: schedule = " + schedule); IList<Card> cards = Card.ListAll(); bool assigned = false; int count = 0; foreach (Card card in cards) { if (card.Enabled && card.canViewTvChannel(schedule.IdChannel)) { // checks if any schedule assigned to this cards overlaps current parsed schedule bool free = true; foreach (Schedule assignedSchedule in cardSchedules[count]) { Log.Info("AssignSchedulesToCard: card {0}, ID = {1} has schedule = " + assignedSchedule, count, card.IdCard); if (schedule.IsOverlapping(assignedSchedule)) { if (!(schedule.isSameTransponder(assignedSchedule) && card.supportSubChannels)) { overlappingSchedules.Add(assignedSchedule); Log.Info("AssignSchedulesToCard: overlapping with " + assignedSchedule + " on card {0}, ID = {1}", count, card.IdCard); free = false; break; } } } if (free) { Log.Info("AssignSchedulesToCard: free on card {0}, ID = {1}", count, card.IdCard); cardSchedules[count].Add(schedule); int recommendedCard = schedule.RecommendedCard; if (recommendedCard != card.IdCard) { schedule.RecommendedCard = card.IdCard; //Only update, do not insert if (schedule.IsPersisted) { schedule.Persist(); } } assigned = true; break; } } count++; } if (!assigned) { return false; } return true; }
public void RecordProgram(int id, int scheduleType) { UpdateTvServer(); Program program = Program.Retrieve(id); bool isSeries; Schedule schedule; if (IsRecording(program, out schedule, out isSeries) == false) { TvBusinessLayer layer = new TvBusinessLayer(); int preInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value); int postInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value); Schedule rec = new Schedule(program.IdChannel, program.Title, program.StartTime, program.EndTime); rec.ScheduleType = (int)scheduleType; rec.PreRecordInterval = preInterval; rec.PostRecordInterval = postInterval; rec.Persist(); RemoteControl.Instance.OnNewSchedule(); } }