Exemplo n.º 1
0
        private void SaveProxiesToXml(HtmlProxyServerCollection service_proxies)
        {
            ProxyRepository <ProxyServer> xmlWriter = new ProxyRepository <ProxyServer>();

            if (!File.Exists(this.path))
            {
                xmlWriter.Clear();
            }
            List <ProxyServer> proxyCollection = new List <ProxyServer>();
            DateTime           defaultLastUsed = DateTime.Now.AddMinutes(-xmlWriter.Interval);

            foreach (HtmlProxyServer service_proxy in service_proxies.HtmlProxies)
            {
                ProxyServer proxy = new ProxyServer();
                if (!xmlWriter.Contains(service_proxy.Ip))
                {
                    if (service_proxy.Ping < 15)
                    {
                        proxy.Priority = 0;
                        proxy.Status   = ProxyStatus.PS_New;
                    }
                    else
                    {
                        proxy.Priority = 1;
                        proxy.Status   = ProxyStatus.PS_Bad;
                    }
                    proxy.Ip       = service_proxy.Ip;
                    proxy.LastUsed = defaultLastUsed;
                    proxy.IsBusy   = false;
                    proxyCollection.Add(proxy);
                }
            }
            xmlWriter.Add(proxyCollection);
        }
Exemplo n.º 2
0
        public void UpdateData(bool clearData, string url)
        {
            ProxyRepository <ProxyServer> writer = new ProxyRepository <ProxyServer>();

            if (clearData)
            {
                writer.Clear();
            }
            this.UpdateData(url);
        }