예제 #1
0
 private long GetPackVersion(ConfigPack cfg)
 {
     foreach (var installed in Program.ProgramSettings.InstalledConfigs)
     {
         if (cfg.URL.Trim('/') == installed.Key)
             return installed.Value;
     }
     return 0L;
 }
예제 #2
0
    private void ReadConfigsIndex()
    {
        XmlTextReader reader = new XmlTextReader(Program.ProgramSettings.ConfigsIndexURL);

        ConfigPack temp = new ConfigPack();
        while (reader.Read())
        {
            if (temp.FriendlyName != null && temp.URL != null && temp.upd != 0)
                temp = new ConfigPack();
            switch (reader.NodeType)
            {
                case XmlNodeType.Element:
                    if (reader.Name == "cpack-index-sheet")
                        continue;
                    //Console.Write("<{0}", reader.Name);
                    while (reader.MoveToNextAttribute())
                    {
                        //Console.Write(" {0}='{1}'", reader.Name, reader.Value);
                        switch (reader.Name)
                        {
                            case "name":
                                temp.FriendlyName = reader.Value;
                                break;
                            case "upd":
                                temp.upd = int.Parse(reader.Value);
                                break;
                        }

                    }
                    //Console.Write(">");
                    break;
                case XmlNodeType.Text:
                    //Console.WriteLine(reader.Value);
                    temp.URL = reader.Value;
                    if (temp.URL != null && temp.FriendlyName != null)
                        ConfigList.Add(temp);
                    break;
                case XmlNodeType.EndElement:
                    //Console.WriteLine("</{0}>", reader.Name);
                    if (temp.URL != null && temp.FriendlyName != null)
                        ConfigList.Add(temp);
                    break;
            }

        }
    }
예제 #3
0
    private static ConfigPackInformation ReadPackInformation(ConfigPack selected)
    {
        WebClient wc = new WebClient();
        string fullXmlText = wc.DownloadString(Program.ProgramSettings.ConfigsRepoURL + selected.URL + "pge_cpack.xml");
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(fullXmlText);

        ConfigPackInformation cpi = new ConfigPackInformation();

        foreach (XmlNode node in doc.DocumentElement.ChildNodes)
        {
            if(cpi.PackName == null)
                cpi.PackName = node.ParentNode.Attributes["name"].Value;
            switch (node.Name)
            {
                case("head"):
                    cpi = IterateThroughHead(node, cpi);
                    break;
                case("files"):
                    if (node.HasChildNodes)
                    {
                        foreach (XmlNode fileNode in node.ChildNodes)
                        {
                            if (fileNode.Name == "file")
                            {
                                FilesStruct temp = new FilesStruct();
                                //temp.Platform = (fileNode.Attributes["platform"].Value);
                                temp.Folder = (fileNode.Attributes["folder"].Value == null) ? "" : fileNode.Attributes["folder"].Value;
                                temp.URL = fileNode.InnerText;

                                if (temp.URL != null && temp.Folder != null)
                                    cpi.FilesParts.Add(temp);
                            }
                        }
                    }
                    break;
            }
        }
        if (cpi.SplashURL != null && cpi.SplashURL != "")
            cpi.SplashURL = Program.ProgramSettings.ConfigsRepoURL + selected.URL + cpi.SplashURL;
        if (cpi.IconURL != null && cpi.IconURL != "")
            cpi.IconURL = Program.ProgramSettings.ConfigsRepoURL + selected.URL + cpi.IconURL;
        return cpi;
    }