コード例 #1
0
        private void FireLogScan(MatchPiDTO piMatchOdd, OddDTO piOdd, MatchIsnDTO isnMatch, OddDTO isnOdd, eServerScan serverScan)
        {
            var msg = new LogScanMessage()
            {
                ProcessorName   = this.ProcessorName,
                Time            = DateTime.Now.ToString("HH:mm:ss.fff"),
                HomeTeamName    = piMatchOdd.HomeTeamName,
                AwayTeamName    = piMatchOdd.AwayTeamName,
                OddType         = piOdd.OddType,
                Odd             = piOdd.Odd,
                FirstOddValues  = piOdd.HomeOdd + " | " + piOdd.AwayOdd,
                SecondOddValues = isnOdd.HomeOdd + " | " + isnOdd.AwayOdd,
                ServerScan      = serverScan
            };

            Task.Run(() =>
            {
                DataContainer.LogScanQueue.Enqueue(msg);
                DataContainer.LogScanResetEvent.Set();
            });
        }
コード例 #2
0
        //// compare from sbo (dataUpdated) to Pi (targetSource)
        public void CompareOdd(List <MatchIsnDTO> dataUpdated, List <MatchPiDTO> targetSource, bool isLive)
        {
            try
            {
                foreach (var isnMatch in dataUpdated)
                {
                    if (/*!DataContainer.LeaguesDenyKeywords.Any(data.LeagueName.ToUpper().Contains)
                         * &&*/(!DataContainer.MatchsDenyKeywords.Any(isnMatch.HomeTeamName.ToUpper().Contains) ||
                         !DataContainer.MatchsDenyKeywords.Any(isnMatch.AwayTeamName.ToUpper().Contains)))
                    {
                        MatchPiDTO piMatchTarget = targetSource.FirstOrDefault(m =>
                                                                               (String.Equals(m.HomeTeamName, isnMatch.HomeTeamName,
                                                                                              StringComparison.CurrentCultureIgnoreCase)
                                                                                ||
                                                                                String.Equals(m.AwayTeamName, isnMatch.AwayTeamName,
                                                                                              StringComparison.CurrentCultureIgnoreCase)
                                                                               )
                                                                               );

                        if (piMatchTarget != null)
                        {
                            foreach (var isnOdd in isnMatch.Odds)
                            {
                                OddDTO piOdd = piMatchTarget.Odds.FirstOrDefault(o => o.Odd.Equals(isnOdd.Odd) && /*&& !(o.HomeOdd == 0 && o.AwayOdd == 0)*/
                                                                                 o.OddType == isnOdd.OddType);


                                if (piOdd != null)
                                {
                                    //bool isValid1 = IsValidOddPair(isnOdd.HomeOdd, piOdd.AwayOdd, CompareValueDifferent);
                                    bool isValid1 = IsValidOddPair(isnOdd.HomeOdd, piOdd.AwayOdd, CompareValueDifferent);
                                    //Debug.WriteLine(isnOdd.HomeOdd + "|" + piOdd.AwayOdd);

                                    //   && IsValidPick(isnOdd, eBetType.Home);

                                    if (isValid1)
                                    {
                                        ProcessPrepareBet(piMatchTarget, piOdd, eBetType.Away, isnMatch, isnOdd, eBetType.Home, isLive);
                                        return;
                                    }

                                    bool isValid2 = IsValidOddPair(isnOdd.AwayOdd, piOdd.HomeOdd, CompareValueDifferent);
                                    //Debug.WriteLine(isnOdd.AwayOdd + "|" + piOdd.HomeOdd);

                                    //      && IsValidPick(isnOdd, eBetType.Away);

                                    if (isValid2)
                                    {
                                        ProcessPrepareBet(piMatchTarget, piOdd, eBetType.Home, isnMatch, isnOdd, eBetType.Away, isLive);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal(ProcessorName, ex);
            }
        }
コード例 #3
0
        /// <summary>
        /// Mr Kiệt version
        /// </summary>
        /// <param name="piMatch"></param>
        /// <param name="piOdd"></param>
        /// <param name="piBetType"></param>
        /// <param name="isnMatch"></param>
        /// <param name="isnOdd"></param>
        /// <param name="isnBetType"></param>
        /// <param name="isLive"></param>
        /// <param name="serverScan"></param>
        /// <returns></returns>
        public bool ProcessPrepareBet(MatchPiDTO piMatch, OddDTO piOdd, eBetType piBetType, MatchIsnDTO isnMatch, OddDTO isnOdd, eBetType isnBetType, bool isLive,
                                      eServerScan serverScan = eServerScan.Local)
        {
            if (isProcess)
            {
                return(false);
            }

            try
            {
                isProcess = true;


                Task <int> taskMaxBet = Task.Run(() => IsnEngine.GetMax((isnBetType == eBetType.Home ? isnOdd.selectionIdHome : isnOdd.selectionIdAway)));

                var taskpreparePina = Task.Run(() => PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd));


                var prepareBetIsn = IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, isLive, isnOdd.Odd);
                if (taskpreparePina.Result == null || prepareBetIsn == null)
                {
                    FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan);
                    return(false);
                }

                bool  betAny;
                float piOddValue = piBetType == eBetType.Home ? piOdd.HomeOdd : piOdd.AwayOdd;
                bool  isGood     = IsGoodOddPair(piOddValue, prepareBetIsn.NewOdd, CompareValueDifferent, out betAny);

                if (isGood)
                {
                    int piStake;
                    int isnStake;

                    if (CaculateStake(BetStakeType,
                                      piMatch.MatchID, 150, (int)((PendingTicket)taskpreparePina.Result.PendingTicket).TicketItem.MaxRiskAmount,
                                      isnMatch.MatchID, 4, taskMaxBet,
                                      out piStake, out isnStake))
                    {
                        // bet kèo dưới trước
                        #region [Bet pina trước nếu là kèo dưới]
                        if (((piOdd.OddType == eOddType.HCP || piOdd.OddType == eOddType.HalfHCP) && piOdd.Odd >= 0) ||// odd dương là được chấp
                            ((piOdd.OddType == eOddType.OU || piOdd.OddType == eOddType.HalfOU) && piBetType == eBetType.Away))   // dựa vào pina bet type để biết là Under
                        {
                            var piConfirmBet = PiEngine.ConfirmBet((PendingTicket)taskpreparePina.Result.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.Success);

                            if (piConfirmBet)
                            {
                                if (IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.Success))
                                {
                                    Task.Run(
                                        () =>
                                    {
                                        UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake);
                                        UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake);
                                    });
                                    Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                                    CountBet++;
                                    LastBetTime = DateTime.Now;
                                    return(true);
                                }
                                else
                                {
                                    Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));

                                    bool ok = false;
                                    for (int i = 0; i < IsnEngine.Rebet; i++)
                                    {
                                        var prepare = IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, true, isnOdd.Odd);
                                        if (prepare != null)
                                        {
                                            ok = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.MissOddIsn, true);
                                            if (ok)
                                            {
                                                LastBetTime = DateTime.Now;

                                                Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake));
                                                return(true);
                                            }
                                        }
                                        Thread.Sleep(500);
                                    }

                                    if (!ok) // ReBet pina
                                    {
                                        var betTypeAgaint = GetAgainstBetType(piBetType);
                                        var prepare       = PiEngine.PrepareBet(piMatch, piOdd, betTypeAgaint, piOdd.Odd);
                                        if (prepare != null)
                                        {
                                            ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true);
                                            if (ok)
                                            {
                                                LastBetTime = DateTime.Now;
                                                Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));
                                                return(true);
                                            }
                                        }
                                    }

                                    IsnEngine.FireLogBet(isnMatch, isnOdd, isnBetType, isnStake, eBetStatusType.Fail, eServerScan.Local);
                                }
                            }
                        }
                        #endregion
                        #region [Bet ISN trước nếu isn là kèo dưới]
                        else // OU
                        {
                            var isnConfirmBet = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.Success);
                            if (isnConfirmBet)
                            {
                                if (PiEngine.ConfirmBet((PendingTicket)taskpreparePina.Result.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.Success))
                                {
                                    Task.Run(
                                        () =>
                                    {
                                        UpdateBetPool(
                                            eServerType.Isn,
                                            isnMatch.MatchID,
                                            IsnBetPool,
                                            isnStake);

                                        UpdateBetPool(
                                            eServerType.Pina,
                                            piMatch.MatchID,
                                            PiBetPool,
                                            piStake);
                                    });
                                    Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                                    CountBet++;
                                    LastBetTime = DateTime.Now;
                                    return(true);
                                }
                                else
                                {
                                    Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake));

                                    bool ok = false;
                                    for (int i = 0; i < PiEngine.Rebet; i++)
                                    {
                                        var prepare = PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd);
                                        if (prepare != null)
                                        {
                                            ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.MissOddPina, true);
                                            if (ok)
                                            {
                                                LastBetTime = DateTime.Now;

                                                Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));

                                                return(true);
                                            }
                                        }
                                        Thread.Sleep(500);
                                    }

                                    if (!ok)// Rebet Isn
                                    {
                                        var betTypeAgaint = GetAgainstBetType(isnBetType);
                                        var prepare       = IsnEngine.PrepareBet(isnMatch, isnOdd, betTypeAgaint, true, isnOdd.Odd);
                                        if (prepare != null)
                                        {
                                            ok = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, betTypeAgaint, eBetStatusType.BetAgainIsn, true);
                                            if (ok)
                                            {
                                                LastBetTime = DateTime.Now;
                                                Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake));
                                                return(true);
                                            }
                                        }
                                    }

                                    PiEngine.FireLogBet(piMatch, piOdd, piBetType, piStake, eBetStatusType.Fail, eServerScan.Local);
                                }
                            }
                        }
                        #endregion



                        // tạm đóng
                        FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan);
                    }
                }
                else
                {
                    // tạm đóng
                    FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan);
                }

                return(false);
            }
            catch (Exception ex)
            {
                Logger.Error(ProcessorName, ex);
                return(false);
            }
            finally
            {
                isProcess = false;
            }
        }
