/// <summary>
        /// Acquire and process Dish Network 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)
        {
            DishNetworkProgramCategory.Load();
            CustomProgramCategory.Load();
            ParentalRating.Load();

            SingleTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary Dish Network 128.cfg"), 1);
            SingleTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary Dish Network 255.cfg"), 2);
            SingleTreeDictionaryEntry.OffsetStart = false;

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

            getDishNetworkData(dataProvider, worker);

            return(CollectorReply.OK);
        }
        /// <summary>
        /// Create the EPG entries.
        /// </summary>
        public override void FinishFrequency()
        {
            foreach (TVStation station in TVStation.StationCollection)
            {
                if (station.Name != null)
                {
                    station.ChannelID = station.OriginalNetworkID + ":" +
                                        station.TransportStreamID + ":" +
                                        station.ServiceID + ":" +
                                        station.Name;
                }
                else
                {
                    station.ChannelID = station.OriginalNetworkID + ":" +
                                        station.TransportStreamID + ":" +
                                        station.ServiceID;
                }
            }

            DishNetworkProgramCategory.LogCategoryUsage();
        }
        private string getEventCategory(string title, string description, int contentType, int contentSubType)
        {
            if (contentType == -1 || contentSubType == -1)
                return (getCustomCategory(title, description));

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

            if (contentType == 0)
            {
                DishNetworkProgramCategory categoryEntry = DishNetworkProgramCategory.FindCategory(0, contentSubType);
                if (categoryEntry == null)
                {
                    DishNetworkProgramCategory.AddUndefinedCategory(contentType, contentSubType, "", title);
                    if (RunParameters.Instance.Options.Contains("CUSTOMCATEGORYOVERRIDE"))
                        return (null);
                    return (getCustomCategory(title, description));
                }

                if (categoryEntry.SampleEvent == null)
                    categoryEntry.SampleEvent = title;
                categoryEntry.UsedCount++;

                return (categoryEntry.Description);
            }

            DishNetworkProgramCategory mainCategoryEntry = DishNetworkProgramCategory.FindCategory(contentType, 0);
            if (mainCategoryEntry == null)
            {
                DishNetworkProgramCategory.AddUndefinedCategory(contentType, contentSubType, "", title);

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

                return (getCustomCategory(title, description));
            }

            if (contentSubType == 0 || !RunParameters.Instance.Options.Contains("USECONTENTSUBTYPE"))
            {
                if (mainCategoryEntry.SampleEvent == null)
                    mainCategoryEntry.SampleEvent = title;
                mainCategoryEntry.UsedCount++;
                return (mainCategoryEntry.Description);
            }

            DishNetworkProgramCategory subCategoryEntry = DishNetworkProgramCategory.FindCategory(0, contentSubType);
            if (subCategoryEntry == null)
            {
                DishNetworkProgramCategory.AddUndefinedCategory(contentType, contentSubType, "", title);

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

                return (getCustomCategory(title, description));
            }

            if (subCategoryEntry.SampleEvent == null)
                subCategoryEntry.SampleEvent = title;
            subCategoryEntry.UsedCount++;

            string combinedDescription = mainCategoryEntry.DishNetworkDescription + " - " + subCategoryEntry.DishNetworkDescription + "=" +
                mainCategoryEntry.WMCDescription + "," + subCategoryEntry.WMCDescription + "=" +
                mainCategoryEntry.DVBLogicDescription + "=" +
                mainCategoryEntry.DVBViewerDescription;

            DishNetworkProgramCategory generatedCategory = new DishNetworkProgramCategory(contentType, contentSubType, combinedDescription);

            return (generatedCategory.Description);
        }
Beispiel #4
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(DishNetworkProgramCategory category, string keyName)
        {
            switch (keyName)
            {
            case "CategoryID":
                if (categoryID == category.CategoryID)
                {
                    if (subCategoryID == category.SubCategoryID)
                    {
                        return(DishNetworkDescription.CompareTo(category.DishNetworkDescription));
                    }
                    else
                    {
                        return(subCategoryID.CompareTo(category.SubCategoryID));
                    }
                }
                else
                {
                    return(categoryID.CompareTo(category.CategoryID));
                }

            case "SubCategoryID":
                if (subCategoryID == category.SubCategoryID)
                {
                    if (categoryID == category.CategoryID)
                    {
                        return(DishNetworkDescription.CompareTo(category.DishNetworkDescription));
                    }
                    else
                    {
                        return(categoryID.CompareTo(category.CategoryID));
                    }
                }
                else
                {
                    return(subCategoryID.CompareTo(category.SubCategoryID));
                }

            case "Description":
                if (DishNetworkDescription == category.DishNetworkDescription)
                {
                    if (categoryID == category.CategoryID)
                    {
                        return(subCategoryID.CompareTo(category.SubCategoryID));
                    }
                    else
                    {
                        return(categoryID.CompareTo(category.CategoryID));
                    }
                }
                else
                {
                    return(DishNetworkDescription.CompareTo(category.DishNetworkDescription));
                }

            case "WMCDescription":
                string thisWMCDescription;
                string otherWMCDescription;

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

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

                if (thisWMCDescription == otherWMCDescription)
                {
                    if (categoryID == category.CategoryID)
                    {
                        return(subCategoryID.CompareTo(category.SubCategoryID));
                    }
                    else
                    {
                        return(categoryID.CompareTo(category.CategoryID));
                    }
                }
                else
                {
                    return(thisWMCDescription.CompareTo(otherWMCDescription));
                }

            case "DVBLogicDescription":
                string thisDVBLogicDescription;
                string otherDVBLogicDescription;

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

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

                if (thisDVBLogicDescription == otherDVBLogicDescription)
                {
                    if (categoryID == category.CategoryID)
                    {
                        return(subCategoryID.CompareTo(category.SubCategoryID));
                    }
                    else
                    {
                        return(categoryID.CompareTo(category.CategoryID));
                    }
                }
                else
                {
                    return(thisDVBLogicDescription.CompareTo(otherDVBLogicDescription));
                }

            default:
                return(0);
            }
        }
