Esempio n. 1
0
        public string LoadAccountConfig()
        {
            //开始需要清空list
            FormSet.listAccount.Clear();

            string fileConfig = FormSet.getfilename();

            if (fileConfig == "")
            {
                MessageBox.Show("account.xml配置文件不存在,无法登录!");
                return("");
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(fileConfig);

            XmlNode root = doc.LastChild;

            XmlNodeList list = root.ChildNodes;

            for (int i = 0; i < list.Count; i++)
            {
                XmlNodeList sublist = list[i].ChildNodes;

                AccountInfo data = new AccountInfo();

                data.account = sublist[0].InnerText.Trim();

                data.pwd = sublist[1].InnerText.Trim();

                data.serverip = sublist[2].InnerText.Trim();

                data.apitype = sublist[3].InnerText.Trim();

                data.brokeid = sublist[4].InnerText.Trim();

                FormSet.listAccount.Add(data);
            }


            //加载合约

            FormSet.listCodeInfo.Clear();

            FormSet.listIp.Clear();

            fileConfig = FormSet.getcodefilename();

            if (fileConfig == "")
            {
                MessageBox.Show("code.xml配置文件不存在,无法连接行情!");
                return("");
            }

            doc.Load(fileConfig);


            list = doc.SelectNodes("/ranges/codeinfo");

            //list = doc.SelectSingleNode("/ranges").ChildNodes;

            for (int i = 0; i < list.Count; i++)
            {
                XmlNodeList sublist = list[i].ChildNodes;

                CodeInfo data = new CodeInfo();

                string s = sublist[0].Name;

                data.code = sublist[0].InnerText.Trim();

                data.name = sublist[1].InnerText.Trim();

                data.subtype = sublist[2].InnerText.Trim();


                FormSet.listCodeInfo.Add(data);
            }

            list = doc.SelectNodes("/ranges/ip");

            for (int i = 0; i < list.Count; i++)
            {
                XmlNodeList sublist = list[i].ChildNodes;

                foreach (XmlNode xn in sublist)
                {
                    if (xn.Name == "ufx")
                    {
                        FormSet.listIp["ufx"] = xn.InnerText.Trim();
                    }
                    else if (xn.Name == "ctp")
                    {
                        FormSet.listIp["ctp"] = xn.InnerText.Trim();
                    }
                }
            }

            list = doc.SelectNodes("/ranges/port");

            for (int i = 0; i < list.Count; i++)
            {
                XmlNodeList sublist = list[i].ChildNodes;

                FormSet.port = sublist[0].InnerText.Trim();
            }

            if (FormSet.listIp.Count == 0)
            {
                FormSet.listIp["ufx"] = "";
                FormSet.listIp["ctp"] = "";
                MessageBox.Show("尚未配置行情地址!");
            }

            return("ok");
        }
Esempio n. 2
0
        public void LoadConfig()
        {
            //开始需要清空list
            listAccount.Clear();

            fsr.clearFundaccount();

            string fileConfig = getfilename();

            XmlDocument doc = new XmlDocument();

            doc.Load(fileConfig);

            XmlNode root = doc.LastChild;

            XmlNodeList list = root.ChildNodes;

            for (int i = 0; i < list.Count; i++)
            {
                XmlNodeList sublist = list[i].ChildNodes;

                AccountInfo data = new AccountInfo();

                data.account = sublist[0].InnerText.Trim();

                cbbAccount.Items.Add(data.account);

                //加到checkedlist里面
                fsr.addFundaccount(data.account);

                data.pwd = sublist[1].InnerText.Trim();

                data.serverip = sublist[2].InnerText.Trim();

                data.apitype = sublist[3].InnerText.Trim();

                data.brokeid = sublist[4].InnerText.Trim();

                InsertList(data);

                listAccount.Add(data);
            }


            //加载合约

            FormSet.listCodeInfo.Clear();

            listIp.Clear();

            fileConfig = FormSet.getcodefilename();

            doc.Load(fileConfig);

            list = doc.SelectNodes("/ranges/codeinfo");

            for (int i = 0; i < list.Count; i++)
            {
                XmlNodeList sublist = list[i].ChildNodes;

                CodeInfo data = new CodeInfo();

                data.code = sublist[0].InnerText.Trim();

                data.name = sublist[1].InnerText.Trim();

                data.subtype = sublist[2].InnerText.Trim();


                FormSet.listCodeInfo.Add(data);

                InsertCode(data);
            }

            list = doc.SelectNodes("/ranges/ip");

            for (int i = 0; i < list.Count; i++)
            {
                XmlNodeList sublist = list[i].ChildNodes;

                foreach (XmlNode xn in sublist)
                {
                    if (xn.Name == "ufx")
                    {
                        FormSet.listIp["ufx"] = xn.InnerText.Trim();
                    }
                    else if (xn.Name == "ctp")
                    {
                        FormSet.listIp["ctp"] = xn.InnerText.Trim();
                    }
                }
            }

            if (FormSet.listIp.Count == 0)
            {
                FormSet.listIp["ufx"] = "";
                FormSet.listIp["ctp"] = "";
            }
        }