Exemplo n.º 1
0
        private bool CallConfirmBet(PrepareBetDTO prepareBet, int stake, float oddDef, bool isLive = false, bool betAgainst = false)
        {
            switch (prepareBet.MatchOdd.ServerType)
            {
            case eServerType.Ibet:
                return(IbetEngine.ConfirmBet(stake, betAgainst));

            case eServerType.Sbo:
                return(SboEngine.ConfirmBet(stake, oddDef, isLive));

            default:
                throw new Exception("CallConfirmBet => FAIL : Unknow prepareBet->MatchOdd->eServerType param");
            }
        }
        private bool CallConfirmBet(PrepareBetDTO prepareBet, int stake)
        {
            switch (prepareBet.MatchOdd.ServerType)
            {
            case eServerType.Ibet:
                return(IbetEngine.ConfirmBet(stake));

            case eServerType.Sbo:
                return(SboEngine.ConfirmBet(stake));

            default:
                throw new Exception("CallConfirmBet => FAIL : Unknow prepareBet->MatchOdd->eServerType param");
            }
        }
Exemplo n.º 3
0
        private bool CallConfirmBet(PrepareBetDTO prepareBet, int stake, float oddDef, out string ibetMsg,
                                    bool isLive            = false, bool betAgainst = false,
                                    eServerScan serverScan = eServerScan.Local, bool callSecondIbet = false)
        {
            ibetMsg = null;
            switch (prepareBet.MatchOdd.ServerType)
            {
            case eServerType.Ibet:
                return(IbetEngine.ConfirmBet(stake, out ibetMsg, betAgainst, serverScan));

            case eServerType.Sbo:
                return(SboEngine.ConfirmBet(stake, oddDef, isLive, serverScan));

            default:
                throw new Exception("CallConfirmBet => FAIL : Unknow prepareBet->MatchOdd->eServerType param");
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 5
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;
            }
        }