示例#1
0
        private void UpdateBetPool(eServerType serverType, string matchId, Dictionary <string, int> betPool, int stake)
        {
            if (!betPool.ContainsKey(matchId))
            {
                betPool.Add(matchId, 0);
            }
            betPool[matchId] += stake;
            if (serverType == eServerType.Ibet)
            {
                IbetEngine.UpdateAvailabeCredit();
            }
            else
            {
                SboEngine.UpdateAvailabeCredit();
            }

            //if (OnLogBetEvent != null)
            //{
            //    var msg = new LogBetMessage()
            //    {
            //        HomeTeamName = match.HomeTeamName,
            //        AwayTeamName = match.AwayTeamName,
            //        OddType = match.OddType,
            //        ServerType = match.ServerType,
            //        HomeOdd = match.HomeOdd,
            //        AwayOdd = match.AwayOdd,
            //        BetStake = stake,
            //        BetType = betType
            //    };
            //    OnLogBetEvent(msg);
            //}
        }
示例#2
0
        public bool ReConnectSbo()
        {
            if (SboEngine.ReLogin())
            {
                Logger.Info("Ket noi sbo thanh cong>>>>>>>>>>>>>>>>>>>>>");

                for (int i = 0; i < 4; i++)
                {
                    Logger.Info(ProcessorName + " START Service LOOP: " + i);

                    if (this.Status == eServiceStatus.Started)
                    {
                        IsReConnect = false;
                        return(true);
                    }

                    if (Start(ScanType) == eServiceStatus.Started)
                    {
                        IsReConnect = false;
                        Logger.Info(ProcessorName + " >>>>>>>>>>>>>>>>>>>>>>>>>>START THANH CONG!!! ");
                        return(true);
                    }
                    Thread.Sleep(15000);
                }

                if (SboEngine.AccountStatus == eAccountStatus.Online)
                {
                    SboEngine.LogOff();
                }

                Thread.Sleep(30000);
            }
            return(false);
            //return ReConnectSbo();
        }
示例#3
0
        public PiSboProcessor(ServerCallback serverCallback)
        {
            StartFailCount = 0;
            PiEngine       = new PiEngine();

            SboEngine = new SboEngine();
        }
示例#4
0
        public void Initialize()
        {
            if (SboEngine.CheckLogin() && IbetEngine.CheckLogin())
            {
                if (SboEngine.Status == eServiceStatus.Unknown)
                {
                    SboBetPool = new Dictionary <string, int>();
                    //SboEngine.UpdateLiveDataChange += sbobetUpdateChange_Event;
                    //SboEngine.UpdateNonLiveDataChange += sbobetUpdateChange_Event;
                    SboEngine.OnExceptionEvent += OnExceptionEvent;
                    SboEngine.InitEngine();
                }

                if (IbetEngine.Status == eServiceStatus.Unknown)
                {
                    //PiEngine.UpdateLiveDataChange += ibetUpdateChange_Event;
                    //PiEngine.UpdateNonLiveDataChange += ibetUpdateChange_Event;

                    IbetEngine.OnExceptionEvent += OnExceptionEvent;
                    //PiEngine.OnReConnectFail += IbetEngine_OnReConnectFail;
                    //PiEngine.OnReConnectSuccess += IbetEngine_OnReConnectSuccess;
                    IbetBetPool = new Dictionary <string, int>();
                    IbetEngine.InitEngine();
                }

                Status = eServiceStatus.Initialized;
            }
        }
示例#5
0
 private void WaitUpdateCreditCallback(object obj)
 {
     try
     {
         IbetEngine.UpdateAvailabeCredit();
         SboEngine.UpdateAvailabeCredit();
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
示例#6
0
        private PrepareBetDTO CallPrepareBet(MatchOddDTO matchOdd, eBetType betType, bool isLive, float oddDef)
        {
            switch (matchOdd.ServerType)
            {
            //case eServerType.Ibet:
            //    return PiEngine.PrepareBet(matchOdd, betType, isLive, oddDef);
            case eServerType.Sbo:
                return(SboEngine.PrepareBet(matchOdd, betType, isLive, oddDef));

            default:
                throw new Exception("CallPrepareBet => FAIL : Unknow 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");
            }
        }
示例#8
0
        private void ReStartFromSbo()
        {
            if (!IsReConnect)
            {
                IsReConnect = true;
                this.Pause();
                FireProcessStateChange(eServiceStatus.Paused, "reconnecting...");
                Logger.Info("TAM DUNG HE THONG, KET NOI LAI SBO!!!!!!!!!");
                SboEngine.LogOff();

                ReConnectSbo();
                IsReConnect = false;
            }
        }
示例#9
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");
            }
        }
