/// <summary> /// 获取比赛实体 /// </summary> /// <param name="matchID"></param> /// <returns></returns> public GameMatchInfo GetGameMatchInfo(int matchID) { string sqlQuery = string.Format("(NOLOCK) WHERE MatchID= {0}", matchID); GameMatchInfo match = aideGameMatchInfoProvider.GetObject <GameMatchInfo>(sqlQuery); return(match); }
/// <summary> /// 更新比赛 /// </summary> /// <param name="gameMatch"></param> public void UpdateGameMatchInfo(GameMatchInfo gameMatch) { StringBuilder sqlQuery = new StringBuilder( ); sqlQuery.Append("UPDATE GameMatchInfo SET ") .Append("MatchTitle=@MatchTitle ,") .Append("MatchSummary=@MatchSummary,") .Append("MatchContent= @MatchContent ,") .Append("ApplyBeginDate= @ApplyBeginDate,") .Append("ApplyEndDate= @ApplyEndDate,") .Append("MatchStatus=@MatchStatus,") .Append("Nullity= @Nullity,") .Append("ModifyDate=@ModifyDate ") .Append("WHERE MatchID= @MatchID"); var prams = new List <DbParameter>( ); prams.Add(Database.MakeInParam("MatchTitle", gameMatch.MatchTitle)); prams.Add(Database.MakeInParam("MatchSummary", gameMatch.MatchSummary)); prams.Add(Database.MakeInParam("MatchContent", gameMatch.MatchContent)); prams.Add(Database.MakeInParam("ApplyBeginDate", gameMatch.ApplyBeginDate)); prams.Add(Database.MakeInParam("ApplyEndDate", gameMatch.ApplyEndDate)); prams.Add(Database.MakeInParam("MatchStatus", gameMatch.MatchStatus)); prams.Add(Database.MakeInParam("Nullity", gameMatch.Nullity)); prams.Add(Database.MakeInParam("ModifyDate", gameMatch.ModifyDate)); prams.Add(Database.MakeInParam("MatchID", gameMatch.MatchID)); Database.ExecuteNonQuery(CommandType.Text, sqlQuery.ToString( ), prams.ToArray( )); }
public IEnumerable <Playernotes> ProcessHand(IEnumerable <NoteObject> notes, Playerstatistic stats, HandHistory handHistory) { if (!licenseService.IsRegistered) { return(null); } var matchInfo = new GameMatchInfo { GameType = handHistory.GameDescription.GameType, CashBuyIn = !handHistory.GameDescription.IsTournament ? Utils.ConvertToCents(handHistory.GameDescription.Limit.BigBlind) : 0, TournamentBuyIn = handHistory.GameDescription.IsTournament ? handHistory.GameDescription.Tournament.BuyIn.PrizePoolValue : 0 }; if (!Limit.IsMatch(matchInfo)) { return(null); } var playernotes = new List <Playernotes>(); foreach (var note in notes) { var playerstatistic = new PlayerstatisticExtended { Playerstatistic = stats, HandHistory = handHistory }; if (NoteManager.IsMatch(note, playerstatistic)) { var playerCardsText = string.IsNullOrEmpty(playerstatistic.Playerstatistic.Cards) ? string.Empty : $"[{playerstatistic.Playerstatistic.Cards}]"; var playerNote = new Playernotes { PlayerId = stats.PlayerId, PokersiteId = (short)stats.PokersiteId, Note = $"=[{note.ParentStageType}]= {note.DisplayedNote}", CardRange = note.Settings.IncludeBoard && !string.IsNullOrEmpty(playerCardsText) && !string.IsNullOrEmpty(playerstatistic.Playerstatistic.Board) ? $"{playerCardsText}({playerstatistic.Playerstatistic.Board})" : playerCardsText, IsAutoNote = true, GameNumber = handHistory.HandId, Timestamp = handHistory.DateOfHandUtc }; playernotes.Add(playerNote); } } return(playernotes); }
public bool IsMatch(GameMatchInfo gameInfo) { if (gameInfo == null) { return(false); } var match = AllowedGameTypes.Contains(gameInfo.GameType) && gameInfo.CashBuyIn <= CashLimit && gameInfo.TournamentBuyIn <= TournamentLimit; return(match); }
public void InsertGameMatchInfo(GameMatchInfo gameMatch) { System.Data.DataRow dataRow = this.aideGameMatchInfoProvider.NewRow(); dataRow["MatchID"] = gameMatch.MatchID; dataRow["MatchTitle"] = gameMatch.MatchTitle; dataRow["MatchSummary"] = gameMatch.MatchSummary; dataRow["MatchContent"] = gameMatch.MatchContent; dataRow["ApplyBeginDate"] = gameMatch.ApplyBeginDate; dataRow["ApplyEndDate"] = gameMatch.ApplyEndDate; dataRow["MatchStatus"] = gameMatch.MatchStatus; dataRow["Nullity"] = gameMatch.Nullity; dataRow["CollectDate"] = gameMatch.CollectDate; dataRow["ModifyDate"] = gameMatch.ModifyDate; this.aideGameMatchInfoProvider.Insert(dataRow); }
public void UpdateGameMatchInfo(GameMatchInfo gameMatch) { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("UPDATE GameMatchInfo SET ").Append("MatchTitle=@MatchTitle ,").Append("MatchSummary=@MatchSummary,").Append("MatchContent= @MatchContent ,").Append("ApplyBeginDate= @ApplyBeginDate,").Append("ApplyEndDate= @ApplyEndDate,").Append("MatchStatus=@MatchStatus,").Append("Nullity= @Nullity,").Append("ModifyDate=@ModifyDate ").Append("WHERE MatchID= @MatchID"); System.Collections.Generic.List <System.Data.Common.DbParameter> list = new System.Collections.Generic.List <System.Data.Common.DbParameter>(); list.Add(base.Database.MakeInParam("MatchTitle", gameMatch.MatchTitle)); list.Add(base.Database.MakeInParam("MatchSummary", gameMatch.MatchSummary)); list.Add(base.Database.MakeInParam("MatchContent", gameMatch.MatchContent)); list.Add(base.Database.MakeInParam("ApplyBeginDate", gameMatch.ApplyBeginDate)); list.Add(base.Database.MakeInParam("ApplyEndDate", gameMatch.ApplyEndDate)); list.Add(base.Database.MakeInParam("MatchStatus", gameMatch.MatchStatus)); list.Add(base.Database.MakeInParam("Nullity", gameMatch.Nullity)); list.Add(base.Database.MakeInParam("ModifyDate", gameMatch.ModifyDate)); list.Add(base.Database.MakeInParam("MatchID", gameMatch.MatchID)); base.Database.ExecuteNonQuery(System.Data.CommandType.Text, stringBuilder.ToString(), list.ToArray()); }
/// <summary> /// 新增比赛 /// </summary> /// <param name="gameMatch"></param> public void InsertGameMatchInfo(GameMatchInfo gameMatch) { DataRow dr = aideGameMatchInfoProvider.NewRow( ); dr[GameMatchInfo._MatchID] = gameMatch.MatchID; dr[GameMatchInfo._MatchTitle] = gameMatch.MatchTitle; dr[GameMatchInfo._MatchSummary] = gameMatch.MatchSummary; dr[GameMatchInfo._MatchContent] = gameMatch.MatchContent; dr[GameMatchInfo._ApplyBeginDate] = gameMatch.ApplyBeginDate; dr[GameMatchInfo._ApplyEndDate] = gameMatch.ApplyEndDate; dr[GameMatchInfo._MatchStatus] = gameMatch.MatchStatus; dr[GameMatchInfo._Nullity] = gameMatch.Nullity; dr[GameMatchInfo._CollectDate] = gameMatch.CollectDate; dr[GameMatchInfo._ModifyDate] = gameMatch.ModifyDate; aideGameMatchInfoProvider.Insert(dr); }
public bool IsMatch(GameMatchInfo gameInfo) { if (gameInfo == null || licenseLimits.Count == 0) { LogProvider.Log.Info($"Licenses not found or game data is empty."); return(false); } if (currencyRates == null) { InitializeCurrencyRates(); } if ((gameInfo.Currency == Currency.PlayMoney && gameInfo.TournamentBuyIn == 0) || (gameInfo.TournamentCurrency == Currency.PlayMoney && gameInfo.CashBuyIn == 0)) { return(true); } var cashBuyin = currencyRates != null && currencyRates.Rates != null && currencyRates.Rates.TryGetValue(gameInfo.Currency, out decimal cashRate) ? cashRate * gameInfo.CashBuyIn : gameInfo.CashBuyIn; var tournamentBuyIn = currencyRates != null && currencyRates.Rates != null && currencyRates.Rates.TryGetValue(gameInfo.TournamentCurrency, out decimal tourneyRate) ? tourneyRate * gameInfo.TournamentBuyIn : gameInfo.TournamentBuyIn; if (!licenseLimits.TryGetValue(gameInfo.GameType, out LicenseLimit licenseLimit)) { LogProvider.Log.Info($"GameType: {gameInfo.GameType}, GameCashBuyIn: {cashBuyin}, GameTournamentBuyIn: {tournamentBuyIn}, Curr: {gameInfo.Currency}, TournCurr: {gameInfo.TournamentCurrency}"); LogProvider.Log.Info($"License not found."); return(false); } var match = cashBuyin <= licenseLimit.CashLimit && tournamentBuyIn <= licenseLimit.TournamentLimit; if (!match) { LogProvider.Log.Info($"GameType: {gameInfo.GameType}, GameCashBuyIn: {cashBuyin}, GameTournamentBuyIn: {tournamentBuyIn}, Curr: {gameInfo.Currency}, TournCurr: {gameInfo.TournamentCurrency}"); LogProvider.Log.Info($"LicenseCashBuyIn: {licenseLimit.CashLimit}, LicenseTournamentBuyIn: {licenseLimit.TournamentLimit}"); } return(match); }
/// <summary> /// 页面加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { matchID = XID.ToString( ); Themes.Standard.Common_Header sHeader = (Themes.Standard.Common_Header) this.FindControl("sHeader"); sHeader.title = "比赛中心"; if (!IsPostBack) { GameMatchInfo match = webFacade.GetMatchInfo(XID); if (match == null) { this.form1.Visible = false; this.divRight.Visible = true; this.divRight.InnerHtml = "比赛不存在!"; return; } else { if (match.ApplyBeginDate > DateTime.Now) { this.form1.Visible = false; this.divRight.Visible = true; this.divRight.InnerHtml = "报名时间:" + match.ApplyBeginDate.ToString("yyyy-MM-dd HH:mm") + " 至 " + match.ApplyEndDate.ToString("yyyy-MM-dd HH:mm"); return; } if (match.ApplyEndDate < DateTime.Now) { this.form1.Visible = false; this.divRight.Visible = true; this.divRight.InnerHtml = "报名已结束!"; return; } } if (Fetch.GetUserCookie( ) != null) { this.txtAccounts.Text = Fetch.GetUserCookie( ).Accounts; } } }
/// <summary> /// 更新比赛 /// </summary> /// <param name="gameMatch"></param> public void UpdateGameMatchInfo(GameMatchInfo gameMatch) { aideNativeWebData.UpdateGameMatchInfo(gameMatch); }
/// <summary> /// 新增比赛 /// </summary> /// <param name="gameMatch"></param> public void InsertGameMatchInfo(GameMatchInfo gameMatch) { aideNativeWebData.InsertGameMatchInfo(gameMatch); }
public void ProcessNotes(IEnumerable <NoteObject> notes, CancellationTokenSource cancellationTokenSource) { try { if (!licenseService.IsRegistered || (cancellationTokenSource != null && cancellationTokenSource.IsCancellationRequested)) { return; } var currentPlayerIds = new HashSet <int>(storageModel.PlayerSelectedItem.PlayerIds); var noteService = ServiceLocator.Current.GetInstance <IPlayerNotesService>() as IPlayerXRayNoteService; var sinceDate = noteService.CurrentNotesAppSettings.IsNoteCreationSinceDate ? noteService.CurrentNotesAppSettings.NoteCreationSinceDate : (DateTime?)null; var isAdvancedLogEnabled = noteService.CurrentNotesAppSettings.IsAdvancedLogEnabled; var takesNotesOnHero = noteService.CurrentNotesAppSettings.TakesNotesOnHero; using (var session = ModelEntities.OpenStatelessSession()) { BuildPlayersDictonary(session); BuildPlayersNotesDictonary(session); var entitiesCount = sinceDate != null? session.Query <Handhistory>().Count(x => x.Handtimestamp >= sinceDate.Value) : session.Query <Handhistory>().Count(); var progressCounter = 0; var progress = 0; var numOfQueries = (int)Math.Ceiling((double)entitiesCount / handHistoryRowsPerQuery); LogProvider.Log.Info(CustomModulesNames.PlayerXRay, $"Processing notes [{notes.Count()}] for {entitiesCount} hands."); for (var i = 0; i < numOfQueries; i++) { if (cancellationTokenSource != null && cancellationTokenSource.IsCancellationRequested) { LogProvider.Log.Info(CustomModulesNames.PlayerXRay, $"The note processing has been canceled [{i}/{numOfQueries}]."); break; } using (var pf = new PerformanceMonitor($"Proccesing notes [{i}/{numOfQueries} iteration].", isAdvancedLogEnabled, CustomModulesNames.PlayerXRay)) { var numOfRowToStartQuery = i * handHistoryRowsPerQuery; var handHistories = sinceDate != null? session.Query <Handhistory>() .Where(x => x.Handtimestamp >= sinceDate.Value) .Skip(numOfRowToStartQuery) .Take(handHistoryRowsPerQuery) .ToArray() : session.Query <Handhistory>() .Skip(numOfRowToStartQuery) .Take(handHistoryRowsPerQuery) .ToArray(); var notesToInsert = new ConcurrentBag <Playernotes>(); Parallel.ForEach(handHistories, handHistory => { try { var parsingResult = ParseHandHistory(handHistory); if (parsingResult != null) { var matchInfo = new GameMatchInfo { GameType = parsingResult.Source.GameDescription.GameType, CashBuyIn = !parsingResult.Source.GameDescription.IsTournament ? Utils.ConvertToCents(parsingResult.Source.GameDescription.Limit.BigBlind) : 0, TournamentBuyIn = parsingResult.Source.GameDescription.IsTournament ? parsingResult.Source.GameDescription.Tournament.BuyIn.PrizePoolValue : 0 }; if (!Limit.IsMatch(matchInfo)) { return; } var playerStatisticCreationInfo = new PlayerStatisticCreationInfo { ParsingResult = parsingResult }; foreach (var player in parsingResult.Players) { // skip notes for current player (need to check setting) if (!takesNotesOnHero && currentPlayerIds.Contains(player.PlayerId)) { continue; } var calculatedEquity = new Dictionary <string, Dictionary <Street, decimal> >(); if (player.PlayerId != 0) { var playerNoteKey = new PlayerPokerSiteKey(player.PlayerId, player.PokersiteId); playerStatisticCreationInfo.Player = player; var playerStatistic = BuildPlayerStatistic(playerStatisticCreationInfo); var playerNotes = ProcessHand(notes, playerStatistic, parsingResult.Source); if (playerNotes.Count() == 0) { continue; } // if player has no notes, then just save all new notes if (!playersNotesDictionary.ContainsKey(playerNoteKey) || (playersNotesDictionary.ContainsKey(playerNoteKey) && !playersNotesDictionary[playerNoteKey].ContainsKey(handHistory.Gamenumber))) { playerNotes.ForEach(note => notesToInsert.Add(note)); continue; } var existingNotes = playersNotesDictionary[playerNoteKey][handHistory.Gamenumber]; var notesToAdd = (from playerNote in playerNotes join existingNote in existingNotes on playerNote.Note equals existingNote.Note into gj from note in gj.DefaultIfEmpty() where note == null select playerNote).ToArray(); notesToAdd.ForEach(note => notesToInsert.Add(note)); } } ; } } catch (Exception hhEx) { LogProvider.Log.Error(CustomModulesNames.PlayerXRay, $"Hand history {handHistory.Gamenumber} has not been processed", hhEx); } // reporting progress progressCounter++; var currentProgress = progressCounter * 100 / entitiesCount; if (progress < currentProgress) { progress = currentProgress; ProgressChanged?.Invoke(this, new NoteProcessingServiceProgressChangedEventArgs(progress)); } }); using (var transaction = session.BeginTransaction()) { notesToInsert.ForEach(x => session.Insert(x)); transaction.Commit(); } } } LogProvider.Log.Info(CustomModulesNames.PlayerXRay, $"Notes have been processed."); } } catch (Exception e) { LogProvider.Log.Error(CustomModulesNames.PlayerXRay, "Notes have not been processed.", e); } }