/// <summary> /// Erstellt eine exakte Kopie dieser Aufzeichnungsinformation. /// </summary> /// <returns>Die exakte Kopie.</returns> public VCRRecordingInfo Clone() { // Create clone var clone = new VCRRecordingInfo { Source = (Source == null) ? null : new SourceSelection { DisplayName = Source.DisplayName, SelectionKey = Source.SelectionKey }, Streams = (Streams == null) ? null : Streams.Clone(), DisableHibernation = DisableHibernation, ScheduleUniqueID = ScheduleUniqueID, m_physicalStart = m_physicalStart, JobUniqueID = JobUniqueID, StartsLate = StartsLate, TotalSize = TotalSize, StartsAt = StartsAt, FileName = FileName, IsHidden = IsHidden, m_endsAt = m_endsAt, Name = Name, }; // File data clone.RecordingFiles.AddRange(RecordingFiles.Select(info => new FileInformation { Path = info.Path, VideoType = info.VideoType, ScheduleIdentifier = info.ScheduleIdentifier })); // Report return(clone); }
/// <summary> /// Erstellt einen neuen Eintrag. /// </summary> /// <param name="planItem">Die zugehörige Beschreibung der geplanten Aktivität.</param> /// <param name="context">Die Abbildung auf die Aufträge.</param> /// <returns>Die angeforderte Repräsentation.</returns> public static VCRRecordingInfo Create(IScheduleInformation planItem, PlanContext context) { // Validate if (planItem == null) { throw new ArgumentNullException(nameof(planItem)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } // Check type var definition = planItem.Definition as IScheduleDefinition <VCRSchedule>; if (definition == null) { // Check for program guide collector var guideCollection = planItem.Definition as ProgramGuideTask; if (guideCollection != null) { return new VCRRecordingInfo { Source = new SourceSelection { ProfileName = planItem.Resource.Name, DisplayName = VCRJob.ProgramGuideName }, FileName = Path.Combine(guideCollection.CollectorDirectory.FullName, Guid.NewGuid().ToString("N") + ".epg"), ScheduleUniqueID = guideCollection.UniqueIdentifier, IsHidden = planItem.Resource == null, StartsLate = planItem.StartsLate, StartsAt = planItem.Time.Start, Name = guideCollection.Name, EndsAt = planItem.Time.End, } } ; // Check for source list update var sourceUpdater = planItem.Definition as SourceListTask; if (sourceUpdater != null) { return new VCRRecordingInfo { Source = new SourceSelection { ProfileName = planItem.Resource.Name, DisplayName = VCRJob.SourceScanName }, FileName = Path.Combine(sourceUpdater.CollectorDirectory.FullName, Guid.NewGuid().ToString("N") + ".psi"), ScheduleUniqueID = sourceUpdater.UniqueIdentifier, IsHidden = planItem.Resource == null, StartsLate = planItem.StartsLate, StartsAt = planItem.Time.Start, EndsAt = planItem.Time.End, Name = sourceUpdater.Name, } } ; // None return(null); } // Attach to the schedule and its job - using the context and the map is the easiest way although there may be better alternatives var job = context.TryFindJob(definition.UniqueIdentifier); var schedule = definition.Context; // Find the source var source = schedule.Source ?? job.Source; if (source != null) { // Create a clone source = new SourceSelection { DisplayName = source.DisplayName, SelectionKey = source.SelectionKey }; // Update the name of the profile var resource = planItem.Resource; if (resource != null) { source.ProfileName = resource.Name; } } // Create the description of this recording var recording = new VCRRecordingInfo { Streams = (schedule.Source == null) ? job.Streams : schedule.Streams, ScheduleUniqueID = schedule.UniqueID, IsHidden = planItem.Resource == null, StartsLate = planItem.StartsLate, StartsAt = planItem.Time.Start, EndsAt = planItem.Time.End, JobUniqueID = job.UniqueID, RelatedSchedule = schedule, FileName = job.Directory, Name = definition.Name, RelatedJob = job, Source = source, }; // May want to adjust start time if job is active var runningInfo = context.GetRunState(definition.UniqueIdentifier); if (runningInfo != null) { if (runningInfo.Schedule.Time.End == recording.EndsAt) { // Assume we never start late - we are running recording.StartsLate = false; // If we started prior to this plan report the time we really started if (planItem.Time.Start > runningInfo.Schedule.Time.Start) { recording.StartsAt = runningInfo.Schedule.Time.Start; } } } // Finish recording.LoadDefaults(); // Report return(recording); }