private void RecordVisit(int id, ServerPlayer player) { var ipaddr = Netplay.Clients[id].Socket.GetRemoteAddress().GetIdentifier(); QQAuth.MySqlManager sqlmanager = new QQAuth.MySqlManager(); sqlmanager.Connect(); MySqlCommand cmd = sqlmanager.command; cmd.CommandText = $"update users set lastIP = '{ipaddr}' where QQ = '{player.qqAuth.QQ}'"; cmd.ExecuteNonQuery(); cmd.Cancel(); }
public void Load() { lock (this) { MarketItems.Clear(); QQAuth.MySqlManager sqlmanager = new QQAuth.MySqlManager(); sqlmanager.Connect(); MySqlCommand cmd = sqlmanager.command; cmd.CommandText = $"select * from normalshop order by id asc"; using (MySqlDataReader mdr = cmd.ExecuteReader()) { if (!mdr.HasRows) { return; } while (mdr.Read()) { var ismod = (bool)mdr["IsMod"]; Item item = new Item(); if (ismod) { var modname = mdr["ModName"].ToString(); var typename = mdr["TypeName"].ToString(); item.netDefaults(ModLoader.GetMod(modname).ItemType(typename)); } else { item.netDefaults((int)mdr["Type"]); } var belong = mdr["Class"].ToString(); MarketItems.Add(item.type, new MarketItem(item, (int)mdr["Price"], (int)mdr["Discount"], belong, (byte)(int)mdr["Coin"], belong.Equals("公会"))); } } cmd.Cancel(); CommandBoardcast.ConsoleMessage($"共计 {MarketItems.Count} 个商店物品"); } }