Example #1
0
        /// <summary>
        /// Manipuliert eine Aufzeichnung.
        /// </summary>
        /// <param name="profile">Das zu verwendende Geräteprofil.</param>
        /// <param name="delete">Gesetzt, wenn eine Aufzeichnung entfernt werden soll.</param>
        /// <param name="stationName">Die gewünschte Quelle.</param>
        /// <param name="title">Der Name der Aufzeichnung.</param>
        /// <param name="start">Der Zeitpunkt der ersten Ausführung.</param>
        /// <param name="minutes">Die Laufzeit in Minuten.</param>
        /// <returns>Der Fehlercode zur Ausführung.</returns>
        private static int UpdateRecording( string profile, bool delete, string stationName, string title, DateTime start, int minutes )
        {
            // Real data
            DateTime utcStart = start.ToUniversalTime();

            // Correct
            utcStart = utcStart.AddMinutes( -Properties.Settings.Default.PreTime );
            minutes += Properties.Settings.Default.PreTime + Properties.Settings.Default.PostTime;

            // Not yet deleting
            if (delete)
            {
                // Process all jobs
                foreach (var job in VCRNETRestProxy.GetJobs( EndPoint ))
                {
                    // Test job data
                    if (!StringComparer.InvariantCultureIgnoreCase.Equals( profile, job.device ))
                        continue;
                    if (!Equals( job.source, stationName ))
                        continue;

                    // Test schedules
                    if (job.schedules.Length != 1)
                        continue;

                    // Attach to the one and only schedule
                    var schedule = job.schedules[0];
                    if (schedule.start != utcStart)
                        continue;
                    if (schedule.duration != minutes)
                        continue;
                    if (schedule.repeatPattern != 0)
                        continue;

                    // Try to delete
                    VCRNETRestProxy.Delete( EndPoint, schedule.id );

                    // Done
                    return 0;
                }

                // Report
                MessageBox.Show( Properties.Resources.NoSuchJob );

                // Done
                return 3;
            }

            // Create the recording
            var newJob =
                new VCRNETRestProxy.Job
                {
                    sourceName = stationName,
                    withVideotext = true,
                    withSubtitles = true,
                    allLanguages = true,
                    includeDolby = true,
                    device = profile,
                    name = title,
                };

            // Correct the name
            foreach (char bad in System.IO.Path.GetInvalidFileNameChars())
                newJob.name = newJob.name.Replace( bad, '_' );

            // Special
            newJob.name = newJob.name.Replace( '&', '_' );

            // Create the schedule
            var newSchedule =
                new VCRNETRestProxy.Schedule
                {
                    lastDay = new DateTime( 2999, 12, 31 ),
                    firstStart = utcStart,
                    name = string.Empty,
                    duration = minutes,
                };

            // Process
            var uniqueId = VCRNETRestProxy.CreateNew( EndPoint, newJob, newSchedule );

            // See if we are allowed to open the browser
            if (Properties.Settings.Default.ShowConfirmation)
            {
                // Create the URL
                string url = string.Format( "{0}/default.html#edit;id={1}", EndPoint, uniqueId );

                // Report error
                try
                {
                    // Show in default browser
                    using (var explorer = Process.Start( url ))
                        if (explorer != null)
                            explorer.Close();
                }
                catch (Exception e)
                {
                    // Report
                    MessageBox.Show( e.Message );
                }
            }

            // Succeeded
            return 0;
        }
        /// <summary>
        /// Startet eine Aufzeichnung im VCR.NET auf dem aktuellen Sender.
        /// </summary>
        /// <param name="duration"></param>
        private void StartRecording( int duration )
        {
            // Read the status
            var status = VCRNETRestProxy.GetStatusSync( m_serverRoot, Profile );

            // Not connected to us
            if (!StringComparer.InvariantCultureIgnoreCase.Equals( status.target, Adaptor.Target ))
                return;

            // Configure the new schedule
            var schedule =
                new VCRNETRestProxy.Schedule
                {
                    lastDay = new DateTime( 2999, 12, 31 ),
                    name = "Gestartet vom DVB.NET Viewer",
                    firstStart = DateTime.UtcNow,
                    duration = duration,
                };

            // Configure the new job
            var job = new VCRNETRestProxy.Job
            {
                sourceName = CurrentSource.nameWithProvider,
                name = "Manuelle Aufzeichnung",
                withSubtitles = true,
                withVideotext = true,
                includeDolby = true,
                allLanguages = true,
                device = Profile,
            };

            // Send it
            VCRNETRestProxy.CreateNewSync( Adaptor.EndPoint, job, schedule );
        }