public TableItem GetTableInfo(string tableName) { string tmpName = tableName.ToLower(); if (TableDic.ContainsKey(tmpName)) { return(TableDic[tmpName]); } else if (tmpName.EndsWith(".snapshot")) { tmpName = tmpName.Substring(0, tmpName.Length - 9); if (TableDic.ContainsKey(tmpName)) { return(new TableItem(tmpName, TableDic[tmpName].TableName + ".snapshot", TableDic[tmpName].ServerName)); } } return(null); }
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)); } } }