示例#10
0
 public void Initialize()
 {
     if (SboEngine.CheckLogin())
     {
         if (SboEngine.Status == eServiceStatus.Unknown)
         {
             SboBetPool = new Dictionary <string, int>();
             SboEngine.OnExceptionEvent += OnExceptionEvent;
             SboEngine.InitEngine();
         }
         PiBetPool = new Dictionary <string, int>();
         PiEngine.InitEngine();
         Status = eServiceStatus.Initialized;
     }
 }
示例#11
0
        public void Dispose()
        {
            Pause();

            SboEngine.OnExceptionEvent -= OnExceptionEvent;

            if (objUpdateCreditTimer != null)
            {
                objUpdateCreditTimer.Dispose();
            }

            SboEngine.LogOff();
            Status         = eServiceStatus.Stopped;
            StartFailCount = 0;
        }
示例#12
0
        public void Dispose()
        {
            ServerCallback.OnSboScanUpdate -= OnSboUpdateScan;
            SboEngine.OnExceptionEvent     -= OnExceptionEvent;
            IbetEngine.OnExceptionEvent    -= OnExceptionEvent;

            if (objUpdateCreditTimer != null)
            {
                objUpdateCreditTimer.Dispose();
            }

            IbetEngine.LogOff();
            SboEngine.LogOff();
            Status         = eServiceStatus.Stopped;
            StartFailCount = 0;
        }
示例#13
0
 private void UpdateBetPool(eServerType serverType, string matchId, Dictionary <string, int> betPool, int stake)
 {
     if (!betPool.ContainsKey(matchId))
     {
         betPool.Add(matchId, 0);
     }
     betPool[matchId] += stake;
     if (serverType == eServerType.Pina)
     {
         PiEngine.UpdateAvailabeCredit();
     }
     else
     {
         SboEngine.UpdateAvailabeCredit();
     }
 }
        private void WaitUpdateCreditCallback(object obj)
        {
            try
            {
                IbetEngine.UpdateAvailabeCredit();
                SboEngine.UpdateAvailabeCredit();

                if (OnUpdateCredit != null)
                {
                    OnUpdateCredit(null, new EventArgs());
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
示例#15
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");
            }
        }
        public void Dispose()
        {
            //IbetEngine.UpdateLiveDataChange -= ibetUpdateChange_Event;
            //IbetEngine.UpdateNonLiveDataChange -= ibetUpdateChange_Event;
            SboEngine.UpdateLiveDataChange    -= sbobetUpdateChange_Event;
            SboEngine.UpdateNonLiveDataChange -= sbobetUpdateChange_Event;
            SboEngine.OnExceptionEvent        -= OnExceptionEvent;
            IbetEngine.OnExceptionEvent       -= OnExceptionEvent;

            if (objUpdateCreditTimer != null)
            {
                objUpdateCreditTimer.Dispose();
            }

            IbetEngine.LogOff();
            SboEngine.LogOff();
            Status = eServiceStatus.Stopped;
        }
示例#17
0
        public eServiceStatus ReStart()
        {
            try
            {
                Logger.Info("KHOI DONG LAI HE THONG!!!!!!!!!!!!!!!!!!!!!!");
                this.Pause();
                SboEngine.LogOff();
                SboEngine.ReLogin();
                var status = Start(ScanType);
                Logger.Info("KHOI DONG LAI HE THONG THANH CONG!!!!!!!!!!!!!!!!!!!!!!");
                return(status);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);;
            }

            return(eServiceStatus.Unknown);
        }
示例#18
0
        public void Pause()
        {
            ServerCallback.OnSboScanUpdate -= OnSboUpdateScan;
            if (IbetEngine.Status == eServiceStatus.Started)
            {
                IbetEngine.PauseScan();
            }

            if (SboEngine.Status == eServiceStatus.Started)
            {
                SboEngine.PauseScan();
            }

            if (objUpdateCreditTimer != null)
            {
                objUpdateCreditTimer.Dispose();
            }

            Status = eServiceStatus.Paused;
        }
