public bool AddToCache(GameInfo gameInfo) { lock (thisLock) { try { Dictionary<int, GameInfo> list = (Dictionary<int, GameInfo>)this.getCache(); if (!list.ContainsKey(gameInfo.ID)) { CommandHelper command = new CommandHelper("GameInfo", EditType.Insert); command.AddParameter("GameID", SqlDbType.Int, gameInfo.ID); command.AddParameter("GameName", SqlDbType.VarChar, gameInfo.Name); command.AddParameter("Currency", SqlDbType.VarChar, gameInfo.Currency); command.AddParameter("Multiple", SqlDbType.Decimal, gameInfo.Multiple); command.AddParameter("AgentsID", SqlDbType.VarChar, gameInfo.AgentsID); command.AddParameter("IsRelease", SqlDbType.Bit, gameInfo.IsRelease); command.AddParameter("ReleaseDate", SqlDbType.DateTime, gameInfo.ReleaseDate); command.AddParameter("PayStyle", SqlDbType.VarChar, gameInfo.PayStyle); command.AddParameter("GameWord", SqlDbType.VarChar, gameInfo.GameWord); command.AddParameter("SocketServer", SqlDbType.VarChar, gameInfo.SocketServer); command.AddParameter("SocketPort", SqlDbType.Int, gameInfo.SocketPort); command.Parser(); SqlHelper.ExecuteNonQuery(config.connectionString, CommandType.Text, command.Sql, command.Parameters); list.Add(gameInfo.ID, gameInfo); } else { CommandHelper command = new CommandHelper("GameInfo", EditType.Update); command.AddParameter("GameName", SqlDbType.VarChar, gameInfo.Name); command.AddParameter("Currency", SqlDbType.VarChar, gameInfo.Currency); command.AddParameter("Multiple", SqlDbType.Decimal, gameInfo.Multiple); command.AddParameter("AgentsID", SqlDbType.VarChar, gameInfo.AgentsID); command.AddParameter("IsRelease", SqlDbType.Bit, gameInfo.IsRelease); command.AddParameter("ReleaseDate", SqlDbType.DateTime, gameInfo.ReleaseDate); command.AddParameter("PayStyle", SqlDbType.VarChar, gameInfo.PayStyle); command.AddParameter("GameWord", SqlDbType.VarChar, gameInfo.GameWord); command.AddParameter("SocketServer", SqlDbType.VarChar, gameInfo.SocketServer); command.AddParameter("SocketPort", SqlDbType.Int, gameInfo.SocketPort); command.Filter = new CommandFilter(); command.Filter.Condition = "GameID=@GameID"; command.Filter.AddParam("@GameID", SqlDbType.Int, 0, gameInfo.ID); command.Parser(); SqlHelper.ExecuteNonQuery(config.connectionString, CommandType.Text, command.Sql, command.Parameters); list[gameInfo.ID] = gameInfo; return true; } this.addCache(list); return true; } catch (Exception ex) { this.SaveLog(ex); return false; } } }
internal void RemoveGame(int gameID) { try { CommandHelper command = new CommandHelper("GameInfo", EditType.Delete); command.Filter = new CommandFilter(); command.Filter.Condition = "GameID=@GameID"; command.Filter.AddParam("@GameID", SqlDbType.Int, 0, gameID); command.Parser(); SqlHelper.ExecuteNonQuery(config.connectionString, CommandType.Text, command.Sql, command.Parameters); Dictionary<int, GameInfo> list = (Dictionary<int, GameInfo>)this.getCache(); lock (thisLock) { if (list.ContainsKey(gameID)) { list.Remove(gameID); } this.addCache(list); } } catch (Exception ex) { this.SaveLog(ex); } }