/// <summary>
        /// Acquire and process MediaHighway1 data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            MediaHighwayProgramCategory.LoadFromFrequency("1", dataProvider.Frequency.ToString());
            CustomProgramCategory.Load();

            getChannelSections(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getCategorySections(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getTitleSections(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getSummarySections(dataProvider, worker);

            return(CollectorReply.OK);
        }
        private string getEventCategory(string title, string description, int categoryID)
        {
            if (categoryID == 0)
            {
                return(getCustomCategory(title, description));
            }

            if (RunParameters.Instance.Options.Contains("CUSTOMCATEGORYOVERRIDE"))
            {
                string customCategory = getCustomCategory(title, description);
                if (customCategory != null)
                {
                    return(customCategory);
                }
            }

            MediaHighwayProgramCategory category = MediaHighwayProgramCategory.FindCategory(categoryID);

            if (category != null)
            {
                return(category.Description);
            }

            if (RunParameters.Instance.Options.Contains("CUSTOMCATEGORYOVERRIDE"))
            {
                return(null);
            }

            return(getCustomCategory(title, description));
        }
        /// <summary>
        /// Create the EPG entries.
        /// </summary>
        public override void FinishFrequency()
        {
            if (MediaHighwayChannel.Channels.Count == 0)
            {
                return;
            }

            Logger titleLogger       = null;
            Logger descriptionLogger = null;

            if (RunParameters.Instance.DebugIDs.Contains("LOGTITLES"))
            {
                titleLogger = new Logger("EPG Titles.log");
            }
            if (RunParameters.Instance.DebugIDs.Contains("LOGDESCRIPTIONS"))
            {
                descriptionLogger = new Logger("EPG Descriptions.log");
            }

            foreach (MediaHighwayChannel channel in MediaHighwayChannel.Channels)
            {
                TVStation station = TVStation.FindStation(channel.OriginalNetworkID, channel.TransportStreamID, channel.ServiceID);
                if (station == null)
                {
                    station = new TVStation(channel.ChannelName);
                    station.OriginalNetworkID = channel.OriginalNetworkID;
                    station.TransportStreamID = channel.TransportStreamID;
                    station.ServiceID         = channel.ServiceID;
                    TVStation.AddStation(station);
                }

                station.Name = channel.ChannelName;

                if (station.LogicalChannelNumber == -1)
                {
                    station.LogicalChannelNumber = channel.UserChannel;
                }

                if (station.EPGCollection.Count == 0)
                {
                    channel.ProcessChannelForEPG(station, titleLogger, descriptionLogger, CollectionType.MediaHighway2);
                }
            }

            MediaHighwayProgramCategory.LogCategories();
            Channel.LogChannelsInChannelOrder();
        }
        private void processCategorySections(Collection <Mpeg2Section> sections)
        {
            foreach (Mpeg2Section section in sections)
            {
                if (RunParameters.Instance.TraceIDs.Contains("DUMPCATEGORYSECTIONS"))
                {
                    Logger.Instance.Dump("Category Section", section.Data, section.Length);
                }

                MediaHighway1CategorySection categorySection = MediaHighway1CategorySection.ProcessMediaHighwayCategoryTable(section.Data);
                if (categorySection != null)
                {
                    if (categorySection.Categories != null)
                    {
                        foreach (MediaHighwayCategoryEntry categoryEntry in categorySection.Categories)
                        {
                            MediaHighwayProgramCategory.AddCategory(categoryEntry.Number, categoryEntry.Description);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Compare this instance with another for sorting purposes.
        /// </summary>
        /// <param name="category">The other instance.</param>
        /// <param name="keyName">The name of the key to compare on.</param>
        /// <returns>Zero if the instances are equal, Greater than 0 if this instance is greater; less than zero otherwise.</returns>
        public int CompareForSorting(MediaHighwayProgramCategory category, string keyName)
        {
            switch (keyName)
            {
                case "CategoryID":
                    if (number == category.CategoryID)
                        return (description.CompareTo(category.MHWDescription));
                    else
                        return (number.CompareTo(category.CategoryID));
                case "Description":
                    if (MHWDescription == category.MHWDescription)
                        return (number.CompareTo(category.CategoryID));
                    else
                        return (MHWDescription.CompareTo(category.MHWDescription));
                case "WMCDescription":
                    string thisWMCDescription;
                    string otherWMCDescription;

                    if (DVBLogicDescription != null)
                        thisWMCDescription = DVBLogicDescription;
                    else
                        thisWMCDescription = string.Empty;

                    if (category.DVBLogicDescription != null)
                        otherWMCDescription = category.DVBLogicDescription;
                    else
                        otherWMCDescription = string.Empty;

                    if (thisWMCDescription == otherWMCDescription)
                        return (number.CompareTo(category.CategoryID));
                    else
                        return (thisWMCDescription.CompareTo(otherWMCDescription));
                case "DVBLogicDescription":
                    string thisLogicDescription;
                    string otherLogicDescription;

                    if (DVBLogicDescription != null)
                        thisLogicDescription = DVBLogicDescription;
                    else
                        thisLogicDescription = string.Empty;

                    if (category.DVBLogicDescription != null)
                        otherLogicDescription = category.DVBLogicDescription;
                    else
                        otherLogicDescription = string.Empty;

                    if (thisLogicDescription == otherLogicDescription)
                        return (number.CompareTo(category.CategoryID));
                    else
                        return (thisLogicDescription.CompareTo(otherLogicDescription));
                case "DVBViewerDescription":
                    string thisViewerDescription;
                    string otherViewerDescription;

                    if (DVBViewerDescription != null)
                        thisViewerDescription = DVBViewerDescription;
                    else
                        thisViewerDescription = string.Empty;

                    if (category.DVBViewerDescription != null)
                        otherViewerDescription = category.DVBViewerDescription;
                    else
                        otherViewerDescription = string.Empty;

                    if (thisViewerDescription == otherViewerDescription)
                        return (number.CompareTo(category.CategoryID));
                    else
                        return (thisViewerDescription.CompareTo(otherViewerDescription));
                default:
                    return (0);
            }
        }
        /// <summary>
        /// Create the EPG entries.
        /// </summary>
        public override void FinishFrequency()
        {
            if (MediaHighwayChannel.Channels.Count == 0)
            {
                return;
            }

            foreach (MediaHighwaySummary summary in MediaHighwaySummary.Summaries)
            {
                if (summary.Replays != null)
                {
                    MediaHighwayChannelTitle title = MediaHighwayChannel.FindChannelTitle(summary.EventID);
                    if (title != null)
                    {
                        foreach (MediaHighway1Replay replay in summary.Replays)
                        {
                            MediaHighwayTitle replayTitle = new MediaHighwayTitle();
                            replayTitle.EventID          = title.Title.EventID;
                            replayTitle.EventName        = title.Title.EventName;
                            replayTitle.CategoryID       = title.Title.CategoryID;
                            replayTitle.StartTime        = replay.ReplayTime;
                            replayTitle.Duration         = title.Title.Duration;
                            replayTitle.SummaryAvailable = true;
                            replayTitle.PreviousPlayDate = title.Title.StartTime;
                            ((MediaHighwayChannel)Channel.FindChannel(replay.Channel)).AddTitleData(replayTitle);

                            if (RunParameters.Instance.DebugIDs.Contains("REPLAYS"))
                            {
                                Logger.Instance.Write("Replay: ch" + replay.Channel + " " +
                                                      title.Title.EventName + " " +
                                                      title.Title.StartTime + " " +
                                                      title.Title.Duration + " " +
                                                      replay.ReplayTime);
                            }
                        }
                    }
                }
            }

            Logger titleLogger       = null;
            Logger descriptionLogger = null;

            if (RunParameters.Instance.DebugIDs.Contains("LOGTITLES"))
            {
                titleLogger = new Logger("EPG Titles.log");
            }
            if (RunParameters.Instance.DebugIDs.Contains("LOGDESCRIPTIONS"))
            {
                descriptionLogger = new Logger("EPG Descriptions.log");
            }

            foreach (MediaHighwayChannel channel in MediaHighwayChannel.Channels)
            {
                TVStation station = TVStation.FindStation(channel.OriginalNetworkID, channel.TransportStreamID, channel.ServiceID);
                if (station == null)
                {
                    station = new TVStation(channel.ChannelName);
                    station.OriginalNetworkID = channel.OriginalNetworkID;
                    station.TransportStreamID = channel.TransportStreamID;
                    station.ServiceID         = channel.ServiceID;
                    TVStation.AddStation(station);
                }

                station.Name = channel.ChannelName;

                if (station.LogicalChannelNumber == -1)
                {
                    station.LogicalChannelNumber = channel.UserChannel;
                }

                if (station.EPGCollection.Count == 0)
                {
                    channel.ProcessChannelForEPG(station, titleLogger, descriptionLogger, CollectionType.MediaHighway1);
                }
            }

            MediaHighwayProgramCategory.LogCategories();
            Channel.LogChannelsInChannelOrder();
        }
Example #7
0
        /// <summary>
        /// Compare this instance with another for sorting purposes.
        /// </summary>
        /// <param name="category">The other instance.</param>
        /// <param name="keyName">The name of the key to compare on.</param>
        /// <returns>Zero if the instances are equal, Greater than 0 if this instance is greater; less than zero otherwise.</returns>
        public int CompareForSorting(MediaHighwayProgramCategory category, string keyName)
        {
            switch (keyName)
            {
            case "CategoryID":
                if (number == category.CategoryID)
                {
                    return(description.CompareTo(category.MHWDescription));
                }
                else
                {
                    return(number.CompareTo(category.CategoryID));
                }

            case "Description":
                if (MHWDescription == category.MHWDescription)
                {
                    return(number.CompareTo(category.CategoryID));
                }
                else
                {
                    return(MHWDescription.CompareTo(category.MHWDescription));
                }

            case "WMCDescription":
                string thisWMCDescription;
                string otherWMCDescription;

                if (DVBLogicDescription != null)
                {
                    thisWMCDescription = DVBLogicDescription;
                }
                else
                {
                    thisWMCDescription = string.Empty;
                }

                if (category.DVBLogicDescription != null)
                {
                    otherWMCDescription = category.DVBLogicDescription;
                }
                else
                {
                    otherWMCDescription = string.Empty;
                }

                if (thisWMCDescription == otherWMCDescription)
                {
                    return(number.CompareTo(category.CategoryID));
                }
                else
                {
                    return(thisWMCDescription.CompareTo(otherWMCDescription));
                }

            case "DVBLogicDescription":
                string thisLogicDescription;
                string otherLogicDescription;

                if (DVBLogicDescription != null)
                {
                    thisLogicDescription = DVBLogicDescription;
                }
                else
                {
                    thisLogicDescription = string.Empty;
                }

                if (category.DVBLogicDescription != null)
                {
                    otherLogicDescription = category.DVBLogicDescription;
                }
                else
                {
                    otherLogicDescription = string.Empty;
                }

                if (thisLogicDescription == otherLogicDescription)
                {
                    return(number.CompareTo(category.CategoryID));
                }
                else
                {
                    return(thisLogicDescription.CompareTo(otherLogicDescription));
                }

            case "DVBViewerDescription":
                string thisViewerDescription;
                string otherViewerDescription;

                if (DVBViewerDescription != null)
                {
                    thisViewerDescription = DVBViewerDescription;
                }
                else
                {
                    thisViewerDescription = string.Empty;
                }

                if (category.DVBViewerDescription != null)
                {
                    otherViewerDescription = category.DVBViewerDescription;
                }
                else
                {
                    otherViewerDescription = string.Empty;
                }

                if (thisViewerDescription == otherViewerDescription)
                {
                    return(number.CompareTo(category.CategoryID));
                }
                else
                {
                    return(thisViewerDescription.CompareTo(otherViewerDescription));
                }

            default:
                return(0);
            }
        }