示例#19
0
        private void WaitUpdateCreditCallback(object obj)
        {
            try
            {
                IbetEngine.UpdateAvailabeCredit();
                SboEngine.UpdateAvailabeCredit();
                //if (PiEngine.UpdateAvailabeCredit()==0)
                //{
                //    OnExceptionEvent(new ExceptionMessage(eExceptionType.LoginFail), eServerType.Ibet);
                //}

                //if (SboEngine.UpdateAvailabeCredit()==0)
                //{
                //    OnExceptionEvent(new ExceptionMessage(eExceptionType.LoginFail), eServerType.Sbo);
                //}
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
示例#20
0
        public void Pause()
        {
            //_driver.OnSboScanUpdate -= OnSboUpdateScan;
            SboEngine.UpdateLiveDataChange -= OnSboUpdateScan;
            PiSboDriver.OnSboScanUpdate    -= PiSboDriver_OnSboScanUpdate;

            PiEngine.PauseScan();

            if (SboEngine.Status == eServiceStatus.Started)
            {
                SboEngine.PauseScan();
            }

            if (objUpdateCreditTimer != null)
            {
                objUpdateCreditTimer.Dispose();
            }


            Status = eServiceStatus.Paused;
        }
        public void Pause()
        {
            //SboEngine.UpdateLiveDataChange -= sbobetUpdateChange_Event;
            //SboEngine.UpdateNonLiveDataChange -= sbobetUpdateChange_Event;

            if (IbetEngine.Status == eServiceStatus.Started)
            {
                IbetEngine.PauseScan();
            }

            if (SboEngine.Status == eServiceStatus.Started)
            {
                SboEngine.PauseScan();
            }

            if (objUpdateCreditTimer != null)
            {
                objUpdateCreditTimer.Dispose();
            }

            Status = eServiceStatus.Paused;
        }
示例#22
0
        public eServiceStatus Start(eScanType scanType)
        {
            CompareValueDifferent = ProcessorConfigInfo.CompareValue;
            ScanType           = scanType;
            CountBet           = 1;
            MaxCountBet        = ProcessorConfigInfo.MaxCountBet;
            LastBetTime        = DateTime.Now.AddMinutes(-10);
            LastBetIbetSuccess = DateTime.Now.AddMinutes(-10);

            BetStakeType     = ProcessorConfigInfo.BetStakeType;
            BetStake         = ProcessorConfigInfo.BetStake;
            TimeOffStakeOdds = ProcessorConfigInfo.TimeOffStakeOdds;
            MinOddDefBet     = ProcessorConfigInfo.MinOddDefBet;
            MinTimeToBet     = ProcessorConfigInfo.MinTimeToBet;

            BetAgainstIbet       = ProcessorConfigInfo.RebetIbet;
            WaitingTimeRebetIbet = ProcessorConfigInfo.WaitingTimeRebetIbet;
            AcceptMinLossIbet    = ProcessorConfigInfo.AcceptMinLossIbet;

            if (ProcessorConfigInfo.AccountFirst.ServerType == eServerType.Ibet)
            {
                IbetMaxStakeMatch = ProcessorConfigInfo.AccountFirst.MaxStake;
                IbetRateExchange  = ProcessorConfigInfo.AccountFirst.RateExchange;
                SboMaxStakeMatch  = ProcessorConfigInfo.AccountSecond.MaxStake;
                SboRateExchange   = ProcessorConfigInfo.AccountSecond.RateExchange;
            }
            else
            {
                IbetMaxStakeMatch = ProcessorConfigInfo.AccountSecond.MaxStake;
                IbetRateExchange  = ProcessorConfigInfo.AccountSecond.RateExchange;
                SboMaxStakeMatch  = ProcessorConfigInfo.AccountFirst.MaxStake;
                SboRateExchange   = ProcessorConfigInfo.AccountFirst.RateExchange;
            }

            try
            {
                Initialize();
                ProcessorName = IbetEngine.UserName + " - " + SboEngine.UserName;
                //EngineLogger engineLogger = new EngineLogger(engineName);

                //if (SboEngine.CheckLogin() && IbetEngine.CheckLogin())
                //{
                SboEngine.EngineName = ProcessorName;
                //SboEngine.EngineLogger = engineLogger;
                SboEngine.Rebet = ProcessorConfigInfo.RebetSbo;
                //SboEngine.InitEngine();
                SboEngine.UpdateAvailabeCredit();
                SboEngine.StartScanEngine(scanType);

                //IbetEngine.InitEngine();
                IbetEngine.EngineName = ProcessorName;
                //IbetEngine.EngineLogger = engineLogger;
                IbetEngine.UpdateAvailabeCredit();
                IbetEngine.StartScanEngine(scanType);

                objUpdateCreditTimer = new Timer(WaitUpdateCreditCallback, null, 60000 * 5, 60000 * 5);
                StartFailCount       = 0;

                //IbetSboDriver.OnSboScanUpdate += IbetSboDriverOnUpdateScan;
                ServerCallback.OnSboScanUpdate  += OnSboUpdateScan;
                ServerCallback.OnIbetScanUpdate += OnIbetUpdateScan;
                FireProcessStateChange(eServiceStatus.Started, ProcessorName);
                Status = eServiceStatus.Started;
                //}

                // return eServiceStatus.Unknown;
            }
            catch (Exception ex)
            {
                Logger.Error("Start Processor Fail !", ex);

                StartFailCount++;

                SboEngine.Dispose();
                SboEngine.Dispose();
                Status = eServiceStatus.Unknown;
            }

            return(Status);
        }
示例#23
0
        public eServiceStatus Start(eScanType scanType)
        {
            CompareValueDifferent = ProcessorConfigInfo.CompareValue;
            ScanType           = scanType;
            CountBet           = 1;
            MaxCountBet        = ProcessorConfigInfo.MaxCountBet;
            LastBetTime        = DateTime.Now.AddMinutes(-10);
            LastBetIbetSuccess = DateTime.Now.AddMinutes(-10);

            BetStakeType = ProcessorConfigInfo.BetStakeType;
            Stake        = ProcessorConfigInfo.BetStake;

            BetStake = new List <int>();
            var stak = Stake.Split(new[] { '#' });

            foreach (var s in stak)
            {
                if (!string.IsNullOrEmpty(s))
                {
                    int stake;
                    int.TryParse(s, out stake);
                    if (stake != 0)
                    {
                        //Logger.Info("STAKE " + stake);
                        BetStake.Add(stake);
                    }
                }
            }

            BetStake.Shuffle();


            TimeOffStakeOdds = ProcessorConfigInfo.TimeOffStakeOdds;
            MinOddDefBet     = ProcessorConfigInfo.MinOddDefBet;
            MinTimeToBet     = ProcessorConfigInfo.MinTimeToBet;

            BetAgainstIbet = ProcessorConfigInfo.RebetIbet;
            //WaitingTimeRebetIbet = ProcessorConfigInfo.WaitingTimeRebetIbet;
            AcceptMinLossIbet = ProcessorConfigInfo.AcceptMinLossIbet;

            if (ProcessorConfigInfo.AccountFirst.ServerType == eServerType.Ibet)
            {
                IbetMaxStakeMatch = ProcessorConfigInfo.AccountFirst.MaxStake;
                IbetRateExchange  = ProcessorConfigInfo.AccountFirst.RateExchange;
                SboMaxStakeMatch  = ProcessorConfigInfo.AccountSecond.MaxStake;
                SboRateExchange   = ProcessorConfigInfo.AccountSecond.RateExchange;
            }
            else
            {
                IbetMaxStakeMatch = ProcessorConfigInfo.AccountSecond.MaxStake;
                IbetRateExchange  = ProcessorConfigInfo.AccountSecond.RateExchange;
                SboMaxStakeMatch  = ProcessorConfigInfo.AccountFirst.MaxStake;
                SboRateExchange   = ProcessorConfigInfo.AccountFirst.RateExchange;
            }

            try
            {
                Initialize();
                ProcessorName = IbetEngine.UserName + " - " + SboEngine.UserName;
                //EngineLogger engineLogger = new EngineLogger(engineName);

                //if (SboEngine.CheckLogin() && PiEngine.CheckLogin())
                //{
                SboEngine.EngineName = ProcessorName;
                //SboEngine.EngineLogger = engineLogger;
                SboEngine.Rebet = ProcessorConfigInfo.RebetSbo;
                //SboEngine.InitEngine();
                SboEngine.UpdateAvailabeCredit();
                SboEngine.StartScanEngine(scanType);

                //PiEngine.InitEngine();
                IbetEngine.EngineName = ProcessorName;
                //PiEngine.EngineLogger = engineLogger;
                IbetEngine.UpdateAvailabeCredit();
                IbetEngine.StartScanEngine(scanType);

                objUpdateCreditTimer = new Timer(WaitUpdateCreditCallback, null, 60000 * 5, 60000 * 5);
                StartFailCount       = 0;

                _driver.OnSboScanUpdate += OnSboUpdateScan;

                //SboEngine.UpdateLiveDataChange += SboEngineOnUpdateLiveDataChange;
                //IbetSboDriver.OnSboScanUpdate += OnSboUpdateScan;
                //ServerCallback.OnSboScanUpdate += OnSboUpdateScan;
                //ServerCallback.OnIbetScanUpdate += OnIbetUpdateScan;
                ServerCallback.OnTransactionStatic += ServerCallback_OnTransaction;
                FireProcessStateChange(eServiceStatus.Started, ProcessorName);
                Status = eServiceStatus.Started;

                //List<TransactionDTO> transactionDtos;
                //while (TransactionQueue.TryDequeue(out transactionDtos))
                //{
                //    // do nothing
                //}
                //processBetThread = new Thread(DoBetTransaction);
                //processBetThread.Start();
                //}

                // return eServiceStatus.Unknown;
            }
            catch (Exception ex)
            {
                Logger.Error("Start Processor Fail !", ex);

                StartFailCount++;

                SboEngine.Dispose();
                SboEngine.Dispose();
                Status = eServiceStatus.Unknown;
            }

            return(Status);
        }
        public eServiceStatus Start(eScanType scanType)
        {
            CompareValueDifferent = ProcessorConfigInfo.CompareValue;

            CountBet         = 1;
            MaxCountBet      = ProcessorConfigInfo.MaxCountBet;
            LastBetTime      = DateTime.Now;
            BetStakeType     = ProcessorConfigInfo.BetStakeType;
            BetStake         = ProcessorConfigInfo.BetStake;
            TimeOffStakeOdds = ProcessorConfigInfo.TimeOffStakeOdds;
            if (ProcessorConfigInfo.AccountFirst.ServerType == eServerType.Ibet)
            {
                IbetMaxStakeMatch = ProcessorConfigInfo.AccountFirst.MaxStake;
                IbetRateExchange  = ProcessorConfigInfo.AccountFirst.RateExchange;
                SboMaxStakeMatch  = ProcessorConfigInfo.AccountSecond.MaxStake;
                SboRateExchange   = ProcessorConfigInfo.AccountSecond.RateExchange;
            }
            else
            {
                IbetMaxStakeMatch = ProcessorConfigInfo.AccountSecond.MaxStake;
                IbetRateExchange  = ProcessorConfigInfo.AccountSecond.RateExchange;
                SboMaxStakeMatch  = ProcessorConfigInfo.AccountFirst.MaxStake;
                SboRateExchange   = ProcessorConfigInfo.AccountFirst.RateExchange;
            }

            try
            {
                Initialize();
                var engineName = IbetEngine.UserName + " - " + SboEngine.UserName;
                //EngineLogger engineLogger = new EngineLogger(engineName);

                //if (SboEngine.CheckLogin() && IbetEngine.CheckLogin())
                //{
                SboEngine.EngineName = engineName;
                //SboEngine.EngineLogger = engineLogger;
                SboEngine.Rebet = ProcessorConfigInfo.RebetSbo;
                //SboEngine.InitEngine();
                SboEngine.UpdateAvailabeCredit();
                SboEngine.StartScanEngine(scanType);

                //IbetEngine.InitEngine();
                IbetEngine.EngineName = engineName;
                //IbetEngine.EngineLogger = engineLogger;
                IbetEngine.UpdateAvailabeCredit();
                IbetEngine.StartScanEngine(scanType);

                objUpdateCreditTimer = new Timer(WaitUpdateCreditCallback, null, 60000 * 5, 60000 * 5);
                StartFailCount       = 0;
                Status = eServiceStatus.Started;
                //}

                // return eServiceStatus.Unknown;
            }
            catch (Exception ex)
            {
                Logger.Error("Start Processor Fail !", ex);

                StartFailCount++;

                SboEngine.Dispose();
                SboEngine.Dispose();
                Status = eServiceStatus.Unknown;
            }

            return(Status);

            //else
            //{
            //    StartServerFault startServerFault = new StartServerFault();
            //    startServerFault.ServerID = IbetEngine.Account.GuidID;
            //    startServerFault.Message = "Login Fail !";
            //    throw new FaultException<StartServerFault>(startServerFault);
            //}
        }
示例#25
0
        public eServiceStatus Start(eScanType scanType)
        {
            Random r = new Random();

            CompareValueDifferent = ProcessorConfigInfo.CompareValue + AddToCompare[r.Next(AddToCompare.Count)];

            ScanType    = scanType;
            CountBet    = 1;
            MaxCountBet = ProcessorConfigInfo.MaxCountBet;
            LastBetTime = DateTime.Now.AddMinutes(-10);

            BetStakeType = ProcessorConfigInfo.BetStakeType;
            Stake        = ProcessorConfigInfo.BetStake;

            BetStake = new List <int>();
            var stak = Stake.Split(new[] { '#' });

            foreach (var s in stak)
            {
                if (!string.IsNullOrEmpty(s))
                {
                    int stake;
                    int.TryParse(s, out stake);
                    if (stake != 0)
                    {
                        //Logger.Info("STAKE " + stake);
                        BetStake.Add(stake);
                    }
                }
            }

            BetStake.Shuffle();


            TimeOffStakeOdds = ProcessorConfigInfo.TimeOffStakeOdds;
            MinOddDefBet     = ProcessorConfigInfo.MinOddDefBet;
            MinTimeToBet     = ProcessorConfigInfo.MinTimeToBet;

            BetAgainstIbet    = ProcessorConfigInfo.RebetIbet;
            AcceptMinLossIbet = ProcessorConfigInfo.AcceptMinLossIbet;

            if (ProcessorConfigInfo.AccountFirst.ServerType == eServerType.Sbo)
            {
                IbetMaxStakeMatch = ProcessorConfigInfo.AccountSecond.MaxStake;
                IbetRateExchange  = ProcessorConfigInfo.AccountSecond.RateExchange;
                SboMaxStakeMatch  = ProcessorConfigInfo.AccountFirst.MaxStake;
                SboRateExchange   = ProcessorConfigInfo.AccountFirst.RateExchange;
            }
            else
            {
                IbetMaxStakeMatch = ProcessorConfigInfo.AccountFirst.MaxStake;
                IbetRateExchange  = ProcessorConfigInfo.AccountFirst.RateExchange;
                SboMaxStakeMatch  = ProcessorConfigInfo.AccountSecond.MaxStake;
                SboRateExchange   = ProcessorConfigInfo.AccountSecond.RateExchange;
            }

            try
            {
                Initialize();
                ProcessorName = PiEngine.UserName + " - " + SboEngine.UserName;

                SboEngine.EngineName = ProcessorName;
                SboEngine.Rebet      = ProcessorConfigInfo.RebetSbo;
                SboEngine.UpdateAvailabeCredit();
                SboEngine.StartScanEngine(scanType);

                PiEngine.EngineName = ProcessorName;
                PiEngine.UpdateAvailabeCredit();
                PiEngine.StartScanEngine(scanType);

                objUpdateCreditTimer = new Timer(WaitUpdateCreditCallback, null, 60000 * 5, 60000 * 5);
                StartFailCount       = 0;

                SboEngine.UpdateLiveDataChange += OnSboUpdateScan;
                PiSboDriver.OnSboScanUpdate    += PiSboDriver_OnSboScanUpdate;
                //_driver.OnSboScanUpdate += OnSboUpdateScan;

                FireProcessStateChange(eServiceStatus.Started, ProcessorName);
                Status = eServiceStatus.Started;
            }
            catch (Exception ex)
            {
                Logger.Error("Start Processor Fail !", ex);

                StartFailCount++;

                PiEngine.Dispose();
                SboEngine.Dispose();
                SboEngine.Dispose();
                Status = eServiceStatus.Unknown;
            }

            return(Status);
        }
示例#26
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;
            }
        }
示例#27
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;
            }
        }