コード例 #1
0
        public void Save()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(WOTHelper.GetUserFile());
            XmlElement root       = xmlDoc.DocumentElement;
            XmlNode    oldPlayers = root.SelectSingleNode(@"FTPDetails");

            root.RemoveChild(oldPlayers);

            XmlElement players = xmlDoc.CreateElement("FTPDetails");

            root.AppendChild(players);

            XmlElement playerNode;

            playerNode = xmlDoc.CreateElement("FTP");
            playerNode.SetAttribute("FTPHost", Host);
            playerNode.SetAttribute("FTPUserID", UserID);
            playerNode.SetAttribute("FTPUserPWD", WOTHelper.Encrypt(UserPWD));
            playerNode.SetAttribute("ShareFiles", AllowFTP == true ? "Yes" : "No");
            players.AppendChild(playerNode);


            xmlDoc.Save(WOTHelper.GetUserFile());
        }
コード例 #2
0
        private static void Save(string id, object value)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(WOTHelper.GetUserFile());
            XmlElement root         = xmlDoc.DocumentElement;
            XmlNode    settingGroup = root.SelectSingleNode("AppSettings");

            if (settingGroup == null)
            {
                settingGroup = xmlDoc.CreateElement("AppSettings");
                root.AppendChild(settingGroup);
            }

            XmlElement iSetting = (XmlElement)root.SelectSingleNode(string.Format(@"AppSettings/Setting[@Key=""{0}""]", id));

            if (iSetting == null)
            {
                iSetting = xmlDoc.CreateElement("Setting");
                settingGroup.AppendChild(iSetting);
            }


            iSetting.SetAttribute("Key", id);
            iSetting.SetAttribute("Value", value.ToString());

            xmlDoc.Save(WOTHelper.GetUserFile());
        }
コード例 #3
0
        private static object GetDetails(string id)
        {
            object      retValue = null;
            XmlDocument xmlDoc   = new XmlDocument();

            XmlNode node = null;

            try
            {
                xmlDoc.Load(WOTHelper.GetUserFile());
                XmlElement root = xmlDoc.DocumentElement;

                node = root.SelectSingleNode(string.Format(@"AppSettings/Setting[@Key=""{0}""]", id));
            }
            catch { }

            if (node != null)
            {
                retValue = node.Attributes["Value"] == null ? null : node.Attributes["Value"].Value;
            }
            else
            {
                retValue = null;
            }

            return(retValue);
        }
コード例 #4
0
        private void ReadGraphSettings()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(WOTHelper.GetUserFile());
            XmlElement root = xmlDoc.DocumentElement;

            if (root.SelectSingleNode(@"Graphs") != null)
            {
                XmlNodeList nodes = root.SelectSingleNode(@"Graphs").ChildNodes;
                if (nodes != null)
                {
                    foreach (XmlNode node in nodes)
                    {
                        if (!_graphCollection.ContainsKey(node.Attributes["Name"].Value))
                        {
                            _graphCollection.Add(node.Attributes["Name"].Value, new GraphFields()
                            {
                                Name      = node.Attributes["Name"].Value,
                                Caption   = node.Attributes["Caption"].Value,
                                DataField = node.Attributes["DataField"].Value,
                                InnerText = node.InnerText,
                                Period    = int.Parse(node.Attributes["Period"].Value),
                                Type      = node.Attributes["Type"].Value,
                                StatsBase = node.Attributes["StatsBase"].Value
                            });
                        }
                    }
                }
            }
        }
コード例 #5
0
        public CustomGrouping(MessageQueue message)
        {
            _message = message;
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(WOTHelper.GetUserFile());
            XmlElement  root  = xmlDoc.DocumentElement;
            XmlNodeList nodes = root.SelectSingleNode(@"CustomGroups").ChildNodes;

            foreach (XmlNode node in nodes)
            {
                if (!_customGroupings.ContainsKey(node.Attributes["Name"] == null ? "" : node.Attributes["Name"].Value))
                {
                    _customGroupings.Add(node.Attributes["Name"] == null ? "" : node.Attributes["Name"].Value, new Tuple <string, string>(node.Attributes["Caption"] == null ? "" : node.Attributes["Caption"].Value, node.InnerText));
                }
            }
        }
コード例 #6
0
        private void GetFTPDetails()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(WOTHelper.GetUserFile());
            XmlElement  root  = xmlDoc.DocumentElement;
            XmlNodeList nodes = root.SelectSingleNode(@"FTPDetails").ChildNodes;
            int         i     = 0;

            foreach (XmlNode node in nodes)
            {
                Host     = node.Attributes["FTPHost"] == null ? "" : node.Attributes["FTPHost"].Value;
                UserID   = node.Attributes["FTPUserID"] == null ? "" : node.Attributes["FTPUserID"].Value;
                UserPWD  = WOTHelper.Decrypt(node.Attributes["FTPUserPWD"] == null ? "" : node.Attributes["FTPUserPWD"].Value);
                AllowFTP = node.Attributes["ShareFiles"] == null ? false : node.Attributes["ShareFiles"].Value == "Yes" ? true : false;
                i++;
            }
        }
