コード例 #1
0
        private void CompareSameMatch()
        {
            this._comparing = true;
            lock (this._listSameMatch)
            {
                System.Collections.Generic.List<MatchDTO> listIBETMatch = this._listIBETMatch;
                System.Collections.Generic.List<MatchDTO> listSbobetMatch = this._listSbobetMatch;

                if (this._listSameMatch != null)
                {
                    this._listSameMatch.Clear();
                }
                else
                {
                    this._listSameMatch = new System.Collections.Generic.List<MatchDTO>();
                }

                if (scantype == ScanningType.both)
                {
                    #region BuonComIBETSBO
                    Dictionary<string, IbetMatch> iMatchs = this._ibetEngine.ibetAgent.parser.LdicMatches[0];
                    Dictionary<string, SboMatch> sMatchs = this._sbobetEngine.sboAgent.parserLive.LdicMatches[0];
                    //var i = iMatchs.Values.
                    foreach (KeyValuePair<string, IbetMatch> iM in iMatchs)
                    {
                        foreach (KeyValuePair<string, SboMatch> sM in sMatchs)
                        {
                            if ((iM.Value.Home == sM.Value.home) || (iM.Value.Away == sM.Value.away))
                            {
                                MatchDTO matchDTO = new MatchDTO();
                                matchDTO.ID = iM.Value.MatchId;
                                matchDTO.AwayTeamName = iM.Value.Away + " / " + sM.Value.away;
                                matchDTO.HomeTeamName = iM.Value.Home + " / " + sM.Value.home;
                                matchDTO.Minute = iM.Value.Minute;
                                matchDTO.HomeScore = iM.Value.ScoreH.ToString();
                                matchDTO.AwayScore = iM.Value.ScoreA.ToString();
                                if (iM.Value.Period == 0)
                                    matchDTO.IsHalfTime = true;
                                else if (iM.Value.Period == 1)
                                    matchDTO.Half = 1;
                                else if (iM.Value.Period == 2)
                                    matchDTO.Half = 2;

                                LeagueDTO leagueDTO = new LeagueDTO();
                                leagueDTO.Name = iM.Value.LeagueName + " / " + sM.Value.leagueName;
                                leagueDTO.ID = iM.Value.LeagueId;
                                matchDTO.League = leagueDTO;

                                foreach (KeyValuePair<string, SboOdd> sO in sM.Value.dicOdds)
                                {
                                    foreach (KeyValuePair<string, IbetOdd> iO in iM.Value.dicOdds)
                                    {
                                        if (sO.Value.oddType == iO.Value.oddType)
                                        {
                                            if (sO.Value.home + iO.Value.away == -0.01m || sO.Value.home + iO.Value.away == 0)
                                            {
                                                //iBet.Utilities.WriteLog.Write("Odd Found:iH sA: " + iM.Value.Home + "/" + sM.Value.home + "-" + iM.Value.Away + "/" + sM.Value.away +
                                                //    " >> ibet Odd: " + iO.Value.home + "/" + iO.Value.away + " >> sbo Odd:" + sO.Value.home + "/" + sO.Value.away +
                                                //    " >> " + iO.Value.oddType + ":" + sO.Value.oddType);
                                                //BetObject betObject = new BetObject();
                                                //betObject.ibet = new Bet();

                                                //this._ibetEngine.ibetAgent.CheckOdds

                                                TransactionDTO transactionDTO = new TransactionDTO();
                                            }
                                            if (sO.Value.away + iO.Value.home == -0.01m || sO.Value.away + iO.Value.home == 0)
                                            {
                                                //iBet.Utilities.WriteLog.Write("Odd Found:iA sH: " + iM.Value.Home + "/" + sM.Value.home + "-" + iM.Value.Away + "/" + sM.Value.away +
                                                //    " >> ibet Odd: " + iO.Value.home + "/" + iO.Value.away + " >> sbo Odd:" + sO.Value.home + "/" + sO.Value.away +
                                                //    " >> " + iO.Value.oddType + ":" + sO.Value.oddType);
                                            }
                                        }
                                    }
                                }
                                this._listSameMatch.Add(matchDTO);
                            }
                        }
                    }
                    System.DateTime now = System.DateTime.Now;
                    System.TimeSpan timeSpan;

                    System.DateTime now2 = System.DateTime.Now;
                    timeSpan = now2 - now;
                    double totalMilliseconds = timeSpan.TotalMilliseconds;
                    BarItem arg_648_0 = this.lblSbobetTotalMatch;
                    int count = sMatchs.Count;
                    arg_648_0.Caption = count.ToString();
                    BarItem arg_663_0 = this.lblIbetTotalMatch;
                    count = iMatchs.Count;
                    arg_663_0.Caption = count.ToString();
                    this.lblSameMatch.Caption = "Total Same Match: " + this._listSameMatch.Count;
                    this.lblLastUpdate.Caption = System.DateTime.Now.ToString();
                    #endregion
                }
                else if (scantype == ScanningType.ibet || scantype == ScanningType.ibetVSibet)
                {                    
                    Dictionary<string, IbetMatch> iMatchs1 = new Dictionary<string, IbetMatch>();
                    Dictionary<string, IbetMatch> iMatchs0 = new Dictionary<string, IbetMatch>();
                    if (checkEdit5.Checked)//live
                        iMatchs0 = this._ibetEngine.ibetAgent.parser.LdicMatches[0];
                    if (checkEdit6.Checked)//non live
                        iMatchs1 = this._ibetEngine.ibetAgent.parser.LdicMatches[1];

                    this._ibetMatchs = iMatchs1.Concat(iMatchs0).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.First().Value);
                    lock (this._ibetMatchs)
                    {
                        foreach (KeyValuePair<string, IbetMatch> iM in _ibetMatchs)
                        {
                            #region SAMEWORD_PREPARE_MATCHLIST
                            MatchDTO matchDTO = new MatchDTO();
                            matchDTO.ID = iM.Value.MatchId;
                            matchDTO.AwayTeamName = iM.Value.Away;
                            matchDTO.HomeTeamName = iM.Value.Home;
                            //matchDTO.KickOffTime = iM.Value.KickOffTime;
                            string formatString = "yyyyMMddHHmm";
                            //string sample = "201006112219";
                            DateTime dt = DateTime.ParseExact(iM.Value.KickOffTime, formatString, null);
                            matchDTO.KickOffTime = dt.ToString("dd/MM HH:mm");
                            DateTime ct = DateTime.Parse(this._ibetEngine.ibetAgent.CT);
                            TimeSpan ts = dt.Subtract(ct);//kick off time - current time
                            double tic = ts.TotalSeconds;
                            if (tic <= 300 && tic > 0)
                            {
                                matchDTO.KickOffTime += " - " + ts.Minutes.ToString() + " mins to start";
                            }
                            else if (tic < 0)
                            {
                                matchDTO.KickOffTime += " !Live";
                            }

                            matchDTO.Minute = iM.Value.Minute;
                            matchDTO.HomeScore = iM.Value.ScoreH.ToString();
                            matchDTO.AwayScore = iM.Value.ScoreA.ToString();

                            if (iM.Value.Period == 0)
                                matchDTO.IsHalfTime = true;
                            else if (iM.Value.Period == 1)
                                matchDTO.Half = 1;
                            else if (iM.Value.Period == 2)
                                matchDTO.Half = 2;

                            LeagueDTO leagueDTO = new LeagueDTO();
                            leagueDTO.Name = iM.Value.LeagueName;
                            leagueDTO.ID = iM.Value.LeagueId;
                            matchDTO.League = leagueDTO;

                            this._listSameMatch.Add(matchDTO);
                            int num = 0;
                            if (this.chbRandomStake.Checked)
                            {
                                while (num == 0)
                                {
                                    string strNum = this.txtStake.Lines[new System.Random().Next(this.txtStake.Lines.Length)];
                                    int.TryParse(strNum, out num);
                                }
                            }

                            #endregion

                            if (scantype == ScanningType.ibetVSibet)
                            {
                                #region IBET_vs_IBET
                                if (leagueDTO.Name.Contains("SPECIFIC 15 MINS OVER/UNDER"))
                                {
                                    if (((System.DateTime.Now - this._lastTransactionTime).Seconds > 8) && !this._betting)
                                    {
                                        if (matchDTO.HomeTeamName.Contains("30:01-45:00") || matchDTO.HomeTeamName.Contains("75:01-90:00"))
                                        {
                                            if (!matchDTO.KickOffTime.Contains("Live"))
                                            {
                                                foreach (KeyValuePair<string, IbetOdd> iO in iM.Value.dicOdds)
                                                {
                                                    if (iO.Value.oddType == 3)//keo OU
                                                    {
                                                        TransactionDTO transactionDTO;
                                                        string strOU = "a";
                                                        if (checkEdit2.Checked)
                                                        {
                                                            strOU = "h";
                                                        }
                                                        if (matchDTO.HomeTeamName.Contains("30:01-45:00"))
                                                        {
                                                            if (checkEdit17.Checked)//allow Half 1
                                                            {
                                                               
                                                                transactionDTO = PlaceSingleIBET("Over15_Fang", iO.Value.home.ToString(),
                                                                    matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, strOU,
                                                                    num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account);
                                                                this.AddTransaction(transactionDTO);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (checkEdit18.Checked) //allow half 2
                                                            {
                                                                transactionDTO = PlaceSingleIBET("Over15_Fang", iO.Value.home.ToString(),
                                                                matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, strOU,
                                                                num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account);
                                                                this.AddTransaction(transactionDTO);
                                                            }
                                                        }
                                                        
                                                    }
                                                }
                                            }
 
                                        }
                                    } 
                                }
                                #endregion
                            }
                            else if (scantype == ScanningType.ibet)
                            {
                                #region IBET_Strategies
                                foreach (KeyValuePair<string, IbetOdd> iO in iM.Value.dicOdds)
                                {
                                    if (((System.DateTime.Now - this._lastTransactionTime).Seconds > 8) && !this._betting)
                                    {
                                        if (checkEdit12.Checked) // under strategy
                                        {
                                            if (iO.Value.oddType == 3 && iO.Value.home == iO.Value.away)
                                            {
                                                if (checkEdit9.Checked)
                                                {
                                                    if (!matchDTO.KickOffTime.Contains("Live"))
                                                    {
                                                        TransactionDTO transactionDTO = PlaceSingleIBET("Under", iO.Value.home.ToString(),
                                                        matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, "a",
                                                        num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account);
                                                        this.AddTransaction(transactionDTO);
                                                    }
                                                }
                                                else
                                                {
                                                    TransactionDTO transactionDTO = PlaceSingleIBET("Under", iO.Value.home.ToString(),
                                                        matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, "a",
                                                        num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account);
                                                    this.AddTransaction(transactionDTO);
                                                }
                                            }
                                        }
                                        if (checkEdit8.Checked) //over strategy
                                        {
                                            if (iO.Value.oddType == 3 && iO.Value.home == iO.Value.away)
                                            {
                                                TransactionDTO transactionDTO = PlaceSingleIBET("Over", iO.Value.home.ToString(),
                                                    matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, "h",
                                                    num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account);
                                                this.AddTransaction(transactionDTO);
                                            }
                                        }
                                        if (checkEdit7.Checked) // Over 92/90
                                        {
                                            if (matchDTO.KickOffTime.Contains("Live"))
                                            {
                                                if (iO.Value.oddType == 3 || iO.Value.oddType == 8)
                                                {
                                                    if (iO.Value.hdp - ((decimal)iM.Value.ScoreH + (decimal)iM.Value.ScoreA) == (decimal)0.5)
                                                    {
                                                        if (iM.Value.Home.Contains("No. of Corners") && iO.Value.home == (decimal)0.90 && iO.Value.away == (decimal)0.92)
                                                        {
                                                            TransactionDTO transactionDTO = PlaceSingleIBET("Over9290", iO.Value.home.ToString(),
                                                            matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, "h",
                                                            num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account);
                                                            this.AddTransaction(transactionDTO);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        if (checkEdit9.Checked) // Odd down: Sap keo
                                        {
                                            if (matchDTO.KickOffTime.Contains("mins to start"))
                                            {
                                                if (iO.Value.oddType == 3)
                                                {
                                                    List<Bet> bl = this._ibetEngine.ibetAgent.betList;
                                                    lock (bl)
                                                    {
                                                        foreach (Bet bet in bl)
                                                        {
                                                            if (bet.Home == matchDTO.HomeTeamName && bet.Away == matchDTO.AwayTeamName)
                                                            {
                                                                iBet.Utilities.WriteLog.Write("Sap Keo:: Tim thay keo trong bet list trong tran : " + bet.Home + " - " + bet.Away);
                                                                if (bet.Handicap == iO.Value.hdp)
                                                                {
                                                                    if (iO.Value.away < 0 || iO.Value.away - bet.OddsValue >= (decimal)0.05)
                                                                    {
                                                                        iBet.Utilities.WriteLog.Write("Sap Keo:: Keo bi sap " + (iO.Value.away - bet.OddsValue).ToString() + " gia. Go to bet over");
                                                                        //keo under sap xuo^'ng an cao hon
                                                                        TransactionDTO transactionDTO = PlaceSingleIBET("SapKeo", iO.Value.home.ToString(),
                                                                            matchDTO, iO.Value.oddsId, iO.Value.hdp.ToString(), eOddType.FulltimeOverUnder, "h",
                                                                            num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account);
                                                                        this.AddTransaction(transactionDTO);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        if (chbHighRevenueBoost.Checked) // Best analysed strategy
                                        {
                                            if (!leagueDTO.Name.Contains("Cup") && !leagueDTO.Name.Contains("CUP"))
                                            {
                                                if (iO.Value.oddType == 3 && iO.Value.home == iO.Value.away)
                                                {
                                                    OddDTO oddDTO = new OddDTO();
                                                    oddDTO.Odd = iO.Value.hdp.ToString();
                                                    string s = CheckBestStrategyValidation(matchDTO, oddDTO);
                                                    if (s == "nguoc")
                                                    {
                                                        TransactionDTO transactionDTO = PlaceSingleIBET("nguoc", iO.Value.home.ToString(),
                                                        matchDTO, iO.Value.oddsId, iO.Value.home.ToString(), eOddType.FulltimeOverUnder, "h",
                                                        num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account);
                                                        this.AddTransaction(transactionDTO);
                                                        //Console.Write("nguoc");
                                                    }
                                                    else if (s == "xuoi")
                                                    {
                                                        TransactionDTO transactionDTO = PlaceSingleIBET("xuoi", iO.Value.home.ToString(),
                                                        matchDTO, iO.Value.oddsId, iO.Value.home.ToString(), eOddType.FulltimeOverUnder, "h",
                                                        num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account);
                                                        this.AddTransaction(transactionDTO);
                                                        //Console.Write("xuoi");
                                                    }
                                                }
                                            }
                                        }
                                        if (checkEdit11.Checked)//fair odd
                                        {
                                            if (!leagueDTO.Name.Contains("Cup") && !leagueDTO.Name.Contains("CUP"))
                                            {
                                                if (iM.Value.Minute >= 35 && iM.Value.Period == 1 && iM.Value.ScoreA == iM.Value.ScoreH)
                                                {
                                                    iBet.Utilities.WriteLog.Write("01:Found fair odd: " + iM.Value.Home + "-" + iM.Value.Away + ":" + iM.Value.Minute + "m");
                                                    if ((iO.Value.home > (decimal)0.9)
                                                        && iO.Value.oddType == 3
                                                        && (iO.Value.hdp - (decimal)(iM.Value.ScoreH + iM.Value.ScoreA) == (decimal)1.75))
                                                    {
                                                        iBet.Utilities.WriteLog.Write("02:Found fair odd correct");
                                                        foreach (KeyValuePair<string, IbetMatch> snapshotMacht in _ibetMatchsSnapShot)
                                                        {
                                                            if (snapshotMacht.Value.Home == iM.Value.Home && snapshotMacht.Value.Away == iM.Value.Away)
                                                            {
                                                                iBet.Utilities.WriteLog.Write("03:Found match in Snapshot");
                                                                foreach (KeyValuePair<string, IbetOdd> snapshotOdd in snapshotMacht.Value.dicOdds)
                                                                {
                                                                    if (snapshotOdd.Value.oddType == 3
                                                                        && snapshotOdd.Value.hdp >= (decimal)2.5
                                                                        && (snapshotOdd.Value.home >= (decimal)0.92 || snapshotOdd.Value.home < (decimal)0))
                                                                    {
                                                                        iBet.Utilities.WriteLog.Write("04:Found odd over 2.5 correct in Snapshot");
                                                                        if (snapshotOdd.Value.oddType == 1 && snapshotOdd.Value.hdp <= (decimal)0.75)
                                                                        {
                                                                            iBet.Utilities.WriteLog.Write("05:Found handicap correct in Snapshot, go to Bet");
                                                                            TransactionDTO transactionDTO = PlaceSingleIBET("Over1.75", iO.Value.home.ToString(),
                                                                            matchDTO, iO.Value.oddsId, iO.Value.home.ToString(), eOddType.FulltimeOverUnder, "h",
                                                                            num.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent.Config.Account);
                                                                            this.AddTransaction(transactionDTO);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                #endregion
                            }                            
                        }
                    }
                    if (scantype == ScanningType.ibetVSibet)
                    {
                        #region IBET_vs_IBET_continue
                        
                        Dictionary<string, IbetMatch> iMatchs2 = new Dictionary<string, IbetMatch>();         
                        iMatchs2 = this._ibetEngine.ibetAgent.parser.LdicMatches[0];
                        //this._ibetEngine.ibetAgent.RefreshBetList();
                        lock (iMatchs2)
                        {
                            foreach (KeyValuePair<string, IbetMatch> iM2 in _ibetMatchs)
                            {                                
                                if ((iM2.Value.Period == 1 && iM2.Value.Minute >= (int)spinEdit1.Value) || (iM2.Value.Period == 2 && iM2.Value.Minute >= (int)spinEdit2.Value)) // chi chon nhung tran p31 cua hiep 1
                                {
                                    foreach (KeyValuePair<string, IbetOdd> iO2 in iM2.Value.dicOdds)
                                    {
                                        if (((System.DateTime.Now - this._lastTransactionTime).Seconds > 8) && !this._betting)
                                        {
                                            if (iO2.Value.oddType == 8 || iO2.Value.oddType == 3)
                                            {
                                                if (iO2.Value.hdp - ((decimal)iM2.Value.ScoreH + (decimal)iM2.Value.ScoreA) == (decimal)0.5)
                                                {
                                                    bl = this._ibetEngine.ibetAgent.betList;
                                                    foreach (Bet bet in bl)
                                                    {
                                                        if (bet.Home.Contains("30:01-45:00") || bet.Home.Contains("75:01-90:00"))
                                                        {
                                                            string HomeTeam = "";
                                                            if (iO2.Value.oddType == 8)
                                                            {
                                                                HomeTeam = bet.Home.Replace(" 30:01-45:00", "");

                                                            }
                                                            else
                                                            {
                                                                HomeTeam = bet.Home.Replace(" 75:01-90:00", "");
                                                            }
                                                            

                                                            if (HomeTeam == iM2.Value.Home.Replace("(N)", "").TrimEnd())
                                                            {                                                                    
                                                                MatchDTO matchDTO = new MatchDTO();
                                                                matchDTO.HomeTeamName = iM2.Value.Home.Replace("(N)", "").TrimEnd();
                                                                matchDTO.AwayTeamName = iM2.Value.Away.Replace("(N)","").TrimEnd();
                                                                matchDTO.Minute = iM2.Value.Minute;
                                                                matchDTO.HomeScore = iM2.Value.ScoreH.ToString();
                                                                matchDTO.AwayScore = iM2.Value.ScoreA.ToString();
                                                                matchDTO.Half = iM2.Value.Period;

                                                                int num = (int)bet.Stake;
                                                                int ExRate1 = (int)config.Ibet.ExchangeRate;
                                                                int ExRate2 = (int)config.Ibet2.ExchangeRate;
                                                                float stake2 = num * ExRate1 / ExRate2;

                                                                decimal giatri1;
                                                                string OU = "h";

                                                                if (bet.Choice == Choice.H)
                                                                {
                                                                    giatri1 = iO2.Value.away;
                                                                    OU = "a";
                                                                }
                                                                else
                                                                {
                                                                    giatri1 = iO2.Value.home;
                                                                }

                                                                //iBet.Utilities.WriteLog.Write("Tim thay tran :" + bet.Home + " -vs- " + bet.Away +
                                                                //    ", o phut thu:" + matchDTO.Minute.ToString() + ", hiep " + matchDTO.Half.ToString() +
                                                                //    "chuan bi xa..");                                                                
                                                                eOddType oddtype;

                                                                if ((giatri1 > 0 && bet.OddsValue + giatri1 >= spinEdit4.Value) || giatri1 < 0)
                                                                {
                                                                    if (checkEdit1.Checked)
                                                                    {
                                                                        
                                                                        string textx = "";
                                                                        if (bet.Home.Contains("30:01-45:00"))
                                                                        {
                                                                            textx = "Over15_XA > 30-45 > Xa loi gia > Min:" + matchDTO.Minute + "half " + matchDTO.Half.ToString() + " > " + bet.OddsValue.ToString() + "/" + giatri1.ToString() + " > Ref ID:" + bet.Id;
                                                                            oddtype = eOddType.FirstHalfOverUnder;
                                                                        }
                                                                        else
                                                                        {
                                                                            textx = "Over15_XA > 75-90 > Xa loi gia > Min:" + matchDTO.Minute + "half " + matchDTO.Half.ToString() + " > " + bet.OddsValue.ToString() + "/" + giatri1.ToString() + " > Ref ID:" + bet.Id;
                                                                            oddtype = eOddType.FulltimeOverUnder;
                                                                        }
                                                                        TransactionDTO transactionDTO = PlaceSingleIBET(textx, giatri1.ToString(),
                                                                            matchDTO, iO2.Value.oddsId, iO2.Value.hdp.ToString(), oddtype, OU,
                                                                            stake2.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent2.Config.Account);
                                                                        this.AddTransaction(transactionDTO);
                                                                        iBet.Utilities.WriteLog.Write(textx);
                                                                    }
                                                                }
                                                                else 
                                                                {
                                                                    string textx = "";
                                                                    if (bet.Choice == Choice.H && matchDTO.Minute >= 30)
                                                                    {
                                                                        
                                                                        if (bet.Home.Contains("30:01-45:00"))
                                                                        {
                                                                            textx = "Over15_XA > 30-45 > Xa thuong > Min:" + matchDTO.Minute + " > " + bet.OddsValue.ToString() + "/" + iO2.Value.away.ToString() + " > Ref ID:" + bet.Id;
                                                                            oddtype = eOddType.FirstHalfOverUnder;
                                                                        }
                                                                        else
                                                                        {
                                                                            textx = "Over15_XA > 75-90 > Xa thuong > Min:" + matchDTO.Minute + " > " + bet.OddsValue.ToString() + "/" + iO2.Value.away.ToString() + " > Ref ID:" + bet.Id;
                                                                            oddtype = eOddType.FulltimeOverUnder;
                                                                        }
                                                                        TransactionDTO transactionDTO = PlaceSingleIBET(textx, iO2.Value.away.ToString(),
                                                                            matchDTO, iO2.Value.oddsId, iO2.Value.hdp.ToString(), oddtype, OU,
                                                                            stake2.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent2.Config.Account);
                                                                        this.AddTransaction(transactionDTO);
                                                                        //iBet.Utilities.WriteLog.Write(textx);
                                                                    }
                                                                    else if (bet.Choice == Choice.A && matchDTO.Minute >= 34)
                                                                    {
                                                                        if (bet.Home.Contains("30:01-45:00"))
                                                                        {
                                                                            textx = "Over15_XA > 30-45 > Xa thuong > Min:" + matchDTO.Minute + " > " + bet.OddsValue.ToString() + "/" + iO2.Value.away.ToString() + " > Ref ID:" + bet.Id;
                                                                            oddtype = eOddType.FirstHalfOverUnder;
                                                                        }
                                                                        else
                                                                        {
                                                                            textx = "Over15_XA > 75-90 > Xa thuong > Min:" + matchDTO.Minute + " > " + bet.OddsValue.ToString() + "/" + iO2.Value.away.ToString() + " > Ref ID:" + bet.Id;
                                                                            oddtype = eOddType.FulltimeOverUnder;
                                                                        }
                                                                        
                                                                        TransactionDTO transactionDTO = PlaceSingleIBET(textx, iO2.Value.away.ToString(),
                                                                            matchDTO, iO2.Value.oddsId, iO2.Value.hdp.ToString(), oddtype, OU,
                                                                            stake2.ToString(), matchDTO.HomeScore, matchDTO.AwayScore, this._ibetEngine, true, "", this._ibetEngine.ibetAgent2.Config.Account);
                                                                        this.AddTransaction(transactionDTO); 
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }                                                    
                                                }
                                            }
                                        }
                                    }                                     
                                }
                            }
                        }
                        #endregion
                    }
                    BarItem arg_663_0 = this.lblIbetTotalMatch;
                    int count = _ibetMatchs.Count;
                    arg_663_0.Caption = count.ToString() + " (" + iMatchs0.Count.ToString() + " live)";
                    this.lblLastUpdate.Caption = System.DateTime.Now.ToString();
                    this.rpgIbet.Text = "IBET - " + this._ibetEngine.ibetAgent.Config.Account + " " + this._ibetEngine.ibetAgent.CT;
                    
                }
                else if (scantype == ScanningType.sbo)
                {
                    #region SBO_Strategies
                    Dictionary<string, SboMatch> sMatchs0 = this._sbobetEngine.sboAgent.parserLive.dicMatches;
                    Dictionary<string, SboMatch> sMatchs1 = this._sbobetEngine.sboAgent.parserNonlive.dicMatches;
                    Dictionary<string, SboMatch> sMatchs = sMatchs1.Concat(sMatchs0).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.First().Value);
                    foreach (KeyValuePair<string, SboMatch> sM in sMatchs)
                    {
                        MatchDTO matchDTO = new MatchDTO();
                        matchDTO.ID = sM.Value.matchId;
                        matchDTO.AwayTeamName = sM.Value.away;
                        matchDTO.HomeTeamName = sM.Value.home;

                        matchDTO.AwayScore = sM.Value.awayscore.ToString();
                        matchDTO.HomeScore = sM.Value.homescore.ToString();
                        matchDTO.Minute = sM.Value.minute;
                        matchDTO.Half = sM.Value.half;
                        if (matchDTO.Half == 0)
                            matchDTO.IsHalfTime = true;

                        LeagueDTO leagueDTO = new LeagueDTO();
                        leagueDTO.Name = sM.Value.leagueName;
                        leagueDTO.ID = sM.Value.leagueId;
                        matchDTO.League = leagueDTO;

                        this._listSameMatch.Add(matchDTO);
                    }
                    BarItem arg_648_0 = this.lblSbobetTotalMatch;
                    int count = sMatchs.Count;
                    arg_648_0.Caption = count.ToString() + " (" + sMatchs0.Count.ToString() + " live)";
                    #endregion
                }
                else if (scantype == ScanningType.ibetVSibet)
                {
                    
                }
                lock (this.grdSameMatch)
                {
                    this.grdSameMatch.RefreshDataSource();
                }
                lock (girdBetList1)
                {
                    this.girdBetList1.RefreshDataSource();
                }
            }
            
            this._comparing = false;
            if (this._compareAgain && !this._comparing)
            {
                this._compareAgain = false;
                this.CompareSameMatch();
            }
        }
コード例 #2
0
		internal void AddTransaction(TransactionDTO transaction)
		{
            if (transaction.IBETTrade || transaction.SBOBETTrade || transaction.THREEIN1Trade)
			{
				TransactionDTO transactionDTO = BaseDTO.DeepClone<TransactionDTO>(transaction);
				transactionDTO.ID = (this._listTransaction.Count + 1).ToString();
				this._listTransaction.Add(transactionDTO);
				lock (this.grdTransaction)
				{
					this.grdTransaction.RefreshDataSource();
				}
				this._dataService.AddTransactionAsync(
                    this._currentUserID, 
                    transaction.AccountPair, 
                    transaction.HomeTeamName, 
                    transaction.AwayTeamName, 
                    transaction.OddType, 
                    transaction.Odd, 
                    transaction.OddValue, 
                    transaction.Stake, 
                    transaction.IBETTrade, 
                    transaction.THREEIN1Trade, 
                    transaction.SBOBETTrade,
                    transaction.THREEIN1ReTrade, 
                    transaction.IBETReTrade,
                    transaction.SBOBETReTrade,
                    transaction.Note, 
                    transaction.DateTime);
			}
		}
コード例 #3
0
        private TransactionDTO PlaceBetAllowMaxBet(bool sendOrNOT, MatchDTO ibetMatch, MatchDTO sbobetMatch, eOddType oddType, string ibetOddID, string sbobetOddID, string ibetOddType, string sbobetOddType, string ibetOddValue, string sbobetOddValue, int ibetStake, int sbobetStake, bool ibetHomeGive, IBetEngine ibetEngine, SbobetEngine sbobetEngine, string sbobetOdd)
        {
            this._betting = true;
            TransactionDTO transactionDTO = new TransactionDTO();
            
            //transactionDTO.OddType = current2.Type.ToString() + " - Home / Away";
            string text = "";
            string text2 = "";
            string text3 = "";
            bool flag = false;
            bool flag2 = false;
            int num = 0;
            int num2 = 0;
            string text4 = "";
            string text5 = "";
            string text6 = "";
            bool flag3 = false;
            bool flag4 = false;
            bool sBOBETReTrade = false;
            int num3 = 0;
            string text7 = "";
            string betCount = "";
            string text8 = "";
            bool flag5 = false;

            float ibetOddValue_ = float.Parse(ibetOddValue);
            float sboOddValue_ = float.Parse(sbobetOddValue);

            if (ibetOddValue_ > 0.84 || (ibetOddValue_ > 0f && txtAddValue.Value.ToString() == "0.01"))
            {
                float valueAdd = ibetStake * (float)txtAddValue.Value;
                ibetStake = ibetStake + (int)valueAdd;
            }
            if (sboOddValue_ > 0.84 || (sboOddValue_ > 0f && txtAddValue.Value.ToString() == "0.01"))
            {
                float valueAdd = sbobetStake * (float)txtAddValue.Value;
                sbobetStake = sbobetStake + (int)valueAdd;
            }

            bool ibetGoFirst = true;// who is Away or Under

            if (checkEdit11.Checked) //safe bet
            {
                if (sbobetOddType == "a") //  ibet  vs sbo
                {
                    if (oddType == eOddType.FirstHalfOverUnder || oddType == eOddType.FulltimeOverUnder)//neu bong over under
                    {
                        ibetGoFirst = false;
                    }
                    else // bong handicap
                    {
                        if (ibetHomeGive) // neu away la doi cua duoi
                        {
                            ibetGoFirst = false;
                        }
                    }
                }
                else //  sbo vs ibet
                {
                    if (oddType == eOddType.FirstHalfOverUnder || oddType == eOddType.FulltimeOverUnder)//neu bong over under
                    {
                        ibetGoFirst = true;
                    }
                    else // bong handicap
                    {
                        if (ibetHomeGive) // neu away la doi cua duoi
                        {
                            ibetGoFirst = true;
                        }
                    }
                }
            }

            if (MatchDTO.IsSameMatch(ibetMatch.HomeTeamName.ToLower(), sbobetMatch.HomeTeamName.ToLower(), ibetMatch.AwayTeamName.ToLower(), sbobetMatch.AwayTeamName.ToLower()))
            {
                try
                {
                    ibetEngine.PrepareBet(ibetOddID, ibetOddType, ibetOddValue, ibetStake.ToString(), out flag, out num, out num2, out text4, out text2, out text3);
                    sbobetEngine.PrepareBet(sbobetOddID, sbobetOddValue, sbobetOddType, out betCount, out num3, out flag3, out text7, out text5, out text6);
                    //object result = this.CallJavascriptFunction("bet", new object[] { 0, ibetMatch.ID.Remove(0, 2), ibetOddID, ibetOddType, ibetOddValue });
                    
                    if (MatchDTO.IsSameMatch(text2, text5, text3, text6)) // ten hom - away giong nhau
                    {                        
                        float num4 = 0f;
                        float num5 = 0f;
                        if (flag && flag3 && float.TryParse(text4, out num4) && float.TryParse(text7, out num5))
                        {
                            if ((checkEdit13.Checked || checkEdit15.Checked) && sendOrNOT)//gui lenh
                            {
                                var taskA = new Task(() => this.AddOddToLocalCommunity(ibetMatch, sbobetMatch, oddType, sbobetOdd, sbobetOdd, ibetOddType, sbobetOddType, ibetOddValue, sbobetOddValue, ibetHomeGive));
                                taskA.Start();
                            }

                            //try parse de tranh hien tuong mat Odd 1 ben
                            //float num4 = float.Parse(text4); 
                            //float num5 = float.Parse(text7);
                            if (num4 + num5 == 0f || num4 == num5)
                            {
                                int num6 = 0;
                                if (num2 >= num3) // num2 maxbet ibet
                                {
                                    num6 = num3; // num3 maxbet sbo
                                }
                                else
                                {
                                    if (num2 <= num3)
                                    {
                                        num6 = num2;
                                    }
                                }
                                if (ibetStake >= num6)
                                {
                                    ibetStake = num6;
                                }
                                if (sbobetStake >= num6)
                                {
                                    sbobetStake = num6;
                                }
                                try
                                {
                                    float currentCredit = 0;
                                    float currentCredit2 = 0;
                                    if (checkEdit8.Checked)
                                    {
                                        currentCredit = ibetEngine.GetCurrentCredit();
                                        currentCredit2 = sbobetEngine.GetCurrentCredit();
                                    }
                                    else
                                    {
                                        currentCredit = ibetEngine._currentCredit;
                                        currentCredit2 = sbobetEngine._currentCredit;
                                    }

                                    if ((float)ibetStake <= currentCredit && (float)sbobetStake <= currentCredit2)
                                    {
                                        try
                                        {
                                            if (ibetGoFirst)
                                            {
                                                
#if TESTMODE
                                                #region IBET_FIRTST_THEN_SBO
                                                if (!checkEdit12.Checked || (checkEdit12.Checked && ibetOddType == "a" && (oddType == eOddType.FirstHalfOverUnder || oddType == eOddType.FulltimeOverUnder)))
                                                    ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), num.ToString(), num2.ToString(), out flag2);
                                                if (flag2 && !checkEdit12.Checked)
                                                {
                                                    sbobetEngine.ConfirmBet(sbobetOddID, sbobetOddValue, sbobetOddType, sbobetStake.ToString(), betCount, out text8, out flag4);
                                                    if (!flag4)
                                                    {
                                                        try
                                                        {
                                                            sbobetEngine.PrepareBet(sbobetOddID, text8, sbobetOddType, out betCount, out num3, out flag5, out text7, out text5, out text6);
                                                            if (MatchDTO.IsSameMatch(text2, text5, text3, text6))
                                                            {
                                                                if (!float.TryParse(text7, out num5)) //text 7 = BetKindValue
                                                                {
                                                                    Thread.Sleep(3000);
                                                                    sbobetEngine.PrepareBet(sbobetOddID, text8, sbobetOddType, out betCount, out num3, out flag5, out text7, out text5, out text6);
                                                                    float.TryParse(text7, out num5);
                                                                }

                                                                if (num4 + num5 == 0f || num4 == num5)
                                                                {
                                                                    text = "Retrade. IBET: " + ibetOddValue + " -  SBOBET: " + text8;
                                                                    //text = "No retrade in this version please trade manually.";
                                                                    sbobetEngine.ConfirmBet(sbobetOddID, text8, sbobetOddType, sbobetStake.ToString(), betCount, out text8, out sBOBETReTrade);
                                                                    this._lastTransactionTime = System.DateTime.Now;
                                                                    playSound(false);
                                                                    
                                                                }
                                                                else
                                                                {
                                                                    text = "Invalid Odd in SBOBET. IBET Odd: " + text4 + " - SBOBET Odd:" + text7;
                                                                    playSound(false);
                                                                }
                                                            }
                                                            else
                                                            {
                                                                text = string.Concat(new string[]
															    {
																    "Not Same Match - Retrade. IBET: ", 
																    text2, 
																    " / ", 
																    text3, 
																    " - SBOBET: ", 
																    text5, 
																    " / ", 
																    text6
															    });
                                                            }
                                                        }
                                                        catch (System.Exception ex)
                                                        {
                                                            text = "Error while Retrade. Details: " + ex.Message;
                                                            playSound(false);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        playSound(true);
                                                    }

                                                    this._lastTransactionTime = System.DateTime.Now;
                                                    object obj = text;
                                                    text = string.Concat(new object[]
												    {
													    obj, 
													    " - Success Transaction. Half: ", 
													    ibetMatch.Half, 
													    " - Minute: ", 
													    ibetMatch.Minute, 
													    " - Halftime: ", 
													    ibetMatch.IsHalfTime
												    });
                                                    ibetEngine.GetCurrentCredit();
                                                    sbobetEngine.GetCurrentCredit();

                                                }
                                                
                                                #endregion
#endif
                                            }

                                            else
                                            {
                                                text = "No more SBOBET comes first.";
                                                //#region SBO_BET_FIRST_THEN_IBET

                                                //sbobetEngine.ConfirmBet(sbobetOddID, sbobetOddValue, sbobetOddType, sbobetStake.ToString(), betCount, out text8, out flag4);
                                                //if (flag4)
                                                //{ 
                                                //    ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), num.ToString(), num2.ToString(), out flag2);
                                                //    if (!flag2)
                                                //    {
                                                //        text = "Invalid Odd while Retrade.";// IBET Odd: " + text4 + " - SBOBET Odd:" + text7;
                                                //        sbobetEngine.GetCurrentCredit();
                                                //        playSound(false);
                                                //    }
                                                //    else
                                                //    {
                                                //        this._lastTransactionTime = System.DateTime.Now;
                                                //        object obj = text;
                                                //        text = string.Concat(new object[]
                                                //        {
                                                //            obj, 
                                                //            " - Success Transaction. Half: ", 
                                                //            ibetMatch.Half, 
                                                //            " - Minute: ", 
                                                //            ibetMatch.Minute, 
                                                //            " - Halftime: ", 
                                                //            ibetMatch.IsHalfTime
                                                //        });
                                                //        ibetEngine.GetCurrentCredit();
                                                //        sbobetEngine.GetCurrentCredit();
                                                //        playSound(true);
                                                //    }
                                                //}

                                                //#endregion
                                            }

                                        }
                                        catch (System.Exception ex)
                                        {
                                            text = "Error while Trading. Details: " + ex.Message;
                                        }
                                    }
                                    else
                                    {
                                        text = string.Concat(new object[]
										{
											"Out of Cash. IBET Credit: ", 
											currentCredit, 
											" -  SBOBET Credit: ", 
											currentCredit2
										});
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                    text = "Error while getting Credit. Details: " + ex.Message;
                                }
                            }
                            else
                            {
                                text = "Invalid Odd while Preparing Ticket. IBET Odd: " + text4 + " - SBOBET Odd:" + text7;
                            }
                        }
                    }                        
                    else
                    {
                        text = string.Concat(new string[]
						{
							"Not Same Match - Preparing Ticket. IBET: ", 
							text2, 
							" / ", 
							text3, 
							" - SBOBET: ", 
							text5, 
							" / ", 
							text6
						});
                    }                    
                }
                catch (System.Exception ex)
                {
                    text = "Error while Preparing Trade. Details: " + ex.Message;
                }
            }
            else
            {
                text = string.Concat(new string[]
				{
					"Not Same Match - Comparing. IBET: ", 
					ibetMatch.HomeTeamName, 
					" / ", 
					ibetMatch.AwayTeamName, 
					" - SBOBET: ", 
					sbobetMatch.HomeTeamName, 
					" / ", 
					sbobetMatch.AwayTeamName
				});
            }
            transactionDTO.HomeTeamName = ibetMatch.HomeTeamName + ":" + ibetMatch.HomeScore + " / " + sbobetMatch.HomeTeamName;
            transactionDTO.AwayTeamName = ibetMatch.AwayTeamName + ":" + ibetMatch.AwayScore + " / " + sbobetMatch.AwayTeamName;
            transactionDTO.Odd = text4 + " / " + text7;
            transactionDTO.OddKindValue = text4 + " / " + text7;
            transactionDTO.OddValue = ibetOddValue + " / " + sbobetOddValue;
            transactionDTO.Stake = ibetStake + " / " + sbobetStake;
            transactionDTO.IBETAllow = flag;
            transactionDTO.IBETTrade = flag2;
            transactionDTO.IBETReTrade = false;
            transactionDTO.SBOBETAllow = flag3;
            transactionDTO.SBOBETTrade = flag4;
            transactionDTO.SBOBETReTrade = sBOBETReTrade;
            //transactionDTO.OddType = oddType.ToString() + ;
            transactionDTO.OddType = oddType.ToString() + " - " + ibetOddType.Replace("h", "Home").Replace("a", "Away") + " / " + sbobetOddType.Replace("h", "Home").Replace("a", "Away");
            transactionDTO.Note = text;
            transactionDTO.DateTime = System.DateTime.Now.ToLocalTime();

            transactionDTO.HomeTeamSBOBET = sbobetMatch.HomeTeamName;
            transactionDTO.AwayTeamSBOBET = sbobetMatch.AwayTeamName;
            
            this._betting = false;
            return transactionDTO;            
        }        
コード例 #4
0
 private void AddTransaction(TransactionDTO transaction)
 {
     lock (this._listTransaction)
     {
         transaction.ID = (this._listTransaction.Count + 1).ToString();
         this._listTransaction.Add(transaction);
         lock (this.grdTransaction)
         {
             this.grdTransaction.RefreshDataSource();
         }
         transaction.AccountPair = this.Text;
         this._mainForm.AddTransaction(transaction);
     }
 }
コード例 #5
0
        private TransactionDTO PlaceSingleIBET(string BetStrategy, string oddPrice, MatchDTO ibetMatch, string oddID, string oddValue, eOddType oddType, string ibetOddType, string stake, string homeScore, string awayScore, IBetEngine ibetEngine, bool followtype, string followref, string accountName)
        {
            this._betting = true;
            TransactionDTO transactionDTO = new TransactionDTO();
            string acctoScan = "";
            List<Bet> bl;
            string RefID = "";
            if (BetStrategy.Contains("Over15_XA"))
            {
                bl = this._ibetEngine.ibetAgent2.betList;
                acctoScan = this._ibetEngine.ibetAgent2.Config.Account;
                string[] array = BetStrategy.Split(new string[] { "Ref ID:" }, System.StringSplitOptions.None);
                RefID = array[1];
                if (!AllowOddBet(RefID + ibetOddType, ibetOddType))
                {
                    transactionDTO.HomeTeamName = ibetMatch.HomeTeamName;
                    transactionDTO.AwayTeamName = ibetMatch.AwayTeamName;
                    transactionDTO.Note = "Under account: " + acctoScan + " just bet on this odd";
                    transactionDTO.DateTime = DateTime.Now;
                    this._betting = false;
                    return transactionDTO;
                }
            }            
            else
            {
                bl = this._ibetEngine.ibetAgent.betList;
                acctoScan = this._ibetEngine.ibetAgent.Config.Account;
            }
            if (BetStrategy.Contains("Warning"))
            {
                transactionDTO.HomeTeamName = ibetMatch.HomeTeamName;
                transactionDTO.AwayTeamName = ibetMatch.AwayTeamName;
                transactionDTO.Note = BetStrategy;
                transactionDTO.DateTime = DateTime.Now;
                this._betting = false;
                return transactionDTO;
            }
            foreach (Bet bet in bl)
            {
                if (bet.Home == ibetMatch.HomeTeamName)
                {                    
                    if (bet.Handicap == decimal.Parse(oddValue))
                    {
                        if (bet.Choice.ToString().ToLower() == ibetOddType)
                        {
                            transactionDTO.HomeTeamName = ibetMatch.HomeTeamName;
                            transactionDTO.AwayTeamName = ibetMatch.AwayTeamName;
                            transactionDTO.Note = acctoScan + " : Bet list contains this odd already";
                            transactionDTO.DateTime = DateTime.Now;
                            this._betting = false;
                            return transactionDTO;
                        }
                    }                    
                }
            }
            if (!AllowOddBet(oddID + ibetOddType,ibetOddType))
            {
                transactionDTO.HomeTeamName = ibetMatch.HomeTeamName;
                transactionDTO.AwayTeamName = ibetMatch.AwayTeamName;
                transactionDTO.Note = acctoScan + " just bet on this odd";
                transactionDTO.DateTime = DateTime.Now;
                this._betting = false;
                return transactionDTO;
            }
            if (this._ibetEngine.ibetAgent.Config.Balance < int.Parse(stake))
            {
                transactionDTO.HomeTeamName = ibetMatch.HomeTeamName;
                transactionDTO.AwayTeamName = ibetMatch.AwayTeamName;
                transactionDTO.Note = "Not enough money";
                transactionDTO.DateTime = DateTime.Now;
                this._betting = false;
                return transactionDTO;
            }

            
            string following = string.Empty;
            if (followtype)
                following = "following";
            else
                following = "unfollowing";

            string betKindValue = string.Empty;
            string homeTeamName = string.Empty;
            string awayTeamName = string.Empty;
            string newOddValue = string.Empty;
            string newHomeScore = string.Empty;
            string newAwayScore = string.Empty;

            bool flag = false;
            bool flag2 = false;
            string text = string.Empty;

            //System.Collections.Generic.List<MatchDTO> listIbetMatch = this._listIBETMatch;
            Dictionary<string, IbetMatch> listIbetMatch = this._ibetMatchs;
            //MatchDTO matchDTO = MatchDTO.SearchMatchFull(ibetMatch, listIbetMatch);
            if (ibetMatch != null && ibetMatch.HomeTeamName != string.Empty)
            {
                //OddDTO oddDTO = OddDTO.SearchOdd(oddType, odd, true, ibetMatch.Odds);
                //if (oddDTO != null)
                //{
                    string ibetOddNow = string.Empty;
                    //if (ibetOddType == "a")
                    //    ibetOddNow = oddDTO.Away.ToString();
                    //else
                    //    ibetOddNow = oddDTO.Home.ToString();
                    if (followtype || (!followtype && ((float.Parse(ibetOddNow) >= (float)txtLowestOddValue.Value && float.Parse(ibetOddNow) > 0)) || float.Parse(ibetOddNow) < 0))
                    {
                        int maxBet = 0;
                        int minBet = 0;
                        string ibetOddID = oddID;
                        try
                        {
                            string valueAway = "";
                            if (BetStrategy == "Under" || BetStrategy == "Over")
                            {
                                #region UNDER_OVER
                                if (BetStrategy == "Under")
                                {
                                    ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                    valueAway = newOddValue;
                                    Thread.Sleep(2000);
                                    ibetEngine.PrepareBet2(ibetOddID, "a", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                }
                                else if (BetStrategy == "Over")
                                {
                                    ibetEngine.PrepareBet2(ibetOddID, "a", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                    valueAway = newOddValue;
                                    Thread.Sleep(2000);
                                    ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                }
                                if (homeTeamName == ibetMatch.HomeTeamName)
                                {
                                    if (valueAway == newOddValue)
                                    {
                                        ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                        if (!flag2)
                                        {
                                            if (BetStrategy == "Under")
                                                text = "Under:: Confirm bet failed";
                                            else
                                                text = "Over:: Confirm bet failed";
                                        }
                                        else
                                        {
                                            this._lastTransactionTime = DateTime.Now;
                                            if (BetStrategy == "Under")
                                            {
                                                text = "Under:: - Success ";
                                                UpdateOddBetHistory(oddID + "a", "a");
                                            }
                                            else
                                            {
                                                text = "Over:: - Success ";
                                                UpdateOddBetHistory(oddID + "h", "h");
                                            }
                                            this._ibetEngine.ibetAgent.RefreshBetList();
                                        }
                                    }
                                    else
                                    {
                                        if (BetStrategy == "Under")
                                            text = "Under:: Odd requested: " + oddPrice.ToString();
                                        else
                                            text = "Over:: Odd requested: " + oddPrice.ToString();
                                    }
                                }
                                else
                                {
                                    if (BetStrategy == "Under")
                                        text = "Under:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                    else
                                        text = "Over:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                }
                                #endregion
                            }
                            else if (BetStrategy == "Over9290")
                            {
                                #region Over9290
                                ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                if (flag && homeTeamName == ibetMatch.HomeTeamName)
                                {
                                    ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                    if (!flag2)
                                    {
                                        text = "Over 92/90:: Confirm bet failed";
                                    }
                                    else
                                    {
                                        this._lastTransactionTime = DateTime.Now;
                                        text = "Over 92/90:: - Success ";
                                        //this._ibetEngine.ibetAgent.RefreshBetList();
                                        UpdateOddBetHistory(oddID + "h", "h");
                                    }
                                }
                                else
                                {
                                    text = "Over1.75:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                }
                                #endregion 
                            }
                            else if (BetStrategy == "SapKeo")
                            {
                                #region SAP_KEO
                                stake = ((int)(int.Parse(stake) * 1.5)).ToString();
                                ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                if (newOddValue == oddPrice.ToString())
                                {
                                    if (homeTeamName == ibetMatch.HomeTeamName)
                                    {
                                        ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                        if (!flag2)
                                        {
                                            text = "Sap Keo:: Confirm bet failed";
                                        }
                                        else
                                        {
                                            this._lastTransactionTime = DateTime.Now;
                                            text = "Odd Down:: - Success ";
                                            //this._ibetEngine.ibetAgent.RefreshBetList();
                                            UpdateOddBetHistory(oddID + "h", "h");
                                        }
                                    }
                                    else
                                    {
                                        text = "Sap Keo:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                    }
                                }
                                else
                                {
                                    text = "Sap Keo:: Odd change. Requested: " + oddPrice.ToString();
                                }
                                #endregion
                            }
                            else if (BetStrategy == "Over1.75")
                            {
                                #region Over1.75
                                ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                if (homeTeamName == ibetMatch.HomeTeamName)
                                {
                                    ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                    if (!flag2)
                                    {
                                        text = "Over1.75:: Confirm bet failed";
                                    }
                                    else
                                    {
                                        this._lastTransactionTime = DateTime.Now;
                                        text = "Over1.75:: - Success ";
                                        //this._ibetEngine.ibetAgent.RefreshBetList();
                                        UpdateOddBetHistory(oddID + "h", "h");
                                    }
                                }
                                else
                                {
                                    text = "Over1.75:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                }
                                #endregion
                            }
                            else if (BetStrategy == "nguoc" || BetStrategy == "xuoi")
                            {
                                #region BEST_STRATEGIES
                                if (BetStrategy == "nguoc")
                                {
                                    ibetEngine.PrepareBet2(ibetOddID, "a", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                    valueAway = newOddValue;
                                    Thread.Sleep(2000);
                                    ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                }
                                else if (BetStrategy == "xuoi")
                                {
                                    ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                    valueAway = newOddValue;
                                    Thread.Sleep(2000);
                                    ibetEngine.PrepareBet2(ibetOddID, "a", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                }

                                if (homeTeamName == ibetMatch.HomeTeamName)
                                {
                                    if (valueAway == newOddValue)
                                    {
                                        ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                        if (!flag2)
                                        {
                                            text = "Best Strategy:: Confirm bet failed";
                                        }
                                        else
                                        {
                                            this._lastTransactionTime = DateTime.Now;
                                            text = "Best Strategy:" + this.txtAddValue.Value.ToString() + " : - Success. " + BetStrategy.Replace("nguoc", "Over").Replace("xuoi", "Under");
                                            this._ibetEngine.ibetAgent.RefreshBetList();
                                            if (BetStrategy == "nguoc")
                                            {
                                                UpdateOddBetHistory(oddID + "h", "h");
                                            }
                                            else if (BetStrategy == "xuoi")
                                            {
                                                UpdateOddBetHistory(oddID + "a", "a");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        text = "Best Strategy:: Odd requested: " + oddPrice.ToString();
                                    }
                                }
                                else
                                {
                                    text = "Best Strategy:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                }
                                #endregion
                            }
                            #region IBET_vs_IBET_Over
                            else if (BetStrategy.Contains("Over15_Fang"))
                            {

                                ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                if (homeTeamName == ibetMatch.HomeTeamName
                                    && (homeTeamName.Contains("30:01-45:00") || homeTeamName.Contains("75:01-90:00"))
                                    )
                                {
                                    ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                    if (!flag2)
                                    {
                                        text = "Over_15:: Confirm bet failed";
                                    }
                                    else
                                    {
                                        this._lastTransactionTime = DateTime.Now;
                                        text = "Over_15:: - Success ";
                                        UpdateOddBetHistory(oddID + "h", "h");

                                        //this._ibetEngine.ibetAgent.RefreshBetList();
                                    }
                                }
                            }

                            #endregion
                            else if (BetStrategy.Contains("Over15_XA"))
                            {
                                #region IBET_vs_IBET_Over30-45_XA

                                ibetEngine.PrepareBetFor2ndIBET(ibetOddID, ibetOddType, oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                if (homeTeamName.TrimEnd() == ibetMatch.HomeTeamName && awayTeamName.TrimEnd() == ibetMatch.AwayTeamName)
                                {
                                    
                                    if (float.Parse(newOddValue) >= 0.35f || float.Parse(newOddValue) < 0f)//tranh suu ban
                                    {
                                        if (!betKindValue.EndsWith("75"))
                                        {
                                            ibetEngine.ConfirmBetFor2ndIBET(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                            if (!flag2)
                                            {
                                                text = BetStrategy + ":: Confirm bet failed";
                                            }
                                            else
                                            {
                                                this._lastTransactionTime = DateTime.Now;
                                                text = BetStrategy + ":: - Success ";
                                                UpdateOddBetHistory(oddID + ibetOddType, ibetOddType);
                                                UpdateOddBetHistory(RefID + ibetOddType, ibetOddType);
                                                this._ibetEngine.ibetAgent2.RefreshBetList();
                                            }
                                        }
                                    }
                                    else
                                    {
                                        text = BetStrategy + ":: Keo nho hon 0.35 >> Hien tai: " + newOddValue + ". Xem xet xa tay >>>>>>>>>>";
                                    }
                                }
                                else
                                {
                                    iBet.Utilities.WriteLog.Write("Not same match: Tim: " + ibetMatch.HomeTeamName + "-" 
                                    + ibetMatch.AwayTeamName + "Tra ve: " + homeTeamName + "-" + awayTeamName);
                                }

                                #endregion


                            }                            
                        }
                        catch (Exception ex)
                        {
                            text = ex.Message;
                        }
                    }
                    else
                    {
                        text = "Odd value is smaller than lowest accepted:" + ibetOddNow;
                    }
                //}
                //else
                //{
                //    string text2 = string.Empty;                    
                //    text = "Odd not found.";
                //}
            }
            else
                text = "Match not found ";


            transactionDTO.HomeTeamName = homeTeamName + ":" + homeScore;
            transactionDTO.AwayTeamName = awayTeamName + ":" + awayScore;
            transactionDTO.HomeScore = homeScore;
            transactionDTO.AwayScore = awayScore;
            transactionDTO.Score = homeScore + "-" + awayScore;
            transactionDTO.AccountPair = this._ibetAccount;// +" - " + this._ibetSubAccount;
            transactionDTO.OddType = oddType.ToString();
            transactionDTO.Odd = betKindValue;
            transactionDTO.OddKindValue = betKindValue;
            transactionDTO.OddValue = newOddValue;
            transactionDTO.Stake = stake;            
            transactionDTO.Note = text + " >>> " + acctoScan;
            transactionDTO.IBETTrade = flag2;
            transactionDTO.IBETAllow = flag;
            transactionDTO.IsFollowTypeTrans = true;
            transactionDTO.DateTime = DateTime.Now;
            transactionDTO.FollowRef = followref;

            this._betting = false;
            return transactionDTO;
        }
コード例 #6
0
        private TransactionDTO PlaceBet(bool sendOrNOT, MatchDTO ibetMatch, MatchDTO sbobetMatch, eOddType oddType, string ibetOddID, string sbobetOddID, string ibetOddType, string sbobetOddType, string ibetOddValue, string sbobetOddValue, int ibetStake, int sbobetStake, IBetEngine ibetEngine, SbobetEngine sbobetEngine, string sbobetOdd, bool ibetHomeGive)
        {
            this._betting = true;
            TransactionDTO transactionDTO = new TransactionDTO();
            //transactionDTO.OddType = oddType.ToString() + " - " + ibetOddType.Replace("h", "Home").Replace("a", "Away") + " / " + sbobetOddType.Replace("h", "Home").Replace("a", "Away");
            string text = "";
            string text2 = "";
            string text3 = "";
            bool flag = false;
            bool flag2 = false;
            int num = 0;
            int num2 = 0;
            string text4 = "";
            string text5 = "";
            string text6 = "";
            bool flag3 = false;
            bool flag4 = false;
            bool sBOBETReTrade = false;
            int num3 = 0;
            string text7 = "";
            string betCount = "";
            string text8 = "";
            bool flag5 = false;

            float ibetOddValue_ = float.Parse(ibetOddValue);
            float sboOddValue_ = float.Parse(sbobetOddValue);

            if (ibetOddValue_ > 0.84 || (ibetOddValue_ > 0f && txtAddValue.Value.ToString() == "0.01"))
            {
                float valueAdd = ibetStake * (float)txtAddValue.Value;
                ibetStake = ibetStake + (int)valueAdd;
            }
            if (sboOddValue_ > 0.84 || (sboOddValue_ > 0f && txtAddValue.Value.ToString() == "0.01"))
            {
                float valueAdd = sbobetStake * (float)txtAddValue.Value;
                sbobetStake = sbobetStake + (int)valueAdd;
            }

            if (MatchDTO.IsSameMatch(ibetMatch.HomeTeamName.ToLower(), sbobetMatch.HomeTeamName.ToLower(), ibetMatch.AwayTeamName.ToLower(), sbobetMatch.AwayTeamName.ToLower()))
            {
                try
                {
                    ibetEngine.PrepareBet(ibetOddID, ibetOddType, ibetOddValue, ibetStake.ToString(), out flag, out num, out num2, out text4, out text2, out text3);
                    sbobetEngine.PrepareBet(sbobetOddID, sbobetOddValue, sbobetOddType, out betCount, out num3, out flag3, out text7, out text5, out text6);
                    if (MatchDTO.IsSameMatch(text2, text5, text3, text6))
                    {
                        if (flag && flag3)
                        {
                            if ((checkEdit13.Checked || checkEdit15.Checked) && sendOrNOT)//gui lenh
                            {
                                var taskA = new Task(() => this.AddOddToLocalCommunity(ibetMatch, sbobetMatch, oddType, sbobetOdd, sbobetOdd, ibetOddType, sbobetOddType, ibetOddValue, sbobetOddValue, ibetHomeGive));
                                taskA.Start();
                            }
                            float num4 = float.Parse(text4);
                            float num5 = float.Parse(text7);
                            if (num4 + num5 == 0f || num4 == num5)
                            {
                                if (ibetStake <= num2 && sbobetStake <= num3)
                                {
                                    try
                                    {                                        
                                        float currentCredit = 0;
                                        float currentCredit2 = 0;
                                        if (checkEdit8.Checked)
                                        {
                                            currentCredit = ibetEngine.GetCurrentCredit();
                                            currentCredit2 = sbobetEngine.GetCurrentCredit();
                                        }
                                        else
                                        {
                                            currentCredit = ibetEngine._currentCredit;
                                            currentCredit2 = sbobetEngine._currentCredit;
                                        }

                                        if ((float)ibetStake <= currentCredit && (float)sbobetStake <= currentCredit2)
                                        {
                                            try
                                            {
                                                
                                                ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), num.ToString(), num2.ToString(), out flag2);
                                                if (flag2)
                                                {
                                                    sbobetEngine.ConfirmBet(sbobetOddID, sbobetOddValue, sbobetOddType, sbobetStake.ToString(), betCount, out text8, out flag4);
                                                    if (!flag4)
                                                    {
                                                        try
                                                        {
                                                            sbobetEngine.PrepareBet(sbobetOddID, text8, sbobetOddType, out betCount, out num3, out flag5, out text7, out text5, out text6);
                                                            if (MatchDTO.IsSameMatch(text2, text5, text3, text6))
                                                            {
                                                                num5 = float.Parse(text7);
                                                                if (num4 + num5 == 0f || num4 == num5)
                                                                {
                                                                    text = "Retrade. IBET: " + ibetOddValue + " -  SBOBET: " + text8;
                                                                    sbobetEngine.ConfirmBet(sbobetOddID, text8, sbobetOddType, sbobetStake.ToString(), betCount, out text8, out sBOBETReTrade);
                                                                    this._lastTransactionTime = System.DateTime.Now;
                                                                }
                                                                else
                                                                {
                                                                    text = "Invalid Odd while Retrade. IBET Odd: " + text4 + " - SBOBET Odd:" + text7;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                text = string.Concat(new string[]
																{
																	"Not Same Match - Retrade. IBET: ", 
																	text2, 
																	" / ", 
																	text3, 
																	" - SBOBET: ", 
																	text5, 
																	" / ", 
																	text6
																});
                                                            }
                                                        }
                                                        catch (System.Exception ex)
                                                        {
                                                            text = "Error while Retrade. Details: " + ex.Message;
                                                        }
                                                    }
                                                    this._lastTransactionTime = System.DateTime.Now;
                                                    object obj = text;
                                                    text = string.Concat(new object[]
													{
														obj, 
														" - Success Transaction. Half: ", 
														ibetMatch.Half, 
														" - Minute: ", 
														ibetMatch.Minute, 
														" - Halftime: ", 
														ibetMatch.IsHalfTime
													});
                                                }
                                                
                                            }
                                            catch (System.Exception ex)
                                            {
                                                text = "Error while Trading. Details: " + ex.Message;
                                            }
                                        }
                                        else
                                        {
                                            text = string.Concat(new object[]
											{
												"Out of Cash. IBET Credit: ", 
												currentCredit, 
												" -  SBOBET Credit: ", 
												currentCredit2
											});
                                        }
                                    }
                                    catch (System.Exception ex)
                                    {
                                        text = "Error while getting Credit. Details: " + ex.Message;
                                    }
                                }
                                else
                                {
                                    text = string.Concat(new object[]
									{
										"Max Bet. IBET: ", 
										num2, 
										" - SBOBET: ", 
										num3
									});
                                }
                            }
                            else
                            {
                                text = "Invalid Odd while Preparing Ticket. IBET Odd: " + text4 + " - SBOBET Odd:" + text7;
                            }
                        }
                    }
                    else
                    {
                        text = string.Concat(new string[]
						{
							"Not Same Match - Preparing Ticket. IBET: ", 
							text2, 
							" / ", 
							text3, 
							" - SBOBET: ", 
							text5, 
							" / ", 
							text6
						});
                    }
                }
                catch (System.Exception ex)
                {
                    text = "Error while Preparing Trade. Details: " + ex.Message;
                }
            }
            else
            {
                text = string.Concat(new string[]
				{
					"Not Same Match - Comparing. IBET: ", 
					ibetMatch.HomeTeamName, 
					" / ", 
					ibetMatch.AwayTeamName, 
					" - SBOBET: ", 
					sbobetMatch.HomeTeamName, 
					" / ", 
					sbobetMatch.AwayTeamName
				});
            }
            transactionDTO.HomeTeamName = ibetMatch.HomeTeamName + " / " + sbobetMatch.HomeTeamName;
            transactionDTO.AwayTeamName = ibetMatch.AwayTeamName + " / " + sbobetMatch.AwayTeamName;
            transactionDTO.Odd = text4 + " / " + text7;
            transactionDTO.OddKindValue = text4 + " / " + text7;
            transactionDTO.OddValue = ibetOddValue + " / " + sbobetOddValue;
            transactionDTO.Stake = ibetStake + " / " + sbobetStake;
            transactionDTO.IBETAllow = flag;
            transactionDTO.IBETTrade = flag2;
            transactionDTO.IBETReTrade = false;
            transactionDTO.SBOBETAllow = flag3;
            transactionDTO.SBOBETTrade = flag4;
            transactionDTO.SBOBETReTrade = sBOBETReTrade;
            transactionDTO.OddType = oddType.ToString();
            transactionDTO.Note = text;
            transactionDTO.DateTime = System.DateTime.Now;
            transactionDTO.OddType = oddType.ToString() + " - " + ibetOddType.Replace("h", "Home").Replace("a", "Away") + " / " + sbobetOddType.Replace("h", "Home").Replace("a", "Away");
            this._betting = false;
            return transactionDTO;
            
        }
コード例 #7
0
        private void CompareSameMatchOld()
        {
            this._comparing = true;
            lock (this._listSameMatch)
            {
                System.Collections.Generic.List<MatchDTO> listIBETMatch = this._listIBETMatch;
                System.Collections.Generic.List<MatchDTO> listSbobetMatch = this._listSbobetMatch;
                if (this._listSameMatch != null)
                {
                    this._listSameMatch.Clear();
                }
                else
                {
                    this._listSameMatch = new System.Collections.Generic.List<MatchDTO>();
                }


                System.DateTime now = System.DateTime.Now;
                System.TimeSpan timeSpan;
                foreach (MatchDTO current in listIBETMatch) // current = IBET
                {
                    MatchDTO matchDTO = MatchDTO.SearchMatch(current, listSbobetMatch);//matchDTO = SBOBET
                    if (matchDTO != null)
                    {
                        this._listSameMatch.Add(current);
                        bool NOTchkAllowMatches = true;
                        if (checkEdit10.Checked)
                        {
                            int numFound = chkListAllowedMatch.FindString(current.HomeTeamName + " - " + current.AwayTeamName);
                            NOTchkAllowMatches = numFound != -1 && chkListAllowedMatch.Items[numFound].CheckState.ToString() == "Checked";

                        }

                        if (NOTchkAllowMatches)
                        {

                            if (this.chbAllowHalftime.Checked || !current.IsHalfTime)
                            {
                                if (current.Minute <= (int)this.txtMaxTimePerHalf.Value)
                                {
                                    foreach (OddDTO current2 in current.Odds) //current2 = odd ibet
                                    {
                                        if (this.AllowOddBet(current2.ID,""))
                                        {
                                            OddDTO oddDTO = OddDTO.SearchOdd(current2, matchDTO.Odds);
                                            if (oddDTO != null)
                                            {
#if DEBUG
                                                Utilities.WriteLog.Write("Odd found: " + oddDTO.Odd.ToString());
#endif
                                                if ((checkEdit4.Checked && ((oddDTO.Type == eOddType.FirstHalfOverUnder || oddDTO.Type == eOddType.FulltimeOverUnder) && (current.Minute < 30 || (checkEdit7.Checked && current.Minute >= 30)))) || (checkEdit3.Checked && (oddDTO.Type == eOddType.FirstHalfHandicap || oddDTO.Type == eOddType.FulltimeHandicap)))
                                                {
                                                    if (current2.Home >= (float)this.txtLowestOddValue.Value || 0f - current2.Home >= (float)this.txtLowestOddValue.Value)
                                                    {
                                                        if (OddDTO.IsValidOddPair(current2.Home, oddDTO.Away, (double)this.txtOddValueDifferenet.Value, this.chbHighRevenueBoost.Checked))
                                                        {//IBET HOME - SBO AWAY
                                                            if (checkEdit15.Checked)//gui lenh pure odd
                                                            {
                                                                var taskA = new Task(() => this.AddOddToLocalCommunity(current, matchDTO, current2.Type, current2.Odd, oddDTO.Odd, "h", "a", current2.Home.ToString(), oddDTO.Away.ToString(), current2.HomeFavor));
                                                                taskA.Start();
                                                            }
                                                            else
                                                            {
                                                                TransactionDTO transactionDTO = new TransactionDTO();
                                                                if (this.chbRandomStake.Checked)
                                                                {
                                                                    int num = 0;
                                                                    while (num == 0)
                                                                    {
                                                                        string strNum = this.txtStake.Lines[new System.Random().Next(this.txtStake.Lines.Length)];
                                                                        int.TryParse(strNum, out num);
                                                                    }
                                                                    int ibetStake = num;
                                                                    int sbobetStake = num;
                                                                    MatchDTO ibetmatch = current;
                                                                    MatchDTO sbobetmatch = matchDTO;
                                                                    eOddType oddtype = current2.Type;
                                                                    string ibetoddID = current2.ID;
                                                                    string sbobetoddID = oddDTO.ID;
                                                                    string ibetoddType = "h";
                                                                    string sbobetoddType = "a";
                                                                    //float num2 = current2.Home;
                                                                    string ibetOddValuee = current2.Home.ToString();
                                                                    float sbobetOddValue = oddDTO.Away;
                                                                    //transactionDTO.OddType = current2.Type.ToString() + " - Home / Away";
                                                                    var taskA = new Task(() =>
                                                                        TransactionProcessMaxBet(ibetmatch, sbobetmatch, oddtype, ibetoddID, sbobetoddID, ibetoddType, sbobetoddType, ibetOddValuee, sbobetOddValue.ToString(), ibetStake, sbobetStake, current2.HomeFavor, this._ibetEngine, this._sbobetEngine, oddDTO.Odd)
                                                                        );
                                                                    taskA.Start();

                                                                }
                                                                else
                                                                {
                                                                    int num = 0;
                                                                    while (num == 0)
                                                                    {
                                                                        string strNum = this.txtStake.Lines[new System.Random().Next(this.txtStake.Lines.Length)];
                                                                        int.TryParse(strNum, out num);
                                                                    }

                                                                    int ibetStake = num;
                                                                    int sbobetStake = (int)Math.Round(num * ((float)this.txtSBOBETFixedStake.Value / (float)this.txtIBETFixedStake.Value));

                                                                    MatchDTO ibetmatch = current;
                                                                    MatchDTO sbobetmatch = matchDTO;
                                                                    eOddType oddtype = current2.Type;
                                                                    string ibetoddID = current2.ID;
                                                                    string sbobetoddID = oddDTO.ID;
                                                                    string ibetoddType = "h";
                                                                    string sbobetoddType = "a";
                                                                    string ibetOddValuee = current2.Home.ToString();
                                                                    float sbobetOddValue = oddDTO.Away;
                                                                    //transactionDTO = this.PlaceBet(ibetmatch, sbobetmatch, oddtype, ibetoddID, sbobetoddID, ibetoddType, sbobetoddType, ibetOddValuee, sbobetOddValue.ToString(), ibetStake, sbobetStake, this._ibetEngine, this._sbobetEngine);
                                                                    //transactionDTO.OddType = current2.Type.ToString() + " - Home / Away";
                                                                    //this.AddTransaction(transactionDTO);
                                                                    var taskA = new Task(() =>
                                                                        TransactionProcess(ibetmatch, sbobetmatch, oddtype, ibetoddID, sbobetoddID, ibetoddType, sbobetoddType, ibetOddValuee, sbobetOddValue.ToString(), ibetStake, sbobetStake, this._ibetEngine, this._sbobetEngine, oddDTO.Odd, current2.IsHomeGive)
                                                                        );
                                                                    taskA.Start();
                                                                }
                                                            }
                                                        }
                                                    }
                                                    if (current2.Away >= (float)this.txtLowestOddValue.Value || 0f - current2.Away >= (float)this.txtLowestOddValue.Value)
                                                    {
                                                        if (OddDTO.IsValidOddPair(current2.Away, oddDTO.Home, (double)this.txtOddValueDifferenet.Value, this.chbHighRevenueBoost.Checked))
                                                        {
                                                            if (checkEdit15.Checked)//gui lenh pure odd
                                                            {
                                                                var taskA = new Task(() => this.AddOddToLocalCommunity(current, matchDTO, current2.Type, current2.Odd, oddDTO.Odd, "h", "a", current2.Home.ToString(), oddDTO.Away.ToString(), current2.HomeFavor));
                                                                taskA.Start();
                                                            }
                                                            else
                                                            {
                                                                if (this.chbRandomStake.Checked)
                                                                {
                                                                    int num = 0;
                                                                    while (num == 0)
                                                                    {
                                                                        string strNum = this.txtStake.Lines[new System.Random().Next(this.txtStake.Lines.Length)];
                                                                        int.TryParse(strNum, out num);
                                                                    }
                                                                    int ibetStake = num;
                                                                    int sbobetStake = num;
                                                                    MatchDTO ibetmatch = current;
                                                                    MatchDTO sbobetmatch = matchDTO;
                                                                    eOddType oddtype = current2.Type;
                                                                    string ibetoddID = current2.ID;
                                                                    string sbobetoddID = oddDTO.ID;
                                                                    string ibetoddType = "a";
                                                                    string sbobetoddType = "h";
                                                                    float num2 = current2.Away;
                                                                    string ibetOddValuee = num2.ToString();
                                                                    string sbobetOddValue = oddDTO.Home.ToString();//sbobetodd value
                                                                    //transactionDTO = this.PlaceBetAllowMaxBet(ibetmatch, sbobetmatch, oddtype, ibetoddID, sbobetoddID, ibetoddType, sbobetoddType, ibetOddValuee, num2.ToString(), ibetStake, sbobetStake, current2.HomeFavor, this._ibetEngine, this._sbobetEngine, current2.Odd, oddDTO.Odd);
                                                                    //transactionDTO.OddType = current2.Type.ToString() + " - Away / Home";
                                                                    //this.AddTransaction(transactionDTO);
                                                                    var taskA = new Task(() =>
                                                                        TransactionProcessMaxBet(ibetmatch, sbobetmatch, oddtype, ibetoddID, sbobetoddID, ibetoddType, sbobetoddType, ibetOddValuee, sbobetOddValue, ibetStake, sbobetStake, current2.HomeFavor, this._ibetEngine, this._sbobetEngine, oddDTO.Odd)
                                                                        );
                                                                    taskA.Start();
                                                                }
                                                                else
                                                                {
                                                                    int num = 0;
                                                                    while (num == 0)
                                                                    {
                                                                        string strNum = this.txtStake.Lines[new System.Random().Next(this.txtStake.Lines.Length)];
                                                                        int.TryParse(strNum, out num);
                                                                    }
                                                                    //int ibetStake = (int)this.txtIBETFixedStake.Value;
                                                                    int ibetStake = num;
                                                                    int sbobetStake = (int)Math.Round(num * ((float)this.txtSBOBETFixedStake.Value / (float)this.txtIBETFixedStake.Value));

                                                                    MatchDTO ibetmatch = current;
                                                                    MatchDTO sbobetmatch = matchDTO;
                                                                    eOddType oddtype = current2.Type;
                                                                    string ibetoddID = current2.ID;
                                                                    string sbobetoddID = oddDTO.ID;
                                                                    string ibetoddType = "a";
                                                                    string sbobetoddType = "h";
                                                                    float num2 = current2.Away;
                                                                    string ibetOddValuee = num2.ToString();
                                                                    string sbobetOddValue = oddDTO.Home.ToString();//sbobet odd value
                                                                    //transactionDTO = this.PlaceBet(ibetmatch, sbobetmatch, oddtype, ibetoddID, sbobetoddID, ibetoddType, sbobetoddType, ibetOddValuee, num2.ToString(), ibetStake, sbobetStake, this._ibetEngine, this._sbobetEngine);
                                                                    //transactionDTO.OddType = current2.Type.ToString() + " - Away / Home";
                                                                    //this.AddTransaction(transactionDTO);
                                                                    var taskA = new Task(() =>
                                                                        TransactionProcess(ibetmatch, sbobetmatch, oddtype, ibetoddID, sbobetoddID, ibetoddType, sbobetoddType, ibetOddValuee, sbobetOddValue.ToString(), ibetStake, sbobetStake, this._ibetEngine, this._sbobetEngine, oddDTO.Odd, current2.IsHomeGive)
                                                                        );
                                                                    taskA.Start();
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                System.DateTime now2 = System.DateTime.Now;
                timeSpan = now2 - now;
                double totalMilliseconds = timeSpan.TotalMilliseconds;
                BarItem arg_648_0 = this.lblSbobetTotalMatch;
                int count = listSbobetMatch.Count;
                arg_648_0.Caption = count.ToString();
                BarItem arg_663_0 = this.lblIbetTotalMatch;
                count = listIBETMatch.Count;
                arg_663_0.Caption = count.ToString();
                this.lblSameMatch.Caption = "Total Same Match: " + this._listSameMatch.Count;
                this.lblLastUpdate.Caption = System.DateTime.Now.ToString();
                lock (this.grdSameMatch)
                {
                    this.grdSameMatch.RefreshDataSource();
                }
            }
            this._comparing = false;
            if (this._compareAgain && !this._comparing)
            {
                this._compareAgain = false;
                this.CompareSameMatch();
            }
        }
コード例 #8
0
 private void TransactionProcess(MatchDTO ibetMatch, MatchDTO sbobetMatch, eOddType oddType, string ibetOddID, string sbobetOddID, string ibetOddType, string sbobetOddType, string ibetOddValue, string sbobetOddValue, int ibetStake, int sbobetStake, IBetEngine ibetEngine, SbobetEngine sbobetEngine, string sbobetOdd, bool homeFavor)
 {
     if (!this._betting)
     {
         TransactionDTO transactionDTO = new TransactionDTO();
         transactionDTO = this.PlaceBet(true, ibetMatch, sbobetMatch, oddType, ibetOddID, sbobetOddID, ibetOddType, sbobetOddType, ibetOddValue, sbobetOddValue.ToString(), ibetStake, sbobetStake, this._ibetEngine, this._sbobetEngine, sbobetOdd, homeFavor);
         this.AddTransaction(transactionDTO);
         if (transactionDTO != null && transactionDTO.IBETTrade)
         {
             this.UpdateOddBetHistory(ibetOddID,"");
         }
     }
 }
コード例 #9
0
		private TransactionDTO PlaceBet(
            MatchDTO ibetMatch,
            MatchDTO threein1betMatch,
            eOddType oddType,
            string ibetOddID,
            string ibetOddType,
            string ibetOddValue,
            OddDTO threein1Odd,
            string threein1OddType,
            int ibetStake,
            int threein1betStake,
            IBetEngine ibetEngine,
            ThreeIn1BetEngine threein1betEngine)
		{
			TransactionDTO transactionDTO = new TransactionDTO();
            string text = string.Empty;
            string text2 = string.Empty;
            string text3 = string.Empty;
			bool flag = false;
			bool flag2 = false;
			int num = 0;
			int num2 = 0;
            string text4 = string.Empty;
            string text5 = string.Empty;
            string text6 = string.Empty;
			bool flag3 = false;
			bool flag4 = false;
			bool sBOBETReTrade = false;
			int num3 = 0;
            
            string text7 = string.Empty;
            string betCount = string.Empty;
            
            string text8 = string.Empty;
			

            bool threein1betAllowance = false;
            int threein1betminStake = 0;
            int threein1betmaxStake = 0;
            string threein1betKindValue = string.Empty;
            string threein1betHomeTeamName = string.Empty;
            string threein1betAwayTeamName = string.Empty;
            string postBODY = string.Empty;  

            if (MatchDTO.IsSameMatch(ibetMatch.HomeTeamName.ToLower(), threein1betMatch.HomeTeamName.ToLower(), ibetMatch.AwayTeamName.ToLower(), threein1betMatch.AwayTeamName.ToLower()))
			{
				try
				{
					ibetEngine.PrepareBet(ibetOddID, ibetOddType, ibetOddValue, ibetStake.ToString(), out flag, out num, out num2, out text4, out text2, out text3);
                    threein1betEngine.PrepareBet(threein1Odd.ID, threein1Odd.Away.ToString(), threein1Odd.Type.ToString().Replace("FulltimeHandicap", "Hdp").Replace("", ""), "Away", threein1Odd.IsHomeGive.ToString().Replace("True", "1").Replace("False", "0"), threein1Odd.Odd, threein1betMatch.HomeScore, threein1betMatch.AwayScore, threein1betMatch.ID, threein1betMatch.IsHalfTime.ToString().Replace("True", "1").Replace("False", "0"), threein1betStake.ToString(),
                        out threein1betAllowance, out threein1betminStake, out threein1betmaxStake, out threein1betKindValue, out threein1betHomeTeamName, out threein1betAwayTeamName, out postBODY);
                    
                    if (MatchDTO.IsSameMatch(text2, text5, text3, text6))
					{
						if (flag && flag3)
						{
							float num4 = float.Parse(text4);
							float num5 = float.Parse(text7);
							if (num4 + num5 == 0f || num4 == num5)
							{
								if (ibetStake <= num2 && threein1betStake <= num3)
								{
									try
									{
										float currentCredit = ibetEngine.GetCurrentCredit();
                                        float currentCredit2 = threein1betEngine.GetCurrentCredit();
										if ((float)ibetStake <= currentCredit && (float)threein1betStake <= currentCredit2)
										{
											try
											{
												ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), num.ToString(), num2.ToString(), out flag2);
												if (flag2)
												{
                                                    //threeIn1BetEngine.ConfirmBet(oddType,
                                                    //    threein1betOddValue,
                                                    //    threein1betStake.ToString(), 
                                                    //    betCount, 
                                                    //    text8, 
                                                    //    out flag4);
													if (!flag4)
													{
														try
														{
                                                            //
														}
														catch (System.Exception ex)
														{
															text = "Error while Retrade. Details: " + ex.Message;
														}
													}
													this._lastTransactionTime = System.DateTime.Now;
													object obj = text;
													text = string.Concat(new object[]
													{
														obj, 
														" - Success Transaction. Half: ", 
														ibetMatch.Half, 
														" - Minute: ", 
														ibetMatch.Minute, 
														" - Halftime: ", 
														ibetMatch.IsHalfTime
													});
												}
											}
											catch (System.Exception ex)
											{
												text = "Error while Trading. Details: " + ex.Message;
											}
										}
										else
										{
											text = string.Concat(new object[]
											{
												"Out of Cash. IBET Credit: ", 
												currentCredit, 
												" -  3in1BET Credit: ", 
												currentCredit2
											});
										}
									}
									catch (System.Exception ex)
									{
										text = "Error while getting Credit. Details: " + ex.Message;
									}
								}
								else
								{
									text = string.Concat(new object[]
									{
										"Max Bet. IBET: ", 
										num2, 
										" - 3in1BET: ", 
										num3
									});
								}
							}
							else
							{
								text = "Invalid Odd while Preparing Ticket. IBET Odd: " + text4 + " - 3in1BET Odd:" + text7;
							}
						}
					}
					else
					{
						text = string.Concat(new string[]
						{
							"Not Same Match - Preparing Ticket. IBET: ", 
							text2, 
							" / ", 
							text3, 
							" - 3in1BET: ", 
							text5, 
							" / ", 
							text6
						});
					}
				}
				catch (System.Exception ex)
				{
					text = "Error while Preparing Trade. Details: " + ex.Message;
				}
			}
			else
			{
				text = string.Concat(new string[]
				{
					"Not Same Match - Comparing. IBET: ", 
					ibetMatch.HomeTeamName, 
					" / ", 
					ibetMatch.AwayTeamName, 
					" - 3in1BET: ", 
					threein1betMatch.HomeTeamName, 
					" / ", 
					threein1betMatch.AwayTeamName
				});
			}
            transactionDTO.HomeTeamName = ibetMatch.HomeTeamName + " / " + threein1betMatch.HomeTeamName;
            transactionDTO.AwayTeamName = ibetMatch.AwayTeamName + " / " + threein1betMatch.AwayTeamName;
			transactionDTO.Odd = text4 + " / " + text7;
			transactionDTO.OddKindValue = text4 + " / " + text7;
			transactionDTO.OddValue = ibetOddValue + " / " + threein1Odd.Away;
			transactionDTO.Stake = ibetStake + " / " + threein1betStake;
			transactionDTO.IBETAllow = flag;
			transactionDTO.IBETTrade = flag2;
			transactionDTO.IBETReTrade = false;
			transactionDTO.THREEIN1Allow = flag3;
			transactionDTO.THREEIN1Trade = flag4;
			transactionDTO.THREEIN1ReTrade = sBOBETReTrade;
			transactionDTO.OddType = oddType.ToString();
			transactionDTO.Note = text;
			transactionDTO.DateTime = System.DateTime.Now;
			return transactionDTO;
		}
コード例 #10
0
		private TransactionDTO PlaceBetAllowMaxBet(
            MatchDTO ibetMatch, 
            MatchDTO threein1betMatch, 
            eOddType oddType, 
            string ibetOddID,
            string ibetOddType,             
            string ibetOddValue, 
            OddDTO threein1Odd,
            string threein1OddType,
            int ibetStake, 
            int threein1betStake, 
            IBetEngine ibetEngine, 
            ThreeIn1BetEngine threein1betEngine)
		{
            
			TransactionDTO transactionDTO = new TransactionDTO(); //khoi tao transaction
            string text = string.Empty;			
            bool flagIBETOK = false;
            bool flag3IN1OK = false;
			
			bool threein1ReTrade = false;            
            string betCount = string.Empty;
            
            bool flagibetAllowance = false;
            int ibetminStake = 0;
            int ibetmaxStake = 0;
            string ibetBetKindValue = string.Empty;
            string ibetHomeTeamName = string.Empty;
            string ibetAwayTeamNam = string.Empty;

            bool ibetGoFirst = true;// who is Away or Under
            string threein1OddValue = string.Empty;
            if (threein1OddType == "Away") //neu 3in1 o vi tri away
            {
                threein1OddValue = threein1Odd.Away.ToString();
                if (threein1Odd.Type == eOddType.FirstHalfOverUnder || threein1Odd.Type == eOddType.FulltimeOverUnder) //neu 3in1 la Under
                {
                    ibetGoFirst = false; // cho 3in1 Confirm truoc
                }
                else // bong handicap
                {
                    if (threein1Odd.IsHomeGive) // neu away la doi cua duoi
                    {
                        ibetGoFirst = false;
                    }
                }
            }
            else if (threein1OddType == "Home") // neu 3in1 o vi tri home - ibet away
            {
                threein1OddValue = threein1Odd.Home.ToString();
                if (threein1Odd.Type == eOddType.FirstHalfOverUnder || threein1Odd.Type == eOddType.FulltimeOverUnder) //neu 3in1 la Over
                {
                    ibetGoFirst = true; // cho ibet Confirm truoc (under)
                }
                else // bong handicap
                {
                    if (!threein1Odd.IsHomeGive) // neu 3in1 la doi cua duoi
                    {
                        ibetGoFirst = false;
                    }
                }
            }

            bool flagthreein1betAllowance = false;
            int threein1betminStake = 0;
            int threein1betmaxStake = 0;
            string threein1betKindValue = string.Empty;
            string threein1betHomeTeamName = string.Empty;
            string threein1betAwayTeamName = string.Empty;
            
            string postBODY = string.Empty;            

            if (MatchDTO.IsSameMatch(ibetMatch.HomeTeamName.ToLower(), threein1betMatch.HomeTeamName.ToLower(), ibetMatch.AwayTeamName.ToLower(), threein1betMatch.AwayTeamName.ToLower()))
			{
				try
				{
                    ibetEngine.PrepareBet(ibetOddID, ibetOddType, ibetOddValue, ibetStake.ToString(), 
                        out flagibetAllowance, out ibetminStake, out ibetmaxStake, out ibetBetKindValue, out ibetHomeTeamName, out ibetAwayTeamNam);
                    
                    threein1betEngine.PrepareBet(
                        threein1Odd.ID,
                        threein1OddValue,//odd price
                        threein1Odd.Type.ToString(), 
                        threein1OddType, // "Away"
                        threein1Odd.IsHomeGive.ToString().Replace("True", "1").Replace("False", "0"),
                        threein1Odd.Odd, 
                        threein1betMatch.HomeScore, 
                        threein1betMatch.AwayScore, 
                        threein1betMatch.ID, 
                        threein1betMatch.IsHalfTime.ToString().Replace("True", "1").Replace("False", "0"), 
                        threein1betStake.ToString(),
                        out flagthreein1betAllowance, 
                        out threein1betminStake, 
                        out threein1betmaxStake, 
                        out threein1betKindValue, 
                        out threein1betHomeTeamName, 
                        out threein1betAwayTeamName,
                        out postBODY);
#if DEBUG
                    Utilities.WriteLog.Write("Calling threein1betEngine.PrepareBet");
#endif

                    if (MatchDTO.IsSameMatch(ibetHomeTeamName, threein1betHomeTeamName, ibetAwayTeamNam, threein1betAwayTeamName))
                    {
                        if (flagibetAllowance && flagthreein1betAllowance)
                        {
                            float numIbet = float.Parse(ibetBetKindValue);
                            float num3in1bet = float.Parse(threein1betKindValue);

                            if (numIbet + num3in1bet == 0f || numIbet == num3in1bet)
                            {
#if DEBUG
                                Utilities.WriteLog.Write("+ Valid bet, system is now going to confirm:" + ibetHomeTeamName + " - " + threein1betAwayTeamName);
#endif
                                int numMax = 0; // get minimum of Maximum bet allowed of two system
                                if (ibetmaxStake >= threein1betmaxStake)
                                {
                                    numMax = threein1betmaxStake;                                    
                                }
                                else
                                {
                                    numMax = ibetmaxStake;
                                }

                                if (ibetStake >= numMax) //compare stake with numMax
                                {
                                    ibetStake = numMax;
                                }
                                if (threein1betStake >= numMax)
                                {
                                    threein1betStake = numMax;
                                }

                                try
                                {
                                    float currentCredit = 0;
                                    float currentCredit2 = 0;
                                    if (checkEdit8.Checked)
                                    {
                                        currentCredit = ibetEngine.GetCurrentCredit();
                                        currentCredit2 = threein1betEngine.GetCurrentCredit();
                                    }
                                    else
                                    {
                                        currentCredit = ibetEngine._currentCredit;
                                        currentCredit2 = threein1betEngine._currentCredit;
                                    }
                                    
                                    
                                    if ((float)ibetStake <= currentCredit && (float)threein1betStake <= currentCredit2)
                                    {
                                        if (ibetGoFirst)
                                        {
                                            #region Confirm_IBET_first_then_3in1
#if DEBUG
                                            Utilities.WriteLog.Write("IBET GO FIRST!");
#endif
                                            try
                                            {
                                                ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), ibetminStake.ToString(), ibetmaxStake.ToString(), out flagIBETOK);
                                                if (flagIBETOK)// iBet Confirm thanh cong
                                                {
                                                    string odd3in1NEW = string.Empty;
                                                    threein1betEngine.ConfirmBet(postBODY, threein1betStake.ToString(), out flag3IN1OK, out odd3in1NEW);
                                                    if (!flag3IN1OK)
                                                    {
                                                        try
                                                        {
                                                            if (odd3in1NEW != "changed")
                                                            {
                                                                //threein1betEngine.ConfirmBet(postBODY, threein1betStake.ToString(), out flag3IN1OK, out odd3in1NEW);
                                                                this._lastTransactionTime = System.DateTime.Now;
                                                                playSound(false);
                                                                text = "Odd 3in1 changed";
                                                                this.lblIbetCurrentCredit.Caption = this._ibetEngine.GetCurrentCredit().ToString();
                                                                
                                                            }
                                                            else
                                                            {
                                                                text = "Invalid Odd while Retrade.";// IBET Odd: " +text4 + " - SBOBET Odd:" + text7;
                                                                this.lblIbetCurrentCredit.Caption = this._ibetEngine.GetCurrentCredit().ToString();
                                                                playSound(false);
                                                            }
                                                        }
                                                        catch (System.Exception ex)
                                                        {
                                                            text = "Error while Retrade. Details: " + ex.Message;
                                                            playSound(false);

#if DEBUG
                                                            Utilities.WriteLog.Write(text);
#endif
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.lbl3in1betCurrentCredit.Caption = this._3in1Engine.GetCurrentCredit().ToString();
                                                        this.lblIbetCurrentCredit.Caption = this._ibetEngine.GetCurrentCredit().ToString();
                                                        playSound(true);
                                                    }
                                                    this._lastTransactionTime = System.DateTime.Now;
                                                    object obj = text;
                                                    text = string.Concat(new object[]
												    {
													    obj, 
													    " - Success Transaction. Half: ", 
													    ibetMatch.Half, 
													    " - Minute: ", 
													    ibetMatch.Minute, 
													    " - Halftime: ", 
													    ibetMatch.IsHalfTime
												    });                                                    
                                                }
                                            }
                                            catch (System.Exception ex)
                                            {
                                                text = "Error while Trading. Details: " + ex.Message;
#if DEBUG
                                                Utilities.WriteLog.Write(text);
#endif
                                            }
                                            #endregion
                                        }
                                        else
                                        {
                                            #region Confirm_3in1_first_then_IBET
#if DEBUG
                                            Utilities.WriteLog.Write("3IN1BET GO FIRST!");
#endif
                                            try
                                            {
                                                string odd3in1NEW = string.Empty;
                                                threein1betEngine.ConfirmBet(postBODY, threein1betStake.ToString(), out flag3IN1OK, out odd3in1NEW);
                                                if (flag3IN1OK)
                                                {
                                                    ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), ibetminStake.ToString(), ibetmaxStake.ToString(), out flagIBETOK);
                                                    if (!flagIBETOK)// iBet Confirm thanh cong
                                                    {
                                                        try
                                                        {
                                                            playSound(false);
#if DEBUG
                                                            Utilities.WriteLog.Write("iBet confirm failed.");
#endif
                                                        }

                                                        catch (System.Exception ex)
                                                        {
                                                            text = "Error while Retrade. Details: " + ex.Message;
                                                            playSound(false);
#if DEBUG
                                                            Utilities.WriteLog.Write(text);
#endif
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.lbl3in1betCurrentCredit.Caption = this._3in1Engine.GetCurrentCredit().ToString();
                                                        this.lblIbetCurrentCredit.Caption = this._ibetEngine.GetCurrentCredit().ToString();
                                                        playSound(true);
                                                    }
                                                    this._lastTransactionTime = System.DateTime.Now;
                                                    object obj = text;
                                                    text = string.Concat(new object[]
												    {
													    obj, 
													    " - Success Transaction. Half: ", 
													    ibetMatch.Half, 
													    " - Minute: ", 
													    ibetMatch.Minute, 
													    " - Halftime: ", 
													    ibetMatch.IsHalfTime
												    });
                                                }
                                            }
                                            catch (System.Exception ex)
                                            {
                                                text = "Error while Trading. Details: " + ex.Message;
#if DEBUG
                                                Utilities.WriteLog.Write(text);
#endif
                                            }
                                            #endregion
                                        }
                                    }
                                    else
                                    {
                                        text = string.Concat(new object[]
										{
											"Out of Cash. IBET Credit: ", 
											currentCredit, 
											" -  SBOBET Credit: ", 
											currentCredit2
										});
#if DEBUG
                                        Utilities.WriteLog.Write(text);
#endif
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                    text = "Error while getting Credit. Details: " + ex.Message;
#if DEBUG
                                    Utilities.WriteLog.Write(text);
#endif
                                }



                            }
                            else
                            {
                                text = "Invalid Odd while Preparing Ticket. IBET Odd: " + ibetBetKindValue + " - SBOBET Odd:" + threein1betKindValue;
#if DEBUG
                                Utilities.WriteLog.Write(text);
#endif
                            }
                        }
                        else
                        { 
#if DEBUG
                            if (!flagibetAllowance)
                                Utilities.WriteLog.Write("IBET DIDN'T ALLOW");
                            if (!flagthreein1betAllowance)
                                Utilities.WriteLog.Write("3IN1 DIDN'T ALLOW");
#endif

                        }
                    }

                    else
                    {
                        text = string.Concat(new string[]
						{
							"Not Same Match - Preparing Ticket. IBET: ", 
							ibetHomeTeamName, 
							" / ", 
							ibetAwayTeamNam, 
							" - 3in1BET: ", 
							threein1betHomeTeamName, 
							" / ", 
							threein1betAwayTeamName
						});
#if DEBUG
                        Utilities.WriteLog.Write(text);
#endif
                    }

                        
				}
				catch (System.Exception ex)
				{
					text = "Error while Preparing Trade. Details: " + ex.Message;
#if DEBUG
                    WriteLog.Write(" *** " + text);
#endif 
				}
			}
			else
			{
				text = string.Concat(new string[]
				{
					"Not Same Match - Comparing. IBET: ", 
					ibetMatch.HomeTeamName, 
					" / ", 
					ibetMatch.AwayTeamName, 
					" - 3in1BET: ", 
					threein1betMatch.HomeTeamName, 
					" / ", 
					threein1betMatch.AwayTeamName
				});
			}
            transactionDTO.HomeTeamName = ibetMatch.HomeTeamName + " / " + threein1betMatch.HomeTeamName;
            transactionDTO.AwayTeamName = ibetMatch.AwayTeamName + " / " + threein1betMatch.AwayTeamName;
            transactionDTO.Odd = ibetBetKindValue + " / " + threein1betKindValue;
			transactionDTO.OddKindValue = ibetBetKindValue + " / " + threein1betKindValue;
            transactionDTO.OddValue = ibetOddValue + " / " + threein1OddValue;
			transactionDTO.Stake = ibetStake + " / " + threein1betStake;
			transactionDTO.IBETAllow = flagibetAllowance;
            transactionDTO.IBETTrade = flagIBETOK;
			transactionDTO.IBETReTrade = false;
            transactionDTO.THREEIN1Allow = flagthreein1betAllowance;
            transactionDTO.THREEIN1Trade = flag3IN1OK;
			transactionDTO.THREEIN1ReTrade = threein1ReTrade;
			transactionDTO.OddType = oddType.ToString();
			transactionDTO.Note = text;
			transactionDTO.DateTime = System.DateTime.Now;
			return transactionDTO;
		}
コード例 #11
0
        private TransactionDTO PlaceSingleIBET(MatchDTO ibetMatch, string odd, string oddValue, eOddType oddType, string ibetOddType, string stake, string homeScore, string awayScore, IBetEngine ibetEngine, bool followtype, string followref, string accountName)
        {
            this._betting = true;
            TransactionDTO transactionDTO = new TransactionDTO();
            string following = string.Empty;
            if (followtype)
                following = "following";
            else
                following = "unfollowing";

            string betKindValue = string.Empty;
            string homeTeamName = string.Empty;
            string awayTeamName = string.Empty;
            string newOddValue = string.Empty;
            string newHomeScore = string.Empty;
            string newAwayScore = string.Empty;

            bool flag = false;
            bool flag2 = false;
            string text = string.Empty;

            System.Collections.Generic.List<MatchDTO> listIbetMatch = this._listIBETMatch;
            //MatchDTO matchDTO = MatchDTO.SearchMatchFull(ibetMatch, listIbetMatch);
            if (ibetMatch != null && ibetMatch.HomeTeamName != string.Empty)
            {
                OddDTO oddDTO = OddDTO.SearchOdd(oddType, odd, true, ibetMatch.Odds);
                if (oddDTO != null)
                {
                    string ibetOddNow = string.Empty;
                    if (ibetOddType == "a")
                        ibetOddNow = oddDTO.Away.ToString();
                    else
                        ibetOddNow = oddDTO.Home.ToString();
                    if (followtype || (!followtype && ((float.Parse(ibetOddNow) >= (float)txtLowestOddValue.Value && float.Parse(ibetOddNow) > 0)) || float.Parse(ibetOddNow) < 0))
                    {
                        int maxBet = 0;
                        int minBet = 0;
                        string ibetOddID = oddDTO.ID;
                        try
                        {
                            ibetEngine.PrepareBet2(ibetOddID, ibetOddType, ibetOddNow.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                            if (homeTeamName == ibetMatch.HomeTeamName)
                            {
                                if (newHomeScore == homeScore && newAwayScore == awayScore)
                                {
                                    float num1 = float.Parse(odd);
                                    float num2 = float.Parse(betKindValue);
                                    if (num1 + num2 == 0f || num1 == num2)
                                    {
                                        if (int.Parse(stake) > maxBet)
                                            stake = maxBet.ToString();

                                        float newIbetOddValue = float.Parse(newOddValue);
                                        float oldIbetOddValue = float.Parse(oddValue);

                                        //if (OddDTO.IsValidOddPair(newIbetOddValue, oldIbetOddValue, (float)txtAllowTradeMinValue.Value, true))
                                        //{
                                        ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                        if (!flag2)
                                        {
                                            //this._lastTransactionTime = System.DateTime.Now;
                                            //SendReportToMainForm("- Follow Bet: " + this._ibetAccount + " >> " + matchDTO.HomeTeamName + " - " + matchDTO.AwayTeamName + ": Bet confirmed failed. ");
                                            text = "Confirm bet failed";
                                        }
                                        else
                                        {
                                            this._lastTransactionTime = DateTime.Now;
                                            text = " - Success " + following + " " + this._ibetSubAccount + ". Follow: " + ibetOddType + " > " + accountName;
                                        }
                                        //}
                                        //else
                                        //{
                                        //    SendReportToMainForm("Follow Bet: " + this._ibetAccount + " >> " + matchDTO.HomeTeamName + " - " + matchDTO.AwayTeamName + ": New odd value: " + newOddValue + " is lower than allowed number ");
                                        //}
                                    }
                                    else
                                        text = "Invalid Odd while Preparing Ticket. IBET Odd: " + betKindValue;
                                }
                                else
                                {
                                    text = "Score changed.";
                                }
                            }
                            else
                            {
                                text = "Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                            }
                        }
                        catch (Exception ex)
                        {
                            text = ex.Message;
                        }
                    }
                    else
                    {
                        text = "Odd value is smaller than lowest accepted:" + ibetOddNow;
                    }
                }
                else
                {
                    string text2 = string.Empty;
                    //foreach (OddDTO o in ibetMatch.Odds)
                    //{
                    //    text2 += o.Odd + ","; 
                    //}
                    text = "Odd not found.";
                }
            }
            else
                text = "Match not found ";


            transactionDTO.HomeTeamName = homeTeamName;
            transactionDTO.AwayTeamName = awayTeamName;
            transactionDTO.HomeScore = homeScore;
            transactionDTO.AwayScore = awayScore;
            transactionDTO.Score = homeScore + "-" + awayScore;
            transactionDTO.AccountPair = this._ibetAccount + " - " + this._ibetSubAccount;
            transactionDTO.OddType = oddType.ToString();
            transactionDTO.Odd = betKindValue;
            transactionDTO.OddKindValue = betKindValue;
            transactionDTO.OddValue = newOddValue;
            transactionDTO.Stake = stake;
            transactionDTO.Note = text;
            transactionDTO.IBETTrade = flag2;
            transactionDTO.IBETAllow = flag;
            transactionDTO.IsFollowTypeTrans = true;
            transactionDTO.DateTime = DateTime.Now;
            transactionDTO.FollowRef = followref;

            this._betting = false;
            return transactionDTO;
        }
コード例 #12
0
        internal bool ReleaseWaitingBet(TransactionDTO tran)
        {
            bool status = false;
            if (this._running)
            {
                eOddType oddtype;
                string ibetOddType = string.Empty;
                if (tran.OddType.StartsWith("FulltimeOverUnder"))
                    oddtype = eOddType.FulltimeOverUnder;
                else if (tran.OddType.StartsWith("FirstHalfOverUnder"))
                    oddtype = eOddType.FirstHalfOverUnder;
                else if (tran.OddType.StartsWith("FulltimeHandicap"))
                    oddtype = eOddType.FulltimeHandicap;
                else if (tran.OddType.StartsWith("FirstHalfHandicap"))
                    oddtype = eOddType.FirstHalfHandicap;
                else if (tran.OddType.StartsWith("FT"))
                    oddtype = eOddType.FT;
                else if (tran.OddType.StartsWith("HT"))
                    oddtype = eOddType.HT;
                else
                    oddtype = eOddType.Unknown;

                MatchDTO matchDTO = new MatchDTO();
                matchDTO.HomeTeamName = tran.HomeTeamName;
                matchDTO.AwayTeamName = tran.AwayTeamName;
                matchDTO.League = new LeagueDTO();
                matchDTO.League.Name = tran.League;

                if (oddtype != eOddType.HT && oddtype != eOddType.FT)
                {
                    if (chkFollowType.Checked)
                    {
                        if (tran.HomePick)
                            ibetOddType = "h";
                        else
                            ibetOddType = "a";
                    }
                    else
                    {
                        if (tran.HomePick)
                            ibetOddType = "a";
                        else
                            ibetOddType = "h";
                    }
                    //return PlaceSingleIBET(matchDTO, tran.Odd, tran.OddValue, oddtype, ibetOddType, tran.Stake, tran.HomeScore, tran.AwayScore, this._ibetEngine);
                }
                else
                {
                    if (chkFollowType.Checked)
                    {
                        ibetOddType = tran.FT1X2Pick;
                        //return PlaceSingleIBET(matchDTO, tran.Odd, tran.OddValue, oddtype, ibetOddType, tran.Stake, tran.HomeScore, tran.AwayScore, this._ibetEngine);
                    }
                }
            }

            return status;
        }
コード例 #13
0
        private void CompareSameMatch()
        {
            //iBet.Utilities.WriteLog.Write("003: Start to comapre now");
            this._comparing = true;

            System.Collections.Generic.List<MatchDTO> listIBETMatch = this._listIBETMatch;
            System.Collections.Generic.List<MatchDTO> listIBETMatchNonLive = this._listIBETMatchNonLive;
            System.Collections.Generic.List<BetDTO> listSubIbetMatch = this._listBetInSubMatch;

            if (this._BetWaitingList == null)
            {
                this._BetWaitingList = new Dictionary<string, DateTime>();
            }
            if (listSubIbetMatch != null)
            {
                foreach (BetDTO bet in listSubIbetMatch)
                {
                    if (!this._OldBetListHistory.ContainsKey(bet.RefID))
                    {
                        if (!_listDoneBetInSub.Any(beted => beted.RefID == bet.RefID))
                        {
                            bet.ID = (_listDoneBetInSub.Count + 1).ToString();
                            this._listDoneBetInSub.Add(bet);
                        }

                        if (bet.Stake >= (int)txtAllowTradeMinValue.Value)
                        {
                            TransactionDTO trans = new TransactionDTO();

                            MatchDTO match = new MatchDTO();
                            match.HomeTeamName = bet.HomeTeamName;
                            match.AwayTeamName = bet.AwayTeamName;
                            match.League = new LeagueDTO();
                            match.League.Name = bet.League;

                            MatchDTO matchDTO = new MatchDTO();
                            if (bet.Live)
                            {
                                matchDTO = MatchDTO.SearchMatchFull(match, listIBETMatch);
                            }
                            else
                            {
                                matchDTO = MatchDTO.SearchMatchFull(match, listIBETMatchNonLive);
                                if (matchDTO == null)
                                    matchDTO = MatchDTO.SearchMatchFull(match, listIBETMatch);//tim trong list live, vi co the tran day chuyen trang thai
                            }

                            if (matchDTO != null)
                            {
                                matchDTO.HomeScore = bet.HomeScore;
                                matchDTO.AwayScore = bet.AwayScore;
                                //_mainForm.ad

                                #region Fang

                                string stake = string.Empty;
                                if (chkFollowPercent.Checked)
                                {
                                    int stk = (int)((bet.Stake * (float)txtFollowPercent.Value) / 100);
                                    if (stk < 5)
                                        stk = 5;
                                    stake = stk.ToString();
                                }
                                else
                                {
                                    stake = txtIBETFixedStake.Value.ToString();
                                }

                                string ibetOddType = string.Empty;
                                bool follow = chkFollowType.Checked;
                                if (bet.Type == eOddType.HT || bet.Type == eOddType.FT)
                                {
                                    if (bet.Choice.Contains(".1"))
                                        ibetOddType = "1";
                                    else if (bet.Choice.Contains(".2"))
                                        ibetOddType = "2";
                                    else if (bet.Choice.Contains(".x"))
                                        ibetOddType = "X";
                                    if (follow)
                                    {
                                        trans = PlaceSingleIBET(matchDTO, bet.Odd, bet.OddValue, bet.Type, ibetOddType, stake, bet.HomeScore, bet.AwayScore, this._ibetEngine, follow, bet.RefID, bet.Account);
                                        //this._mainForm.AddLocalSingleIBET(match, bet.Odd, bet.OddValue, bet.Type, ibetOddType, bet.Stake.ToString(), bet.HomeScore, bet.AwayScore, follow, bet.RefID, bet.Account, bet.Live);
                                    }
                                }
                                else
                                {
                                    if (bet.Choice.Contains("Over"))
                                    {
                                        if (follow)
                                            ibetOddType = "h";
                                        else
                                            ibetOddType = "a";
                                    }
                                    else if (bet.Choice.Contains("Under"))
                                    {
                                        if (follow)
                                            ibetOddType = "a";
                                        else
                                            ibetOddType = "h";
                                    }
                                    else if (bet.HomeTeamName.Contains(bet.Choice))
                                    {
                                        if (follow)
                                            ibetOddType = "h";
                                        else
                                            ibetOddType = "a";
                                    }
                                    else
                                    {
                                        if (chkFollowType.Checked)
                                            ibetOddType = "a";
                                        else
                                            ibetOddType = "h";
                                    }
                                    trans = PlaceSingleIBET(matchDTO, bet.Odd, bet.OddValue, bet.Type, ibetOddType, stake, bet.HomeScore, bet.AwayScore, this._ibetEngine, follow, bet.RefID, bet.Account);
                                    //this._mainForm.AddLocalSingleIBET(match, bet.Odd, bet.OddValue, bet.Type, ibetOddType, bet.Stake.ToString(), bet.HomeScore, bet.AwayScore, follow, bet.RefID, bet.Account, bet.Live);
                                }
                                #endregion
                                if (trans.IBETTrade)
                                {
                                    trans.SBOBETTrade = true;
                                    this._OldBetListHistory.Add(bet.RefID, DateTime.Now);
                                }
                                else if (trans.Note == "Score changed.")
                                {
                                    trans.IBETTrade = true;
                                    trans.Note += " Cancel this bet.";
                                    this._OldBetListHistory.Add(bet.RefID, DateTime.Now);
                                }
                                else
                                {
                                    trans.Note += " Add this bet to pending list.";
                                }
                                this.AddTransaction(trans);
                                if (listSubIbetMatch.Count > 1)
                                    Thread.Sleep(800);
                            }
                        }
                        else
                        {
                            this._OldBetListHistory.Add(bet.RefID, DateTime.Now);
                        }
                    }
                }
                lock (grdBetList)
                {
                    this.grdBetList.RefreshDataSource();
                }
            }
            else
            {
                //iBet.Utilities.WriteLog.Write("list bet just parsed is null"); 
            }

            BarItem arg_648_0 = this.lblSbobetTotalMatch;
            int count;
            if (_listBetInSubMatch != null)
            {
                count = _listBetInSubMatch.Count;
                arg_648_0.Caption = count.ToString();
                this.lblSameMatch.Caption = "Total Waiting Bet: " + this._BetWaitingList.Count;
            }
            else
                arg_648_0.Caption = "No Bet";
            //BarItem arg_663_0 = this.lblIbetTotalMatch;
            //count = listIBETMatch.Count;
            //arg_663_0.Caption = count.ToString();

            this.lblLastUpdate.Caption = System.DateTime.Now.ToString();

            this._comparing = false;
            if (this._compareAgain && !this._comparing)
            {
                this._compareAgain = false;
                this.CompareSameMatch();
            }
        }