public bool UpdateRaiderRoundMetaDataInfo(RaiderRoundMetaDataInfo roundInfo, CustomerMySqlTransaction myTrans) { MySqlCommand mycmd = null; try { string sqlText = "UPDATE raiderroundmetadatainfo " + " set `State` = @State, `StartTime` = @StartTime, `AwardPoolSumStones` = @AwardPoolSumStones, `JoinedPlayerCount`=@JoinedPlayerCount, `WinnerUserName`=@WinnerUserName,`WinStones`=@WinStones,`EndTime`=@EndTime where `id` = @id ; "; mycmd = myTrans.CreateCommand(); mycmd.CommandText = sqlText; mycmd.Parameters.AddWithValue("@State", (int)roundInfo.State); mycmd.Parameters.AddWithValue("@StartTime", roundInfo.StartTime == null ? DBNull.Value : (object)roundInfo.StartTime.ToDateTime()); mycmd.Parameters.AddWithValue("@AwardPoolSumStones", roundInfo.AwardPoolSumStones); mycmd.Parameters.AddWithValue("@JoinedPlayerCount", roundInfo.JoinedPlayerCount); mycmd.Parameters.AddWithValue("@WinnerUserName", string.IsNullOrEmpty(roundInfo.WinnerUserName) ? DBNull.Value : (object)DESEncrypt.EncryptDES(roundInfo.WinnerUserName)); mycmd.Parameters.AddWithValue("@WinStones", roundInfo.WinStones); mycmd.Parameters.AddWithValue("@EndTime", roundInfo.EndTime == null ? DBNull.Value : (object)roundInfo.EndTime.ToDateTime()); mycmd.Parameters.AddWithValue("@id", roundInfo.ID); mycmd.ExecuteNonQuery(); return(true); } finally { if (mycmd != null) { mycmd.Dispose(); } } }
public void RaiseOnPlayerWinedRaiderNotify(RaiderRoundMetaDataInfo record) { Action <RaiderRoundMetaDataInfo> handler = this.OnPlayerWinedRaiderNotify; if (null != handler) { handler(record); } }
public void RaiseOnPlayerJoinRaiderSucceed(RaiderRoundMetaDataInfo roundInfo) { Action <RaiderRoundMetaDataInfo> handler = this.OnPlayerJoinRaiderSucceed; if (null != handler) { handler(roundInfo); } }
public void CreateNewRound() { RaiderRoundMetaDataInfo lastRoundInfo = new RaiderRoundMetaDataInfo(); lastRoundInfo = DBProvider.GameRaiderofLostArkDBProvider.AddNewRaiderRoundMetaDataInfo(lastRoundInfo); this._currentRoundInfo = lastRoundInfo; this.listPlayerBetInfos.Clear(); this.listPlayerUserName.Clear(); }
//private void NotifyPlayerToRefreshBetRecords(RaiderRoundMetaDataInfo roundInfo, List<string> listPlayerUserName) //{ // foreach (var username in listPlayerUserName) // { // string token = ClientManager.GetToken(username); // new Thread(new ParameterizedThreadStart(o => // { // this.PlayerJoinRaiderSucceed(o.ToString(), roundInfo); // })).Start(token); // } //} private void NotifyAllPlayerRaiderWinner(RaiderRoundMetaDataInfo roundInfo) { LogHelper.Instance.AddInfoLog("玩家[" + roundInfo.WinnerUserName + "] 赢得第" + roundInfo.ID + "期 夺宝奇兵,赢得" + roundInfo.WinStones + "矿石"); PlayerActionController.Instance.AddLog(roundInfo.WinnerUserName, MetaData.ActionLog.ActionType.GameRaiderWin, roundInfo.ID, roundInfo.WinStones.ToString()); //var token = ClientManager.GetToken(roundInfo.WinnerUserName); //new Thread(new ParameterizedThreadStart(o => //{ // this.PlayerWinedRaiderNotify(o.ToString(), roundInfo); //})).Start(token); }
public RaiderRoundMetaDataInfo AddNewRaiderRoundMetaDataInfo(RaiderRoundMetaDataInfo roundInfo) { MySqlConnection myconn = null; MySqlCommand mycmd = null; try { myconn = MyDBHelper.Instance.CreateConnection(); myconn.Open(); //1. Save to DB string sqlTextA = "insert into raiderroundmetadatainfo (`State`) values ( @State) ;"; mycmd = myconn.CreateCommand(); mycmd.CommandText = sqlTextA; mycmd.Parameters.AddWithValue("@State", (int)roundInfo.State); mycmd.ExecuteNonQuery(); mycmd.Dispose(); //2. Select from DB string sqlTextB = "SELECT * FROM raiderroundmetadatainfo order by id desc limit 1; "; mycmd = myconn.CreateCommand(); mycmd.CommandText = sqlTextB; DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd); adapter.Fill(table); var roundInfos = MetaDBAdapter <RaiderRoundMetaDataInfo> .GetRaiderRoundMetaDataInfoFromDataTable(table); table.Clear(); table.Dispose(); adapter.Dispose(); if (roundInfos == null || roundInfos.Length == 0) { return(null); } return(roundInfos[0]); } finally { if (mycmd != null) { mycmd.Dispose(); } MyDBHelper.Instance.DisposeConnection(myconn); } }
private void ResetRoundInfo() { RaiderRoundMetaDataInfo lastRoundInfo = DBProvider.GameRaiderofLostArkDBProvider.GetLastRaiderRoundMetaDataInfo(); if (lastRoundInfo == null || lastRoundInfo.State == RaiderRoundState.Finished) { lastRoundInfo = new RaiderRoundMetaDataInfo(); lastRoundInfo = DBProvider.GameRaiderofLostArkDBProvider.AddNewRaiderRoundMetaDataInfo(lastRoundInfo); this._currentRoundInfo = lastRoundInfo; this.listPlayerBetInfos.Clear(); this.listPlayerUserName.Clear(); } else { this._currentRoundInfo = lastRoundInfo; this.listPlayerBetInfos.Clear(); this.listPlayerUserName.Clear(); int AwardPoolSumStones = 0; int JoinedPlayerCount = 0; var lastRoundJoinedBetRecords = DBProvider.GameRaiderofLostArkDBProvider.GetPlayerBetInfoByRoundID(lastRoundInfo.ID, "", -1, -1); if (lastRoundJoinedBetRecords != null) { foreach (var item in lastRoundJoinedBetRecords) { AwardPoolSumStones += item.BetStones; this.listPlayerBetInfos.Add(item); if (!this.listPlayerUserName.Contains(item.UserName)) { this.listPlayerUserName.Add(item.UserName); JoinedPlayerCount++; } } this._currentRoundInfo.AwardPoolSumStones = AwardPoolSumStones; this._currentRoundInfo.JoinedPlayerCount = JoinedPlayerCount; //if (this.listPlayerUserName != null && this.listPlayerUserName.Count > 0 && this.NotifyPlayerToRefreshBetRecordsEvent != null) //{ // this.NotifyPlayerToRefreshBetRecordsEvent(this.CurrentRoundInfo, this.listPlayerUserName); //} } } }
public RaiderRoundMetaDataInfoUIModel(RaiderRoundMetaDataInfo parent) { this.ParentObject = parent; }