Ejemplo n.º 1
0
        /// <summary>
        /// 得到抽奖的结果
        /// </summary>
        /// <returns></returns>
        public string GetLotteryOpenResult()
        {
            Ku.Common.HttpHelper http     = new Common.HttpHelper();
            HttpItem             httpItem = new HttpItem();

            httpItem.URL         = "http://" + Domain + "/tools/_ajax/cache/lotteryOpenCache";
            httpItem.Method      = "POST";
            httpItem.Postdata    = "{\"requirement\":[\"OG1K3\"]}";
            httpItem.UserAgent   = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36";
            httpItem.Host        = Domain;
            httpItem.Referer     = "http://" + Domain + "/lottery/K3/OG1K3";
            httpItem.ContentType = "application/json";
            httpItem.Cookie      = Cookie;
            HttpResult httpRes = http.GetHtml(httpItem);

            if (httpRes.StatusCode == System.Net.HttpStatusCode.OK)
            {
                requestFailCount = 0;
                string html = httpRes.Html;
                return(html);
            }
            else
            {
                requestFailCount++;
                LogsRecord.write("接口调用异常", "获取开奖结果,次数=" + requestFailCount + ",异常=" + httpRes.Html);
                if (requestFailCount >= requestMaxFailCount)
                {
                    throw new LogException("请求异常," + httpRes.Html);
                }
                return(GetLotteryOpenResult());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取服务器的时间
        /// </summary>
        /// <returns></returns>
        public long getServerTimeMillisecond()
        {
            Ku.Common.HttpHelper http     = new Common.HttpHelper();
            HttpItem             httpItem = new HttpItem();

            httpItem.URL              = "http://" + Domain + "/tools/_ajax/getServerTimeMillisecond";
            httpItem.Method           = "POST";
            httpItem.Postdata         = "{\"requirement\":[\"OG1K3\"]}";
            httpItem.UserAgent        = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36";
            httpItem.Host             = Domain;
            httpItem.Referer          = "http://" + Domain + "/lottery/K3/OG1K3";
            httpItem.ContentType      = "application/json";
            httpItem.Cookie           = Cookie;
            httpItem.ReadWriteTimeout = 10000;
            HttpResult httpRes = http.GetHtml(httpItem);

            if (httpRes.StatusCode == System.Net.HttpStatusCode.OK)
            {
                requestFailCount = 0;
                string html = httpRes.Html;
                JsonServerTimeMillisecond res = Util.DeserializeObject <JsonServerTimeMillisecond>(html);
                return(res.data.serverTime);
            }
            else
            {
                requestFailCount++;
                LogsRecord.write("接口调用异常", "获取服务时间,次数=" + requestFailCount + ",异常=" + httpRes.Html);
                if (requestFailCount >= requestMaxFailCount)
                {
                    throw new LogException("请求异常," + httpRes.Html);
                }
                return(getServerTimeMillisecond());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 投注
        /// </summary>
        /// <returns></returns>
        public string BetSingle(string issueNo, double money, JJBetEnum codes)
        {
            ResBetSingle resEntity = new ResBetSingle();

            resEntity.accountId  = accountId;
            resEntity.clientTime = 1234;
            resEntity.gameId     = gameId;
            resEntity.issue      = issueNo;
            List <BetEntity> betList = new List <BetEntity>();

            betList.Add(new BetEntity()
            {
                methodid = "",
                nums     = 1,    //数量
                rebate   = 0.00, //回扣
                times    = money.ToString(),
                money    = money,
                mode     = 1,
                issueNo  = issueNo,
                codes    = codes.ToString(),
                playId   = new string[] { "K3002001010" }
            });
            resEntity.item = betList.ToArray();

            Ku.Common.HttpHelper http     = new Common.HttpHelper();
            HttpItem             httpItem = new HttpItem();

            httpItem.URL         = "http://" + Domain + "/tools/_ajax/cache/lotteryOpenCache";
            httpItem.Method      = "POST";
            httpItem.Postdata    = "{\"requirement\":[\"OG1K3\"]}";
            httpItem.UserAgent   = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36";
            httpItem.Host        = Domain;
            httpItem.Referer     = "http://" + Domain + "/lottery/K3/OG1K3";
            httpItem.ContentType = "application/json";
            httpItem.Cookie      = Cookie;
            HttpResult httpRes = http.GetHtml(httpItem);

            if (httpRes.StatusCode == System.Net.HttpStatusCode.OK)
            {
                requestFailCount = 0;
                string html = httpRes.Html;
                return(html);
            }
            else
            {
                requestFailCount++;
                LogsRecord.write("接口调用异常", "投注,次数=" + requestFailCount + ",异常=" + httpRes.Html);
                if (requestFailCount >= requestMaxFailCount)
                {
                    throw new LogException("请求异常," + httpRes.Html);
                }
                return(BetSingle(issueNo, money, codes));
            }
        }
Ejemplo n.º 4
0
        private int requestMaxFailCount = 3;//请求允许次数

        #region 登陆账号
        public bool Login(string uName, string pwd, string phone = "1540139107855")
        {
            _userName = uName;
            _password = pwd;
            _phone    = phone;

            string md5Pwd = Ku.Common.MD5Helper.MD5Encrypt(pwd);

            Ku.Common.HttpHelper http     = new Common.HttpHelper();
            HttpItem             httpItem = new HttpItem();

            httpItem.URL = "http://" + Domain + "/tools/_ajax/login";
            //httpItem.Postdata = "{\"requirement\":[\"OG1K3\"]}";
            httpItem.Postdata = "{\"loginName\":\"" + _userName + "\",\"loginPwd\":\"" + md5Pwd + "\",\"validCode\":\"\",\"validateDate\":\"" + phone + "\",\"isdefaultLogin\":true}";

            httpItem.Method      = "POST";
            httpItem.UserAgent   = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36";
            httpItem.Host        = Domain;
            httpItem.Cookie      = Cookie;
            httpItem.ContentType = "application/json";
            httpItem.Referer     = "http://" + Domain + "/login";
            HttpResult httpRes = http.GetHtml(httpItem);

            if (httpRes.StatusCode == System.Net.HttpStatusCode.OK)
            {
                requestFailCount = 0;
                string       html  = httpRes.Html;
                JsonUserInfo jsonR = Util.DeserializeObject <JsonUserInfo>(html);
                string       code  = jsonR.code;
                if (code == "success")
                {
                    Cookie    = httpRes.Cookie;
                    accountId = jsonR.data.user.userDetail.accountId;
                    money     = jsonR.data.user.money;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                requestFailCount++;
                LogsRecord.write("接口调用异常", "重新登录,次数=" + requestFailCount + ",异常=" + httpRes.Html);
                if (requestFailCount >= requestMaxFailCount)
                {
                    throw new LogException("请求异常," + httpRes.Html);
                }
                return(Login(uName, pwd, phone));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取余额
        /// </summary>
        /// <returns></returns>
        public double GetUserBanlance()
        {
            Ku.Common.HttpHelper http     = new Common.HttpHelper();
            HttpItem             httpItem = new HttpItem();

            httpItem.URL         = "http://" + Domain + "/tools/_ajax//getUserBanlance";
            httpItem.Method      = "POST";
            httpItem.Postdata    = "{\"userName\": \"" + _userName + "\"}";
            httpItem.UserAgent   = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36";
            httpItem.Host        = Domain;
            httpItem.Referer     = "http://" + Domain + "/home";
            httpItem.ContentType = "application/json";
            httpItem.Cookie      = Cookie;
            HttpResult httpRes = http.GetHtml(httpItem);

            if (httpRes.StatusCode == System.Net.HttpStatusCode.OK)
            {
                requestFailCount = 0;
                string           html     = httpRes.Html;
                JsonUserBanlance jsResult = Util.DeserializeObject <JsonUserBanlance>(html);
                string           code     = jsResult.code;
                if (code == "success")
                {
                    return(jsResult.data.money);
                }
                else
                {
                    if (code == "nologin")
                    {
                        RepeatLogin();
                    }
                    return(GetUserBanlance());
                }
            }
            else
            {
                requestFailCount++;
                LogsRecord.write("接口调用异常", "获取余额,次数=" + requestFailCount + ",异常=" + httpRes.Html);
                if (requestFailCount >= requestMaxFailCount)
                {
                    throw new LogException("请求异常," + httpRes.Html);
                }
                return(GetUserBanlance());
            }
        }
Ejemplo n.º 6
0
        private void DoThreadTask()
        {
            while (true)
            {
                try
                {
                    var  list    = GetBetList();
                    long issueNo = list[0].issueNo;
                    if (issueNo != oldIssueNo)
                    {
                        oldIssueNo = issueNo;
                        //监听重复次数
                        //从api获取最新50条记录信息
                        var    repeatDxCount = GetDaxiaoRepeatTimes(list);
                        var    repeatDSount  = GetDanshuangRepeatTimes(list);
                        string message       = "检测重复次数,大小=" + repeatDxCount + ",单双=" + repeatDSount;
                        msg(message);
                        if (repeatDxCount > 6 || repeatDSount > 6)
                        {
                            //string message = "检测重复次数,大小=" + repeatDxCount + ",单双=" + repeatDSount;
                            //msg(message);
                            //连续出现6次 提示


                            StartNotify(message);
                            int num = repeatDxCount;
                            if (repeatDSount > repeatDxCount)
                            {
                                num = repeatDSount;
                            }
                            TipsSound(num);
                        }
                    }
                    Thread.Sleep(1000 * 10);
                }
                catch (Exception ex)
                {
                    LogsRecord.write("异常", ex.ToString());
                    Thread.Sleep(1000 * 10);
                }
            }
        }
Ejemplo n.º 7
0
        protected void Show(string type, string content, DebugType debugType = DebugType.LogOnly)
        {
            switch (debugType)
            {
            case DebugType.MsgOnly:
                msg(content);
                break;

            case DebugType.LogOnly:
                LogsRecord.write(type, content);
                break;

            case DebugType.Both:
                msg(content);
                LogsRecord.write(type, content);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 8
0
        private void DoTask()
        {
            try
            {
                bool b = Login();
                if (!b)
                {
                    md.msg("登录失败");
                    Login();
                }
                ProofSecond();
                new Thread(DoThreadDownTime).Start();
                new Thread(DoThreadPickTask).Start();
            }
            catch (Exception ex)
            {
                LogsRecord.write("Error-DoTask", ex.ToString());

                DoTask();
                Thread.Sleep(10000);
            }
        }
Ejemplo n.º 9
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     LogsRecord.write("UnknownError(在发生未捕获线程异常时发生)", e.Exception.ToString());
 }
Ejemplo n.º 10
0
 static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     LogsRecord.write("UnknownError(当某个异常未被捕获时出现)", e.ExceptionObject.ToString());
 }