コード例 #1
0
        public void InitProxyHashSet(string url, DaiLiType daiLiType, string postData = null)
        {
            var httpHelper = new HttpHelper();

            string html;

            switch (daiLiType)
            {
            case DaiLiType.DaXiangDaiLi:
                html = httpHelper.GetHtmlByPost(url, postData);
                var matchCollectionDaXiang = Regex.Matches(html, @"\d+\.\d+\.\d+\.\d+:\d+");
                foreach (Match match in matchCollectionDaXiang)
                {
                    var value = match.Value;
                    //Add时如果HashSet中存在,则不会Add进去
                    _proxyHashSetSet.Add(value);
                    _notUsedHashSet.Add(value);
                }
                break;

            case DaiLiType.KuaiDaiLi:
                html = httpHelper.GetHtmlByGet(url);
                var matchCollectionKuai = Regex.Matches(html, @"\d+\.\d+\.\d+\.\d+:\d+");
                foreach (Match match in matchCollectionKuai)
                {
                    var value = match.Value;
                    //Add时如果HashSet中存在,则不会Add进去
                    _proxyHashSetSet.Add(value);
                    _notUsedHashSet.Add(value);
                }
                break;

            case DaiLiType.XDaiLi:
                html = httpHelper.GetHtmlByGet(url);
                var jObject = JObject.Parse(html);
                var jArray  = JArray.Parse(jObject["RESULT"].ToString());
                foreach (var jToken in jArray)
                {
                    var proxy = $"{jToken["ip"]}:{jToken["port"]}";
                    //Add时如果HashSet中存在,则不会Add进去
                    _proxyHashSetSet.Add(proxy);
                    _notUsedHashSet.Add(proxy);
                }
                break;
            }


            ////浅复制 不是想要的结果
            //_notUsedHashSet = _proxyHashSetSet;
        }
コード例 #2
0
        /// <summary>
        /// 修改当前系统代理的库存(比如发邮件减少代理的库存
        /// </summary>
        /// <param name="Gold">在原有基础上的增减值,比如Gold=-100,则在原有库存上减去100</param>
        /// <returns></returns>
        internal static int UpdateDaiLiKuCun(int no, Int64 Gold, DaiLiType type)
        {
            string otherDBSqlCon = GetDaiLiConnection(no, 2);



            using (var cn = new MySqlConnection(otherDBSqlCon))
            {
                cn.Open();

                StringBuilder str = new StringBuilder();
                //使用存储过程,这样方便回滚
                str.AppendFormat(@"sys_updateDaiLiKuCun");

                int i = cn.Execute(str.ToString(), param: new {
                    I_Gold = Gold, I_OperType = Convert.ToInt32(type)
                }, commandType: CommandType.StoredProcedure);

                cn.Close();

                return(i);
            }
        }
コード例 #3
0
ファイル: DaiLiBLL.cs プロジェクト: singlag888/NewWeb
 public static int UpdateDaiLiKuCun(int no, Int64 Gold, DaiLiType type = DaiLiType.充值库存)
 {
     return(DaiLiDAL.UpdateDaiLiKuCun(no, Gold, type));
 }