예제 #1
0
        public void playBetLive(ticket o, string money, string IsLive, string phieuchung, string group)
        {
            bool   doBet    = true;
            string betGroup = group.Split(',')[1];

            this.phieuchung = phieuchung;
            int    usdbet    = int.Parse(money) / int.Parse(usd);
            double hdp       = o.hdp;
            string keoid     = o.keoid;
            double odd       = o.odd;
            string bettype   = o.bettype;
            string choose    = o.choose;
            string homescore = o.score.Split('-')[0];
            string awayscore = o.score.Split('-')[1];

            string PostData  = "ItemList[0][sportname]=Soccer&ItemList[0][Hscore]=" + homescore + "&ItemList[0][Ascore]=" + awayscore + "&ItemList[0][type]=OU&ItemList[0][bettype]=" + bettype + "&ItemList[0][oddsid]=" + keoid.Trim() + "&ItemList[0][betteam]=" + choose + "&ItemList[0][stake]=" + usdbet;
            string GetTicket = http.Fetch(mainHost + "/Betting/GetTickets", HttpHelper.HttpMethod.Post, sportLink, PostData, ip);

            if (GetTicket.Replace("\"", "").IndexOf("ErrorCode:0") == -1)
            {
                message = "IBET: [" + username + "] LOG OUT";
            }
            else
            {
                double oddBet       = double.Parse(Util.GetSubstringByString(GetTicket.Replace("\"", ""), "DisplayOdds:", ","));
                int    deviationOdd = UtilSoccer.getDeviationOdd(odd, oddBet);
                if (betGroup == "d" && deviationOdd <= 2)
                {
                    doBet = true;
                }
                else if (betGroup == "c" && deviationOdd <= 1)
                {
                    doBet = true;
                }
                else if (UtilSoccer.CheckOddChange(odd, oddBet) == "Down")
                {
                    doBet   = false;
                    message = "IBET: [" + username + "] Odd Down " + odd + "/" + oddBet;
                    Thread.Sleep(2000);
                }
                if (doBet)
                {
                    if (UtilSoccer.CheckOddChange(odd, oddBet) == "Up")
                    {
                        message = "IBET: [" + username + "] Odd Up " + odd + "/" + oddBet;
                    }
                    string MinBet = Util.GetSubstringByString(GetTicket, "\"Minbet\":\"", "\",");
                    string MaxBet = Util.GetSubstringByString(GetTicket, "Maxbet\":\"", "\",");
                    PostData = PostData + "&ItemList[0][oddsStatus]=&ItemList[0][min]=" + MinBet + "&ItemList[0][max]=" + MaxBet;
                    if (double.Parse(MaxBet) < usdbet)
                    {
                        PostData = PostData.Replace("ItemList[0][stake]=" + usdbet, "ItemList[0][stake]=" + MaxBet);
                        money    = (int.Parse(MaxBet.Replace(",", "")) * int.Parse(usd)).ToString();
                    }
                    string ProcessBet = http.Fetch(mainHost + "/Betting/ProcessBet", HttpHelper.HttpMethod.Post, sportLink, PostData, ip);
                    if (ProcessBet.IndexOf("Đơn cược đã được chấp nhận") < 0 && ProcessBet.IndexOf("Your bet has been accepted") < 0 && ProcessBet.IndexOf("đang được xử lý") < 0)
                    {
                        message = "IBET: [" + username + "] BET FAILED - INFO: " + o.ToString();
                    }
                    else
                    {
                        this.phieuchung = mylib.generateID("T");
                        this.realmoney  = money;
                        db.doInsertTicket("IBET", username, o.bettype, o.hdp.ToString(), o.home, o.away, choose, oddBet.ToString(), money, usd, "* " + group, this.phieuchung);
                        message = "IBET: [" + username + "] BET SUCCESS - INFO: " + o.ToString();
                    }
                }
            }
        }