public bool ProcessPrepareBet(MatchOddDTO ibetMatchOdd, eBetType ibetBetType, MatchOddDTO sboMatchOdd, eBetType sboBetType, bool isLive, eServerScan serverScan = eServerScan.Local, bool callSecond = false, string bpMatch = "", PrepareBetDTO sboPrepareBet = null) { if (isProcess && !callSecond) // || LastProcessPrepare.AddMilliseconds(200) > DateTime.Now { return(false); } try { isProcess = true; PrepareBetDTO ibetPrepareBet; if (!callSecond) { sboMatchOdd.OldOdd = sboBetType == eBetType.Home ? sboMatchOdd.HomeOdd : sboMatchOdd.AwayOdd; var taskPrepareBetSbo = Task.Run(() => CallPrepareBet(sboMatchOdd, sboBetType, isLive, ibetMatchOdd.Odd)); ibetPrepareBet = CallPrepareBet(ibetMatchOdd, ibetBetType, isLive, sboMatchOdd.Odd); if (!ibetPrepareBet.IsSuccess || taskPrepareBetSbo.Result == null) { return(false); } sboPrepareBet = taskPrepareBetSbo.Result; } else { Logger.Warn("BAT DAU PREPARE LAN 2"); ibetPrepareBet = CallPrepareIbetAgain(ibetMatchOdd, ibetBetType, isLive, sboMatchOdd.Odd, bpMatch); if (!ibetPrepareBet.IsSuccess) { return(false); } } //sboMatchOdd.OldOdd = sboBetType == eBetType.Home ? sboMatchOdd.HomeOdd : sboMatchOdd.AwayOdd; //var taskPrepareBetSbo = // Task.Run(() => CallPrepareBet(sboMatchOdd, sboBetType, isLive, ibetMatchOdd.Odd)); //PrepareBetDTO ibetPrepareBet = CallPrepareBet(ibetMatchOdd, ibetBetType, isLive, sboMatchOdd.Odd); //if (!ibetPrepareBet.IsSuccess || taskPrepareBetSbo.Result == null) //{ // return false; //} //PrepareBetDTO sboPrepareBet = taskPrepareBetSbo.Result; if (ibetPrepareBet.IsRunning) { bool isGood = IsGoodOddPair(ibetPrepareBet.NewOdd, sboPrepareBet.NewOdd, CompareValueDifferent); if (isGood) { int ibetStake; int sboStake; if (CaculateStake(BetStakeType, ibetPrepareBet.MatchOdd.MatchID, ibetPrepareBet.MinBet, ibetPrepareBet.MaxBet, sboPrepareBet.MatchOdd.MatchID, sboPrepareBet.MinBet, sboPrepareBet.MaxBet, out ibetStake, out sboStake)) { string ibetConfirmMsg; if (CallConfirmBet(ibetPrepareBet, ibetStake, sboMatchOdd.Odd, out ibetConfirmMsg, isLive, false, serverScan, callSecond)) { LastBetIbetSuccess = DateTime.Now; if (CallConfirmBet(sboPrepareBet, sboStake, ibetMatchOdd.Odd, out ibetConfirmMsg, isLive, false, serverScan)) { Task.Run( () => { UpdateBetPool( sboPrepareBet.MatchOdd.ServerType, sboPrepareBet.MatchOdd.MatchID, SboBetPool, sboStake); UpdateBetPool( ibetPrepareBet.MatchOdd.ServerType, ibetPrepareBet.MatchOdd.MatchID, IbetBetPool, ibetStake); }); Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); CountBet++; LastBetTime = DateTime.Now; return(true); } else { if (BetAgainstIbet) { Logger.Info(ProcessorName + " DAT NGUOC IBET<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); if (!BetAgainstIbetRequest(ibetPrepareBet, ibetMatchOdd, ibetBetType, isLive, sboMatchOdd.Odd, ibetStake, false)) { Thread.Sleep(3000); Logger.Info("CALL LAN 2 BET MGUOC IBET<<<<<<<<<<<<<<<<"); if (BetAgainstIbetRequest(ibetPrepareBet, ibetMatchOdd, ibetBetType, isLive, sboMatchOdd.Odd, ibetStake, true)) { isProcess = false; return(true); } else { Logger.Info("DAT NGUOC THAT BAI, KHOI DONG LAI IBET!!!"); IbetEngine.BetAgainstTransactions.Add(new BetAgainstTransaction() { BetType = GetAgainstBetType(ibetBetType), IsLive = isLive, MatchOdd = ibetMatchOdd, OddCompare = sboMatchOdd.Odd, Stake = ibetStake, HomeScore = ibetPrepareBet.HomeScore, AwayScore = ibetPrepareBet.AwayScore }); Task.Run(() => { Logger.Info("CALL KHOI DONG LAI IBET!!!"); IbetEngine.UpdateException(IbetEngine, eExceptionType.LoginFail); }); } } else { isProcess = false; return(true); } Logger.Info("BET MGUOC IBET FAIL...DAT NGUOC THAT BAI..."); } } LastBetTime = DateTime.Now; Task.Run( () => UpdateBetPool(ibetPrepareBet.MatchOdd.ServerType, ibetPrepareBet.MatchOdd.MatchID, IbetBetPool, ibetStake)); return(true); } else { if (!string.IsNullOrEmpty(ibetConfirmMsg)) { string bpValue = GetBpMatchIbet(ibetConfirmMsg); Logger.Info("GOI COMPARE LAI LAN 2, bp_match: " + bpValue); return(ProcessPrepareBet(ibetMatchOdd, ibetBetType, sboMatchOdd, sboBetType, isLive, serverScan, true, bpValue, sboPrepareBet)); } } FireLogScan(ibetMatchOdd, sboMatchOdd, serverScan); } } else { FireLogScan(ibetMatchOdd, sboMatchOdd, serverScan); } } else { FireLogScan(ibetMatchOdd, sboMatchOdd, serverScan); } return(false); } catch (Exception ex) { Logger.Error(ProcessorName, ex); return(false); } finally { //LastProcessPrepare = DateTime.Now; isProcess = false; } }