public void playBetLive(ticket o, string money, string IsLive, string phieuchung, string group, bool AutoAccept = true)
        {
            o = GetKeoSbo(lstSboLiveBet, o);
            if (o != null)
            {
                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 hdpType = "";
                if (bettype == "7" || bettype == "9")
                {
                    hdpType = "2";
                }

                string UrlTicketSbo = "http://" + Util.GetSubstringByString(welcomeLink, "http://", "&").Replace("default", "ticket/ticket") + "&id=" + keoid + "&op=" + choose + "&odds=" + odd + "&hdpType=" + hdpType + "&isor=0&isLive=" + IsLive + "&betpage=18&style=1";
                string UrlBetSbo    = "http://" + Util.GetSubstringByString(welcomeLink, "http://", "&").Replace("default", "ticket/confirm") + "&sameticket=0&betcount=" + betcount + "&stake=" + usdbet.ToString() + "&ostyle=1&stakeInAuto=10&betpage=18&acceptIfAny=0&autoProcess=0&autoRefresh=1&oid=" + keoid + "&timeDiff=2100";

                string data1        = http.Fetch(UrlTicketSbo, HttpHelper.HttpMethod.Get, welcomeLink, null, ip, "ContentLength=0");
                string oddbet       = Util.GetSubstringByString(data1.Replace("'", "").Replace("Over", "h").Replace("Under", "a").Replace("Tài", "h").Replace("Xỉu", "a"), "," + choose + ",", ",");
                string infobet      = (bettype + choose).Replace("1h", o.home.Substring(0, 5) + "(FT) ").Replace("1a", o.away + "(FT) ").Replace("7h", o.home + "(H1) ").Replace("7a", o.away + "(H1) ").Replace("3h", o.home + "(OFT) ").Replace("3a", o.home + "(UFT) ").Replace("9h", o.home + "(OH1) ").Replace("9a", o.home + "(UH1) ") + hdp + " " + oddbet + " [" + usdbet + "]";
                int    deviationOdd = UtilSoccer.getDeviationOdd(odd, double.Parse(oddbet));
                if (deviationOdd < 0 && AutoAccept == false)
                {
                    message = "Odd Down:" + deviationOdd;
                    return;
                }
                string ProcessBet = http.Fetch(UrlBetSbo, HttpHelper.HttpMethod.Get, welcomeLink, null, ip);
                if (ProcessBet.IndexOf("onOrderSubmitted") == -1)
                {
                    db.doInsertTicket("SBOBET", username, o.bettype, o.hdp.ToString(), "", "", choose, oddbet, money, usd, group, phieuchung);
                    message = "BET FAILED" + infobet;
                    db.doInsertTicket("SBO", "BET FAIL", o.bettype, o.hdp.ToString(), o.home, o.away, choose, odd.ToString(), money, usd, group, this.phieuchung);
                }
                else
                {
                    db.doInsertTicket("SBOBET", username, o.bettype, o.hdp.ToString(), o.home, o.away, choose, oddbet, money, usd, group, phieuchung);
                    message = "(OK)" + infobet;
                    betcount++;
                }

                if (deviationOdd < 0)
                {
                    message += "Odd Down:" + deviationOdd;
                }
                if (deviationOdd > 0)
                {
                    message += "Odd Up:" + deviationOdd;
                }
            }
        }
        public void playBetLive(ticket o, string money, string IsLive, string phieuchung, string groupinput = "", bool AutoAccept = true)
        {
            bool   doBet = true;
            string group = "";

            if (groupinput != "")
            {
                group = groupinput.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 = GetTicket;
            }
            else
            {
                double oddbet = double.Parse(Util.GetSubstringByString(GetTicket.Replace("\"", ""), "DisplayOdds:", ","));

                int deviationOdd = UtilSoccer.getDeviationOdd(odd, oddbet);
                if (groupinput != "")
                {
                    if (group == "d" && deviationOdd >= -2)
                    {
                        doBet = true;
                    }
                    else if (group == "c" && deviationOdd >= -1)
                    {
                        doBet = true;
                    }
                    else if (deviationOdd >= 0)
                    {
                        doBet = true;
                    }
                    else
                    {
                        doBet   = false;
                        message = "Odd Down:" + deviationOdd;
                        db.doInsertTicket("IBET", "ODD DOWN", o.bettype, o.hdp.ToString(), o.home, o.away, choose, odd.ToString(), money, usd, group, this.phieuchung);
                    }
                }
                else
                {
                    message = "group empty";
                    return;
                }
                if (doBet)
                {
                    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();
                    }
                    usdbet = int.Parse(money) / int.Parse(usd);
                    string infobet    = (bettype + choose).Replace("1h", o.home + "(FT) ").Replace("1a", o.away + "(FT) ").Replace("7h", o.home + "(H1) ").Replace("7a", o.away + "(H1) ").Replace("3h", o.home + "(OFT) ").Replace("3a", o.home + "(UFT) ").Replace("9h", o.home + "(OH1) ").Replace("9a", o.home + "(UH1) ") + hdp + " " + oddbet + " [" + usdbet + "]";
                    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 = "BET FAILED" + infobet;
                    }
                    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 = "(OK)" + infobet;
                        if (deviationOdd > 0)
                        {
                            message += "Odd Up:" + deviationOdd;
                        }
                    }
                }
            }
        }
        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();
                    }
                }
            }
        }