public void Pause() { try { //_driver.OnSboScanUpdate -= OnSboUpdateScan; IsnEngine.UpdateLiveDataChange -= OnIsnUpdateScan; // tạm đóng // PiSboDriver.OnSboScanUpdate -= PiSboDriver_OnSboScanUpdate; PiEngine.PauseScan(); if (IsnEngine.Status == eServiceStatus.Started) { IsnEngine.PauseScan(); } if (objUpdateCreditTimer != null) { objUpdateCreditTimer.Dispose(); } Status = eServiceStatus.Paused; } catch (Exception ex) { Logger.Error("Dispose: " + ex.Message); } }
public PiSboProcessor(ServerCallback serverCallback) { StartFailCount = 0; PiEngine = new PiEngine(); SboEngine = new SboEngine(); }
private void WaitUpdateCreditCallback(object obj) { try { PiEngine.UpdateAvailabeCredit(); IsnEngine.UpdateAvailabeCredit(); } catch (Exception ex) { Logger.Error(ex); } }
public void Dispose() { Pause(); SboEngine.OnExceptionEvent -= OnExceptionEvent; PiEngine.OnExceptionEvent -= OnExceptionEvent; if (objUpdateCreditTimer != null) { objUpdateCreditTimer.Dispose(); } PiEngine.LogOff(); SboEngine.LogOff(); Status = eServiceStatus.Stopped; StartFailCount = 0; }
public void Initialize() { if (IsnEngine.CheckLogin()) { if (IsnEngine.Status == eServiceStatus.Unknown) { IsnBetPool = new Dictionary <string, int>(); IsnEngine.OnExceptionEvent += OnExceptionEvent; IsnEngine.InitEngine(); } PiBetPool = new Dictionary <string, int>(); PiEngine.InitEngine(); Status = eServiceStatus.Initialized; } }
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 { IsnEngine.UpdateAvailabeCredit(); } }
public bool ReConnectPina() { try { if (PiEngine.TryLogin()) { Logger.Info("Ket noi Pina 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 (PiEngine.AccountStatus == eAccountStatus.Online) { PiEngine.LogOff(); } Thread.Sleep(30000); } return(false); } catch (Exception ex) { Logger.Error("ReConnectPina: " + ex.Message); return(false); } }
public eServiceStatus ReStart() { try { Logger.Info("KHOI DONG LAI HE THONG!!!!!!!!!!!!!!!!!!!!!!"); this.Pause(); IsnEngine.LogOff(); PiEngine.LogOff(); // IsnEngine.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() { //_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; }
private void ReStartFromPina() { try { if (!IsReConnect) { IsReConnect = true; this.Pause(); FireProcessStateChange(eServiceStatus.Paused, "reconnecting..."); Logger.Info("TAM DUNG HE THONG, KET NOI LAI Pina!!!!!!!!!"); PiEngine.LogOff(); ReConnectPina(); IsReConnect = false; } } catch (Exception ex) { Logger.Error("ReStartFromPina: " + ex.Message); } }
public void Dispose() { try { Pause(); IsnEngine.OnExceptionEvent -= OnExceptionEvent; PiEngine.OnExceptionEvent -= OnExceptionEvent; if (objUpdateCreditTimer != null) { objUpdateCreditTimer.Dispose(); } PiEngine.LogOff(); IsnEngine.LogOff(); Status = eServiceStatus.Stopped; StartFailCount = 0; } catch (Exception ex) { Logger.Error("Dispose: " + ex.Message); } }
public void Train(Microsoft.Extensions.Logging.ILogger logger) { try { Model = ProcessFirstStep((pipeline, dataPath) => { pipeline.Add(new TextLoader(this.LearningDataPath).CreateFrom <DataModel>()); }, this.PiEngine, this.LearningDataPath, logger) .ProcessExceptionChecking() .ProcessNextStep((pipeline) => { pipeline.Add(new TextFeaturizer("Features", "sentimentText")); }, LearningStage.FeatureEngineering) .ProcessExceptionChecking() .ProcessNextStep((pipeline) => { pipeline.Add(new FastTreeBinaryClassifier() { NumLeaves = Config.TBC.NumLeaves, NumTrees = Config.TBC.NumTrees, MinDocumentsInLeafs = Config.TBC.MinDocumentsInLeafs }); }, LearningStage.LearningAlg) .ProcessExceptionChecking() .ReturnTrained(() => { return(PiEngine.Train <DataModel, PredictedDataModel>()); }) .ProcessExceptionChecking() .Item1; } catch (Exception) { throw new NullReferenceException("Logger needed"); } }
public bool ProcessPrepareBet(MatchPiDTO piMatch, OddDTO piOdd, eBetType piBetType, MatchIsnDTO isnMatch, OddDTO isnOdd, eBetType isnBetType, bool isLive, eServerScan serverScan = eServerScan.Local) { if (isProcess) { return(false); } //what? //string oddCheck = sboMatchOdd.OddID + sboMatchOdd.HomeOdd + sboMatchOdd.AwayOdd + piOdd.HomeOdd + // piOdd.AwayOdd; //if (oddCheck.Equals(OddCheck)) //{ // return false; //} //OddCheck = oddCheck; try { isProcess = true; // wwhat? //sboMatchOdd.OldOdd = piBetType == eBetType.Home ? sboMatchOdd.HomeOdd : sboMatchOdd.AwayOdd; // Logger.Debug(""); // Logger.Debug("Before call PREPARE ISN " + piMatch.HomeTeamName + "-" + piMatch.AwayTeamName + " " + piOdd.HomeOdd + "_" + piOdd.AwayOdd + " " + piBetType.ToString()); Stopwatch a = new Stopwatch(); a.Start(); Task <int> taskMaxBet = Task.Run(() => IsnEngine.GetMax((isnBetType == eBetType.Home ? isnOdd.selectionIdHome : isnOdd.selectionIdAway))); var prepareBetIsn = Task.Run(() => IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, isLive, isnOdd.Odd)); var preparePina = PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd); if (preparePina == null || prepareBetIsn.Result == null) { FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan); return(false); } a.Stop(); Logger.Info("Total time prepare: " + a.ElapsedMilliseconds + " ms"); // Debug.WriteLine("Thoi gian prepare: " + a.ElapsedMilliseconds); bool betAny; // float piOddValue = piBetType == eBetType.Home ? piOdd.HomeOdd : piOdd.AwayOdd; //bool isGood = IsGoodOddPair(piOddValue, prepareBetIsn.NewOdd, CompareValueDifferent, out betAny); bool isGood = IsGoodOddPair(preparePina.NewOdd, prepareBetIsn.Result.NewOdd, CompareValueDifferent, out betAny); // Logger.Debug("After isGood=" + isGood.ToString() + " " + piOddValue + "_" + prepareBetIsn.NewOdd + " " + piBetType.ToString()); if (isGood) { int piStake; int isnStake; if (CaculateStake(BetStakeType, piMatch.MatchID, 150, (int)((PendingTicket)preparePina.PendingTicket).TicketItem.MaxRiskAmount, isnMatch.MatchID, 4, taskMaxBet, out piStake, out isnStake)) // if (true) { a.Restart(); Logger.Info("Total time prepare: " + a.ElapsedMilliseconds + " ms"); var taskpiConfirmBet = Task.Run(() => PiEngine.ConfirmBet((PendingTicket)preparePina.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.Success)); var betisnOk = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.Success); if (taskpiConfirmBet.Result == true && betisnOk == true) { a.Stop(); Logger.Info("Total time prepare: " + a.ElapsedMilliseconds + " ms"); Task.Run( () => { UpdateBetPool( eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake); UpdateBetPool( eServerType.Pina, piMatch.MatchID, PiBetPool, piStake); }); Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); CountBet++; LastBetTime = DateTime.Now; return(true); } else if (taskpiConfirmBet.Result == false && betisnOk == false) { return(false); } else if (taskpiConfirmBet.Result == true) { Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake)); bool ok = false; for (int i = 0; i < IsnEngine.Rebet; i++) { var prepare = IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, true, isnOdd.Odd); if (prepare != null) { ok = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.MissOddIsn, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake)); return(true); } } Thread.Sleep(500); } if (!ok) // ReBet pina { var betTypeAgaint = GetAgainstBetType(piBetType); var prepare = PiEngine.PrepareBet(piMatch, piOdd, betTypeAgaint, piOdd.Odd); if (prepare != null) { ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake)); return(true); } } } IsnEngine.FireLogBet(isnMatch, isnOdd, isnBetType, isnStake, eBetStatusType.Fail, eServerScan.Local); } else if (betisnOk == true) { Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake)); bool ok = false; for (int i = 0; i < PiEngine.Rebet; i++) { var prepare = PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd); if (prepare != null) { ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.MissOddPina, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake)); return(true); } } Thread.Sleep(500); } if (!ok)// Rebet Isn { var betTypeAgaint = GetAgainstBetType(isnBetType); var prepare = IsnEngine.PrepareBet(isnMatch, isnOdd, betTypeAgaint, true, isnOdd.Odd); if (prepare != null) { ok = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, betTypeAgaint, eBetStatusType.BetAgainIsn, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake)); return(true); } } } PiEngine.FireLogBet(piMatch, piOdd, piBetType, piStake, eBetStatusType.Fail, eServerScan.Local); } return(false); } // tạm đóng FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan); } //else //{ // // tạm đóng // FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan); //} return(false); } catch (Exception ex) { Logger.Error(ProcessorName, ex); return(false); } finally { isProcess = false; } }
/// <summary> /// Mr Kiệt version /// </summary> /// <param name="piMatch"></param> /// <param name="piOdd"></param> /// <param name="piBetType"></param> /// <param name="isnMatch"></param> /// <param name="isnOdd"></param> /// <param name="isnBetType"></param> /// <param name="isLive"></param> /// <param name="serverScan"></param> /// <returns></returns> public bool ProcessPrepareBet(MatchPiDTO piMatch, OddDTO piOdd, eBetType piBetType, MatchIsnDTO isnMatch, OddDTO isnOdd, eBetType isnBetType, bool isLive, eServerScan serverScan = eServerScan.Local) { if (isProcess) { return(false); } try { isProcess = true; Task <int> taskMaxBet = Task.Run(() => IsnEngine.GetMax((isnBetType == eBetType.Home ? isnOdd.selectionIdHome : isnOdd.selectionIdAway))); var taskpreparePina = Task.Run(() => PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd)); var prepareBetIsn = IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, isLive, isnOdd.Odd); if (taskpreparePina.Result == null || prepareBetIsn == null) { FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan); return(false); } bool betAny; float piOddValue = piBetType == eBetType.Home ? piOdd.HomeOdd : piOdd.AwayOdd; bool isGood = IsGoodOddPair(piOddValue, prepareBetIsn.NewOdd, CompareValueDifferent, out betAny); if (isGood) { int piStake; int isnStake; if (CaculateStake(BetStakeType, piMatch.MatchID, 150, (int)((PendingTicket)taskpreparePina.Result.PendingTicket).TicketItem.MaxRiskAmount, isnMatch.MatchID, 4, taskMaxBet, out piStake, out isnStake)) { // bet kèo dưới trước #region [Bet pina trước nếu là kèo dưới] if (((piOdd.OddType == eOddType.HCP || piOdd.OddType == eOddType.HalfHCP) && piOdd.Odd >= 0) ||// odd dương là được chấp ((piOdd.OddType == eOddType.OU || piOdd.OddType == eOddType.HalfOU) && piBetType == eBetType.Away)) // dựa vào pina bet type để biết là Under { var piConfirmBet = PiEngine.ConfirmBet((PendingTicket)taskpreparePina.Result.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.Success); if (piConfirmBet) { if (IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.Success)) { Task.Run( () => { UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake); UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake); }); Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); CountBet++; LastBetTime = DateTime.Now; return(true); } else { Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake)); bool ok = false; for (int i = 0; i < IsnEngine.Rebet; i++) { var prepare = IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, true, isnOdd.Odd); if (prepare != null) { ok = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.MissOddIsn, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake)); return(true); } } Thread.Sleep(500); } if (!ok) // ReBet pina { var betTypeAgaint = GetAgainstBetType(piBetType); var prepare = PiEngine.PrepareBet(piMatch, piOdd, betTypeAgaint, piOdd.Odd); if (prepare != null) { ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake)); return(true); } } } IsnEngine.FireLogBet(isnMatch, isnOdd, isnBetType, isnStake, eBetStatusType.Fail, eServerScan.Local); } } } #endregion #region [Bet ISN trước nếu isn là kèo dưới] else // OU { var isnConfirmBet = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.Success); if (isnConfirmBet) { if (PiEngine.ConfirmBet((PendingTicket)taskpreparePina.Result.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.Success)) { Task.Run( () => { UpdateBetPool( eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake); UpdateBetPool( eServerType.Pina, piMatch.MatchID, PiBetPool, piStake); }); Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); CountBet++; LastBetTime = DateTime.Now; return(true); } else { Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake)); bool ok = false; for (int i = 0; i < PiEngine.Rebet; i++) { var prepare = PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd); if (prepare != null) { ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.MissOddPina, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake)); return(true); } } Thread.Sleep(500); } if (!ok)// Rebet Isn { var betTypeAgaint = GetAgainstBetType(isnBetType); var prepare = IsnEngine.PrepareBet(isnMatch, isnOdd, betTypeAgaint, true, isnOdd.Odd); if (prepare != null) { ok = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, betTypeAgaint, eBetStatusType.BetAgainIsn, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake)); return(true); } } } PiEngine.FireLogBet(piMatch, piOdd, piBetType, piStake, eBetStatusType.Fail, eServerScan.Local); } } } #endregion // tạm đóng FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan); } } else { // tạm đóng FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan); } return(false); } catch (Exception ex) { Logger.Error(ProcessorName, ex); return(false); } finally { isProcess = false; } }
public eServiceStatus Start(eScanType scanType) { CompareValueDifferent = ProcessorConfigInfo.CompareValue; //CompareValueDifferent = ProcessorConfigInfo.CompareValue + 0.005; 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.Pina) { 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 = PiEngine.UserName + " - " + IsnEngine.UserName; IsnEngine.EngineName = ProcessorName; IsnEngine.Rebet = ProcessorConfigInfo.RebetSbo; IsnEngine.UpdateAvailabeCredit(); IsnEngine.StartScanEngine(scanType); PiEngine.Rebet = ProcessorConfigInfo.RebetSbo; PiEngine.EngineName = ProcessorName; PiEngine.UpdateAvailabeCredit(); PiEngine.StartScanEngine(scanType); objUpdateCreditTimer = new Timer(WaitUpdateCreditCallback, null, 60000 * 5, 60000 * 5); StartFailCount = 0; IsnEngine.UpdateLiveDataChange += OnIsnUpdateScan; //tạm đóng //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(); IsnEngine.Dispose(); Status = eServiceStatus.Unknown; } return(Status); }
public PiIsnProcessor3() { StartFailCount = 0; PiEngine = new PiEngine(); IsnEngine = new IsnEngine(); }
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; } }
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; } }
public bool ProcessPrepareBet(MatchPiDTO piMatch, OddDTO piOdd, eBetType piBetType, MatchIsnDTO isnMatch, OddDTO isnOdd, eBetType isnBetType, bool isLive, eServerScan serverScan = eServerScan.Local) { if (isProcess) { return(false); } //what? //string oddCheck = sboMatchOdd.OddID + sboMatchOdd.HomeOdd + sboMatchOdd.AwayOdd + piOdd.HomeOdd + // piOdd.AwayOdd; //if (oddCheck.Equals(OddCheck)) //{ // return false; //} //OddCheck = oddCheck; try { isProcess = true; // wwhat? //sboMatchOdd.OldOdd = piBetType == eBetType.Home ? sboMatchOdd.HomeOdd : sboMatchOdd.AwayOdd; // Logger.Debug(""); // Logger.Debug("Before call PREPARE ISN " + piMatch.HomeTeamName + "-" + piMatch.AwayTeamName + " " + piOdd.HomeOdd + "_" + piOdd.AwayOdd + " " + piBetType.ToString()); //Stopwatch a = new Stopwatch(); //a.Start(); Task <int> taskMaxBet = Task.Run(() => IsnEngine.GetMax((isnBetType == eBetType.Home ? isnOdd.selectionIdHome : isnOdd.selectionIdAway))); Task <PrepareBetDTO> preparePina = null; Task <PrepareBetDTO> prepareIsn = null; if ((isnOdd.OddType == eOddType.OU || isnOdd.OddType == eOddType.HalfOU) && isnBetType == eBetType.Away) { preparePina = Task.Run(() => PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd)); prepareIsn = Task.Run(() => IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, isLive, isnOdd.Odd)); } else { prepareIsn = Task.Run(() => IsnEngine.PrepareBet(isnMatch, isnOdd, isnBetType, isLive, isnOdd.Odd)); preparePina = Task.Run(() => PiEngine.PrepareBet(piMatch, piOdd, piBetType, piOdd.Odd)); } if (preparePina.Result == null || prepareIsn.Result == null) { FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan); return(false); } //a.Stop(); //Debug.WriteLine("Thoi gian prepare: " + a.ElapsedMilliseconds); // float piOddValue = piBetType == eBetType.Home ? piOdd.HomeOdd : piOdd.AwayOdd; //bool isGood = IsGoodOddPair(piOddValue, prepareBetIsn.NewOdd, CompareValueDifferent, out betAny); bool isGood = IsGoodOddPair(preparePina.Result.NewOdd, prepareIsn.Result.NewOdd, CompareValueDifferent); // Logger.Debug("After isGood=" + isGood.ToString() + " " + piOddValue + "_" + prepareBetIsn.NewOdd + " " + piBetType.ToString()); if (isGood) { float firstOdd = piOdd.Odd; int piStake; int isnStake; if (CaculateStake(BetStakeType, piMatch.MatchID, 300, (int)((PendingTicket)preparePina.Result.PendingTicket).TicketItem.MaxRiskAmount, isnMatch.MatchID, 4, taskMaxBet, out piStake, out isnStake)) // if (true) { //if (piStake<(int)((PendingTicket)preparePina.Result.PendingTicket).TicketItem.MinRiskAmount) //{ // Logger.Info("Pi lower than riskamout"); // return false; //} // kèo xỉu isn đnáh trước if ((isnOdd.OddType == eOddType.OU || isnOdd.OddType == eOddType.HalfOU) && isnBetType == eBetType.Away) { var isnConfirmBet = IsnEngine.ConfirmBet2(isnStake, isnMatch, isnOdd, isnBetType, eBetStatusType.Success); if (isnConfirmBet) { if (PiEngine.ConfirmBet2((PendingTicket)preparePina.Result.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.Success)) { Task.Run( () => { UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake); UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake); }); Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); CountBet++; LastBetTime = DateTime.Now; return(true); } else { Task.Run(() => UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake)); var betTypeAgaint = GetAgainstBetType(isnBetType); for (int i = 0; i < PiEngine.Rebet; i++) { lock (IsnEngine.LockLive) { var newIsnMatch = IsnEngine._matchs.FirstOrDefault(p => p.MatchID == isnMatch.MatchID); if (newIsnMatch != null) { var newIsnOdd = newIsnMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == isnOdd.OddType); if (newIsnOdd != null) { var prepare = IsnEngine.PrepareBet(newIsnMatch, newIsnOdd, betTypeAgaint, true, firstOdd); if (prepare != null) { var ok = IsnEngine.ConfirmBet2(isnStake, newIsnMatch, newIsnOdd, betTypeAgaint, eBetStatusType.BetAgainIsn, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Isn, newIsnMatch.MatchID, IsnBetPool, isnStake)); return(true); } } } } } Thread.Sleep(2000); } IsnEngine.FireLogBet(isnMatch, isnOdd, isnBetType, isnStake, eBetStatusType.Fail, eServerScan.Local); } } } else { var piConfirmBet = PiEngine.ConfirmBet((PendingTicket)preparePina.Result.PendingTicket, piStake, piMatch, piOdd, piBetType, eBetStatusType.Success); if (piConfirmBet) { if (IsnEngine.ConfirmBet(isnStake, isnMatch, isnOdd, isnBetType)) { Task.Run( () => { UpdateBetPool(eServerType.Isn, isnMatch.MatchID, IsnBetPool, isnStake); UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake); }); Logger.Info("BET SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); CountBet++; LastBetTime = DateTime.Now; return(true); } else if (BetAgainstIbet) { var betTypeAgaint = GetAgainstBetType(piBetType); for (int i = 0; i < IsnEngine.Rebet; i++) { var prepare = PiEngine.PrepareBet(piMatch, piOdd, betTypeAgaint, firstOdd); if (prepare != null) { var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake)); return(true); } } Thread.Sleep(1000); lock (PiEngine.LockLive) { var newPiMatch = PiEngine._matchs.FirstOrDefault(p => p.MatchID == piMatch.MatchID); if (newPiMatch != null) { var newPiOdd = newPiMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == piOdd.OddType); if (newPiOdd != null) { prepare = PiEngine.PrepareBet(newPiMatch, newPiOdd, betTypeAgaint, firstOdd); if (prepare != null) { var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, newPiMatch, newPiOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake)); return(true); } } } } } Thread.Sleep(1000); lock (IsnEngine.LockLive) { var newIsnMatch = IsnEngine._matchs.FirstOrDefault(p => p.MatchID == isnMatch.MatchID); if (newIsnMatch != null) { var newIsnOdd = newIsnMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == isnOdd.OddType); if (newIsnOdd != null) { prepare = IsnEngine.PrepareBet(newIsnMatch, newIsnOdd, isnBetType, true, firstOdd); if (prepare != null) { var ok = IsnEngine.ConfirmBet2(isnStake, newIsnMatch, newIsnOdd, isnBetType, eBetStatusType.MissOddIsn, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Isn, newIsnMatch.MatchID, IsnBetPool, isnStake)); return(true); } } } } } Thread.Sleep(1000); } Thread.Sleep(60000); for (int i = 0; i < IsnEngine.Rebet * 2; i++) { var prepare = PiEngine.PrepareBet(piMatch, piOdd, betTypeAgaint, firstOdd); if (prepare != null) { var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, piMatch, piOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake)); return(true); } } Thread.Sleep(10000); lock (PiEngine.LockLive) { var newPiMatch = PiEngine._matchs.FirstOrDefault(p => p.MatchID == piMatch.MatchID); if (newPiMatch != null) { var newPiOdd = newPiMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == piOdd.OddType); if (newPiOdd != null) { prepare = PiEngine.PrepareBet(newPiMatch, newPiOdd, betTypeAgaint, firstOdd); if (prepare != null) { var ok = PiEngine.ConfirmBet((PendingTicket)prepare.PendingTicket, piStake, newPiMatch, newPiOdd, betTypeAgaint, eBetStatusType.BetAgainPina, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake)); return(true); } } } } } Thread.Sleep(10000); lock (IsnEngine.LockLive) { var newIsnMatch = IsnEngine._matchs.FirstOrDefault(p => p.MatchID == isnMatch.MatchID); if (newIsnMatch != null) { var newIsnOdd = newIsnMatch.Odds.FirstOrDefault(p => p.Odd == firstOdd && p.OddType == isnOdd.OddType); if (newIsnOdd != null) { prepare = IsnEngine.PrepareBet(newIsnMatch, newIsnOdd, betTypeAgaint, true, firstOdd); if (prepare != null) { var ok = IsnEngine.ConfirmBet2(isnStake, newIsnMatch, newIsnOdd, betTypeAgaint, eBetStatusType.MissOddIsn, true); if (ok) { LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Isn, newIsnMatch.MatchID, IsnBetPool, isnStake)); return(true); } } } } } Thread.Sleep(10000); } } LastBetTime = DateTime.Now; Task.Run(() => UpdateBetPool(eServerType.Pina, piMatch.MatchID, PiBetPool, piStake)); return(true); } } // tạm đóng FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan); } } else { // tạm đóng FireLogScan(piMatch, piOdd, isnMatch, isnOdd, serverScan); } return(false); } catch (Exception ex) { Logger.Error(ProcessorName, ex); return(false); } finally { isProcess = false; } }