public static void TryDeleteTax(TaxCollector tc) { try { lock (Cache) { Cache.Remove(tc.ActorId); tc.Items.Values.ToList().ForEach(x => InventoryItemTable.removeItem(x.ID)); } DatabaseManager.Provider.ExecuteQuery("DELETE FROM taxcollector WHERE guid = '" + tc.ActorId + "'"); } catch (Exception ex) { Logger.Error("DatabaseEntities::TryDeleteperco : Guid=" + tc.ActorId + " " + ex.ToString()); } }
public static void Update(CharacterInventory cache) { try { MySqlCommand Command; foreach (String id in cache.getItemsIDSplitByChar(":").Split(':')) { int guid; try { guid = int.Parse(id); } catch (Exception e) { continue; } InventoryItemModel item = InventoryItemTable.getItem(guid); if (item == null) { continue; } Command = new MySqlCommand() { Connection = DatabaseManager.Provider.getConnection(), CommandText = "UPDATE `inventory_item` set template = @template, qua = @qua, pos = @pos, stats = @stats , speaking = @speaking WHERE guid= @guid;", }; Command.Prepare(); Command.Parameters.AddWithValue("@guid", item.ID); Command.Parameters.AddWithValue("@template", item.TemplateID); Command.Parameters.AddWithValue("@qua", item.Quantity); Command.Parameters.AddWithValue("@pos", item.Position); Command.Parameters.AddWithValue("@stats", item.GetStats().ToItemStats(true)); Command.Parameters.AddWithValue("@speaking", item.SpeakingID); Command.ExecuteNonQuery(); } } catch (Exception e) { Logger.Error("Can't execute query : " + e.ToString()); } }
public static void Update(Player character) { try { MySqlCommand Command = new MySqlCommand() { Connection = DatabaseManager.RealmProvider.getConnection(), CommandText = "UPDATE characters SET owner = @owner,name = @name,level = @level,color1 = @color1,color2 = @color2,color3 = @color3,look = @look,sexe = @sexe,classe = @class,map = @map,cell = @CellId,restriction = @res,experience = @experience,kamas = @kamas,capital = @capital,spellboost = @spellboost,lifeper = @lifeper,energy = @energy,ap = @ap,mp = @mp,vitality = @vitality,wisdom = @wisdom,strength = @strength,intell = @intell,agility = @agility,chance = @chance,alignement = @align,honor = @h,deshonor = @ds, stuff= @stuff, spells = @spells, savepos = @spos, zaaps = @za, mount = @mount, mountxpgive = @mxp, wornitem = @witem, seeAlign = @hw, title = @ti, cote = @cote WHERE guid = @guid", }; Command.Prepare(); Command.Parameters.AddWithValue("@guid", character.ID); Command.Parameters.AddWithValue("@owner", character.Owner); Command.Parameters.AddWithValue("@name", character.Name); Command.Parameters.AddWithValue("@level", character.Level); Command.Parameters.AddWithValue("@color1", character.Color1); Command.Parameters.AddWithValue("@color2", character.Color2); Command.Parameters.AddWithValue("@color3", character.Color3); Command.Parameters.AddWithValue("@look", character.Look); Command.Parameters.AddWithValue("@sexe", character.Sexe); Command.Parameters.AddWithValue("@class", character.Classe); Command.Parameters.AddWithValue("@map", character.Map); Command.Parameters.AddWithValue("@CellId", character.CellId); Command.Parameters.AddWithValue("@res", character.Restriction); Command.Parameters.AddWithValue("@experience", character.Experience); Command.Parameters.AddWithValue("@kamas", character.Kamas); Command.Parameters.AddWithValue("@capital", character.CaractPoint); Command.Parameters.AddWithValue("@spellboost", character.SpellPoint); Command.Parameters.AddWithValue("@energy", character.Energy); Command.Parameters.AddWithValue("@lifeper", character.GetPDVper()); Command.Parameters.AddWithValue("@ap", character.AP); Command.Parameters.AddWithValue("@mp", character.MP); Command.Parameters.AddWithValue("@vitality", character.Vitality); Command.Parameters.AddWithValue("@wisdom", character.Wisdom); Command.Parameters.AddWithValue("@strength", character.Strength); Command.Parameters.AddWithValue("@intell", character.Strength); Command.Parameters.AddWithValue("@agility", character.Agility); Command.Parameters.AddWithValue("@chance", character.Chance); Command.Parameters.AddWithValue("@align", character.Alignement); Command.Parameters.AddWithValue("@h", character.Honor); Command.Parameters.AddWithValue("@ds", character.Deshonor); Command.Parameters.AddWithValue("@stuff", character.parseItemsToDB()); Command.Parameters.AddWithValue("@spells", character.GetSpellBook().ToDatabase()); Command.Parameters.AddWithValue("@spos", character.SavePos); Command.Parameters.AddWithValue("@za", character.parseZaaps()); Command.Parameters.AddWithValue("@mount", character.Mount != null ? character.Mount.ID : -1); Command.Parameters.AddWithValue("@mxp", character.MountXPGive); Command.Parameters.AddWithValue("@hw", character.showWings ? 1 : 0); Command.Parameters.AddWithValue("@ti", character.Title); Command.Parameters.AddWithValue("@cote", character.Cote); if (character.InventoryCache == null) { Command.Parameters.AddWithValue("@witem", ",,,,"); } else { Command.Parameters.AddWithValue("@witem", character.InventoryCache.SerializeAsDisplayEquipment()); } DatabaseManager.RealmProvider.ExecuteQuery(Command); if (character.InventoryCache != null) { InventoryItemTable.Update(character.InventoryCache); } if (character.getCharacterGuild() != null) { CharactersGuildTable.Add(character.getCharacterGuild()); } if (character.Mount != null) { MountTable.Update(character.Mount); } } catch (System.InvalidOperationException e1) { DatabaseManager.RealmProvider.Restart(); Update(character); } catch (Exception e) { Logger.Error(e.ToString()); } }