コード例 #4
0
        public bool ProcessPrepareBet(MatchPiDTO piMatchOdd, OddDTO piOdd, eBetType piBetType, MatchOddDTO sboMatchOdd, eBetType sboBetType, bool isLive,
                                      eServerScan serverScan = eServerScan.Local)
        {
            if (isProcess)
            {
                return(false);
            }
            string oddCheck = sboMatchOdd.OddID + sboMatchOdd.HomeOdd + sboMatchOdd.AwayOdd + piOdd.HomeOdd +
                              piOdd.AwayOdd;

            if (oddCheck.Equals(OddCheck))
            {
                return(false);
            }

            OddCheck = oddCheck;

            try
            {
                isProcess = true;

                sboMatchOdd.OldOdd = sboBetType == eBetType.Home ? sboMatchOdd.HomeOdd : sboMatchOdd.AwayOdd;

                var prepareBetSbo = CallPrepareBet(sboMatchOdd, sboBetType, isLive, piOdd.PiOdd);

                if (prepareBetSbo == null)
                {
                    return(false);
                }

                bool  betAny;
                float piOddValue = piBetType == eBetType.Home ? piOdd.HomeOdd : piOdd.AwayOdd;
                bool  isGood     = IsGoodOddPair(piOddValue, prepareBetSbo.NewOdd, CompareValueDifferent, out betAny);

                if (isGood)
                {
                    int piStake;
                    int sboStake;

                    if (CaculateStake(BetStakeType,
                                      piMatchOdd.MatchID,
                                      150,
                                      (int)piOdd.max.Value,
                                      prepareBetSbo.MatchOdd.MatchID,
                                      prepareBetSbo.MinBet,
                                      prepareBetSbo.MaxBet,
                                      out piStake, out sboStake))
                    {
                        var piConfirmBet = PiEngine.ConfirmBet(piStake, piMatchOdd, piOdd, piBetType);

                        if (piConfirmBet)
                        {
                            if (SboEngine.ConfirmBet(sboStake, piOdd.PiOdd, isLive, serverScan, piMatchOdd.HomeTeamName, piMatchOdd.AwayTeamName))
                            {
                                Task.Run(
                                    () =>
                                {
                                    UpdateBetPool(
                                        prepareBetSbo.MatchOdd.ServerType,
                                        prepareBetSbo.MatchOdd.MatchID,
                                        SboBetPool, sboStake);
                                    UpdateBetPool(
                                        eServerType.Pina,
                                        piMatchOdd.MatchID,
                                        PiBetPool,
                                        piStake);
                                });
                                Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                                CountBet++;
                                LastBetTime = DateTime.Now;
                                return(true);
                            }
                            else
                            {
                                if (BetAgainstIbet)
                                {
                                    Logger.Info(ProcessorName + " DAT NGUOC PINA<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
                                    var betTypeAgaint = GetAgainstBetType(piBetType);

                                    if (!PiEngine.TryConfirmBet(piStake, piMatchOdd, piOdd, betTypeAgaint))
                                    {
                                        Thread.Sleep(15000);
                                        Logger.Info("CALL LAN 2 BET MGUOC PINA<<<<<<<<<<<<<<<<");
                                        if (PiEngine.TryConfirmBet(piStake, piMatchOdd, piOdd, betTypeAgaint))
                                        {
                                            isProcess = false;
                                            return(true);
                                        }
                                        else
                                        {
                                            Logger.Info("CALL LAN 3 BET MGUOC LAI PINA<<<<<<<<<<<<<<<<");
                                            prepareBetSbo = CallPrepareBet(sboMatchOdd, sboBetType, isLive, piOdd.PiOdd);
                                            if (prepareBetSbo == null)
                                            {
                                                Logger.Fatal("CALL LAN 3 Prepare Sbo fail!!!!!");
                                                Thread.Sleep(25000);
                                                if (PiEngine.TryConfirmBet(piStake, piMatchOdd, piOdd, betTypeAgaint))
                                                {
                                                    isProcess = false;
                                                    return(true);
                                                }
                                            }
                                            else
                                            {
                                                if (!SboEngine.ConfirmBet(sboStake, piOdd.PiOdd, isLive, serverScan, piMatchOdd.HomeTeamName, piMatchOdd.AwayTeamName))
                                                {
                                                    Thread.Sleep(25000);
                                                    if (PiEngine.TryConfirmBet(piStake, piMatchOdd, piOdd, betTypeAgaint))
                                                    {
                                                        isProcess = false;
                                                        return(true);
                                                    }
                                                    else
                                                    {
                                                        prepareBetSbo = CallPrepareBet(sboMatchOdd, sboBetType, isLive, piOdd.PiOdd);
                                                        if (prepareBetSbo == null)
                                                        {
                                                            Logger.Fatal("CALL LAN 4 Prepare Sbo fail!!!!!");
                                                            Thread.Sleep(25000);
                                                            PiEngine.TryConfirmBet(piStake, piMatchOdd, piOdd,
                                                                                   betTypeAgaint);
                                                        }
                                                        else
                                                        {
                                                            SboEngine.ConfirmBet(sboStake, piOdd.PiOdd, isLive, serverScan, piMatchOdd.HomeTeamName, piMatchOdd.AwayTeamName);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    isProcess = false;
                                                    return(true);
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        isProcess = false;
                                        return(true);
                                    }

                                    Logger.Info("BET MGUOC IBET FAIL...DAT NGUOC THAT BAI...");
                                }
                            }

                            LastBetTime = DateTime.Now;

                            Task.Run(
                                () =>
                                UpdateBetPool(eServerType.Pina, piMatchOdd.MatchID, PiBetPool, piStake));

                            return(true);
                        }

                        FireLogScan(piMatchOdd, piOdd, sboMatchOdd, serverScan);
                    }
                }
                else
                {
                    FireLogScan(piMatchOdd, piOdd, sboMatchOdd, serverScan);
                }

                return(false);
            }
            catch (Exception ex)
            {
                Logger.Error(ProcessorName, ex);
                return(false);
            }
            finally
            {
                isProcess = false;
            }
        }
コード例 #5
0
        //// compare from sbo (dataUpdated) to Pi (targetSource)
        public void CompareOdd(List <MatchOddDTO> dataUpdated, List <MatchPiDTO> targetSource, bool isLive)
        {
            try
            {
                foreach (var sbo in dataUpdated)
                {
                    if (!DataContainer.LeaguesDenyKeywords.Any(sbo.LeagueName.ToUpper().Contains) &&
                        (!DataContainer.MatchsDenyKeywords.Any(sbo.HomeTeamName.ToUpper().Contains) ||
                         !DataContainer.MatchsDenyKeywords.Any(sbo.AwayTeamName.ToUpper().Contains)))
                    {
                        MatchPiDTO piMatchTarget = targetSource.FirstOrDefault(m =>
                                                                               (String.Equals(m.HomeTeamName, sbo.HomeTeamName,
                                                                                              StringComparison.CurrentCultureIgnoreCase)
                                                                                ||
                                                                                String.Equals(m.AwayTeamName, sbo.AwayTeamName,
                                                                                              StringComparison.CurrentCultureIgnoreCase)));

                        if (piMatchTarget != null)
                        {
                            OddDTO piOdd = piMatchTarget.Odds.FirstOrDefault(o => o.PiOdd.Equals(sbo.Odd) &&
                                                                             o.OddType.Equals(sbo.OddType));

                            if (piOdd != null)
                            {
                                bool isValid1 = IsValidOddPair(sbo.HomeOdd, piOdd.AwayOdd, CompareValueDifferent) &&
                                                IsValidPick(sbo, eBetType.Home);

                                if (isValid1)
                                {
                                    MatchOddDTO sboMatchSource = GetSboMatch(sbo, isLive);

                                    if (sboMatchSource != null)
                                    {
                                        //     if (data.HomeOdd.Equals(sboMatchSource.OldOdd) && data.HomeOdd != sboMatchSource.NewUpdateOdd)
                                        //     {
                                        //         continue;
                                        //     }

                                        sboMatchSource.HomeOdd = sbo.HomeOdd;
                                        sboMatchSource.AwayOdd = sbo.AwayOdd;

                                        ProcessPrepareBet(piMatchTarget, piOdd, eBetType.Away, sboMatchSource, eBetType.Home, isLive);
                                        return;
                                    }
                                }

                                bool isValid2 = IsValidOddPair(sbo.AwayOdd, piOdd.HomeOdd, CompareValueDifferent) &&
                                                IsValidPick(sbo, eBetType.Away);

                                if (isValid2)
                                {
                                    MatchOddDTO sboMatchSource = GetSboMatch(sbo, isLive);

                                    if (sboMatchSource != null)
                                    {
                                        //       if (data.AwayOdd == sboMatchSource.OldOdd && data.AwayOdd != sboMatchSource.NewUpdateOdd)
                                        //       {
                                        //           continue;
                                        //       }

                                        sboMatchSource.HomeOdd = sbo.HomeOdd;
                                        sboMatchSource.AwayOdd = sbo.AwayOdd;

                                        ProcessPrepareBet(piMatchTarget, piOdd, eBetType.Home, sboMatchSource, eBetType.Away, isLive);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal(ProcessorName, ex);
            }
        }
コード例 #6
0
        public bool ProcessPrepareBet(MatchPiDTO piMatch, OddDTO piOdd, eBetType piBetType, MatchOddDTO sboMatchOdd, eBetType sboBetType, bool isLive,
                                      eServerScan serverScan = eServerScan.Local)
        {
            if (isProcess)
            {
                return(false);
            }

            try
            {
                isProcess = true;

                sboMatchOdd.OldOdd = sboBetType == eBetType.Home ? sboMatchOdd.HomeOdd : sboMatchOdd.AwayOdd;

                var prepareBetPina = Task.Run(() => PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd));


                var prepareBetSbo = CallPrepareBet(sboMatchOdd, sboBetType, isLive, piOdd.PiOdd);

                if (prepareBetSbo == null || prepareBetPina.Result == null)
                {
                    FireLogScan(piMatch, piOdd, sboMatchOdd, serverScan);

                    return(false);
                }

                float piOddValue = piBetType == eBetType.Home ? piOdd.HomeOdd : piOdd.AwayOdd;
                bool  isGood     = IsGoodOddPair(piOddValue, prepareBetSbo.NewOdd, CompareValueDifferent);

                if (isGood)
                {
                    float firstOdd = piOdd.Odd;
                    int   piStake;
                    int   sboStake;

                    if (CaculateStake(BetStakeType,
                                      piMatch.MatchID,
                                      150,
                                      (int)((PendingTicket)prepareBetPina.Result.PendingTicket).TicketItem.MaxRiskAmount,
                                      prepareBetSbo.MatchOdd.MatchID,
                                      prepareBetSbo.MinBet,
                                      prepareBetSbo.MaxBet,
                                      out piStake, out sboStake))
                    {
                        var piConfirmBet = PiEngine.ConfirmBet((PendingTicket)prepareBetPina.Result.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.Success);

                        if (piConfirmBet)
                        {
                            if (SboEngine.ConfirmBet(sboStake, piOdd.PiOdd, isLive, serverScan, piMatch.HomeTeamName, piMatch.AwayTeamName))
                            {
                                Task.Run(
                                    () =>
                                {
                                    UpdateBetPool(
                                        prepareBetSbo.MatchOdd.ServerType,
                                        prepareBetSbo.MatchOdd.MatchID,
                                        SboBetPool, sboStake);
                                    UpdateBetPool(
                                        eServerType.Pina,
                                        piMatch.MatchID,
                                        PiBetPool,
                                        piStake);
                                });
                                Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                                CountBet++;
                                LastBetTime = DateTime.Now;
                                return(true);
                            }
                            else
                            {
                                if (BetAgainstIbet)
                                {
                                    var betTypeAgaint = GetAgainstBetType(piBetType);

                                    for (int i = 0; i < SboEngine.Rebet; i++)
                                    {
                                        var prepare = PiEngine.PrepareBet(piMatch, piOdd, betTypeAgaint, firstOdd);
                                        if (prepare != null)
                                        {
                                            var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, betTypeAgaint, eBetStatusType.BetAgainstIbet, true);
                                            if (ok)
                                            {
                                                LastBetTime = DateTime.Now;
                                                Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));
                                                return(true);
                                            }
                                        }
                                        Thread.Sleep(1000);

                                        lock (PiEngine.LockLive)
                                        {
                                            var newPiMatch = PiEngine._matchs.FirstOrDefault(p => p.MatchID == piMatch.MatchID);
                                            if (newPiMatch != null)
                                            {
                                                var newPiOdd = newPiMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == piOdd.OddType);
                                                if (newPiOdd != null)
                                                {
                                                    prepare = PiEngine.PrepareBet(newPiMatch, newPiOdd, betTypeAgaint, firstOdd);
                                                    if (prepare != null)
                                                    {
                                                        var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, newPiMatch, newPiOdd, betTypeAgaint, eBetStatusType.BetAgainstIbet, true);
                                                        if (ok)
                                                        {
                                                            LastBetTime = DateTime.Now;
                                                            Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));
                                                            return(true);
                                                        }
                                                    }
                                                }
                                            }
                                        }



                                        Thread.Sleep(1000);
                                    }

                                    Thread.Sleep(60000);

                                    for (int i = 0; i < SboEngine.Rebet * 2; i++)
                                    {
                                        var prepare = PiEngine.PrepareBet(piMatch, piOdd, betTypeAgaint, firstOdd);
                                        if (prepare != null)
                                        {
                                            var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, betTypeAgaint, eBetStatusType.BetAgainstIbet, true);
                                            if (ok)
                                            {
                                                LastBetTime = DateTime.Now;
                                                Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));
                                                return(true);
                                            }
                                        }
                                        Thread.Sleep(10000);

                                        lock (PiEngine.LockLive)
                                        {
                                            var newPiMatch = PiEngine._matchs.FirstOrDefault(p => p.MatchID == piMatch.MatchID);
                                            if (newPiMatch != null)
                                            {
                                                var newPiOdd = newPiMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == piOdd.OddType);
                                                if (newPiOdd != null)
                                                {
                                                    prepare = PiEngine.PrepareBet(newPiMatch, newPiOdd, betTypeAgaint, firstOdd);
                                                    if (prepare != null)
                                                    {
                                                        var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, newPiMatch, newPiOdd, betTypeAgaint, eBetStatusType.BetAgainstIbet, true);
                                                        if (ok)
                                                        {
                                                            LastBetTime = DateTime.Now;
                                                            Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));
                                                            return(true);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        Thread.Sleep(1000);
                                    }

                                    Logger.Info("BET MGUOC IBET FAIL...DAT NGUOC THAT BAI...");
                                }
                            }

                            LastBetTime = DateTime.Now;

                            Task.Run(
                                () =>
                                UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));

                            return(true);
                        }

                        FireLogScan(piMatch, piOdd, sboMatchOdd, serverScan);
                    }
                }
                else
                {
                    FireLogScan(piMatch, piOdd, sboMatchOdd, serverScan);
                }

                return(false);
            }
            catch (Exception ex)
            {
                Logger.Error(ProcessorName, ex);
                return(false);
            }
            finally
            {
                isProcess = false;
            }
        }
コード例 #7
0
        public bool ProcessPrepareBet(MatchPiDTO piMatch, OddDTO piOdd, eBetType piBetType, MatchIsnDTO isnMatch, OddDTO isnOdd, eBetType isnBetType, bool isLive,
                                      eServerScan serverScan = eServerScan.Local)
        {
            if (isProcess)
            {
                return(false);
            }

            //what?
            //string oddCheck = sboMatchOdd.OddID + sboMatchOdd.HomeOdd + sboMatchOdd.AwayOdd + piOdd.HomeOdd +
            //                  piOdd.AwayOdd;

            //if (oddCheck.Equals(OddCheck))
            //{
            //    return false;
            //}

            //OddCheck = oddCheck;

            try
            {
                isProcess = true;

                // wwhat?
                //sboMatchOdd.OldOdd = piBetType == eBetType.Home ? sboMatchOdd.HomeOdd : sboMatchOdd.AwayOdd;
                //   Logger.Debug("");
                //  Logger.Debug("Before call PREPARE ISN " + piMatch.HomeTeamName + "-" + piMatch.AwayTeamName + " " + piOdd.HomeOdd + "_" + piOdd.AwayOdd + " " + piBetType.ToString());
                //Stopwatch a = new Stopwatch();
                //a.Start();

                Task <int> taskMaxBet = Task.Run(() => IsnEngine.GetMax((isnBetType == eBetType.Home ? isnOdd.selectionIdHome : isnOdd.selectionIdAway)));

                Task <PrepareBetDTO> preparePina = null;
                Task <PrepareBetDTO> prepareIsn  = null;

                if ((isnOdd.OddType == eOddType.OU || isnOdd.OddType == eOddType.HalfOU) && isnBetType == eBetType.Away)
                {
                    preparePina = Task.Run(() => PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd));

                    prepareIsn = Task.Run(() => IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, isLive, isnOdd.Odd));
                }
                else
                {
                    prepareIsn = Task.Run(() => IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, isLive, isnOdd.Odd));

                    preparePina = Task.Run(() => PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd));
                }

                if (preparePina.Result == null || prepareIsn.Result == null)
                {
                    FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan);

                    return(false);
                }

                //a.Stop();
                //Debug.WriteLine("Thoi gian prepare: " + a.ElapsedMilliseconds);

                //   float piOddValue = piBetType == eBetType.Home ? piOdd.HomeOdd : piOdd.AwayOdd;
                //bool isGood = IsGoodOddPair(piOddValue, prepareBetIsn.NewOdd, CompareValueDifferent, out betAny);
                bool isGood = IsGoodOddPair(preparePina.Result.NewOdd, prepareIsn.Result.NewOdd, CompareValueDifferent);
                // Logger.Debug("After isGood=" + isGood.ToString() + " " + piOddValue + "_" + prepareBetIsn.NewOdd + " " + piBetType.ToString());

                if (isGood)
                {
                    float firstOdd = piOdd.Odd;

                    int piStake;
                    int isnStake;

                    if (CaculateStake(BetStakeType,
                                      piMatch.MatchID, 300, (int)((PendingTicket)preparePina.Result.PendingTicket).TicketItem.MaxRiskAmount,
                                      isnMatch.MatchID, 4, taskMaxBet,
                                      out piStake, out isnStake))
                    // if (true)
                    {
                        //if (piStake<(int)((PendingTicket)preparePina.Result.PendingTicket).TicketItem.MinRiskAmount)
                        //{
                        //    Logger.Info("Pi lower than riskamout");
                        //    return false;
                        //}
                        // kèo xỉu isn đnáh trước
                        if ((isnOdd.OddType == eOddType.OU || isnOdd.OddType == eOddType.HalfOU) && isnBetType == eBetType.Away)
                        {
                            var isnConfirmBet = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.Success);
                            if (isnConfirmBet)
                            {
                                if (PiEngine.ConfirmBet2((PendingTicket)preparePina.Result.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.Success))
                                {
                                    Task.Run(
                                        () =>
                                    {
                                        UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake);
                                        UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake);
                                    });
                                    Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                                    CountBet++;
                                    LastBetTime = DateTime.Now;
                                    return(true);
                                }
                                else
                                {
                                    Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake));
                                    var betTypeAgaint = GetAgainstBetType(isnBetType);

                                    for (int i = 0; i < PiEngine.Rebet; i++)
                                    {
                                        lock (IsnEngine.LockLive)
                                        {
                                            var newIsnMatch = IsnEngine._matchs.FirstOrDefault(p => p.MatchID == isnMatch.MatchID);
                                            if (newIsnMatch != null)
                                            {
                                                var newIsnOdd = newIsnMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == isnOdd.OddType);
                                                if (newIsnOdd != null)
                                                {
                                                    var prepare = IsnEngine.PrepareBet(newIsnMatch, newIsnOdd, betTypeAgaint, true, firstOdd);
                                                    if (prepare != null)
                                                    {
                                                        var ok = IsnEngine.ConfirmBet2(isnStake, newIsnMatch, newIsnOdd, betTypeAgaint, eBetStatusType.BetAgainIsn, true);
                                                        if (ok)
                                                        {
                                                            LastBetTime = DateTime.Now;
                                                            Task.Run(() => UpdateBetPool(eServerType.Isn, newIsnMatch.MatchID, IsnBetPool, isnStake));
                                                            return(true);
                                                        }
                                                    }
                                                }
                                            }
                                        }


                                        Thread.Sleep(2000);
                                    }



                                    IsnEngine.FireLogBet(isnMatch, isnOdd, isnBetType, isnStake, eBetStatusType.Fail, eServerScan.Local);
                                }
                            }
                        }
                        else
                        {
                            var piConfirmBet = PiEngine.ConfirmBet((PendingTicket)preparePina.Result.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.Success);

                            if (piConfirmBet)
                            {
                                if (IsnEngine.ConfirmBet(isnStake, isnMatch, isnOdd, isnBetType))
                                {
                                    Task.Run(
                                        () =>
                                    {
                                        UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake);
                                        UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake);
                                    });
                                    Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                                    CountBet++;
                                    LastBetTime = DateTime.Now;
                                    return(true);
                                }
                                else if (BetAgainstIbet)
                                {
                                    var betTypeAgaint = GetAgainstBetType(piBetType);

                                    for (int i = 0; i < IsnEngine.Rebet; i++)
                                    {
                                        var prepare = PiEngine.PrepareBet(piMatch, piOdd, betTypeAgaint, firstOdd);
                                        if (prepare != null)
                                        {
                                            var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true);
                                            if (ok)
                                            {
                                                LastBetTime = DateTime.Now;
                                                Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));
                                                return(true);
                                            }
                                        }

                                        Thread.Sleep(1000);

                                        lock (PiEngine.LockLive)
                                        {
                                            var newPiMatch = PiEngine._matchs.FirstOrDefault(p => p.MatchID == piMatch.MatchID);
                                            if (newPiMatch != null)
                                            {
                                                var newPiOdd = newPiMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == piOdd.OddType);
                                                if (newPiOdd != null)
                                                {
                                                    prepare = PiEngine.PrepareBet(newPiMatch, newPiOdd, betTypeAgaint, firstOdd);
                                                    if (prepare != null)
                                                    {
                                                        var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, newPiMatch, newPiOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true);
                                                        if (ok)
                                                        {
                                                            LastBetTime = DateTime.Now;
                                                            Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));
                                                            return(true);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        Thread.Sleep(1000);

                                        lock (IsnEngine.LockLive)
                                        {
                                            var newIsnMatch = IsnEngine._matchs.FirstOrDefault(p => p.MatchID == isnMatch.MatchID);
                                            if (newIsnMatch != null)
                                            {
                                                var newIsnOdd = newIsnMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == isnOdd.OddType);
                                                if (newIsnOdd != null)
                                                {
                                                    prepare = IsnEngine.PrepareBet(newIsnMatch, newIsnOdd, isnBetType, true, firstOdd);
                                                    if (prepare != null)
                                                    {
                                                        var ok = IsnEngine.ConfirmBet2(isnStake, newIsnMatch, newIsnOdd, isnBetType, eBetStatusType.MissOddIsn, true);
                                                        if (ok)
                                                        {
                                                            LastBetTime = DateTime.Now;
                                                            Task.Run(() => UpdateBetPool(eServerType.Isn, newIsnMatch.MatchID, IsnBetPool, isnStake));
                                                            return(true);
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        Thread.Sleep(1000);
                                    }

                                    Thread.Sleep(60000);

                                    for (int i = 0; i < IsnEngine.Rebet * 2; i++)
                                    {
                                        var prepare = PiEngine.PrepareBet(piMatch, piOdd, betTypeAgaint, firstOdd);
                                        if (prepare != null)
                                        {
                                            var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true);
                                            if (ok)
                                            {
                                                LastBetTime = DateTime.Now;
                                                Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));
                                                return(true);
                                            }
                                        }

                                        Thread.Sleep(10000);

                                        lock (PiEngine.LockLive)
                                        {
                                            var newPiMatch = PiEngine._matchs.FirstOrDefault(p => p.MatchID == piMatch.MatchID);
                                            if (newPiMatch != null)
                                            {
                                                var newPiOdd = newPiMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == piOdd.OddType);
                                                if (newPiOdd != null)
                                                {
                                                    prepare = PiEngine.PrepareBet(newPiMatch, newPiOdd, betTypeAgaint, firstOdd);
                                                    if (prepare != null)
                                                    {
                                                        var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, newPiMatch, newPiOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true);
                                                        if (ok)
                                                        {
                                                            LastBetTime = DateTime.Now;
                                                            Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));
                                                            return(true);
                                                        }
                                                    }
                                                }
                                            }
                                        }


                                        Thread.Sleep(10000);

                                        lock (IsnEngine.LockLive)
                                        {
                                            var newIsnMatch = IsnEngine._matchs.FirstOrDefault(p => p.MatchID == isnMatch.MatchID);
                                            if (newIsnMatch != null)
                                            {
                                                var newIsnOdd = newIsnMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == isnOdd.OddType);
                                                if (newIsnOdd != null)
                                                {
                                                    prepare = IsnEngine.PrepareBet(newIsnMatch, newIsnOdd, betTypeAgaint, true, firstOdd);
                                                    if (prepare != null)
                                                    {
                                                        var ok = IsnEngine.ConfirmBet2(isnStake, newIsnMatch, newIsnOdd, betTypeAgaint, eBetStatusType.MissOddIsn, true);
                                                        if (ok)
                                                        {
                                                            LastBetTime = DateTime.Now;
                                                            Task.Run(() => UpdateBetPool(eServerType.Isn, newIsnMatch.MatchID, IsnBetPool, isnStake));
                                                            return(true);
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        Thread.Sleep(10000);
                                    }
                                }

                                LastBetTime = DateTime.Now;

                                Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));

                                return(true);
                            }
                        }
                        // tạm đóng
                        FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan);
                    }
                }
                else
                {
                    // tạm đóng
                    FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan);
                }

                return(false);
            }
            catch (Exception ex)
            {
                Logger.Error(ProcessorName, ex);
                return(false);
            }
            finally
            {
                isProcess = false;
            }
        }
