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();
    }
Beispiel #2
0
    public void Load()
    {
      _ConfigList = new ArrayList();

      string configFile = _strPath + "\\WebEPG.xml";
      if (!File.Exists(configFile))
      {
        return;
      }

      Log.Info("WebEPG Config: Loading Existing WebEPG.xml");
      Xml xmlreader = new Xml(configFile);
      _MaxGrab = xmlreader.GetValueAsInt("General", "MaxDays", 1);
      int channelCount = xmlreader.GetValueAsInt("ChannelMap", "Count", 0);
      for (int i = 1; i <= channelCount; i++)
      {
        EPGConfigData channel = new EPGConfigData();
        channel.ChannelID = xmlreader.GetValueAsString(i.ToString(), "ChannelID", "");
        channel.DisplayName = xmlreader.GetValueAsString(i.ToString(), "DisplayName", "");

        string GrabberID = xmlreader.GetValueAsString(i.ToString(), "Grabber1", "");
        if (GrabberID != "")
        {
          int start = GrabberID.IndexOf("\\") + 1;
          int end = GrabberID.LastIndexOf(".");

          string GrabberSite = GrabberID.Substring(start, end - start);
          GrabberSite = GrabberSite.Replace("_", ".");
          channel.PrimaryGrabberName = GrabberSite;
          channel.PrimaryGrabberID = GrabberID;
          channel.Linked = xmlreader.GetValueAsBool(i.ToString(), "Grabber1-Linked", false);
          channel.linkStart = xmlreader.GetValueAsInt(i.ToString(), "Grabber1-Start", 18);
          channel.linkEnd = xmlreader.GetValueAsInt(i.ToString(), "Grabber1-End", 23);

          _ConfigList.Add(channel);
        }
      }
    }
    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);
              }
            }
          }
        }
      }
    }