Ejemplo n.º 1
0
        private bool ReconnectIbet()
        {
            if (IbetEngine.ReLogin())
            {
                Logger.Info("Ket noi ibet 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 (IbetEngine.AccountStatus == eAccountStatus.Online)
                {
                    IbetEngine.LogOff();
                }

                Thread.Sleep(30000);
                //Start(ScanType);
            }

            return(ReconnectIbet());
        }
Ejemplo n.º 2
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)
                {
                    //IbetEngine.UpdateLiveDataChange += ibetUpdateChange_Event;
                    //IbetEngine.UpdateNonLiveDataChange += ibetUpdateChange_Event;

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

                Status = eServiceStatus.Initialized;
            }
        }
Ejemplo n.º 3
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);
            //}
        }
        public void Dispose()
        {
            //IbetEngine.UpdateLiveDataChange -= ibetUpdateChange_Event;
            //IbetEngine.UpdateNonLiveDataChange -= ibetUpdateChange_Event;

            IbetEngine.Dispose();
        }
Ejemplo n.º 5
0
        public void Dispose()
        {
            //if (processBetThread != null)
            //{
            //    processBetThread.Abort();
            //}

            //SboEngine.UpdateLiveDataChange -= SboEngineOnUpdateLiveDataChange;
            //ServerCallback.OnTransaction -= ServerCallback_OnTransaction;
            ServerCallback.OnTransactionStatic -= ServerCallback_OnTransaction;
            _driver.OnSboScanUpdate            -= OnSboUpdateScan;
            //IbetSboDriver.OnSboScanUpdate -= OnSboUpdateScan;
            //ServerCallback.OnIbetScanUpdate -= OnIbetUpdateScan;
            //ServerCallback.OnSboScanUpdate -= OnSboUpdateScan;
            SboEngine.OnExceptionEvent  -= OnExceptionEvent;
            IbetEngine.OnExceptionEvent -= OnExceptionEvent;

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

            IbetEngine.LogOff();
            SboEngine.LogOff();
            Status         = eServiceStatus.Stopped;
            StartFailCount = 0;
        }
Ejemplo n.º 6
0
        public void Pause()
        {
            //if (processBetThread != null)
            //{
            //    processBetThread.Abort();
            //}

            //SboEngine.UpdateLiveDataChange -= SboEngineOnUpdateLiveDataChange;
            //ServerCallback.OnTransaction -= ServerCallback_OnTransaction;
            ServerCallback.OnTransactionStatic -= ServerCallback_OnTransaction;
            _driver.OnSboScanUpdate            -= OnSboUpdateScan;
            //IbetSboDriver.OnSboScanUpdate -= OnSboUpdateScan;
            //ServerCallback.OnIbetScanUpdate -= OnIbetUpdateScan;
            //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;
        }
        public void PrepareBetTest(string oddId)
        {
            var match  = IbetEngine.LiveMatchOddDatas.Where(l => l.OddID == oddId);
            var fmatch = match.FirstOrDefault();

            IbetEngine.PrepareBet(fmatch, eBetType.Home, true);
            IbetEngine.ConfirmBet(3);
        }
Ejemplo n.º 8
0
 private void WaitUpdateCreditCallback(object obj)
 {
     try
     {
         IbetEngine.UpdateAvailabeCredit();
         SboEngine.UpdateAvailabeCredit();
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
        private void CallConfirmBet(PrepareBetDTO prepareBet)
        {
            switch (prepareBet.MatchOdd.ServerType)
            {
            case eServerType.Ibet:
                IbetEngine.ConfirmBet(3);
                break;

            default:
                throw new Exception("CallConfirmBet => FAIL : Unknow prepareBet->MatchOdd->eServerType param");
                break;
            }
        }
        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");
            }
        }
Ejemplo n.º 11
0
        private PrepareBetDTO CallPrepareBet(MatchOddDTO matchOdd, eBetType betType, bool isLive, float oddDef)
        {
            switch (matchOdd.ServerType)
            {
            case eServerType.Ibet:
                return(IbetEngine.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");
            }
        }
Ejemplo n.º 12
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");
            }
        }
 public void Start()
 {
     if (IbetEngine.CheckLogin())
     {
         IbetEngine.InitEngine();
         IbetEngine.StartScanEngine();
     }
     else
     {
         StartServerFault startServerFault = new StartServerFault();
         startServerFault.ServerID = IbetEngine.Account.GuidID;
         startServerFault.Message  = "Login Fail !";
         throw new FaultException <StartServerFault>(startServerFault);
     }
 }
