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); } } }
public void SetServer(int serverId, int gameId, string serverName, int TargetServer, string serverUrl, string status, int weight, string intranetAddress) { try { CommandHelper command = new CommandHelper("ServerInfo", EditType.Update); command.AddParameter("ServerName", SqlDbType.VarChar, serverName); command.AddParameter("BaseUrl", SqlDbType.VarChar, serverUrl); command.AddParameter("IntranetAddress", SqlDbType.VarChar, intranetAddress); command.AddParameter("TargetServer", SqlDbType.Int, TargetServer); if (weight > 0) { command.AddParameter("Weight", SqlDbType.Int, weight); } //command.AddParameter("ActiveNum", SqlDbType.Int, serverInfo.ActiveNum); command.Filter = new CommandFilter(); command.Filter.Condition = "ID=@ServerID and GameID=@GameID"; command.Filter.AddParam("@ServerID", SqlDbType.Int, 0, serverId); command.Filter.AddParam("@GameID", SqlDbType.Int, 0, gameId); command.Parser(); SqlHelper.ExecuteNonQuery(config.connectionString, CommandType.Text, command.Sql, command.Parameters); lock (thisLock) { Dictionary <int, ServerList> serverDict = (Dictionary <int, ServerList>)getCache(); if (serverDict.ContainsKey(gameId)) { ServerList serverList = serverDict[gameId]; if (serverList.ContainsKey(serverId)) { ServerInfo cacheServer = serverList[serverId]; cacheServer.ServerName = serverName; cacheServer.ServerUrl = serverUrl; cacheServer.TargetServer = TargetServer; cacheServer.IntranetAddress = intranetAddress; cacheServer.Status = status; if (weight > 0) { cacheServer.Weight = weight; } serverList[serverId] = cacheServer; } serverDict[gameId] = serverList; } addCache(serverDict); } } catch (Exception ex) { SaveLog(ex); } }
public void SetServerEnableDate(int gameId, int serverId, DateTime enableDate) { try { CommandHelper command = new CommandHelper("ServerInfo", EditType.Update); command.AddParameter("EnableDate", SqlDbType.DateTime, enableDate); command.Filter = new CommandFilter(); command.Filter.Condition = "ID=@ServerID and GameID=@GameID"; command.Filter.AddParam("@ServerID", SqlDbType.Int, 0, serverId); command.Filter.AddParam("@GameID", SqlDbType.Int, 0, gameId); command.Parser(); SqlHelper.ExecuteNonQuery(config.connectionString, CommandType.Text, command.Sql, command.Parameters); lock (thisLock) { var serverDict = (Dictionary <int, ServerList>)getCache(); if (serverDict.ContainsKey(gameId)) { ServerList serverList = serverDict[gameId]; if (serverList.ContainsKey(serverId)) { ServerInfo cacheServer = serverList[serverId]; cacheServer.EnableDate = enableDate; serverList[serverId] = cacheServer; } serverDict[gameId] = serverList; } addCache(serverDict); } } catch (Exception ex) { SaveLog(ex); } }
private void Load() { var commandHelper = new CommandHelper(new MySqlCommand(@"SELECT RowID As UERowID, Name1 As UEName1, FirmCr As UEFirmCr, Code As UECode, CodeCr As UECodeCr, Unit As UEUnit, Volume As UEVolume, Quantity As UEQuantity, Note, Period As UEPeriod, Doc, PriorProductId As UEPriorProductId, p.CatalogId As UEPriorCatalogId, PriorProducerId As UEPriorProducerId, ProductSynonymId As UEProductSynonymId, ProducerSynonymId As UEProducerSynonymId, Status As UEStatus, Already As UEAlready, Junk As UEJunk, HandMade As UEHandMade, c.Pharmacie FROM farm.UnrecExp left join Catalogs.Products p on p.Id = PriorProductId left join Catalogs.Catalog c on p.CatalogId = c.Id WHERE PriceItemId= ?LockedPriceItemId ORDER BY Name1" , (MySqlConnection)session.Connection)); commandHelper.AddParameter("?LockedPriceItemId", price.Costs.First().PriceItem.Id); var set = new DataSet(); commandHelper.Fill(set, "Data"); data = set.Tables[0]; if (!data.Columns.Contains("SynonymObject")) { data.Columns.Add("SynonymObject", typeof(object)); } }
public bool AddToCache(ServerInfo serverInfo) { try { lock (thisLock) { Dictionary <int, ServerList> serverDict = (Dictionary <int, ServerList>)getCache(); ServerList serverList = new ServerList(); int gameId = serverInfo.GameID; if (serverDict.ContainsKey(gameId)) { serverList = serverDict[gameId]; } //判断是否重名 ServerInfo tempServer; if (!serverList.Contains(serverInfo.ServerName, out tempServer)) { tempServer.ID = serverInfo.ID; tempServer.GameID = serverInfo.GameID; tempServer.TargetServer = serverInfo.TargetServer; tempServer.ServerName = serverInfo.ServerName; tempServer.ServerUrl = serverInfo.ServerUrl; tempServer.ActiveNum = serverInfo.ActiveNum; tempServer.Status = serverInfo.Status; tempServer.EnableDate = serverInfo.EnableDate; tempServer.IntranetAddress = serverInfo.IntranetAddress; CommandHelper command = new CommandHelper("ServerInfo", EditType.Insert); command.AddParameter("ID", SqlDbType.Int, serverInfo.ID); command.AddParameter("GameID", SqlDbType.Int, serverInfo.GameID); command.AddParameter("TargetServer", SqlDbType.Int, serverInfo.TargetServer); command.AddParameter("ServerName", SqlDbType.VarChar, serverInfo.ServerName); command.AddParameter("BaseUrl", SqlDbType.VarChar, serverInfo.ServerUrl); command.AddParameter("ActiveNum", SqlDbType.Int, serverInfo.ActiveNum); command.AddParameter("EnableDate", SqlDbType.DateTime, serverInfo.EnableDate); command.AddParameter("IntranetAddress", SqlDbType.VarChar, serverInfo.IntranetAddress); command.Parser(); SqlHelper.ExecuteNonQuery(config.connectionString, CommandType.Text, command.Sql, command.Parameters); serverList.Add(tempServer.ID, tempServer); } else { tempServer.TargetServer = serverInfo.TargetServer; tempServer.ActiveNum = serverInfo.ActiveNum; tempServer.Status = serverInfo.Status; serverList[tempServer.ID] = tempServer; } if (serverDict.ContainsKey(gameId)) { serverDict[gameId] = serverList; } else { serverDict.Add(gameId, serverList); } addCache(serverDict); } return(true); } catch (Exception ex) { SaveLog(ex); return(false); } }