示例#1
0
        public void reload(SettingServer ss)
        {
            XmlDocument xd = new XmlDocument();
            string[] urls = { ss.serverurl, ss.configurl };
            foreach (string url in urls)
            {
                try
                {
                    WebClient wc = new WebClient();
                    //wc.Headers.Add("Connection: keep-alive");
                    wc.Headers.Add("User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7");
                    wc.Headers.Add("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
                    //wc.Headers.Add("Accept-Encoding: gzip,deflate,sdch");
                    wc.Headers.Add("Accept-Language: sv-SE,sv;q=0.8,en-US;q=0.6,en;q=0.4");
                    wc.Headers.Add("Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3");
                    wc.Headers.Add("Cookie: stnetsid=143fbb57965bf491cb54cd3fe99c579b; ip_addresses=1607562521%2C1334492615%2C1607581380%2C1832561699%2C1607553702%2C1306196242%2C1832578173%2C1832567539%2C1334501197%2C1607547521%2C1607581091%2C1334497589%2C1832528682%2C1607545688%2C1832574465%2C1519204042%2C1607559989%2C1519203981%2C1832519925%2C1832580514%2C1832539683%2C1519203750%2C1519203198%2C1832545907%2C1519202764%2C1607538350%2C1832520568%2C1334489887%2C1832579905%2C1519200207%2C1832528448%2C1607559974%2C1832520096%2C1607555046%2C1832579579%2C1519200619%2C3566735255");

                    wc.Encoding = Encoding.UTF8;
                    string strXml = wc.DownloadString(url);
                    xd.LoadXml(strXml);
                    XmlElement xe = xd.DocumentElement;
                    foreach (PropertyInfo pi in this.GetType().GetProperties().Where(x => x.PropertyType == typeof(string)))
                    {

                        XmlNode xn = xd.SelectSingleNode("//settings/" + pi.Name);
                        if (xn != null)
                        {
                            pi.SetValue(this, xn.InnerText, null);
                        }
                    }
                    XmlNode xnc = xd.SelectSingleNode("//settings/client");
                    if (xnc != null)
                    {
                        this.client = new Client();
                        foreach (PropertyInfo pi in this.client.GetType().GetProperties().Where(x => x.PropertyType == typeof(string)))
                        {
                            XmlAttribute xatt = xnc.Attributes[pi.Name];
                            if (xatt != null)
                            {
                                pi.SetValue(this.client, xatt.Value, null);
                            }
                        }
                    }
                    if (xd.SelectNodes("//settings/servers/server").Count > 0)
                    {
                        servers = new List<Server>();
                        foreach (XmlNode xn in xd.SelectNodes("//settings/servers/server"))
                        {
                            Server server = new Server(xn);
                            if (!servers.Any(x => x.name.Equals(server.name)))
                                servers.Add(server);
                        }
                    }
                }
                catch { }
            }
            if (SettingsRefreshed != null)
                SettingsRefreshed.Invoke(this, EventArgs.Empty);
        }
示例#2
0
文件: Form1.cs 项目: bangush/csharp
 private void cBSettings_SelectedValueChanged(object sender, EventArgs e)
 {
     if ((sender as ComboBox).SelectedItem != null)
     {
         SettingServer ss = (sender as ComboBox).SelectedItem as SettingServer;
         if (ss != null)
         {
             reloadServers(ss);
         }
     }
 }
示例#3
0
文件: Form1.cs 项目: bangush/csharp
 private void reloadServers(SettingServer ss)
 {
     try
     {
         if (ss != null)
         {
             settingserver = ss;
             bks.reload(settingserver);
             comboBox1.DataSource    = bks.ClosestServers.Take(50).ToList();
             comboBox1.DisplayMember = "Name";
         }
     }
     catch { }
 }
示例#4
0
 public bksettings(SettingServer ss)
 {
     reload(ss);
 }
示例#5
0
        public void reload(SettingServer ss)
        {
            XmlDocument xd = new XmlDocument();

            string[] urls = { ss.serverurl, ss.configurl };
            foreach (string url in urls)
            {
                try
                {
                    WebClient wc = new WebClient();
                    //wc.Headers.Add("Connection: keep-alive");
                    wc.Headers.Add("User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7");
                    wc.Headers.Add("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
                    //wc.Headers.Add("Accept-Encoding: gzip,deflate,sdch");
                    wc.Headers.Add("Accept-Language: sv-SE,sv;q=0.8,en-US;q=0.6,en;q=0.4");
                    wc.Headers.Add("Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3");
                    wc.Headers.Add("Cookie: stnetsid=143fbb57965bf491cb54cd3fe99c579b; ip_addresses=1607562521%2C1334492615%2C1607581380%2C1832561699%2C1607553702%2C1306196242%2C1832578173%2C1832567539%2C1334501197%2C1607547521%2C1607581091%2C1334497589%2C1832528682%2C1607545688%2C1832574465%2C1519204042%2C1607559989%2C1519203981%2C1832519925%2C1832580514%2C1832539683%2C1519203750%2C1519203198%2C1832545907%2C1519202764%2C1607538350%2C1832520568%2C1334489887%2C1832579905%2C1519200207%2C1832528448%2C1607559974%2C1832520096%2C1607555046%2C1832579579%2C1519200619%2C3566735255");

                    wc.Encoding = Encoding.UTF8;
                    string strXml = wc.DownloadString(url);
                    xd.LoadXml(strXml);
                    XmlElement xe = xd.DocumentElement;
                    foreach (PropertyInfo pi in this.GetType().GetProperties().Where(x => x.PropertyType == typeof(string)))
                    {
                        XmlNode xn = xd.SelectSingleNode("//settings/" + pi.Name);
                        if (xn != null)
                        {
                            pi.SetValue(this, xn.InnerText, null);
                        }
                    }
                    XmlNode xnc = xd.SelectSingleNode("//settings/client");
                    if (xnc != null)
                    {
                        this.client = new Client();
                        foreach (PropertyInfo pi in this.client.GetType().GetProperties().Where(x => x.PropertyType == typeof(string)))
                        {
                            XmlAttribute xatt = xnc.Attributes[pi.Name];
                            if (xatt != null)
                            {
                                pi.SetValue(this.client, xatt.Value, null);
                            }
                        }
                    }
                    if (xd.SelectNodes("//settings/servers/server").Count > 0)
                    {
                        servers = new List <Server>();
                        foreach (XmlNode xn in xd.SelectNodes("//settings/servers/server"))
                        {
                            Server server = new Server(xn);
                            if (!servers.Any(x => x.name.Equals(server.name)))
                            {
                                servers.Add(server);
                            }
                        }
                    }
                }
                catch { }
            }
            if (SettingsRefreshed != null)
            {
                SettingsRefreshed.Invoke(this, EventArgs.Empty);
            }
        }
示例#6
0
 public bksettings(SettingServer ss)
 {
     reload(ss);
 }
示例#7
0
文件: Form1.cs 项目: Hagser/csharp
        private void reloadServers(SettingServer ss)
        {

            try
            {
                if (ss != null)
                {
                    settingserver = ss;
                    bks.reload(settingserver);
                    comboBox1.DataSource = bks.ClosestServers.Take(50).ToList();
                    comboBox1.DisplayMember = "Name";
                }
            }
            catch { }
        }