Beispiel #5
0
        private string getEventCategory(string title, string description, int contentType, int contentSubType)
        {
            if (contentType == -1 || contentSubType == -1)
            {
                return(getCustomCategory(title, description));
            }

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

            if (contentType == 0)
            {
                DishNetworkProgramCategory categoryEntry = DishNetworkProgramCategory.FindCategory(0, contentSubType);
                if (categoryEntry == null)
                {
                    DishNetworkProgramCategory.AddUndefinedCategory(contentType, contentSubType, "", title);
                    if (RunParameters.Instance.Options.Contains("CUSTOMCATEGORYOVERRIDE"))
                    {
                        return(null);
                    }
                    return(getCustomCategory(title, description));
                }

                if (categoryEntry.SampleEvent == null)
                {
                    categoryEntry.SampleEvent = title;
                }
                categoryEntry.UsedCount++;

                return(categoryEntry.Description);
            }

            DishNetworkProgramCategory mainCategoryEntry = DishNetworkProgramCategory.FindCategory(contentType, 0);

            if (mainCategoryEntry == null)
            {
                DishNetworkProgramCategory.AddUndefinedCategory(contentType, contentSubType, "", title);

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

                return(getCustomCategory(title, description));
            }

            if (contentSubType == 0 || !RunParameters.Instance.Options.Contains("USECONTENTSUBTYPE"))
            {
                if (mainCategoryEntry.SampleEvent == null)
                {
                    mainCategoryEntry.SampleEvent = title;
                }
                mainCategoryEntry.UsedCount++;
                return(mainCategoryEntry.Description);
            }

            DishNetworkProgramCategory subCategoryEntry = DishNetworkProgramCategory.FindCategory(0, contentSubType);

            if (subCategoryEntry == null)
            {
                DishNetworkProgramCategory.AddUndefinedCategory(contentType, contentSubType, "", title);

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

                return(getCustomCategory(title, description));
            }

            if (subCategoryEntry.SampleEvent == null)
            {
                subCategoryEntry.SampleEvent = title;
            }
            subCategoryEntry.UsedCount++;

            string combinedDescription = mainCategoryEntry.DishNetworkDescription + " - " + subCategoryEntry.DishNetworkDescription + "=" +
                                         mainCategoryEntry.WMCDescription + "," + subCategoryEntry.WMCDescription + "=" +
                                         mainCategoryEntry.DVBLogicDescription + "=" +
                                         mainCategoryEntry.DVBViewerDescription;

            DishNetworkProgramCategory generatedCategory = new DishNetworkProgramCategory(contentType, contentSubType, combinedDescription);

            return(generatedCategory.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(DishNetworkProgramCategory category, string keyName)
        {
            switch (keyName)
            {
                case "CategoryID":
                    if (categoryID == category.CategoryID)
                    {
                        if (subCategoryID == category.SubCategoryID)
                            return (DishNetworkDescription.CompareTo(category.DishNetworkDescription));
                        else
                            return (subCategoryID.CompareTo(category.SubCategoryID));
                    }
                    else
                        return (categoryID.CompareTo(category.CategoryID));
                case "SubCategoryID":
                    if (subCategoryID == category.SubCategoryID)
                    {
                        if (categoryID == category.CategoryID)
                            return (DishNetworkDescription.CompareTo(category.DishNetworkDescription));
                        else
                            return (categoryID.CompareTo(category.CategoryID));
                    }
                    else
                        return (subCategoryID.CompareTo(category.SubCategoryID));
                case "Description":
                    if (DishNetworkDescription == category.DishNetworkDescription)
                    {
                        if (categoryID == category.CategoryID)
                            return (subCategoryID.CompareTo(category.SubCategoryID));
                        else
                            return (categoryID.CompareTo(category.CategoryID));
                    }
                    else
                        return (DishNetworkDescription.CompareTo(category.DishNetworkDescription));
                case "WMCDescription":
                    string thisWMCDescription;
                    string otherWMCDescription;

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

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

                    if (thisWMCDescription == otherWMCDescription)
                    {
                        if (categoryID == category.CategoryID)
                            return (subCategoryID.CompareTo(category.SubCategoryID));
                        else
                            return (categoryID.CompareTo(category.CategoryID));
                    }
                    else
                        return (thisWMCDescription.CompareTo(otherWMCDescription));
                case "DVBLogicDescription":
                    string thisDVBLogicDescription;
                    string otherDVBLogicDescription;

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

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

                    if (thisDVBLogicDescription == otherDVBLogicDescription)
                    {
                        if (categoryID == category.CategoryID)
                            return (subCategoryID.CompareTo(category.SubCategoryID));
                        else
                            return (categoryID.CompareTo(category.CategoryID));
                    }
                    else
                        return (thisDVBLogicDescription.CompareTo(otherDVBLogicDescription));
                default:
                    return (0);
            }
        }