Example #1
0
        public ServerItem GetServerInfo(string serverName)
        {
            string tmpName = serverName.ToLower();

            if (ServerDic.ContainsKey(tmpName))
            {
                return(ServerDic[tmpName]);
            }

            return(null);
        }
Example #2
0
        public void LoadCfg()
        {
            XmlDocument xmlCfg = new XmlDocument();

            xmlCfg.Load(Directory.GetCurrentDirectory() + "/proxy.xml");

            var serverList = xmlCfg.SelectSingleNode("Proxy/ServerSet").ChildNodes;

            foreach (XmlNode node in serverList)
            {
                string serverName = node.Attributes["name"].Value.ToLower();
                string ip         = node.Attributes["ip"].Value;
                int    port       = Convert.ToInt32(node.Attributes["port"].Value);
                string user       = node.Attributes["username"].Value;
                string pwd        = node.Attributes["password"].Value;
                int    maxConn    = Convert.ToInt32(node.Attributes["maxconn"].Value);
                if (!ServerDic.ContainsKey(serverName))
                {
                    ServerDic.Add(serverName, new ServerItem(serverName, ip, port, user, pwd, maxConn));
                }
            }

            var tableList = xmlCfg.SelectSingleNode("Proxy/TableSet").ChildNodes;

            foreach (XmlNode node in tableList)
            {
                string aliasName = node.Attributes["aliasName"].Value.ToLower();
                string tableName = node.Attributes["tableName"].Value;
                string server    = node.Attributes["server"].Value.ToLower();

                if (ServerDic.ContainsKey(server) && !TableDic.ContainsKey(aliasName))
                {
                    TableDic.Add(aliasName, new TableItem(aliasName, tableName, server));
                }
            }
        }