Ejemplo n.º 14
0
        private void ReStartFromIbet()
        {
            if (!IsReConnect)
            {
                IsReConnect = true;

                this.Pause();
                FireProcessStateChange(eServiceStatus.Paused, "reconnecting...");
                Logger.Info("TAM DUNG HE THONG, KET NOI LAI IBET!!!!!!!!!");
                IbetEngine.LogOff();

                ReconnectIbet();
                IsReConnect = false;
            }
        }
Ejemplo n.º 15
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;
        }
Ejemplo n.º 16
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");
            }
        }
        private void WaitUpdateCreditCallback(object obj)
        {
            try
            {
                IbetEngine.UpdateAvailabeCredit();
                SboEngine.UpdateAvailabeCredit();

                if (OnUpdateCredit != null)
                {
                    OnUpdateCredit(null, new EventArgs());
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
        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;
        }
Ejemplo n.º 19
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;
        }
Ejemplo n.º 20
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);
            }
        }
Ejemplo n.º 21
0
        public eServiceStatus ReStart()
        {
            try
            {
                Logger.Info("KHOI DONG LAI HE THONG!!!!!!!!!!!!!!!!!!!!!!");
                this.Pause();
                IbetEngine.LogOff();
                SboEngine.LogOff();
                IbetEngine.ReLogin();
                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);
        }
        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;
        }
        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);
            //}
        }
Ejemplo n.º 24
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);
        }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
