Example #1
0
        private void LoadOldConfigFile()
        {
            Log.Info("Trying to load old config file format");

            _configFile = new WebepgConfigFile();

            Xml xmlreader = new Xml(_configFileDir + "\\WebEPG.xml");

            _configFile.Info            = new WebepgInfo();
            _configFile.Info.GrabDays   = xmlreader.GetValueAsInt("General", "MaxDays", 2);
            _configFile.Info.GrabberDir = xmlreader.GetValueAsString("General", "GrabberDir", null);

            int AuthCount = xmlreader.GetValueAsInt("AuthSites", "Count", 0);

            if (AuthCount > 0)
            {
                _configFile.Sites = new List <SiteAuth>();
                for (int i = 1; i <= AuthCount; i++)
                {
                    SiteAuth site = new SiteAuth();
                    site.id       = xmlreader.GetValueAsString("Auth" + i.ToString(), "Site", "");
                    site.username = xmlreader.GetValueAsString("Auth" + i.ToString(), "Login", "");
                    site.password = xmlreader.GetValueAsString("Auth" + i.ToString(), "Password", "");
                    _configFile.Sites.Add(site);
                }
            }

            _configFile.Channels = new List <ChannelMap>();

            int channelCount = xmlreader.GetValueAsInt("ChannelMap", "Count", 0);

            for (int i = 1; i <= channelCount; i++)
            {
                ChannelMap channel = new ChannelMap();
                channel.displayName = xmlreader.GetValueAsString(i.ToString(), "DisplayName", "");
                string grabber = xmlreader.GetValueAsString(i.ToString(), "Grabber1", "");
                ;
                //if (mergedList.ContainsKey(channel.displayName))
                //{
                //  channel.merged = mergedList[channel.displayName];
                //  foreach (MergedChannel mergedChannel in channel.merged)
                //    mergedChannel.grabber = grabber;
                //}
                //else
                //{
                channel.id      = xmlreader.GetValueAsString(i.ToString(), "ChannelID", "");
                channel.grabber = grabber;
                //}
                _configFile.Channels.Add(channel);
            }

            int mergeCount = xmlreader.GetValueAsInt("MergeChannels", "Count", 0);
            Dictionary <string, List <MergedChannel> > mergedList = new Dictionary <string, List <MergedChannel> >();

            if (mergeCount > 0)
            {
                for (int i = 1; i <= mergeCount; i++)
                {
                    int channelcount = xmlreader.GetValueAsInt("Merge" + i.ToString(), "Channels", 0);
                    if (channelcount > 0)
                    {
                        List <MergedChannel> mergedChannels = new List <MergedChannel>();
                        ChannelMap           channel        = new ChannelMap();
                        channel.displayName = xmlreader.GetValueAsString("Merge" + i.ToString(), "DisplayName", "");
                        channel.merged      = new List <MergedChannel>();
                        for (int c = 1; c <= channelcount; c++)
                        {
                            MergedChannel mergedChannel = new MergedChannel();
                            mergedChannel.id    = xmlreader.GetValueAsString("Merge" + i.ToString(), "Channel" + c.ToString(), "");
                            mergedChannel.start = xmlreader.GetValueAsString("Merge" + i.ToString(), "Start" + c.ToString(), "0:0");
                            mergedChannel.end   = xmlreader.GetValueAsString("Merge" + i.ToString(), "End" + c.ToString(), "0:0");
                            channel.merged.Add(mergedChannel);
                        }

                        _configFile.Channels.Add(channel);
                    }
                }
            }

            xmlreader.Clear();
            xmlreader.Dispose();
        }