/// <summary> /// Erstellt einen neuen Zustand. /// </summary> /// <param name="target">Das aktuelle Ziel des Datenversands.</param> /// <param name="server">Die zugehörigen Informationen des Aufzeichnungsprozesses.</param> /// <returns>Der gwünschte Zustand.</returns> public static ZappingStatus Create( string target, ServerInformation server ) { // Create new var status = new ZappingStatus { Target = target, Services = s_NoServices }; // No state if (server == null) return status; // Attach to the first stream var streams = server.Streams; if (streams != null) if (streams.Count > 0) status.Source = SourceIdentifier.ToString( streams[0].Source ).Replace( " ", "" ); // Fill in NVOD services in the standard index order var services = server.Services; if (services != null) status.Services = services .Where( service => service != null ) .Select( ZappingService.Create ) .OrderBy( service => service.Index ) .ToArray(); // Report return status; }
/// <summary> /// Ergänzt die Beschreibung der aktuellen Aufzeichnungen. /// </summary> /// <param name="info">Die Beschreibung der Gesamtaufgabe des aktuellen Aufzeichnungsprozesses.</param> /// <param name="finalCall">Gesetzt, wenn es sich um den abschließenden Aufruf handelt. Dieser /// wird ausschließlich für die Erstellung des Protokolleintrags verwendet.</param> /// <param name="state">Der aktuelle Zustand.</param> protected override void OnFillInformation( FullInfo info, bool finalCall, ServerInformation state ) { // Set static data info.IsDynamic = true; info.CanStream = true; // Synchronize access lock (m_recordings) { // Load all files we've seen so far info.Recording.RecordingFiles.Clear(); info.Recording.RecordingFiles.AddRange( m_files ); // Create the file mapping var files = m_files .Where( file => !string.IsNullOrEmpty( file.ScheduleIdentifier ) ) .GroupBy( file => new Guid( file.ScheduleIdentifier ), file => file.Path ) .ToDictionary( group => group.Key, group => group.ToArray() ); // Process all recordings info .Streams .AddRange( (finalCall ? m_allRecordings : m_recordings) .Select( recording => { // Collect the data var streamInfo = (state == null) ? null : state.Streams.Find( recording.Match ); var target = (streamInfo == null) ? null : streamInfo.StreamTarget; // Create record return StreamInfo.Create( recording, target, files ); } ) ); } }
/// <summary> /// Bearbeitet neue Daten vom Aufzeichnungsprozess. Dieser Aufruf erfolgt immer, /// wenn neue Informationen vorliegen und zusätzlich einmal unmittelbar nach /// dem Beenden durch <see cref="OnStop"/>. /// </summary> /// <param name="state">Die neuen Daten.</param> protected override void OnNewStateAvailable( ServerInformation state ) { // Scan results var newFiles = new List<FileInformation>(); var totalSize = default( long ); // Process all files lock (m_recordings) { // Collect files foreach (var stream in state.Streams ?? Enumerable.Empty<StreamInformation>()) foreach (var file in stream.AllFiles ?? Enumerable.Empty<FileStreamInformation>()) { // If we do not know this file remember for extension processing var info = FileInformation.Create( file, stream.UniqueIdentifier ); if (m_files.Add( info )) newFiles.Add( info ); } // Count up the total sum if (m_files.Count > 0) totalSize = m_files.Sum( file => file.FileSize.GetValueOrDefault( 0 ) ); } // Total file size Representative.TotalSize = (uint) (totalSize / 1024); // No new files if (newFiles.Count < 1) return; // Report Tools.ExtendedLogging( "Found {0} new Recording File(s) on {1}", newFiles.Count, ProfileName ); // Time to clone the environment var environment = new Dictionary<string, string>( ExtensionEnvironment ); // Fill environment AddFilesToEnvironment( environment, "Planned", newFiles ); // Fire up extensions FireRecordingStartedExtensions( environment ); }
/// <summary> /// Wird aufgerufen, sobald eine neuer Zustand verfügbar ist. /// </summary> /// <param name="state">Der neue Zustand.</param> protected override void OnNewStateAvailable( ServerInformation state ) { // See if we are finished if (state.UpdateProgress.GetValueOrDefault( 0 ) >= 1) ChangeEndTime( Representative.ScheduleUniqueID.Value, DateTime.UtcNow.AddDays( -365 ), false ); }
/// <summary> /// Ergänzt den aktuellen Zustand des Suchlaufs. /// </summary> /// <param name="info">Die bereits vorbereitete Informationsstruktur.</param> /// <param name="finalCall">Gesetzt, wenn dieser Zustand als Protokoll verwendet wird.</param> /// <param name="state">Der zuletzt erhaltene Zustand.</param> protected override void OnFillInformation( FullInfo info, bool finalCall, ServerInformation state ) { // Copy current result if (state == null) info.Recording.TotalSize = 0; else if (!state.UpdateProgress.HasValue) info.Recording.TotalSize = 0; else info.Recording.TotalSize = (uint) state.UpdateSourceCount; }
/// <summary> /// Ermittelt eine Beschreibung der aktuellen Aufzeichnung. /// </summary> /// <param name="info">Vorabinformation der Basisklasse.</param> /// <param name="finalCall">Gesetzt, wenn das Ergebnis zum Protokolleintrag wird.</param> /// <param name="state">Die zuletzt erhaltenen Zustandsinformationen.</param> protected override void OnFillInformation( FullInfo info, bool finalCall, ServerInformation state ) { // Just copy the progress if (state == null) info.Recording.TotalSize = 0; else if (!state.ProgramGuideProgress.HasValue) info.Recording.TotalSize = 0; else info.Recording.TotalSize = (uint) state.CurrentProgramGuideItems; }