コード例 #8
0
        public bool ProcessPrepareBet(MatchPiDTO piMatch, OddDTO piOdd, eBetType piBetType, MatchIsnDTO isnMatch, OddDTO isnOdd, eBetType isnBetType, bool isLive,
                                      eServerScan serverScan = eServerScan.Local)
        {
            if (isProcess)
            {
                return(false);
            }

            //what?
            //string oddCheck = sboMatchOdd.OddID + sboMatchOdd.HomeOdd + sboMatchOdd.AwayOdd + piOdd.HomeOdd +
            //                  piOdd.AwayOdd;

            //if (oddCheck.Equals(OddCheck))
            //{
            //    return false;
            //}

            //OddCheck = oddCheck;

            try
            {
                isProcess = true;

                // wwhat?
                //sboMatchOdd.OldOdd = piBetType == eBetType.Home ? sboMatchOdd.HomeOdd : sboMatchOdd.AwayOdd;
                //   Logger.Debug("");
                //  Logger.Debug("Before call PREPARE ISN " + piMatch.HomeTeamName + "-" + piMatch.AwayTeamName + " " + piOdd.HomeOdd + "_" + piOdd.AwayOdd + " " + piBetType.ToString());
                Stopwatch a = new Stopwatch();
                a.Start();
                Task <int> taskMaxBet = Task.Run(() => IsnEngine.GetMax((isnBetType == eBetType.Home ? isnOdd.selectionIdHome : isnOdd.selectionIdAway)));

                var prepareBetIsn = Task.Run(() => IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, isLive, isnOdd.Odd));

                var preparePina = PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd);

                if (preparePina == null || prepareBetIsn.Result == null)
                {
                    FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan);
                    return(false);
                }

                a.Stop();
                Logger.Info("Total time prepare: " + a.ElapsedMilliseconds + " ms");
                // Debug.WriteLine("Thoi gian prepare: " + a.ElapsedMilliseconds);

                bool betAny;
                //   float piOddValue = piBetType == eBetType.Home ? piOdd.HomeOdd : piOdd.AwayOdd;
                //bool isGood = IsGoodOddPair(piOddValue, prepareBetIsn.NewOdd, CompareValueDifferent, out betAny);
                bool isGood = IsGoodOddPair(preparePina.NewOdd, prepareBetIsn.Result.NewOdd, CompareValueDifferent, out betAny);
                // Logger.Debug("After isGood=" + isGood.ToString() + " " + piOddValue + "_" + prepareBetIsn.NewOdd + " " + piBetType.ToString());

                if (isGood)
                {
                    int piStake;
                    int isnStake;

                    if (CaculateStake(BetStakeType,
                                      piMatch.MatchID, 150, (int)((PendingTicket)preparePina.PendingTicket).TicketItem.MaxRiskAmount,
                                      isnMatch.MatchID, 4, taskMaxBet,
                                      out piStake, out isnStake))
                    // if (true)
                    {
                        a.Restart();
                        Logger.Info("Total time prepare: " + a.ElapsedMilliseconds + " ms");

                        var taskpiConfirmBet = Task.Run(() => PiEngine.ConfirmBet((PendingTicket)preparePina.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.Success));
                        var betisnOk         = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.Success);
                        if (taskpiConfirmBet.Result == true && betisnOk == true)
                        {
                            a.Stop();
                            Logger.Info("Total time prepare: " + a.ElapsedMilliseconds + " ms");

                            Task.Run(
                                () =>
                            {
                                UpdateBetPool(
                                    eServerType.Isn,
                                    isnMatch.MatchID,
                                    IsnBetPool,
                                    isnStake);

                                UpdateBetPool(
                                    eServerType.Pina,
                                    piMatch.MatchID,
                                    PiBetPool,
                                    piStake);
                            });
                            Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                            CountBet++;
                            LastBetTime = DateTime.Now;
                            return(true);
                        }
                        else if (taskpiConfirmBet.Result == false && betisnOk == false)
                        {
                            return(false);
                        }
                        else if (taskpiConfirmBet.Result == true)
                        {
                            Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));

                            bool ok = false;
                            for (int i = 0; i < IsnEngine.Rebet; i++)
                            {
                                var prepare = IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, true, isnOdd.Odd);
                                if (prepare != null)
                                {
                                    ok = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.MissOddIsn, true);
                                    if (ok)
                                    {
                                        LastBetTime = DateTime.Now;

                                        Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake));
                                        return(true);
                                    }
                                }
                                Thread.Sleep(500);
                            }

                            if (!ok) // ReBet pina
                            {
                                var betTypeAgaint = GetAgainstBetType(piBetType);
                                var prepare       = PiEngine.PrepareBet(piMatch, piOdd, betTypeAgaint, piOdd.Odd);
                                if (prepare != null)
                                {
                                    ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true);
                                    if (ok)
                                    {
                                        LastBetTime = DateTime.Now;
                                        Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));
                                        return(true);
                                    }
                                }
                            }

                            IsnEngine.FireLogBet(isnMatch, isnOdd, isnBetType, isnStake, eBetStatusType.Fail, eServerScan.Local);
                        }
                        else if (betisnOk == true)
                        {
                            Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake));

                            bool ok = false;
                            for (int i = 0; i < PiEngine.Rebet; i++)
                            {
                                var prepare = PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd);
                                if (prepare != null)
                                {
                                    ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.MissOddPina, true);
                                    if (ok)
                                    {
                                        LastBetTime = DateTime.Now;

                                        Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake));

                                        return(true);
                                    }
                                }
                                Thread.Sleep(500);
                            }

                            if (!ok)// Rebet Isn
                            {
                                var betTypeAgaint = GetAgainstBetType(isnBetType);
                                var prepare       = IsnEngine.PrepareBet(isnMatch, isnOdd, betTypeAgaint, true, isnOdd.Odd);
                                if (prepare != null)
                                {
                                    ok = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, betTypeAgaint, eBetStatusType.BetAgainIsn, true);
                                    if (ok)
                                    {
                                        LastBetTime = DateTime.Now;
                                        Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake));
                                        return(true);
                                    }
                                }
                            }

                            PiEngine.FireLogBet(piMatch, piOdd, piBetType, piStake, eBetStatusType.Fail, eServerScan.Local);
                        }

                        return(false);
                    }

                    // tạm đóng
                    FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan);
                }
                //else
                //{
                //    // tạm đóng
                //    FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan);
                //}

                return(false);
            }
            catch (Exception ex)
            {
                Logger.Error(ProcessorName, ex);
                return(false);
            }
            finally
            {
                isProcess = false;
            }
        }