Пример #1
0
        /// <summary>
        /// Erstellt einen neuen Eintrag für die Programmzeitschrift.
        /// </summary>
        /// <param name="entry">Der originale Eintrag aus der Verwaltung.</param>
        /// <param name="profileName">Der Name des zugehörigen Geräteprofils.</param>
        /// <returns>Die gewünschte Beschreibung.</returns>
        public static GuideItem Create(ProgramGuideEntry entry, string profileName)
        {
            // Validate
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            // Default name of the station
            var source = VCRProfiles.FindSource(profileName, entry.Source);

            // Create
            return
                (new GuideItem
            {
                Identifier = $"{entry.StartTime.Ticks}:{profileName}:{SourceIdentifier.ToString( entry.Source ).Replace( " ", "" )}",
                Station = (source == null) ? entry.StationName : source.GetUniqueName(),
                Duration = TimeSpan.FromSeconds(entry.Duration),
                Categories = entry.Categories.ToArray(),
                Ratings = entry.Ratings.ToArray(),
                Summary = entry.ShortDescription,
                Description = entry.Description,
                StartTime = entry.StartTime,
                Language = entry.Language,
                Name = entry.Name,
            });
        }
Пример #2
0
        /// <summary>
        /// Wählt einen NVOD Dienst aus.
        /// </summary>
        /// <param name="service">Der gewünschte Dienst.</param>
        /// <returns>Name des Dienstes inklusive der aktuellen Tonspur oder
        /// <i>null</i>, wenn eine Aktivierung des Dienstes nicht möglich war.</returns>
        public override string SetService(ServiceItem service)
        {
            // Must be a known channel
            VCRNETRestProxy.Source source;
            if (!Sources.TryGetValue(service.Identifier, out source))
            {
                return(null);
            }

            // Stop sending data
            Accessor.Stop();

            // Tune
            VCRNETRestProxy.TuneSync(m_serverRoot, Profile, SourceIdentifier.ToString(service.Identifier));

            // Got the portal
            if (service.Index == 0)
            {
                // Reset
                CurrentService = null;

                // Done
                return(source.nameWithProvider);
            }

            // Got a real service
            CurrentService = service.Name;

            // Done
            return(CurrentService);
        }
Пример #3
0
        /// <summary>
        /// Erstellt eine neue Dienstbeschreibung.
        /// </summary>
        /// <param name="service">Die Beschreibung des Dienstes.</param>
        /// <returns>Der gewünschte Dienst.</returns>
        public static ZappingService Create(ServiceInformation service)
        {
            // Validate
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            // Create new
            return
                (new ZappingService
            {
                Source = SourceIdentifier.ToString(service.Service).Replace(" ", ""),
                Index = GetServiceIndex(service.UniqueName),
                Name = service.UniqueName
            });
        }
Пример #4
0
        /// <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);
        }
Пример #5
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();
        }
Пример #6
0
        /// <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);
        }
Пример #7
0
 /// <summary>
 /// Führt individuelle Initialisierungen aus.
 /// </summary>
 /// <param name="station">Die Informationen zur Quelle.</param>
 protected override void OnCreate(Station station) => Source = SourceIdentifier.ToString(station).Replace(" ", "");
Пример #8
0
 /// <summary>
 /// Erzeugt eine neue Ausnahme.
 /// </summary>
 /// <param name="source">Die unbekannte Quelle.</param>
 public NoSourceFault(SourceIdentifier source)
     : base(string.Format(Properties.Resources.Exception_NoSource, SourceIdentifier.ToString(source)))
 {
     // Remember
     Source = source;
 }
        /// <summary>
        /// Führt die zugehörige Operation aus.
        /// </summary>
        /// <param name="request">Optionale Parameter für den Aufruf.</param>
        /// <returns>Das Ergebnis der Operation.</returns>
        protected override InformationResponse OnExecute(InformationRequest request)
        {
            // Check mode
            if (request.Type == InformationRequestType.NetworkInformation)
            {
                // Load it
                var locationInformation = Device.GetLocationInformation();

                // Create result
                var response = new NetworkInformationResponse();

                // Fill it
                if (locationInformation != null)
                {
                    if (locationInformation.Groups != null)
                    {
                        response.Groups.AddRange(locationInformation.Groups.Cast <SourceGroup>());
                    }
                }

                // Done
                return(response);
            }

            // Result
            var result = new List <string>();

            // Check mode
            if (request.Type == InformationRequestType.GroupInformation)
            {
                // Load it
                var groupInformation = Device.GetGroupInformation();

                // Check mode
                if (groupInformation != null)
                {
                    result.AddRange(groupInformation.Sources.Select(s => SourceIdentifier.ToString(s)));
                }
            }
            else if (request.Type == InformationRequestType.SourceInformation)
            {
                foreach (var source in request.SourceList)
                {
                    // Get the information
                    var sourceInformation = source.GetSourceInformation(Device, CardServer.Profile);

                    // Report
                    if (sourceInformation == null)
                    {
                        result.Add(source.ToString());
                    }
                    else
                    {
                        result.Add(sourceInformation.Name);
                    }
                }
            }

            // Not supported
            return(new GenericInformationResponse {
                Strings = result.ToArray()
            });
        }