0
        public bool ProcessPrepareBet(MatchOddDTO ibetMatchOdd, eBetType ibetBetType, MatchOddDTO sboMatchOdd, eBetType sboBetType, bool isLive,
                                      eServerScan serverScan = eServerScan.Local, bool callSecond = false, string bpMatch = "", PrepareBetDTO sboPrepareBet = null)
        {
            if (isProcess && !callSecond) // || LastProcessPrepare.AddMilliseconds(200) > DateTime.Now
            {
                return(false);
            }

            try
            {
                isProcess = true;
                PrepareBetDTO ibetPrepareBet;
                if (!callSecond)
                {
                    sboMatchOdd.OldOdd = sboBetType == eBetType.Home ? sboMatchOdd.HomeOdd : sboMatchOdd.AwayOdd;

                    var taskPrepareBetSbo =
                        Task.Run(() => CallPrepareBet(sboMatchOdd, sboBetType, isLive, ibetMatchOdd.Odd));
                    ibetPrepareBet = CallPrepareBet(ibetMatchOdd, ibetBetType, isLive, sboMatchOdd.Odd);

                    if (!ibetPrepareBet.IsSuccess || taskPrepareBetSbo.Result == null)
                    {
                        return(false);
                    }

                    sboPrepareBet = taskPrepareBetSbo.Result;
                }
                else
                {
                    Logger.Warn("BAT DAU PREPARE LAN 2");
                    ibetPrepareBet = CallPrepareIbetAgain(ibetMatchOdd, ibetBetType, isLive, sboMatchOdd.Odd, bpMatch);
                    if (!ibetPrepareBet.IsSuccess)
                    {
                        return(false);
                    }
                }


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

                //var taskPrepareBetSbo =
                //    Task.Run(() => CallPrepareBet(sboMatchOdd, sboBetType, isLive, ibetMatchOdd.Odd));
                //PrepareBetDTO ibetPrepareBet = CallPrepareBet(ibetMatchOdd, ibetBetType, isLive, sboMatchOdd.Odd);

                //if (!ibetPrepareBet.IsSuccess || taskPrepareBetSbo.Result == null)
                //{
                //    return false;
                //}
                //PrepareBetDTO sboPrepareBet = taskPrepareBetSbo.Result;

                if (ibetPrepareBet.IsRunning)
                {
                    bool isGood = IsGoodOddPair(ibetPrepareBet.NewOdd, sboPrepareBet.NewOdd, CompareValueDifferent);

                    if (isGood)
                    {
                        int ibetStake;
                        int sboStake;

                        if (CaculateStake(BetStakeType,
                                          ibetPrepareBet.MatchOdd.MatchID,
                                          ibetPrepareBet.MinBet,
                                          ibetPrepareBet.MaxBet,
                                          sboPrepareBet.MatchOdd.MatchID,
                                          sboPrepareBet.MinBet,
                                          sboPrepareBet.MaxBet,
                                          out ibetStake, out sboStake))
                        {
                            string ibetConfirmMsg;

                            if (CallConfirmBet(ibetPrepareBet, ibetStake, sboMatchOdd.Odd, out ibetConfirmMsg, isLive, false, serverScan, callSecond))
                            {
                                LastBetIbetSuccess = DateTime.Now;

                                if (CallConfirmBet(sboPrepareBet, sboStake, ibetMatchOdd.Odd, out ibetConfirmMsg, isLive, false, serverScan))
                                {
                                    Task.Run(
                                        () =>
                                    {
                                        UpdateBetPool(
                                            sboPrepareBet.MatchOdd.ServerType,
                                            sboPrepareBet.MatchOdd.MatchID,
                                            SboBetPool, sboStake);
                                        UpdateBetPool(
                                            ibetPrepareBet.MatchOdd.ServerType,
                                            ibetPrepareBet.MatchOdd.MatchID,
                                            IbetBetPool,
                                            ibetStake);
                                    });
                                    Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                                    CountBet++;
                                    LastBetTime = DateTime.Now;
                                    return(true);
                                }
                                else
                                {
                                    if (BetAgainstIbet)
                                    {
                                        Logger.Info(ProcessorName + " DAT NGUOC IBET<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");

                                        if (!BetAgainstIbetRequest(ibetPrepareBet, ibetMatchOdd, ibetBetType,
                                                                   isLive, sboMatchOdd.Odd, ibetStake, false))
                                        {
                                            Thread.Sleep(3000);
                                            Logger.Info("CALL LAN 2 BET MGUOC IBET<<<<<<<<<<<<<<<<");
                                            if (BetAgainstIbetRequest(ibetPrepareBet, ibetMatchOdd, ibetBetType,
                                                                      isLive, sboMatchOdd.Odd, ibetStake, true))
                                            {
                                                isProcess = false;
                                                return(true);
                                            }
                                            else
                                            {
                                                Logger.Info("DAT NGUOC THAT BAI, KHOI DONG LAI IBET!!!");
                                                IbetEngine.BetAgainstTransactions.Add(new BetAgainstTransaction()
                                                {
                                                    BetType    = GetAgainstBetType(ibetBetType),
                                                    IsLive     = isLive,
                                                    MatchOdd   = ibetMatchOdd,
                                                    OddCompare = sboMatchOdd.Odd,
                                                    Stake      = ibetStake,
                                                    HomeScore  = ibetPrepareBet.HomeScore,
                                                    AwayScore  = ibetPrepareBet.AwayScore
                                                });

                                                Task.Run(() =>
                                                {
                                                    Logger.Info("CALL KHOI DONG LAI IBET!!!");
                                                    IbetEngine.UpdateException(IbetEngine, eExceptionType.LoginFail);
                                                });
                                            }
                                        }
                                        else
                                        {
                                            isProcess = false;
                                            return(true);
                                        }

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

                                LastBetTime = DateTime.Now;

                                Task.Run(
                                    () =>
                                    UpdateBetPool(ibetPrepareBet.MatchOdd.ServerType,
                                                  ibetPrepareBet.MatchOdd.MatchID, IbetBetPool,
                                                  ibetStake));
                                return(true);
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(ibetConfirmMsg))
                                {
                                    string bpValue = GetBpMatchIbet(ibetConfirmMsg);
                                    Logger.Info("GOI COMPARE LAI LAN 2, bp_match: " + bpValue);
                                    return(ProcessPrepareBet(ibetMatchOdd, ibetBetType, sboMatchOdd, sboBetType,
                                                             isLive,
                                                             serverScan, true, bpValue, sboPrepareBet));
                                }
                            }

                            FireLogScan(ibetMatchOdd, sboMatchOdd, serverScan);
                        }
                    }
                    else
                    {
                        FireLogScan(ibetMatchOdd, sboMatchOdd, serverScan);
                    }
                }
                else
                {
                    FireLogScan(ibetMatchOdd, sboMatchOdd, serverScan);
                }
                return(false);
            }
            catch (Exception ex)
            {
                Logger.Error(ProcessorName, ex);
                return(false);
            }
            finally
            {
                //LastProcessPrepare = DateTime.Now;
                isProcess = false;
            }
        }
Ejemplo n.º 27
0
 private PrepareBetDTO CallPrepareIbet(MatchOddDTO matchOdd, eBetType betType, bool isLive, float oddDef)
 {
     return(IbetEngine.PrepareBet(matchOdd, betType, isLive, oddDef, true));
 }
Ejemplo n.º 28
0
 private PrepareBetDTO CallPrepareIbetAgain(MatchOddDTO matchOdd, eBetType betType, bool isLive, float oddDef, string bpMatch)
 {
     return(IbetEngine.PrepareBet(matchOdd, betType, isLive, oddDef, bpMatch));
 }