/// <summary> /// Kovertiert einen Protokolleintrag in ein für den Client nützliches Format. /// </summary> /// <param name="entry">Der originale Eintrag.</param> /// <returns>Der zugehörige Protokolleintrag.</returns> public static ProtocolEntry Create(VCRRecordingInfo entry) { // Single recording - typically a task var source = entry.Source; var sourceName = source.DisplayName; // Create var protocol = new ProtocolEntry { PrimaryFile = string.IsNullOrEmpty(entry.FileName) ? null : Path.GetFileName(entry.FileName), Files = entry.RecordingFiles.Select(file => file.Path).Where(File.Exists).ToArray(), Source = entry.Source.DisplayName, StartTime = entry.PhysicalStart, EndTime = entry.EndsAt, }; // Finish if (VCRJob.ProgramGuideName.Equals(sourceName)) { protocol.SizeHint = $"{entry.TotalSize:N0} Einträge"; } else if (VCRJob.SourceScanName.Equals(sourceName)) { protocol.SizeHint = $"{entry.TotalSize:N0} Quellen"; } else { protocol.SizeHint = PlanCurrent.GetSizeHint(entry.TotalSize); } // Report return(protocol); }
/// <summary> /// Erstellt eine neue Beschreibung aus dem Aufzeichnungsplan. /// </summary> /// <param name="plan">Die Planung der Aufzeichnung.</param> /// <param name="context">Die aktuelle Analyseumgebung.</param> /// <param name="server">Der zugehörige Dienst.</param> /// <returns>Die gewünschte Beschreibung.</returns> public static PlanCurrent Create(IScheduleInformation plan, PlanContext context, VCRServer server) { // Attach to the definition var definition = (IScheduleDefinition <VCRSchedule>)plan.Definition; var job = context.TryFindJob(definition.UniqueIdentifier); var schedule = (job == null) ? null : job[definition.UniqueIdentifier]; var source = (schedule == null) ? null : (schedule.Source ?? job.Source); // Create var planned = new PlanCurrent { Identifier = (schedule == null) ? null : ServerRuntime.GetUniqueWebId(job, schedule), ProfileName = plan.Resource.Name, Duration = plan.Time.Duration, StartTime = plan.Time.Start, IsLate = plan.StartsLate, SizeHint = string.Empty, Name = definition.Name, m_source = source, Files = _NoFiles, Index = -1, }; // Finish planned.Complete(server); // Report return(planned); }
/// <summary> /// Erstellt eine reduzierte Version der Information zu einer Aktivität. /// </summary> /// <param name="full">Die volle Information.</param> /// <returns>Die reduzierte Information.</returns> public static PlanCurrentMobile Create(PlanCurrent full) { // Cut down return (new PlanCurrentMobile { HasGuideEntry = full.HasGuideEntry, ProfileName = full.ProfileName, SourceName = full.SourceName, StartTime = full.StartTime, Duration = full.Duration, Source = full.Source, Name = full.Name, }); }
/// <summary> /// Erstellt eine Beschreibung zu einer einzelnen Aufzeichnung auf einem Gerät. /// </summary> /// <param name="active">Beschreibt die gesamte Aufzeichnung.</param> /// <param name="stream">Die zu verwendende Teilaufzeichnung.</param> /// <param name="streamIndex">Die laufende Nummer dieses Datenstroms.</param> /// <param name="server">Der zugehörige Dienst.</param> /// <returns>Die gewünschte Beschreibung.</returns> private static IEnumerable <PlanCurrent> Create(FullInfo active, StreamInfo stream, int streamIndex, VCRServer server) { // Static data var recording = active.Recording; var profileName = recording.Source.ProfileName; var sizeHint = GetSizeHint(recording.TotalSize) + " (Gerät)"; // Process all - beginning with VCR.NET 4.1 there is only one schedule per stream foreach (var scheduleInfo in stream.Schedules) { // Try to locate the context var job = string.IsNullOrEmpty(scheduleInfo.JobUniqueID) ? null : server.JobManager[new Guid(scheduleInfo.JobUniqueID)]; var schedule = ((job == null) || string.IsNullOrEmpty(scheduleInfo.ScheduleUniqueID)) ? null : job[new Guid(scheduleInfo.ScheduleUniqueID)]; // Create var start = RoundToSecond(scheduleInfo.StartsAt); var end = RoundToSecond(scheduleInfo.EndsAt); var current = new PlanCurrent { Identifier = (schedule == null) ? null : ServerRuntime.GetUniqueWebId(job, schedule), PlanIdentifier = scheduleInfo.ScheduleUniqueID, Files = scheduleInfo.Files ?? _NoFiles, StreamTarget = stream.StreamsTo, m_source = scheduleInfo.Source, ProfileName = profileName, Name = scheduleInfo.Name, Duration = end - start, Index = streamIndex, SizeHint = sizeHint, StartTime = start, }; // Finish current.Complete(server); // Report yield return(current); } }
/// <summary> /// Erstellt einen neuen Eintrag. /// </summary> /// <param name="schedule">Die zugehörige Beschreibung der geplanten Aktivität.</param> /// <param name="context">Die Abbildung auf die Aufträge.</param> /// <param name="profiles">Die Verwaltung der Geräteprofile.</param> /// <returns>Die angeforderte Repräsentation.</returns> public static PlanActivity Create(IScheduleInformation schedule, PlanContext context, ProfileStateCollection profiles) { // Request context information var definition = schedule.Definition; var runningInfo = context.GetRunState(definition.UniqueIdentifier); var isAllocation = definition is IResourceAllocationInformation; // Maybe it's an resource allocation if (isAllocation) { if (runningInfo != null) { definition = runningInfo.Schedule.Definition; } else { return(null); } } // Create initial entry var time = schedule.Time; var start = time.Start; var end = time.End; var activity = new PlanActivity { IsHidden = (schedule.Resource == null), IsLate = schedule.StartsLate, }; // May need some correction if (runningInfo != null) { if (end == runningInfo.Schedule.Time.End) { // Only report the allocation itself if (!isAllocation) { return(null); } // Reload the real start and times - just in case someone manipulated start = runningInfo.Schedule.Time.Start; end = runningInfo.RealTime.End; // Never report as late - actually since we have some spin up time most of the time the recording is late activity.IsLate = false; } } // Get the beautified range start = PlanCurrent.RoundToSecond(start); end = PlanCurrent.RoundToSecond(end); // Set times activity.Duration = end - start; activity.StartTime = start; // Set name if (definition != null) { activity.FullName = definition.Name; } // Set resource var resource = schedule.Resource; if (resource != null) { activity.Device = resource.Name; } // Schedule to process VCRSchedule vcrSchedule = null; VCRJob vcrJob = null; // Analyse definition var scheduleDefinition = definition as IScheduleDefinition <VCRSchedule>; if (scheduleDefinition != null) { // Regular plan vcrSchedule = scheduleDefinition.Context; vcrJob = context.TryFindJob(vcrSchedule); } // Process if we found one if (vcrSchedule != null) { // See if we have a job if (vcrJob != null) { activity.LegacyReference = ServerRuntime.GetUniqueWebId(vcrJob, vcrSchedule); } // Find the source to use - stream selection is always bound to the context of the source var streams = vcrSchedule.Streams; var source = vcrSchedule.Source; if (source == null) { if (vcrJob != null) { // Try job source = vcrJob.Source; // Adjust stream flags to use if (source == null) { streams = null; } else { streams = vcrJob.Streams; } } } // Copy station name if (source != null) { // Remember activity.Source = SourceIdentifier.ToString(source.Source).Replace(" ", ""); activity.Station = source.DisplayName; // Load the profile var profile = profiles[activity.GuideEntryDevice = source.ProfileName]; if (profile != null) { activity.HasGuideEntry = profile.ProgramGuide.HasEntry(source.Source, activity.StartTime, activity.StartTime + activity.Duration); } } // Apply special settings activity.CurrentProgramGuide = streams.GetUsesProgramGuide(); activity.AllLanguages = streams.GetUsesAllAudio(); activity.SubTitles = streams.GetUsesSubtitles(); activity.VideoText = streams.GetUsesVideotext(); activity.Dolby = streams.GetUsesDolbyAudio(); // Check for exception rule on the day var exception = vcrSchedule.FindException(time.End); if (exception != null) { activity.ExceptionRule = PlanException.Create(exception, vcrSchedule); } // May want to add end time checks if (!isAllocation) { if (!activity.IsLate) { if (!activity.IsHidden) { if ((exception == null) || exception.IsEmpty) { activity.EndTimeCouldBeWrong = activity.CheckEndTime(vcrSchedule.FirstStart); } } } } } else if (definition is ProgramGuideTask) { activity.Station = VCRJob.ProgramGuideName; } else if (definition is SourceListTask) { activity.Station = VCRJob.SourceScanName; } // Report return(activity); }
/// <summary> /// Erstellt eine neue Liste von Beschreibungen für eine aktive Aufzeichnung. /// </summary> /// <param name="active">Die Daten zur aktiven Aufzeichnung.</param> /// <param name="server">Der zugehörige Dienst.</param> /// <returns>Die gewünschten Beschreibungen.</returns> public static PlanCurrent[] Create(FullInfo active, VCRServer server) { // Validate if (active == null) { throw new ArgumentNullException(nameof(active)); } // Validate var recording = active.Recording; if (recording == null) { throw new ArgumentNullException("recording"); } // Multiple recordings var streams = active.Streams; if (streams != null) { if (streams.Count > 0) { return(streams.SelectMany((stream, index) => Create(active, stream, index, server)).ToArray()); } } // Single recording - typically a task var start = RoundToSecond(active.Recording.PhysicalStart.GetValueOrDefault(DateTime.UtcNow)); var end = RoundToSecond(recording.EndsAt); var source = recording.Source; var sourceName = source.DisplayName; // Create var current = new PlanCurrent { PlanIdentifier = recording.ScheduleUniqueID.Value.ToString("N"), ProfileName = source.ProfileName, Duration = end - start, Name = recording.Name, m_source = source, StartTime = start, Files = _NoFiles, IsLate = false, Index = -1, }; // Finish if (VCRJob.ProgramGuideName.Equals(sourceName)) { current.SizeHint = $"{recording.TotalSize:N0} Einträge"; } else if (VCRJob.SourceScanName.Equals(sourceName)) { current.SizeHint = $"{recording.TotalSize:N0} Quellen"; } else if (VCRJob.ZappingName.Equals(sourceName)) { current.SizeHint = GetSizeHint(recording.TotalSize); } else { current.Complete(server); } // Report return(new[] { current }); }
/// <summary> /// Erstellt eine reduzierte Version der Information zu einer Aktivität. /// </summary> /// <param name="full">Die volle Information.</param> /// <returns>Die reduzierte Information.</returns> public static PlanCurrentMobile Create( PlanCurrent full ) { // Cut down return new PlanCurrentMobile { HasGuideEntry = full.HasGuideEntry, ProfileName = full.ProfileName, SourceName = full.SourceName, StartTime = full.StartTime, Duration = full.Duration, Source = full.Source, Name = full.Name, }; }
/// <summary> /// Erstellt eine neue Beschreibung aus dem Aufzeichnungsplan. /// </summary> /// <param name="plan">Die Planung der Aufzeichnung.</param> /// <param name="context">Die aktuelle Analyseumgebung.</param> /// <param name="server">Der zugehörige Dienst.</param> /// <returns>Die gewünschte Beschreibung.</returns> public static PlanCurrent Create( IScheduleInformation plan, PlanContext context, VCRServer server ) { // Attach to the definition var definition = (IScheduleDefinition<VCRSchedule>) plan.Definition; var job = context.TryFindJob( definition.UniqueIdentifier ); var schedule = (job == null) ? null : job[definition.UniqueIdentifier]; var source = (schedule == null) ? null : (schedule.Source ?? job.Source); // Create var planned = new PlanCurrent { Identifier = (schedule == null) ? null : ServerRuntime.GetUniqueWebId( job, schedule ), ProfileName = plan.Resource.Name, Duration = plan.Time.Duration, StartTime = plan.Time.Start, IsLate = plan.StartsLate, SizeHint = string.Empty, Name = definition.Name, m_source = source, Files = _NoFiles, Index = -1, }; // Finish planned.Complete( server ); // Report return planned; }
/// <summary> /// Erstellt eine Beschreibung zu einer einzelnen Aufzeichnung auf einem Gerät. /// </summary> /// <param name="active">Beschreibt die gesamte Aufzeichnung.</param> /// <param name="stream">Die zu verwendende Teilaufzeichnung.</param> /// <param name="streamIndex">Die laufende Nummer dieses Datenstroms.</param> /// <param name="server">Der zugehörige Dienst.</param> /// <returns>Die gewünschte Beschreibung.</returns> private static IEnumerable<PlanCurrent> Create( FullInfo active, StreamInfo stream, int streamIndex, VCRServer server ) { // Static data var recording = active.Recording; var profileName = recording.Source.ProfileName; var sizeHint = GetSizeHint( recording.TotalSize ) + " (Gerät)"; // Process all - beginning with VCR.NET 4.1 there is only one schedule per stream foreach (var scheduleInfo in stream.Schedules) { // Try to locate the context var job = string.IsNullOrEmpty( scheduleInfo.JobUniqueID ) ? null : server.JobManager[new Guid( scheduleInfo.JobUniqueID )]; var schedule = ((job == null) || string.IsNullOrEmpty( scheduleInfo.ScheduleUniqueID )) ? null : job[new Guid( scheduleInfo.ScheduleUniqueID )]; // Create var start = RoundToSecond( scheduleInfo.StartsAt ); var end = RoundToSecond( scheduleInfo.EndsAt ); var current = new PlanCurrent { Identifier = (schedule == null) ? null : ServerRuntime.GetUniqueWebId( job, schedule ), PlanIdentifier = scheduleInfo.ScheduleUniqueID, Files = scheduleInfo.Files ?? _NoFiles, StreamTarget = stream.StreamsTo, m_source = scheduleInfo.Source, ProfileName = profileName, Name = scheduleInfo.Name, Duration = end - start, Index = streamIndex, SizeHint = sizeHint, StartTime = start, }; // Finish current.Complete( server ); // Report yield return current; } }
/// <summary> /// Erstellt eine neue Liste von Beschreibungen für eine aktive Aufzeichnung. /// </summary> /// <param name="active">Die Daten zur aktiven Aufzeichnung.</param> /// <param name="server">Der zugehörige Dienst.</param> /// <returns>Die gewünschten Beschreibungen.</returns> public static PlanCurrent[] Create( FullInfo active, VCRServer server ) { // Validate if (active == null) throw new ArgumentNullException( "active" ); // Validate var recording = active.Recording; if (recording == null) throw new ArgumentNullException( "recording" ); // Multiple recordings var streams = active.Streams; if (streams != null) if (streams.Count > 0) return streams.SelectMany( ( stream, index ) => Create( active, stream, index, server ) ).ToArray(); // Single recording - typically a task var start = RoundToSecond( active.Recording.PhysicalStart.GetValueOrDefault( DateTime.UtcNow ) ); var end = RoundToSecond( recording.EndsAt ); var source = recording.Source; var sourceName = source.DisplayName; // Create var current = new PlanCurrent { PlanIdentifier = recording.ScheduleUniqueID.Value.ToString( "N" ), ProfileName = source.ProfileName, Duration = end - start, Name = recording.Name, m_source = source, StartTime = start, Files = _NoFiles, IsLate = false, Index = -1, }; // Finish if (VCRJob.ProgramGuideName.Equals( sourceName )) current.SizeHint = $"{recording.TotalSize:N0} Einträge"; else if (VCRJob.SourceScanName.Equals( sourceName )) current.SizeHint = $"{recording.TotalSize:N0} Quellen"; else if (VCRJob.ZappingName.Equals( sourceName )) current.SizeHint = GetSizeHint( recording.TotalSize ); else current.Complete( server ); // Report return new[] { current }; }