コード例 #7
0
        public void Save(GraphFields fields)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(WOTHelper.GetUserFile());
            XmlElement  root            = xmlDoc.DocumentElement;
            XmlNodeList oldCustomGroups = root.SelectNodes("Graphs/Graph[@Name='" + fields.Name + "']");
            XmlNode     customGroups    = root.SelectSingleNode("Graphs");
            XmlElement  customGroup     = null;

            if (oldCustomGroups.Count != 0)
            {
                foreach (XmlNode item in oldCustomGroups)
                {
                    customGroup = (XmlElement)item;
                }
            }
            else
            {
                customGroup = xmlDoc.CreateElement("Graph");
            }

            customGroup.SetAttribute("Name", fields.Name.Replace(" ", "_"));
            customGroup.SetAttribute("Caption", fields.Caption);
            customGroup.SetAttribute("StatsBase", fields.StatsBase);
            customGroup.SetAttribute("Type", fields.Type);
            customGroup.SetAttribute("DataField", fields.DataField);
            customGroup.SetAttribute("Period", fields.Period.ToString());
            customGroup.InnerText = fields.InnerText;

            if (customGroups == null)
            {
                customGroups = xmlDoc.CreateElement("Graphs");
                root.AppendChild(customGroups);
            }

            if (oldCustomGroups.Count == 0)
            {
                customGroups.AppendChild(customGroup);
            }

            xmlDoc.Save(WOTHelper.GetUserFile());
        }
コード例 #8
0
        public void Refresh()
        {
            _players.Clear();
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(WOTHelper.GetUserFile());
            XmlElement  root  = xmlDoc.DocumentElement;
            XmlNodeList nodes = root.SelectSingleNode(@"Players").ChildNodes;
            int         i     = 0;

            foreach (XmlNode node in nodes)
            {
                string sRealm = string.Empty;

                if (node.Attributes["Realm"] == null)
                {
                    //XmlAttribute oAttr = new XmlAttribute();
                    //oAttr.InnerText = "Realm";
                    //node.Attributes.Append(oAttr);
                    sRealm = "worldoftanks.eu";
                }
                else
                {
                    sRealm = node.Attributes["Realm"].Value;
                }


                _players.Add(node.Attributes["ID"].Value.Replace("_", "*"), new Player()
                {
                    PlayerID     = node.Attributes["ID"].Value,
                    PlayerRealm  = sRealm,
                    WatchFile    = node.Attributes["WatchFile"].Value,
                    Monitor      = node.Attributes["Monitor"].Value,
                    PreviousFile = node.Attributes["FileA"] == null ? "1" : node.Attributes["FileA"].Value,
                    CurrentFile  = node.Attributes["FileB"] == null ? "0" : node.Attributes["FileB"].Value,
                    OnlineURL    = (node.Attributes["OnlineURL"] == null) ? "#" : node.Attributes["OnlineURL"].Value == "" ? "#" : node.Attributes["OnlineURL"].Value
                });
                i++;
            }
        }
コード例 #9
0
        public void Remove(string name)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(WOTHelper.GetUserFile());
            XmlElement  root            = xmlDoc.DocumentElement;
            XmlNodeList oldCustomGroups = root.SelectNodes(string.Format(@"CustomGroups/CustomGroup[@Name=""{0}""]", name.Replace(" ", "_")));

            try
            {
                foreach (XmlNode item in oldCustomGroups)
                {
                    item.ParentNode.RemoveChild(item);
                }
            }
            catch
            {
                _message.Add("Info : cant find item in settings.");
            }

            xmlDoc.Save(WOTHelper.GetUserFile());
        }
コード例 #10
0
        public void Save()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(WOTHelper.GetUserFile());

            if (xmlDoc.FirstChild.NodeType == XmlNodeType.XmlDeclaration)
            {
                XmlDeclaration dec = (XmlDeclaration)xmlDoc.FirstChild;
                dec.Encoding = "UTF-8";
            }

            XmlElement root = xmlDoc.DocumentElement;

            XmlNode oldPlayers = root.SelectSingleNode(@"Players");

            root.RemoveChild(oldPlayers);

            XmlElement players = xmlDoc.CreateElement("Players");

            root.AppendChild(players);

            XmlElement playerNode;

            foreach (KeyValuePair <string, Player> player in _players)
            {
                playerNode = xmlDoc.CreateElement("Player");
                playerNode.SetAttribute("ID", player.Value.PlayerID);
                playerNode.SetAttribute("Realm", player.Value.PlayerRealm);
                playerNode.SetAttribute("WatchFile", player.Value.WatchFile);
                playerNode.SetAttribute("Monitor", player.Value.Monitor);
                playerNode.SetAttribute("FileA", player.Value.PreviousFile);
                playerNode.SetAttribute("FileB", player.Value.CurrentFile);
                playerNode.SetAttribute("OnlineURL", player.Value.OnlineURL);
                players.AppendChild(playerNode);
            }

            xmlDoc.Save(WOTHelper.GetUserFile());
        }