Esempio n. 1
0
        private void LoadConfig()
        {
            Log.Info("WebEPG Config: Loading Channels");
            hChannelConfigInfo               = new Hashtable();
            TvMappings.HChannelConfigInfo    = hChannelConfigInfo;
            RadioMappings.HChannelConfigInfo = hChannelConfigInfo;

            if (File.Exists(_webepgFilesDir + "\\channels\\channels.xml"))
            {
                Log.Info("WebEPG Config: Loading Existing channels.xml");
                Xml xmlreader    = new Xml(_webepgFilesDir + "\\channels\\channels.xml");
                int channelCount = xmlreader.GetValueAsInt("ChannelInfo", "TotalChannels", 0);

                for (int i = 0; i < channelCount; i++)
                {
                    ChannelConfigInfo channel = new ChannelConfigInfo();
                    channel.ChannelID = xmlreader.GetValueAsString(i.ToString(), "ChannelID", "");
                    channel.FullName  = xmlreader.GetValueAsString(i.ToString(), "FullName", "");
                    hChannelConfigInfo.Add(channel.ChannelID, channel);
                }
            }

            Log.Info("WebEPG Config: Loading Grabbers");
            hGrabberConfigInfo = new Hashtable();
            CountryList        = new SortedList();
            tGrabbers          = new TreeNode("Web Sites");
            if (Directory.Exists(_webepgFilesDir + "Grabbers"))
            {
                GetTreeGrabbers(ref tGrabbers, _webepgFilesDir + "Grabbers");
            }
            else
            {
                Log.Info("WebEPG Config: Cannot find grabbers directory");
            }

            IDictionaryEnumerator Enumerator = hChannelConfigInfo.GetEnumerator();

            while (Enumerator.MoveNext())
            {
                ChannelConfigInfo info = (ChannelConfigInfo)Enumerator.Value;
                if (info.ChannelID != null && info.FullName != null)
                {
                    if (info.GrabberList != null)
                    {
                        IDictionaryEnumerator grabEnum = info.GrabberList.GetEnumerator();
                        while (grabEnum.MoveNext())
                        {
                            GrabberConfigInfo gInfo  = (GrabberConfigInfo)grabEnum.Value;
                            SortedList        chList = (SortedList)CountryList[gInfo.Country];
                            if (chList[info.ChannelID] == null)
                            {
                                chList.Add(info.ChannelID, gInfo.GrabberID);
                                //CountryList.Remove(gInfo.Country);
                                //CountryList.Add(gInfo.Country, chList);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void GetGrabbers(ref TreeNode Main, string Location)
        {
            DirectoryInfo dir = new DirectoryInfo(Location);

            Log.Debug("WebEPG Config: Directory: {0}", Location);
            GrabberConfigInfo gInfo;

            foreach (FileInfo file in dir.GetFiles("*.xml"))
            {
                gInfo = new GrabberConfigInfo();
                //XmlDocument xml = new XmlDocument();
                GrabberConfigFile grabberXml;
                try
                {
                    Log.Debug("WebEPG Config: File: {0}", file.Name);

                    XmlSerializer s = new XmlSerializer(typeof(GrabberConfigFile));
                    TextReader    r = new StreamReader(file.FullName);
                    grabberXml = (GrabberConfigFile)s.Deserialize(r);
                }
                catch (Exception)
                {
                    Log.Info("WebEPG Config: File open failed - XML error");
                    return;
                }

                gInfo.GrabDays = grabberXml.Info.GrabDays;

                string GrabberSite = file.Name.Replace(".xml", "");
                GrabberSite = GrabberSite.Replace("_", ".");

                gInfo.GrabberID   = file.Directory.Name + "\\" + file.Name;
                gInfo.GrabberName = GrabberSite;
                gInfo.Country     = file.Directory.Name;
                hGrabberConfigInfo.Add(gInfo.GrabberID, gInfo);

                if (CountryList[file.Directory.Name] == null)
                {
                    CountryList.Add(file.Directory.Name, new SortedList());
                }

                TreeNode gNode = new TreeNode(GrabberSite);
                Main.Nodes.Add(gNode);
                //XmlNode cl=sectionList.Attributes.GetNamedItem("ChannelList");

                foreach (ChannelInfo channel in grabberXml.Channels)
                {
                    if (channel.id != null)
                    {
                        ChannelConfigInfo info = (ChannelConfigInfo)hChannelConfigInfo[channel.id];
                        if (info != null) // && info.GrabberList[gInfo.GrabberID] != null)
                        {
                            TreeNode tNode = new TreeNode(info.FullName);
                            tNode.Tag = new GrabberSelectionInfo(info.ChannelID, gInfo.GrabberID);
                            gNode.Nodes.Add(tNode);
                            if (info.GrabberList == null)
                            {
                                info.GrabberList = new SortedList();
                            }
                            if (info.GrabberList[gInfo.GrabberID] == null)
                            {
                                info.GrabberList.Add(gInfo.GrabberID, gInfo);
                            }
                        }
                        else
                        {
                            info             = new ChannelConfigInfo();
                            info.ChannelID   = channel.id;
                            info.FullName    = info.ChannelID;
                            info.GrabberList = new SortedList();
                            info.GrabberList.Add(gInfo.GrabberID, gInfo);
                            hChannelConfigInfo.Add(info.ChannelID, info);

                            TreeNode tNode = new TreeNode(info.FullName);
                            tNode.Tag = new GrabberSelectionInfo(info.ChannelID, gInfo.GrabberID);
                            gNode.Nodes.Add(tNode);
                        }
                    }
                }
            }
        }