Exemple #1
0
        private void ReStartSbo(object obj)
        {
            SboEngine s = obj as SboEngine;

            Logger.Info("TAM DUNG SBO SCAN<<<<<<<<<<<<<<<<<<");
            s.OnExceptionEvent        -= OnExceptionEvent;
            s.UpdateLiveDataChange    -= sbobetUpdateChange_Event;
            s.UpdateNonLiveDataChange -= sbobetUpdateChange_Event;
            s.LogOff();

            if (s.ReLogin())
            {
                s.UpdateLiveDataChange    += sbobetUpdateChange_Event;
                s.UpdateNonLiveDataChange += sbobetUpdateChange_Event;
                s.OnExceptionEvent        += OnExceptionEvent;
                s.StartScanDriver(ScanType);

                switch (ScanType)
                {
                case eScanType.Live:
                    s.StartUpdateLiveDriver();
                    break;

                case eScanType.NonLive:
                    s.StartUpdateNonLiveDriver();
                    break;

                case eScanType.All:
                    s.StartUpdateLiveDriver();
                    s.StartUpdateNonLiveDriver();
                    break;
                }
            }
        }
Exemple #2
0
 public IbetSboBrokerHigher()
 {
     SboEn      = new SboEngine();
     SboEnScan  = new SboEngine();
     IbetEn     = new IbetSubBrokerEngine();
     IbetEnScan = new IbetSubBrokerEngine();
 }
