Ejemplo n.º 1
0
        /// <summary>
        /// Speichert diesen Auftrag ab.
        /// </summary>
        /// <param name="target">Der Pfad zu einem Zielverzeichnis.</param>
        /// <returns>Gesetzt, wenn der Speichervorgang erfolgreich war. <i>null</i> wird
        /// gemeldet, wenn diesem Auftrag keine Datei zugeordnet ist.</returns>
        public bool?Save(DirectoryInfo target)
        {
            // Get the file
            var file = GetFileName(target);

            if (file == null)
            {
                return(null);
            }

            // Be safe
            try
            {
                // Process
                SerializationTools.Save(this, file);
            }
            catch (Exception e)
            {
                // Report
                VCRServer.Log(e);

                // Done
                return(false);
            }

            // Done
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Erzeugt eine neue Laufzeitumgebung und bindet diese an einen lokalen
        /// TCP/IP Port.
        /// </summary>
        /// <remarks>
        /// Als virtuelles Verzeichnis wird <i>/VCR.NET</i> verwendet. Dieses wird
        /// physikalisch an das Verzeichnis gebunden, dass der aktuellen Anwendung
        /// übergeordnet ist. Es empfiehlt sich, die Anwendung in einem Unterverzeichnis
        /// <i>bin</i> unterzubringen.
        /// </remarks>
        /// <exception cref="InvalidOperationException">Es wurde bereits eine Laufzeitumgebung
        /// angelegt.</exception>
        public void Start()
        {
            // Report
            Tools.ExtendedLogging("Starting Web Server");

            // Already running
            if (m_endPoints.Count > 0)
            {
                return;
            }

            // Create
            m_endPoints.Add(new PrimaryEndPoint(m_server));

            // Check the application directory
            var appDir = new DirectoryInfo(Path.Combine(Tools.ApplicationDirectory.Parent.FullName, ApplicationRoot));

            if (appDir.Exists)
            {
                foreach (var app in appDir.GetDirectories())
                {
                    m_endPoints.Add(new ExtensionEndPoint(app.Name, Path.Combine(ApplicationRoot, app.Name)));
                }
            }

            // Report
            Tools.ExtendedLogging("Listener is up and running");

            // Report
            VCRServer.Log(LoggingLevel.Full, Properties.Resources.WebServerStarted);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Aktualisiert die Programmzeitschrift mit neuen Daten.
        /// </summary>
        /// <param name="entries">Die neuen Daten.</param>
        internal void UpdateGuide(ProgramGuideEntries entries)
        {
            // Report
            Tools.ExtendedLogging("Program Guide of {0} will be updated", ProfileName);

            // Did collection
            LastUpdateTime = DateTime.UtcNow;

            // Try to load resulting file
            try
            {
                // Create brand new
                var newData = m_Events.Clone();

                // Merge new
                newData.Merge(entries);

                // Cleanup
                newData.DiscardOld();

                // Save
                SerializationTools.Save(newData, ProgramGuideFile, Encoding.UTF8);

                // Use it
                m_Events = newData;

                // Report
                Tools.ExtendedLogging("Now using new Program Guide");
            }
            catch (Exception e)
            {
                // Report
                VCRServer.Log(LoggingLevel.Errors, Properties.Resources.EPGMergeFailed, e);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Löschte diesen Auftrag.
        /// </summary>
        /// <param name="target">Der Pfad zu einem Zielverzeichnis.</param>
        /// <returns>Gesetzt, wenn der Löschvorgang erfolgreich war. <i>null</i> wird gemeldet,
        /// wenn die Datei nicht existierte.</returns>
        public bool?Delete(DirectoryInfo target)
        {
            // Get the file
            var file = GetFileName(target);

            if (file == null)
            {
                return(null);
            }
            if (!file.Exists)
            {
                return(null);
            }

            // Be safe
            try
            {
                // Process
                file.Delete();
            }
            catch (Exception e)
            {
                // Report error
                VCRServer.Log(e);

                // Failed
                return(false);
            }

            // Did it
            return(true);
        }
Ejemplo n.º 5
0
            /// <summary>
            /// Erstellt eine Verwaltung der Anwendung.
            /// </summary>
            /// <param name="server">Der Dienst selbst.</param>
            public PrimaryEndPoint(VCRServer server)
                : base("VCR.NET", string.Empty)
            {
                m_server = server;

                Start();
            }
Ejemplo n.º 6
0
        /// <summary>
        /// Verbindet die ASP.NET Laufzeitumgebung des aktuellen virtuellen Verzeichnisses
        /// mit der aktiven VCR.NET Instanz.
        /// </summary>
        /// <param name="server">Die aktive VCR.NET Instanz.</param>
        public void SetServer(VCRServer server)
        {
            // Activate configuration from main domain
            VCRConfiguration.Register(server.Configuration);

            // Add to permanent cache
            _VCRServer = server;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Beendet die ASP.NET Laufzeitumgebung.
        /// </summary>
        /// <remarks>
        /// Der Aufruf kehrt erst wieder zurück, wenn alle ausstehenden Anfragen bearbeitet
        /// wurden. Neue Anfragen werden nicht angenommen.
        /// </remarks>
        public override void Stop()
        {
            // Reset
            _VCRServer = null;

            // Forward
            base.Stop();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Erzeugt eine neue Verwaltungsinstanz.
        /// </summary>
        /// <param name="jobs">Die zugehörige Auftragsverwaltung.</param>
        /// <param name="profileName">Der Name des verwalteten DVB.NET Geräteprofils.</param>
        public ProgramGuideManager(JobManager jobs, string profileName)
        {
            // Remember
            ProfileName = profileName;
            JobManager  = jobs;

            // Calculate file
            ProgramGuideFile = new FileInfo(Path.Combine(JobManager.CollectorDirectory.FullName, $"EPGData for {ProfileName}.xml"));

            // See if profile has it's own program guide
            if (!HasProgramGuide)
            {
                return;
            }

            // Report
            Tools.ExtendedLogging("Looking for Program Guide of {0}", ProfileName);

            // No such file - start empty
            if (!ProgramGuideFile.Exists)
            {
                return;
            }

            // Process
            var events = SerializationTools.Load <ProgramGuideEntries>(ProgramGuideFile);

            if (events != null)
            {
                // Use it
                m_Events = events;

                // Report
                Tools.ExtendedLogging("Found valid Program Guide and using it");

                // Done
                return;
            }

            // Report
            VCRServer.Log(LoggingLevel.Errors, Properties.Resources.EPGFileCorrupted, ProgramGuideFile.FullName);

            // Save delete
            try
            {
                // Process
                ProgramGuideFile.Delete();
            }
            catch
            {
                // Discard any error
                VCRServer.Log(LoggingLevel.Errors, Properties.Resources.EPGDeleteDenied, ProgramGuideFile.FullName);
            }
        }
Ejemplo n.º 9
0
        static void Main_PSIRun(string[] args)
        {
            // Create the server
            using (VCRServer server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs")))
            {
                // Attach to the profile state of interest
                ProfileState nova  = server.FindProfile("DVB-S2");
                ProfileState nexus = server.FindProfile("Nexus");

                // Report
                Console.WriteLine("{0} {1}", nova.ProfileName, nova.NextSourceUpdateTime);
                Console.WriteLine("{0} {1}", nexus.ProfileName, nexus.NextSourceUpdateTime);
            }
        }
Ejemplo n.º 10
0
        static void Main6(string[] args)
        {
            // Attach to job manager
            VCRServer  server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs"));
            JobManager jobs   = server.JobManager;

            // Create EPG collection
            using (ZappingRequest request = ZappingRequest.CreateDefault("Nexus Scan", jobs))
                if (null != request)
                {
                    // Get the information
                    FullInfo info0 = request.CreateFullInformation();

                    // Report
                    Console.WriteLine(info0.Recording.JobType);

                    // Start it
                    request.BeginExecute(false);

                    // Go to ZDF
                    LiveModeStatus stat1 = request.SetSource(VCRProfiles.FindSource("Nexus Scan", "ZDF [ZDFvision]"), "localhost:5555");

                    // Report
                    Console.WriteLine("ZDF on");
                    Console.ReadLine();

                    // Get status
                    LiveModeStatus stat2 = request.CreateStatus();

                    // Go to PREMIERE
                    LiveModeStatus stat3 = request.SetSource(VCRProfiles.FindSource("Nexus Scan", "PREMIERE DIREKT [PREMIERE]"), "localhost:5555");

                    // Report
                    Console.WriteLine("PREMIERE on");
                    Console.ReadLine();

                    // Get status
                    LiveModeStatus stat4 = request.CreateStatus();

                    // Stop it
                    request.Stop();

                    // Get the information
                    FullInfo info1 = request.CreateFullInformation();
                }

            // Done
            Console.WriteLine("Done");
            Console.ReadLine();
        }
Ejemplo n.º 11
0
        static void Main7(string[] args)
        {
            // Attach to job manager
            VCRServer  server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs"));
            JobManager jobs   = server.JobManager;

            ProgramGuideEntries entries = new ProgramGuideEntries();

            entries.Add(new ProgramGuideEntry {
                Name = "Te\x0005st"
            });
            SerializationTools.Save(entries, @"c:\temp\test.xml");
            ProgramGuideEntries reload = SerializationTools.Load <ProgramGuideEntries>(new FileInfo(@"c:\temp\test.xml"));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Beendet die Anwendung endgültig.
        /// </summary>
        public void Dispose()
        {
            // Forward
            var listener = Interlocked.Exchange(ref m_listener, null);

            if (listener != null)
            {
                if (listener.IsListening)
                {
                    try
                    {
                        // Process
                        listener.Stop();
                    }
                    catch (Exception)
                    {
                        // Report to event log
                        VCRServer.Log(LoggingLevel.Errors, EventLogEntryType.Warning, Properties.Resources.WebServerStopFailedChannel);
                    }
                }
            }

            // Wait for all outstanding requests to terminate
            while (Thread.VolatileRead(ref m_Threads) > 0)
            {
                Thread.Sleep(100);
            }

            // See if worker is up
            var runtime = Interlocked.Exchange(ref m_runtime, null);

            if (runtime != null)
            {
                try
                {
                    // Save call - may be already dead
                    runtime.Stop();

                    // Terminate the domain
                    AppDomain.Unload(runtime.AppDomain);
                }
                catch (Exception)
                {
                    // Report to event log
                    VCRServer.Log(LoggingLevel.Errors, EventLogEntryType.Warning, Properties.Resources.WebServerStopFailed);
                }
            }
        }
        /// <summary>
        /// Erstellt eine neue Aktualisierung.
        /// </summary>
        /// <param name="state">Das zugehörige Geräteprofil.</param>
        /// <param name="recording">Daten der primären Aufzeichnung.</param>
        private ProgramGuideProxy(ProfileState state, VCRRecordingInfo recording)
            : base(state, recording)
        {
            // Reset fields
            if (VCRConfiguration.Current.EnableFreeSat)
            {
                m_extensions = EPGExtensions.FreeSatUK;
            }
            else
            {
                m_extensions = EPGExtensions.None;
            }

            // All sources we know about
            var allSources = new Dictionary <string, SourceSelection>(StringComparer.InvariantCultureIgnoreCase);

            // Load all sources of this profile
            foreach (var source in VCRProfiles.GetSources(ProfileName))
            {
                // Remember by direct name
                allSources[source.DisplayName] = source;

                // allSources by unique name
                allSources[source.QualifiedName] = source;
            }

            // Fill in all
            foreach (var legacyName in VCRConfiguration.Current.ProgramGuideSources)
            {
                // Skip if empty
                if (string.IsNullOrEmpty(legacyName))
                {
                    continue;
                }

                // Locate
                SourceSelection realSource;
                if (allSources.TryGetValue(legacyName, out realSource))
                {
                    m_selected.Add(realSource.Source);
                }
                else
                {
                    VCRServer.Log(LoggingLevel.Full, Properties.Resources.BadEPGStation, legacyName);
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Beendet den Suchlauf endgültig.
        /// </summary>
        protected override void OnStop()
        {
            // Remember the time of the last scan
            ProfileState.LastSourceUpdateTime = DateTime.UtcNow;

            // Log
            VCRServer.Log(LoggingLevel.Full, Properties.Resources.PSIReplace);

            // Finish
            ServerImplementation.EndRequest(Server.BeginEndScan(m_mergeSources));

            // Report
            Tools.ExtendedLogging("Card Server has updated Profile {0} - VCR.NET will reload all Profiles now", ProfileName);

            // Time to refresh our lists
            VCRProfiles.Reset();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Beendet die Nutzung dieser Instantz.
        /// </summary>
        /// <param name="explicitDisposing">Wird ignoriert.</param>
        protected override void Dispose(bool explicitDisposing)
        {
            // Self
            try
            {
                // Forward
                AbortWaiter();
            }
            catch (Exception e)
            {
                // Report
                VCRServer.Log(e);
            }

            // Forward
            base.Dispose(explicitDisposing);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Rekonstruiert einen Auftrag und eine Aufzeichnung aus einer Textdarstellung.
        /// </summary>
        /// <param name="id">Die Textdarstellung.</param>
        /// <param name="job">Der ermittelte Auftrag.</param>
        /// <returns>Die zugehörige Aufzeichnung im Auftrag.</returns>
        public static VCRSchedule ParseUniqueWebId(string id, out VCRJob job)
        {
            ParseUniqueWebId(id, out Guid jobID, out Guid scheduleID);

            // Find the job
            job = VCRServer.FindJob(jobID);

            // Report schedule if job exists
            if (job == null)
            {
                return(null);
            }
            else
            {
                return(job[scheduleID]);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Beendet einen asynchronen Aufruf. Im Fall einer Ausnahme wird diese nur protokolliert
        /// und der Aufruf als abgeschlossen angenommen.
        /// </summary>
        /// <typeparam name="TAsync">Die Art des Aufrufs.</typeparam>
        /// <param name="request">Der aktive Aufruf.</param>
        /// <param name="traceFormat">Meldung bei Abschluss des Aufrufs. Ist dieser Parameter <i>null</i>, so
        /// wartet die Methode auf den Abschluss des asynchronen Aufrufs.</param>
        /// <param name="traceArgs">Parameter zum Aufbau der Meldung.</param>
        /// <returns>Gesetzt, wenn der Aufruf abgeschlossen wurde oder bereits war. Ansonsten
        /// ist der Aufruf weiterhin aktiv.</returns>
        protected bool WaitForEnd <TAsync>(ref TAsync request, string traceFormat = null, params object[] traceArgs) where TAsync : class, IAsyncResult
        {
            // No request at all
            var pending = request;

            if (pending == null)
            {
                return(true);
            }

            // Request still busy - calling this method with only a single parameter will do a synchronous call
            if (traceFormat != null)
            {
                if (!pending.IsCompleted)
                {
                    return(false);
                }
            }

            // Synchronize
            try
            {
                // Fetch result
                ServerImplementation.EndRequest(pending);

                // Report
                if (!string.IsNullOrEmpty(traceFormat))
                {
                    Tools.ExtendedLogging(traceFormat, traceArgs);
                }
            }
            catch (Exception e)
            {
                // Report only!
                VCRServer.Log(LoggingLevel.Errors, "Failed Operation for '{0}': {1}", ProfileName, e.Message);
            }
            finally
            {
                // Forget
                request = null;
            }

            // Stopped it
            return(true);
        }
Ejemplo n.º 18
0
        static void Main5(string[] args)
        {
            // Attach to job manager
            VCRServer  server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs"));
            JobManager jobs   = server.JobManager;

            // Create EPG collection
            using (SourceScanRequest request = SourceScanRequest.CreateDefault("Nexus Scan", jobs))
                if (null != request)
                {
                    // Get the information
                    FullInfo info0 = request.CreateFullInformation();

                    // Report
                    Console.WriteLine(info0.Recording.JobType);

                    // Start it
                    request.BeginExecute(false);

                    // Wait for end
                    Console.WriteLine("Updateing...");

                    // Process
                    for (string line; !string.IsNullOrEmpty(line = Console.ReadLine());)
                    {
                        // Get the information
                        FullInfo info2 = request.CreateFullInformation();

                        // Report
                        Console.WriteLine(info2.Recording.TotalSize);
                    }

                    // Stop it
                    request.Stop();

                    // Get the information
                    FullInfo info1 = request.CreateFullInformation();
                }

            // Done
            Console.WriteLine("Done");
            Console.ReadLine();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Beendet die aktuelle ASP.NET Laufzeitumgebung.
        /// <seealso cref="ServerRuntime.Stop"/>
        /// </summary>
        public void Stop()
        {
            // Terminate all end-points we started
            foreach (var endPoint in Interlocked.Exchange(ref m_endPoints, new List <IDisposable>()))
            {
                try
                {
                    // Try shutdown
                    endPoint.Dispose();
                }
                catch (Exception)
                {
                    // Ignore any error
                }
            }

            // Report
            VCRServer.Log(LoggingLevel.Full, Properties.Resources.WebServerStopped);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Startet eine Aufzeichnung oder eine Aufgabe.
        /// </summary>
        /// <param name="item">Die Beschreibung der Aufgabe.</param>
        /// <returns>Gesetzt, wenn der Vorgang erfolgreich war.</returns>
        public bool Start(IScheduleInformation item)
        {
            // Validate
            if (item is ScheduleInformation)
            {
                VCRServer.LogError(Properties.Resources.BadScheduleInformation, item.Definition.UniqueIdentifier, item.Definition.Name);
            }

            // Try start
            if (!m_manager.Start(item))
            {
                return(false);
            }

            // Remember
            m_started.Add(item.Definition.UniqueIdentifier, new ScheduleInformation(item));

            // Did it
            return(true);
        }
Ejemplo n.º 21
0
        static void Main(string[] args)
        {
            // Start server
            using (VCRServer server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs")))
            {
                // Load the settings
                Settings settings = server.Settings;

                // Fire our first schedule
                PowerManager.OnResume();

                // Report
                Console.WriteLine("Running {4} {0} [Hibernate={1} S3={2} NVOD={3}]", string.Join(",", settings.Profiles.ToArray()), settings.MayHibernateSystem, settings.UseStandByForHibernation, settings.CanRecordNVOD, VCRServer.CurrentVersion);
                Console.ReadLine();
            }

            // Done
            Console.WriteLine("Done");
            Console.ReadLine();
        }
Ejemplo n.º 22
0
        static void Main_EPGLookup(string[] args)
        {
            // Create the server
            using (VCRServer server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs")))
            {
                // Create filter
                GuideEntryFilter filter =
                    new GuideEntryFilter
                {
                    MaximumEntriesPerStation = 30,
                    MinimumDateTime          = DateTime.UtcNow,
                    MinimumIsCurrent         = true,
                    Profile       = null,
                    Station       = "ZDF [ZDFvision]",
                    ContentFilter = null
                };

                // Load a bit of events
                ProgramGuideEntry[] entries = server.GetProgramGuideEntries(filter);
            }
        }
Ejemplo n.º 23
0
        static void Main_EPGScan(string[] args)
        {
            // Create the server
            using (VCRServer server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs")))
            {
                // Attach to the profile state of interest
                ProfileState state = server.FindProfile("DVB-S2");

                // Report all
                Console.WriteLine(ProgramGuideManager.UpdateEnabled);
                Console.WriteLine(state.ProgramGuide.NextUpdateTime);

                // Create request
                using (ProgramGuideRequest request = state.CreateProgramGuideRequest())
                    if (null != request)
                    {
                        // Manipulate
                        request.Recording.EndsAt = DateTime.UtcNow.AddSeconds(30);

                        // Get the information
                        FullInfo info0 = request.CreateFullInformation();

                        // Start it
                        request.Start();

                        // Wait for end
                        for (; request.IsRunning; Thread.Sleep(2500))
                        {
                            Console.WriteLine("Collecting... {0}", DateTime.Now);
                        }

                        // Get the information
                        FullInfo info1 = request.CreateFullInformation();

                        // Report
                        Console.WriteLine(info1.Recording.TotalSize);
                    }
            }
        }
Ejemplo n.º 24
0
        static void Main3(string[] args)
        {
            // Attach to job manager
            VCRServer  server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs"));
            JobManager jobs   = server.JobManager;

            // Get the profile
            Profile nexus = VCRProfiles.FindProfile("Nexus");

            // Find the next recording
            VCRRecordingInfo rec = jobs.FindNextJob(new DateTime(2009, 2, 19, 20, 0, 0), null, nexus);

            if (null != rec)
            {
                if (rec.StartsAt.HasValue)
                {
                    using (RecordingRequest recording = jobs.CreateRecording(rec, rec.StartsAt.Value, nexus))
                    {
                        // Get the information
                        FullInfo info0 = recording.CreateFullInformation();

                        // Start it
                        recording.BeginExecute(false);

                        // Report
                        Console.WriteLine("Recording...");
                        Console.ReadLine();

                        // Get the information
                        FullInfo info1 = recording.CreateFullInformation();
                    }
                }
            }

            // Done
            Console.WriteLine("Done");
            Console.ReadLine();
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Löst auf einem separaten <see cref="Thread"/> <see cref="OnPowerUp"/> aus.
 /// </summary>
 public static void OnResume()
 {
     // Start wakeup thread
     new Thread(forbid =>
     {
         // With reset
         using ((IDisposable)forbid)
             try
             {
                 // Trigger events
                 var sink = OnPowerUp;
                 if (sink != null)
                 {
                     sink();
                 }
             }
             catch (Exception e)
             {
                 // Report
                 VCRServer.Log(e);
             }
     }).Start(StartForbidHibernation());
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Schließt die Konfiguration einer Beschreibung ab.
        /// </summary>
        /// <param name="server">Der zugehörige Dienst.</param>
        private void Complete(VCRServer server)
        {
            // No source
            if (m_source == null)
            {
                return;
            }

            // At least we have this
            Source = SourceIdentifier.ToString(m_source.Source).Replace(" ", "");

            // Check profile - should normally be available
            var profile = server.Profiles[ProfileName];

            if (profile == null)
            {
                return;
            }

            // Load the profile
            HasGuideEntry = profile.ProgramGuide.HasEntry(m_source.Source, StartTime, StartTime + Duration);
            SourceName    = m_source.GetUniqueName();
        }
Ejemplo n.º 27
0
        static void Main_FindRecording(string[] args)
        {
            // Create the server
            using (VCRServer server = new VCRServer(new DirectoryInfo(@"C:\temp\VCR.NET 3.9 Alpha\Jobs")))
            {
                // Attach to the state of a profile
                ProfileState nexus = server.FindProfile("Nexus");

                // Get the next job to execute
                VCRRecordingInfo next = nexus.NextJob;

                // Get recording information for the next jon
                bool incomplete;
                VCRRecordingInfo[] hidden;
                FullInfo           full = nexus.FindNextRecording(DateTime.UtcNow, out incomplete, out hidden);

                // Prepare it
                using (HardwareRequest request = nexus.CreateRecordingRequest(next, DateTime.UtcNow))
                {
                    // Set end time
                    request.Recording.EndsAt = DateTime.UtcNow.AddSeconds(30);

                    // Report
                    Console.WriteLine("Recording {0}", request.Recording.FileName);

                    // Process it
                    request.Start();

                    // Wait
                    while (request.IsRunning)
                    {
                        Thread.Sleep(100);
                    }
                }
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Erstellt eine neue Planung.
        /// </summary>
        /// <param name="site">Die zugehörige Arbeitsumgebung.</param>
        private RecordingPlanner(IRecordingPlannerSite site)
        {
            // Remember
            m_site = site;

            // Process all profiles
            foreach (var profileName in site.ProfileNames)
            {
                // Look up the profile
                var profile = ProfileManager.FindProfile(profileName);
                if (profile == null)
                {
                    continue;
                }

                // Create the resource for it
                var profileResource = ProfileScheduleResource.Create(profileName);

                // Remember
                m_resources.Add(profileName, profileResource);

                // See if this is a leaf profile
                if (!string.IsNullOrEmpty(profile.UseSourcesFrom))
                {
                    continue;
                }

                // See if we should process guide updates
                var guideTask = site.CreateProgramGuideTask(profileResource, profile);
                if (guideTask != null)
                {
                    m_tasks.Add(guideTask);
                }

                // See if we should update the source list
                var scanTask = site.CreateSourceScanTask(profileResource, profile);
                if (scanTask != null)
                {
                    m_tasks.Add(scanTask);
                }
            }

            // Make sure we report all errors
            try
            {
                // Create the manager
                m_manager = ResourceManager.Create(site.ScheduleRulesPath, ProfileManager.ProfileNameComparer);
            }
            catch (Exception e)
            {
                // Report
                VCRServer.LogError(Properties.Resources.BadRuleFile, e.Message);

                // Use standard rules
                m_manager = ResourceManager.Create(ProfileManager.ProfileNameComparer);
            }

            // Safe configure it
            try
            {
                // All all resources
                foreach (var resource in m_resources.Values)
                {
                    m_manager.Add(resource);
                }
            }
            catch (Exception e)
            {
                // Cleanup
                Dispose();

                // Report
                VCRServer.Log(e);
            }
        }
Ejemplo n.º 29
0
        /// <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 };
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Schließt die Konfiguration einer Beschreibung ab.
        /// </summary>
        /// <param name="server">Der zugehörige Dienst.</param>
        private void Complete( VCRServer server )
        {
            // No source
            if (m_source == null)
                return;

            // At least we have this
            Source = SourceIdentifier.ToString( m_source.Source ).Replace( " ", "" );

            // Check profile - should normally be available
            var profile = server.Profiles[ProfileName];
            if (profile == null)
                return;

            // Load the profile
            HasGuideEntry = profile.ProgramGuide.HasEntry( m_source.Source, StartTime, StartTime + Duration );
            SourceName = m_source.GetUniqueName();
        }
Ejemplo n.º 31
0
        /// <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;
            }
        }
Ejemplo n.º 32
0
        /// <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);
        }
Ejemplo n.º 33
0
        /// <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);
            }
        }
Ejemplo n.º 34
0
        /// <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;
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Verbindet die ASP.NET Laufzeitumgebung des aktuellen virtuellen Verzeichnisses
        /// mit der aktiven VCR.NET Instanz.
        /// </summary>
        /// <param name="server">Die aktive VCR.NET Instanz.</param>
        public void SetServer( VCRServer server )
        {
            // Activate configuration from main domain
            VCRConfiguration.Register( server.Configuration );

            // Add to permanent cache
            _VCRServer = server;
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Beendet die ASP.NET Laufzeitumgebung.
        /// </summary>
        /// <remarks>
        /// Der Aufruf kehrt erst wieder zurück, wenn alle ausstehenden Anfragen bearbeitet
        /// wurden. Neue Anfragen werden nicht angenommen.
        /// </remarks>
        public override void Stop()
        {
            // Reset
            _VCRServer = null;

            // Forward
            base.Stop();
        }