示例#1
0
        public void DoSearch(bool cnproxyChecked, bool minidailiChecked, bool proxycnChecked)
        {
            IsStop = false;
            string remoteSite = "http://www.alibaba.com";
            IList<string> ipList = new List<string>();
            if (cnproxyChecked && !IsStop)
            {
                ipList = SearchIpAddressFromCnproxy(ipList);
                LogToLabelAndFile( "www.cnproxy.com search proxy number " + ipList.Count);
            }
            if (minidailiChecked && !IsStop)
            {
                ipList = SearchIpAddressFromMinidaili(ipList);
                LogToLabelAndFile("www.minidaili.com search proxy number " + ipList.Count);
            }
            if (proxycnChecked && !IsStop)
            {
                ipList = SearchIpAddressFromProxycn(ipList);
                LogToLabelAndFile("www.proxycn.com search proxy number " + ipList.Count);
            }
            IList<string> validIpList = new List<string>();
            LogToLabelAndFile(ipList.Count + " == valid IP Address.");
            DAO.UpdateAllProxyToDisabled();
            foreach (string ipAddress in ipList)
            {
                LogToLabelAndFile("start check proxy address " + ipAddress + "...");
                Boolean isValid = HttpUtils.CheckProxyIP(ipAddress, remoteSite);
                if (isValid)
                {
                    ProxyIpModel model = new ProxyIpModel();
                    model.Ip = ipAddress;
                    model.IpDesc = HttpUtils.GetIPAddressLocationFormYouDao(ipAddress.Split(':')[0]);
                    model.UseNumber = 0;
                    model.LastUseTime = DateTime.Now;
                    model.CheckTime = DateTime.Now;
                    model.Enabled = true;
                    validIpList.Add(ipAddress);
                    CheckSuccessEvent(this, new MyEventArgs(model));
                    LogToLabelAndFile(ipAddress + " is valid proxy address, location is [" + model.IpDesc + "]");
                }
                if (IsStop)
                {
                    validIpList = null;
                    ipList = null;
                    return;
                }
            }

            LogToLabelAndFile("Search proxy address end. total:" + validIpList.Count + "/" + ipList.Count);
            validIpList = null;
            ipList = null;
        }
示例#2
0
文件: DAO.cs 项目: rew170/soomecode
 public static void AddProxy(ProxyIpModel model)
 {
     string sql = "insert into proxy_ip_list (ip,ip_desc,check_time,use_number,last_use_time,enabled) values(@1, @2, @3, @4, @5, @6)";
     object[] parampters = new object[]
     {
         model.Ip.Trim(),
         model.IpDesc.Trim(),
         model.CheckTime,
         model.UseNumber,
         model.LastUseTime,
         model.Enabled
     };
     SQLiteHelper.ExecuteNonQuery(connectionString, sql, parampters);
 }
示例#3
0
文件: DAO.cs 项目: rew170/soomecode
 public static int UpdateProxy(ProxyIpModel model)
 {
     string sql = "update proxy_ip_list  set check_time = @1, enabled = @2 where ip= @3";
     object[] parampters = new object[]{ model.CheckTime, model.Enabled, model.Ip};
     return SQLiteHelper.ExecuteNonQuery(connectionString, sql, parampters);
 }
示例#4
0
文件: DAO.cs 项目: rew170/soomecode
 public static IList<ProxyIpModel> GetEnableProxyList()
 {
     string sql = "select id,ip,ip_desc from proxy_ip_list where enabled = 1 order by last_use_time asc ";
     DataSet ds =  SQLiteHelper.ExecuteDataSet(connectionString, sql, null);
     IList<ProxyIpModel> list = new List<ProxyIpModel>();
     if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
     {
         ProxyIpModel model = null;
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             model = new ProxyIpModel();
             model.Id = (Int64)dr[0];
             model.Ip = (string)dr[1];
             model.IpDesc = (string)dr[2];
             list.Add(model);
         }
     }
     return list;
 }