Exemple #3
0
        public void StartSbo()
        {
            int sboCount = DataContainer.SboScanAccounts.Count;

            foreach (var sboAcc in DataContainer.SboScanAccounts)
            {
                Random r   = new Random();
                string url = DataContainer.SboScanServers[r.Next(DataContainer.SboScanServers.Count())];

                SboEngine sbo1 = new SboEngine();
                //sbo1.IpFake = IpHelper.GetRandomIp();

                sbo1.TryLoginScan(url, sboAcc.Username, sboAcc.Password);
                if (sbo1.AccountStatus == eAccountStatus.Online)
                {
                    sbo1.UpdateLiveDataChange += sbobetUpdateChange_Event;
                    sbo1.OnExceptionEvent     += OnExceptionEvent;
                    sbo1.StartScanDriver(eScanType.Live);
                    SboScanEngines.Add(sbo1);
                }
            }
            var timeSboLiveSleep = TimeSboLiveScan / sboCount;
            int oType            = 0;

            foreach (var sboScanEngine in SboScanEngines)
            {
                sboScanEngine.TypeGetScan = oType;
                sboScanEngine.StartUpdateLiveDriver();
                Thread.Sleep(timeSboLiveSleep);

                oType = oType == 0 ? 1 : 0;
            }

            Logger.Info("START SBO SCAN THANH CONG>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        }
Exemple #4
0
        private SboEngine InitLoginSbo(string domain, string username, string pass, object ipFake, int rate)
        {
            UpdateLogText(string.Format("Bắt đầu đăng nhập tài khoản SBO [{0}]......", username), eLogTextType.Warning);

            SboEngine sboEngine = new SboEngine();

            if (ipFake != null)
            {
                if (!string.IsNullOrEmpty(ipFake.ToString()))
                {
                    sboEngine.IpFake = ipFake.ToString();
                }
            }

            if (sboEngine.Login(domain, username, pass))
            {
                sboEngine.EngineId     = Guid.NewGuid().ToString();
                sboEngine.ExchangeRate = rate * 10;
                sboEngine.StartScanEngine(eScanType.Live);
                UpdateLogText(string.Format("Đăng nhập [{0}] thành công! Số dư khả dụng là {1}", username, sboEngine.UpdateAvailabeCredit()));
                return(sboEngine);
            }
            else
            {
                UpdateLogText(string.Format("Đăng nhập sbo [{0}] không thành công!", username), eLogTextType.Error);
                return(null);
            }
        }
        private void OnBtnRefeshClick(object sender, EventArgs e)
        {
            var btn = (PictureBox)sender;

            this.Invoke((MethodInvoker) delegate()
            {
                if (btn.Name == "btnRefeshIbet")
                {
                    var ibetProfile         = IbetEngine.GetAccountProfile();
                    lblIbetStatus.Text      = IbetEngine.AccountStatus.ToString();
                    lblIbetRealDomain.Text  = ibetProfile.UrlHost;
                    lblIbetCreadit.Text     = ibetProfile.AvailabeCredit.ToString();
                    lblIbetCashBalance.Text = ibetProfile.CashBalance.ToString();
                    lblPingSbo.Text         = "SKIPPED";
                    lblPingIbet.Text        = "SKIPPED";
                }
                else
                {
                    var sboProfile         = SboEngine.GetAccountProfile();
                    lblSboStatus.Text      = SboEngine.AccountStatus.ToString();
                    lblSboRealDomain.Text  = sboProfile.UrlHost;
                    lblSboCreadit.Text     = sboProfile.AvailabeCredit.ToString();
                    lblSboCashBalance.Text = sboProfile.CashBalance.ToString();
                    lblPingSbo.Text        = "SKIPPED";
                    lblPingIbet.Text       = "SKIPPED";
                }
            });
        }
 private void btnHistory_Click(object sender, EventArgs e)
 {
     this.Invoke((MethodInvoker) delegate()
     {
         var ibetBetList = IbetEngine.GetStatement(dateHistoryPick.Value);
         var sboBetList  = SboEngine.GetStatement(dateHistoryPick.Value);
         webIbetStatement.DocumentText = ibetBetList;
         webSboStatement.DocumentText  = RemoveHTMLTagsText(sboBetList, "<head>");
     });
 }
Exemple #7
0
        public void StartLoginSbo()
        {
            int i           = 0;
            int countServer = DataContainer.SboServers.Count();
            int countIp     = 0;

            if (_useRealIp)
            {
                countIp = ScanData.IpAddress.Count;
            }

            Parallel.ForEach(ScanData.ScanAccount.SboAccounts, sboAcc =>
            {
                try
                {
                    Random r = new Random();
                    var url  = DataContainer.SboServers[r.Next(countServer)];

                    SboEngine sbo1 = new SboEngine();

                    if (_useRealIp)
                    {
                        var ip             = ScanData.IpAddress[r.Next(countIp)];
                        sbo1.RealIpAddress = ip;
                    }

                    if (ScanData.HasFakeIpSbo)
                    {
                        sbo1.IpFake = IpHelper.GetRandomIp();
                    }

                    sbo1.OnFakeRequest += OnFakeRequest;

                    sbo1.TryLogin(url, sboAcc.Username, sboAcc.Password);

                    if (sbo1.AccountStatus == eAccountStatus.Online)
                    {
                        i++;
                        SboScanEngines.Add(sbo1);
                        Logger.Info("SBO COUNT = " + i);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }
            });

            //foreach (var sboAcc in ScanData.ScanAccount.SboAccounts)
            //{

            //}

            Logger.Info("LOGIN SBO SCAN THANH CONG @@@@@@@@@@@@@@@@@@@ TONG ACC: " + SboScanEngines.Count);
        }
        private bool TryLoginSbo(string url, string un, string pass)
        {
            SboEngine.IpFake = txtIpFake.Text;
            if (SboEngine.Login(url, un, pass))
            {
                return(true);
            }

            Task.Run(() => SboEngine.TryFakeRequest(url));

            return(SboEngine.Login(url, un, pass));
        }
Exemple #9
0
        public void StartSbo()
        {
            int sboCount = DataContainer.SboScanAccounts.Count;

            foreach (var sboAcc in DataContainer.SboScanAccounts)
            {
                Random r   = new Random();
                string url = DataContainer.SboScanServers[r.Next(DataContainer.SboScanServers.Count())];

                SboEngine sbo1 = new SboEngine();
                //sbo1.IpFake = IpHelper.GetRandomIp();
                sbo1.OnFakeRequest += OnFakeRequest;

                sbo1.TryLoginScan(url, sboAcc.Username, sboAcc.Password);
                if (sbo1.AccountStatus == eAccountStatus.Online)
                {
                    sbo1.UpdateLiveDataChange    += sbobetUpdateChange_Event;
                    sbo1.UpdateNonLiveDataChange += sbobetUpdateChange_Event;
                    sbo1.OnExceptionEvent        += OnExceptionEvent;
                    sbo1.StartScanDriver(ScanType);
                    SboScanEngines.Add(sbo1);
                }
            }

            switch (ScanType)
            {
            case eScanType.Live:
                StartUpdateSboLiveDriver();
                break;

            case eScanType.NonLive:
                StartUpdateSboNonLiveDriver();
                break;

            case eScanType.All:
                StartUpdateSboLiveDriver();
                StartUpdateSboNonLiveDriver();
                break;
            }
            //var timeSboLiveSleep = SystemConfig.TIME_GET_UPDATE_LIVE_SBOBET / sboCount;
            //int oType = 0;
            //foreach (var sboScanEngine in SboScanEngines)
            //{
            //    sboScanEngine.TypeGetScan = oType;
            //    sboScanEngine.StartUpdateLiveDriver();
            //    //Thread.Sleep(1000);
            //    Thread.Sleep(timeSboLiveSleep);
            //    oType = oType == 0 ? 1 : 0;
            //}

            Logger.Info("START SBO SCAN THANH CONG>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        }
Exemple #10
0
        private void ReStartSboBet(object obj)
        {
            SboEngine s = obj as SboEngine;

            UpdateLogText(string.Format("Mất kết nối tài khoản [{0}] đang thực hiện kết nối lại....", s.UserName), eLogTextType.Error);
            s.OnExceptionEvent -= SboBetOnOnExceptionEvent;
            s.LogOff();

            if (s.ReLogin())
            {
                s.OnExceptionEvent += SboBetOnOnExceptionEvent;
                s.StartBetRunEngine(scanType, true);
                UpdateLogText(string.Format("Kết nối tài khoản [{0}] thành công!", s.UserName), eLogTextType.Warning);
            }
        }
Exemple #11
0
        public void StartSbo(string url)
        {
            var sboScanAccs = System.IO.File.ReadAllLines(@"Config/SboScanAccs.txt");
            Dictionary <string, string> sboAccdics = new Dictionary <string, string>();

            foreach (var sboScanAcc in sboScanAccs)
            {
                var leagues = sboScanAcc.Split(new[] { "<>" }, StringSplitOptions.None);
                sboAccdics[leagues[0]] = leagues[1];
            }

            //sboAccdics.AsParallel().ForAll(item =>
            //{

            //});

            foreach (var sboAcc in sboAccdics)
            {
                SboEngine sbo1 = new SboEngine();
                sbo1.OnFakeRequest += OnFakeRequest;

                while (sbo1.AccountStatus == eAccountStatus.Offline)
                {
                    sbo1.TryLogin(url, sboAcc.Key, sboAcc.Value);
                }

                sbo1.UpdateLiveDataChange += sbobetUpdateChange_Event;
                sbo1.OnExceptionEvent     += OnExceptionEvent;
                sbo1.StartScanLiveDriver();
                SboScanEngines.Add(sbo1);
            }

            var timeSboLiveSleep = SystemConfig.TIME_GET_UPDATE_LIVE_SBOBET / sboAccdics.Count;
            int oType            = 0;

            foreach (var sboScanEngine in SboScanEngines)
            {
                sboScanEngine.TypeGetScan = oType;
                sboScanEngine.StartUpdateLiveDriver();
                //Thread.Sleep(1000);
                Thread.Sleep(timeSboLiveSleep);

                oType = oType == 0 ? 1 : 0;
            }

            Logger.Info("START SBO SCAN THANH CONG>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        }
        private void ReStartSbo(object obj)
        {
            SboEngine s = obj as SboEngine;

            Logger.Info("TAM DUNG SBO SCAN<<<<<<<<<<<<<<<<<<");
            s.OnExceptionEvent     -= OnExceptionEvent;
            s.UpdateLiveDataChange -= sbobetUpdateChange_Event;
            s.LogOff();

            if (s.ReLogin())
            {
                s.UpdateLiveDataChange += sbobetUpdateChange_Event;
                s.OnExceptionEvent     += OnExceptionEvent;
                s.StartScanLiveDriver();
                s.StartUpdateLiveDriver();
            }
        }
Exemple #13
0
        private void ReStartSbo(object obj)
        {
            SboEngine s = obj as SboEngine;

            s.OnExceptionEvent        -= sboScan_OnExceptionEvent;
            s.UpdateLiveDataChange    -= sboScan_UpdateLiveDataChange;
            s.UpdateNonLiveDataChange -= sboScan_UpdateLiveDataChange;
            s.LogOff();

            if (s.ReLogin())
            {
                s.UpdateLiveDataChange    += sboScan_UpdateLiveDataChange;
                s.UpdateNonLiveDataChange += sboScan_UpdateLiveDataChange;
                s.OnExceptionEvent        += sboScan_OnExceptionEvent;
                s.StartBetRunEngine(scanType, false);
            }
        }
        public static void Initialize()
        {
            IbetEngineObj       = new IbetEngine();
            SboEngineObj        = new SboEngine();
            IbetSboProcessorObj = new IbetSboProcessor();

            //DataContainer.IbetAccounts = new List<AccountDTO>()
            //{
            //    new AccountDTO() {Username = "******", Password = "******"}
            //};

            //DataContainer.SboAccounts = new List<AccountDTO>()
            //{
            //    new AccountDTO() {Username = "******", Password = "******"}
            //};

            //DataContainer.CookieContainer = new CookieContainer();
        }
Exemple #15
0
        private void SboScan_OnExceptionEvent(ExceptionMessage logMsg, eServerType serverType, object obj)
        {
            SboEngine engine = obj as SboEngine;

            engine.OnExceptionEvent -= SboScan_OnExceptionEvent;
            engine.LogOff();

            while (engine.AccountStatus == eAccountStatus.Offline)
            {
                if (engine.ReLogin())
                {
                    engine.StartScanEngine(eScanType.Live);
                    engine.OnExceptionEvent += SboScan_OnExceptionEvent;
                    break;
                }

                Thread.Sleep(15000);
            }
        }
        private void Init(IbetSboDriver driver, ServerCallback serverCallback)
        {
            if (!this.IsHandleCreated)
            {
                this.CreateHandle();
            }

            ID = Guid.NewGuid();
            SetDefaultStyle();
            Processor = new IbetSboProcessor(driver, serverCallback);
            //DataContainer.TransactionProcess.Add(Processor.TransactionQueue);
            IbetEngine = new IbetEngine();
            IbetEngine.RealIpAddress = IpReal;
            SboEngine = new SboEngine();
            SboEngine.RealIpAddress = IpReal;
            IbetEngine.TabCode      = Code;
            SboEngine.TabCode       = Code;

            cboIBetDomain.DataSource      = DataContainer.IbetServers;
            cboSboDomain.DataSource       = DataContainer.SboServers;
            dgvLeaguesSetting.DataSource  = DataContainer.LeaguesSettings;
            cboMarket.SelectedIndex       = 0;
            cboCompareValue.SelectedIndex = 0;
            cboMinOddDef.SelectedIndex    = 1;

            BindConvertStakeInfo();

            lblSboStatus.TextChanged  += OnStatusTextChanged;
            lblIbetStatus.TextChanged += OnStatusTextChanged;

            IbetEngine.OnLogOffEvent += OnLogOffEvent;
            SboEngine.OnLogOffEvent  += OnLogOffEvent;

            Processor.OnProcessStateChange     += ProcessorOnOnProcessStateChange;
            Processor.OnPingEvent              += ProcessorOnOnPingEvent;
            webIbetStatement.DocumentCompleted += OnIbetStatementDocumentCompleted;
            webSboStatement.DocumentCompleted  += OnSboStatementDocumentCompleted;

            timerCheck          = new System.Timers.Timer(60000 * 2);
            timerCheck.Elapsed += CheckInfoStatus;
        }
        private void ProcessorOnOnProcessStateChange(eServiceStatus status, string processState)
        {
            TabControl tabMain    = MainIbetSboForm.Controls.Find("tabMain", true).FirstOrDefault() as TabControl;
            TabPage    currentTab = tabMain.TabPages[ID.ToString()];

            this.Invoke((MethodInvoker) delegate()
            {
                currentTab.Text = processState;
                if (processState != "reconnecting...")
                {
                    var sboProfile         = SboEngine.GetAccountProfile();
                    lblSboStatus.Text      = SboEngine.AccountStatus.ToString();
                    lblSboRealDomain.Text  = sboProfile.UrlHost;
                    lblSboCreadit.Text     = sboProfile.AvailabeCredit.ToString();
                    lblSboCashBalance.Text = sboProfile.CashBalance.ToString();

                    var ibetProfile         = IbetEngine.GetAccountProfile();
                    lblIbetStatus.Text      = IbetEngine.AccountStatus.ToString();
                    lblIbetRealDomain.Text  = ibetProfile.UrlHost;
                    lblIbetCreadit.Text     = ibetProfile.AvailabeCredit.ToString();
                    lblIbetCashBalance.Text = ibetProfile.CashBalance.ToString();
                }
            });
        }
        public Guid InitProcessor(IbetEngine ibetEngine, SboEngine sboEngine, ProcessorConfigInfoDTO secondAccountDto)
        {
            try
            {
                Guid       ni        = Guid.NewGuid();
                IProcessor processor = new IbetSboProcessor();
                processor.IbetEngine = ibetEngine;
                processor.SboEngine  = sboEngine;

                //processor.IbetEngine.InitEngine();
                //processor.SboEngine.InitEngine();
                //processor.Initialize();
                //processor.Start();
                ProcessorContainer.Add(ni, processor);
                return(ni);
            }
            finally
            {
                //RemoveTab(firstAccountDto.GuidID);
                //RemoveTab(secondAccountDto.GuidID);
            }

            //Object.ReferenceEquals(n1.GetType(), n2.GetType()));
        }
        public void StartProcessor()
        {
            if (!rdoMax.Checked && string.IsNullOrEmpty(txtBetStake.Text))
            {
                return;
            }

            SetProcessingStyle();

            if (IbetEngine.AccountStatus == eAccountStatus.Offline)
            {
                LoginIbet();
            }

            if (SboEngine.AccountStatus == eAccountStatus.Offline)
            {
                LoginSbo();
            }

            TabControl tabMain    = MainIbetSboForm.Controls.Find("tabMain", true).FirstOrDefault() as TabControl;
            TabPage    currentTab = tabMain.TabPages[ID.ToString()];

            if (SboEngine.AccountStatus == eAccountStatus.Online &&
                IbetEngine.AccountStatus == eAccountStatus.Online)
            {
                this.Invoke((MethodInvoker) delegate()
                {
                    scanType                      = (eScanType)cboMarket.SelectedIndex;
                    Processor.IbetEngine          = IbetEngine;
                    Processor.SboEngine           = SboEngine;
                    Processor.ProcessorConfigInfo = ProcessBindData();

                    if (Processor.Start(scanType) == eServiceStatus.Started)
                    {
                        //currentTab.Text = Processor.ProcessorName;

                        var sboProfile         = SboEngine.GetAccountProfile();
                        lblSboStatus.Text      = SboEngine.AccountStatus.ToString();
                        lblSboRealDomain.Text  = sboProfile.UrlHost;
                        lblSboCreadit.Text     = sboProfile.AvailabeCredit.ToString();
                        lblSboCashBalance.Text = sboProfile.CashBalance.ToString();

                        var ibetProfile         = IbetEngine.GetAccountProfile();
                        lblIbetStatus.Text      = IbetEngine.AccountStatus.ToString();
                        lblIbetRealDomain.Text  = ibetProfile.UrlHost;
                        lblIbetCreadit.Text     = ibetProfile.AvailabeCredit.ToString();
                        lblIbetCashBalance.Text = ibetProfile.CashBalance.ToString();
                        StartCheckStatus();
                        SetStartClickStyle();

                        ////TODO:QUOCLE: REM TO TEST
                        if (_driver.Status != eServiceStatus.Started && DataContainer.HasLocalScan)
                        {
                            Thread thread = new Thread(StartDriver);
                            thread.SetApartmentState(ApartmentState.STA);
                            thread.Start();
                        }

                        if (OnAccountSatus != null)
                        {
                            OnAccountSatus(Code, true);
                        }
                    }
                    else
                    {
                        //Quang msgbox start ko thanh cong
                        if (Processor.StartFailCount >= 3)
                        {
                            currentTab.Text = "FAIL (Force STOP)";
                            StopProcessor();
                        }
                        else
                        {
                            currentTab.Text = "FAIL";
                            SetDefaultStyle();
                        }
                    }
                });

                //Processor.OnLogScanEvent += dashboard.OnLogScanEvent;
                //Processor.OnProcessExceptionEvent += dashboard.OnProcessorExceptionEvent;
                //Processor.OnUpdateCredit += dashboard.OnUpdateCredit;
            }
            else
            {
                SetDefaultStyle();
            }
        }
Exemple #20
0
        private void btnLoginGroup_Click(object sender, EventArgs e)
        {
            var          button  = sender as PictureBox;
            DataGridView dgvView = button.Name == "btnLoginBuyGroup" ? dgvUserBuy : dgvUserSell;

            bool hasFakeIp;

            if (button.Name == "btnLoginBuyGroup")
            {
                hasFakeIp = ckBuyAccRandomIp.Checked;
            }
            else
            {
                hasFakeIp = ckSellAccRandomIp.Checked;
            }

            //var aaa = dgvUserBuy.DataSource;
            for (int rows = 0; rows < dgvView.Rows.Count; rows++)
            {
                var user   = dgvView.Rows[rows].Cells[0].Value;
                var pass   = dgvView.Rows[rows].Cells[1].Value;
                var status = dgvView.Rows[rows].Cells[2].Value;

                if (user == null && pass == null)
                {
                    continue;
                }

                if (user == null || pass == null)
                {
                    UpdateLogText(string.Format("Thông tin tài khoản {0}/{1} không đúng!", user, pass), eLogTextType.Error);
                    continue;
                }

                if (status == null || status.ToString() == "Login")
                {
                    UpdateLogText(string.Format("Bắt đầu đăng nhập tài khoản [{0}]......", user),
                                  eLogTextType.Warning);
                    SboEngine sbo = new SboEngine();
                    if (hasFakeIp)
                    {
                        sbo.IpFake = IpHelper.GetRandomIp();
                    }

                    Random r   = new Random();
                    var    url = DataContainer.SboScanServers[r.Next(DataContainer.SboScanServers.Count())];
                    sbo.Login(url, user.ToString(), pass.ToString());
                    if (sbo.AccountStatus == eAccountStatus.Online)
                    {
                        sbo.OnExceptionEvent += SboBetOnOnExceptionEvent;
                        sbo.StartBetRunEngine(scanType, true);
                        UpdateLogText(string.Format("Đăng nhập [{0}] thành công! Số dư khả dụng là {1}", user,
                                                    sbo.UpdateAvailabeCredit()));
                        if (dgvView.Name == "dgvUserBuy")
                        {
                            buyAccEngines.Add(sbo);
                        }
                        else
                        {
                            sellAccEngines.Add(sbo);
                        }

                        accSboBet.Add(user.ToString());

                        dgvView.Rows[rows].Cells[0]                 = new DataGridViewLinkCell();
                        dgvView.Rows[rows].Cells[0].Value           = user.ToString();
                        dgvView.Rows[rows].Cells[2].Style.BackColor = Color.SteelBlue;
                        dgvView.Rows[rows].Cells[2].Value           = "Logout";

                        //dgvView.Invoke(new MethodInvoker(
                        //    delegate
                        //    {

                        //    }));

                        //this.Invoke((MethodInvoker) (() =>
                        //{
                        //    dgvView.Rows[rows].Cells[0] = new DataGridViewLinkCell();
                        //    dgvView.Rows[rows].Cells[0].Value = user.ToString();
                        //    dgvView.Rows[rows].Cells[2].Style.BackColor = Color.SteelBlue;
                        //    dgvView.Rows[rows].Cells[2].Value = "Logout";
                        //}));
                    }
                    else
                    {
                        UpdateLogText(string.Format("Đăng nhập [{0}] thất bai.", user), eLogTextType.Error);
                    }
                }
            }
        }
Exemple #21
0
        private void dgvAccEngine_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            DataGridView    dgv         = (DataGridView)sender;
            DataGridViewRow selectedRow = dgv.Rows[e.RowIndex];
            var             user        = selectedRow.Cells[0].Value;
            var             pass        = selectedRow.Cells[1].Value;
            var             status      = selectedRow.Cells[2].Value;

            if (status == null)
            {
                selectedRow.Cells[2].Style.BackColor = Color.Red;
                selectedRow.Cells[2].Value           = "Login";
                return;
            }

            if (e.ColumnIndex == dgv.Columns[0].Index && status.ToString() == "Logout")
            {
                SboEngine s;
                if (dgv.Name == "dgvUserBuy")
                {
                    s = buyAccEngines.First(se => se.UserName == user.ToString());
                }
                else
                {
                    s = sellAccEngines.First(se => se.UserName == user.ToString());
                }

                var        betlist = s.GetBetList();
                frmBetList f       = new frmBetList(betlist, user.ToString());
                f.Show();
            }

            if (e.ColumnIndex == dgv.Columns[3].Index)
            {
                if (status.ToString() != "Logout")
                {
                    UpdateLogText("Lỗi tài khoản chưa được đăng nhập.", eLogTextType.Error);
                    return;
                }

                SboEngine s;
                if (dgv.Name == "dgvUserBuy")
                {
                    s = buyAccEngines.First(se => se.UserName == user.ToString());
                }
                else
                {
                    s = sellAccEngines.First(se => se.UserName == user.ToString());
                }

                var creadit = s.UpdateAvailabeCredit();
                UpdateLogText(string.Format("Hạn mức khả dụng tài khoản [{0}] là {1}", user, creadit), eLogTextType.Warning);
            }

            if (e.ColumnIndex == dgv.Columns[2].Index && status.ToString() == "Login")
            {
                if (user == null || pass == null)
                {
                    UpdateLogText("Thông tin tài khoản không hợp lệ!", eLogTextType.Error);
                    return;
                }

                if (accSboBet.Exists(s => s == user.ToString()))
                {
                    UpdateLogText("Tài khoản này đã tồn tại trong hệ thống, vui lòng kiểm tra lại!", eLogTextType.Error);
                    return;
                }

                bool hasFakeIp;
                if (dgv.Name == "dgvUserBuy")
                {
                    hasFakeIp = ckBuyAccRandomIp.Checked;
                }
                else
                {
                    hasFakeIp = ckSellAccRandomIp.Checked;
                }

                UpdateLogText(string.Format("Bắt đầu đăng nhập tài khoản [{0}]......", user), eLogTextType.Warning);
                SboEngine sbo = new SboEngine();
                if (hasFakeIp)
                {
                    sbo.IpFake = IpHelper.GetRandomIp();
                }

                Random r   = new Random();
                var    url = DataContainer.SboScanServers[r.Next(DataContainer.SboScanServers.Count())];
                sbo.Login(url, user.ToString(), pass.ToString());
                if (sbo.AccountStatus == eAccountStatus.Online)
                {
                    sbo.OnExceptionEvent += SboBetOnOnExceptionEvent;
                    sbo.StartBetRunEngine(scanType, true);
                    UpdateLogText(string.Format("Đăng nhập [{0}] thành công! Số dư khả dụng là {1}", user, sbo.UpdateAvailabeCredit()));
                    if (dgv.Name == "dgvUserBuy")
                    {
                        buyAccEngines.Add(sbo);
                    }
                    else
                    {
                        sellAccEngines.Add(sbo);
                    }

                    accSboBet.Add(user.ToString());

                    selectedRow.Cells[0]                 = new DataGridViewLinkCell();
                    selectedRow.Cells[0].Value           = user.ToString();
                    selectedRow.Cells[2].Style.BackColor = Color.SteelBlue;
                    selectedRow.Cells[2].Value           = "Logout";
                }
                else
                {
                    UpdateLogText(string.Format("Đăng nhập [{0}] thất bai.", user), eLogTextType.Error);
                }
            }

            if (e.ColumnIndex == dgv.Columns[2].Index && status.ToString() == "Logout")
            {
                SboEngine s;

                if (dgv.Name == "dgvUserBuy")
                {
                    s = buyAccEngines.First(se => se.UserName == user.ToString());
                }
                else
                {
                    s = sellAccEngines.First(se => se.UserName == user.ToString());
                }

                s.LogOff();

                if (s.AccountStatus == eAccountStatus.Offline)
                {
                    accSboBet.RemoveAll(x => x == user.ToString());

                    UpdateLogText(string.Format("Đã đăng xuất tài khoản [{0}]", user), eLogTextType.Warning);

                    if (dgv.Name == "dgvUserBuy")
                    {
                        buyAccEngines.Remove(s);
                    }
                    else
                    {
                        sellAccEngines.Remove(s);
                    }
                    selectedRow.Cells[0]                 = new DataGridViewTextBoxCell();
                    selectedRow.Cells[0].Value           = user.ToString();
                    selectedRow.Cells[2].Style.BackColor = Color.Red;
                    selectedRow.Cells[2].Value           = "Login";
                }
            }
        }
        private void CheckInfoStatus(object sender, ElapsedEventArgs e)
        {
            try
            {
                var ibetProfile = IbetEngine.GetAccountProfile();

                if (ibetProfile.AvailabeCredit == 0)
                {
                    this.StopProcessor();
                    this.SetStartClickStyle();

                    Thread thread = new Thread(() => this.Processor.ReStart());
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();

                    return;
                }
                else
                {
                    this.Invoke((MethodInvoker) delegate
                    {
                        lblIbetStatus.Text      = IbetEngine.AccountStatus.ToString();
                        lblIbetRealDomain.Text  = IbetEngine.Host;
                        lblIbetCreadit.Text     = ibetProfile.AvailabeCredit.ToString();
                        lblIbetCashBalance.Text = ibetProfile.CashBalance.ToString();
                    });
                }
            }
            catch (Exception ex)
            {
                this.StopProcessor();
            }

            try
            {
                var sboProfile = SboEngine.GetAccountProfile();

                if (sboProfile.AvailabeCredit == 0)
                {
                    this.StopProcessor();
                    this.SetStartClickStyle();
                    Thread thread = new Thread(() => this.Processor.ReStart());
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                }
                else
                {
                    this.Invoke((MethodInvoker) delegate
                    {
                        lblSboStatus.Text      = SboEngine.AccountStatus.ToString();
                        lblSboRealDomain.Text  = SboEngine.Host;
                        lblSboCreadit.Text     = sboProfile.AvailabeCredit.ToString();
                        lblSboCashBalance.Text = sboProfile.CashBalance.ToString();
                    });
                }
            }
            catch (Exception ex)
            {
                this.StopProcessor();
            }
        }
 public IbetSboBroker2()
 {
     SboEn  = new SboEngine();
     IbetEn = new IbetSubBrokerEngine();
 }