/// <summary> /// Returns the item information for the items with the given ID /// </summary> /// <param name="itemID">ID of the item</param> /// <returns>Item object containing all item information, or null if the itemName is invalid</returns> public GW2PAO.API.Data.Entities.Item GetItem(int itemID) { GW2PAO.API.Data.Entities.Item item = null; try { var itemService = GW2.V2.Items.ForCurrentUICulture(); var itemDetails = itemService.Find(itemID); if (itemDetails != null) { item = new Data.Entities.Item(itemID, itemDetails.Name); item.Icon = itemDetails.IconFileUrl; item.Description = itemDetails.Description; item.Rarity = (Data.Enums.ItemRarity)itemDetails.Rarity; item.Flags = (Data.Enums.ItemFlags)itemDetails.Flags; item.GameTypes = (Data.Enums.ItemGameTypes)itemDetails.GameTypes; item.LevelRequirement = itemDetails.Level; item.VenderValue = itemDetails.VendorValue; item.ChatCode = itemDetails.GetItemChatLink().ToString(); item.Prices = this.GetItemPrices(itemID); // Since there is no need to use ALL details right now, we'll just get what we need... // TODO: Finish this up, get all details, such as Type, SkinID } } catch (GW2NET.Common.ServiceException ex) { // Don't crash, just return null logger.Warn("Error finding item with id {0}: {1}", itemID, ex); } return(item); }
public async IAsyncEnumerable <ItemDTO> CloneItemWithSubItem(Data.Entities.Item item, IAsyncEnumerable <PropertyDTO> propertyDTOList, List <SubItemDTO> subItemDTOList) { List <PropertyDTO> propertyList = new List <PropertyDTO>(); await foreach (var property in propertyDTOList) { propertyList.Add(property); } ; ItemDTO itemDTO = new ItemDTO { Id = item.Id, PropertyList = propertyList, CreatedDate = item.CreatedDate, CreatedBy = item.CreatedBy, UpdatedDate = item.UpdatedDate, UpdatedBy = item.UpdatedBy, DeletedDate = item.DeletedDate, DeletedBy = item.DeletedBy, SubItemList = subItemDTOList }; yield return(itemDTO); }
public async static Task <Data.Entities.Item> SpawnCharacterItem(int itemid) { Data.Entities.Item item = new Data.Entities.Item(0, "NO", 0, 0); using (MySqlConnection connection = new MySqlConnection(Data.DatabaseHandler.connectionHandle)) { await connection.OpenAsync().ConfigureAwait(false); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM items WHERE id = @itemid"; command.Parameters.AddWithValue("@itemid", itemid); DbDataReader reader = await command.ExecuteReaderAsync().ConfigureAwait(false); if (reader.HasRows) { while (await reader.ReadAsync().ConfigureAwait(false)) { item.id = reader.GetInt32(reader.GetOrdinal("id")); item.name = reader.GetString(reader.GetOrdinal("name")); item.quantity = reader.GetInt32(reader.GetOrdinal("quantity")); item.type = reader.GetInt32(reader.GetOrdinal("type")); } } } return(item); }
private void ApplyItemFeatures(NWItem item) { Data.Entities.Item entity = GetItemEntity(item); if (entity == null) { return; } item.CustomAC = entity.AC; item.CustomItemType = (CustomItemType)entity.ItemTypeID; item.RecommendedLevel = entity.RecommendedLevel; item.LoggingBonus = entity.LoggingBonus; item.MiningBonus = entity.MiningBonus; item.CastingSpeed = entity.CastingSpeed; item.CraftBonusMetalworking = entity.CraftBonusMetalworking; item.CraftBonusArmorsmith = entity.CraftBonusArmorsmith; item.CraftBonusWeaponsmith = entity.CraftBonusWeaponsmith; item.CraftBonusCooking = entity.CraftBonusCooking; item.CraftBonusWoodworking = entity.CraftBonusWoodworking; item.AssociatedSkillID = entity.AssociatedSkillID; item.CraftTierLevel = entity.CraftTierLevel; item.HPBonus = entity.HPBonus; item.ManaBonus = entity.ManaBonus; if (entity.Weight > 0) { _nwnxItem.SetWeight(item, entity.Weight); } if (entity.DurabilityPoints > 0) { _durability.SetMaxDurability(item, entity.DurabilityPoints); } }
public async IAsyncEnumerable <ItemDTO> GetByIdAsync(Guid id) { Data.Entities.Item item = await _context.FindAsync <Data.Entities.Item>(id); if (item is null || item.DeletedDate != null) { yield return(new ItemDTO()); } IAsyncEnumerable <PropertyDTO> propertyDTOList = _propertyService.GetByItemAsync(item.Id); await foreach (var tempitem in CloneItemEntity(item, propertyDTOList)) { yield return(tempitem); } }
/// <summary> /// Returns the item information for the items with the given IDs /// </summary> /// <param name="itemIDs">IDs of the items to retrieve</param> /// <returns>Collection of Item objects containing all item information</returns> public IDictionary <int, GW2PAO.API.Data.Entities.Item> GetItems(ICollection <int> itemIDs) { Dictionary <int, GW2PAO.API.Data.Entities.Item> items = new Dictionary <int, GW2PAO.API.Data.Entities.Item>(); try { // Remove all items with itemID of 0 or less var validIDs = itemIDs.Where(id => id > 0).ToList(); var itemService = GW2.V2.Items.ForCurrentUICulture(); var itemDetails = itemService.FindAll(validIDs); var prices = this.GetItemPrices(validIDs); foreach (var itemDetail in itemDetails) { GW2PAO.API.Data.Entities.Item item = new Data.Entities.Item(itemDetail.Key, itemDetail.Value.Name); item.Icon = itemDetail.Value.IconFileUrl; item.Description = itemDetail.Value.Description; item.Rarity = (Data.Enums.ItemRarity)itemDetail.Value.Rarity; item.Flags = (Data.Enums.ItemFlags)itemDetail.Value.Flags; item.GameTypes = (Data.Enums.ItemGameTypes)itemDetail.Value.GameTypes; item.LevelRequirement = itemDetail.Value.Level; item.VenderValue = itemDetail.Value.VendorValue; item.ChatCode = itemDetail.Value.GetItemChatLink().ToString(); if (prices.ContainsKey(item.ID)) { item.Prices = prices[item.ID]; } else { item.Prices = new ItemPrices(); // empty, no prices found } // Since there is no need to use ALL details right now, we'll just get what we need... // TODO: Finish this up, get all details, such as Type, SkinID items.Add(item.ID, item); } } catch (GW2NET.Common.ServiceException ex) { // Don't crash, just return null logger.Warn("Error finding item: {0}", ex); } return(items); }
public async static Task <Data.Entities.Inventory> SpawnInventoryItems(int idpj) { Data.Entities.Inventory inventory = new Data.Entities.Inventory(); using (MySqlConnection connection = new MySqlConnection(Data.DatabaseHandler.connectionHandle)) { await connection.OpenAsync().ConfigureAwait(false); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM items WHERE userid = @idpj"; command.Parameters.AddWithValue("@idpj", idpj); DbDataReader reader = await command.ExecuteReaderAsync().ConfigureAwait(false); if (reader.HasRows) { while (await reader.ReadAsync().ConfigureAwait(false)) { int id = reader.GetInt32(reader.GetOrdinal("id")); string name = reader.GetString(reader.GetOrdinal("name")); int type = reader.GetInt32(reader.GetOrdinal("type")); int quantity = reader.GetInt32(reader.GetOrdinal("quantity")); int slot = reader.GetInt32(reader.GetOrdinal("slot")); Data.Entities.Item item = new Data.Entities.Item(id, name, type, quantity); switch (slot) { case 1: inventory.slot1 = item; break; case 2: inventory.slot2 = item; break; case 3: inventory.slot3 = item; break; case 4: inventory.slot4 = item; break; case 5: inventory.slot5 = item; break; case 6: inventory.slot6 = item; break; case 7: inventory.slot7 = item; break; case 8: inventory.slot8 = item; break; case 9: inventory.slot9 = item; break; case 10: inventory.slot10 = item; break; case 11: inventory.slot11 = item; break; case 12: inventory.slot12 = item; break; } } } } return(inventory); }
/// <summary> /// Returns the item information for the items with the given IDs /// </summary> /// <param name="itemIDs">IDs of the items to retrieve</param> /// <returns>Collection of Item objects containing all item information</returns> public IDictionary<int, GW2PAO.API.Data.Entities.Item> GetItems(ICollection<int> itemIDs) { Dictionary<int, GW2PAO.API.Data.Entities.Item> items = new Dictionary<int, GW2PAO.API.Data.Entities.Item>(); try { // Remove all items with itemID of 0 or less var validIDs = itemIDs.Where(id => id > 0).ToList(); var itemService = GW2.V2.Items.ForCurrentUICulture(); var itemDetails = itemService.FindAll(validIDs); var prices = this.GetItemPrices(validIDs); foreach (var itemDetail in itemDetails) { GW2PAO.API.Data.Entities.Item item = new Data.Entities.Item(itemDetail.Key, itemDetail.Value.Name); item.Icon = itemDetail.Value.IconFileUrl; item.Description = itemDetail.Value.Description; item.Rarity = (Data.Enums.ItemRarity)itemDetail.Value.Rarity; item.Flags = (Data.Enums.ItemFlags)itemDetail.Value.Flags; item.GameTypes = (Data.Enums.ItemGameTypes)itemDetail.Value.GameTypes; item.LevelRequirement = itemDetail.Value.Level; item.VenderValue = itemDetail.Value.VendorValue; item.ChatCode = itemDetail.Value.GetItemChatLink().ToString(); if (prices.ContainsKey(item.ID)) item.Prices = prices[item.ID]; else item.Prices = new ItemPrices(); // empty, no prices found // Since there is no need to use ALL details right now, we'll just get what we need... // TODO: Finish this up, get all details, such as Type, SkinID items.Add(item.ID, item); } } catch (GW2NET.Common.ServiceException ex) { // Don't crash, just return null logger.Warn("Error finding item: {0}", ex); } return items; }
/// <summary> /// Returns the item information for the items with the given ID /// </summary> /// <param name="itemID">ID of the item</param> /// <returns>Item object containing all item information, or null if the itemName is invalid</returns> public GW2PAO.API.Data.Entities.Item GetItem(int itemID) { GW2PAO.API.Data.Entities.Item item = null; try { var itemService = GW2.V2.Items.ForCurrentUICulture(); var itemDetails = itemService.Find(itemID); if (itemDetails != null) { item = new Data.Entities.Item(itemID, itemDetails.Name); item.Icon = itemDetails.IconFileUrl; item.Description = itemDetails.Description; item.Rarity = (Data.Enums.ItemRarity)itemDetails.Rarity; item.Flags = (Data.Enums.ItemFlags)itemDetails.Flags; item.GameTypes = (Data.Enums.ItemGameTypes)itemDetails.GameTypes; item.LevelRequirement = itemDetails.Level; item.VenderValue = itemDetails.VendorValue; item.ChatCode = itemDetails.GetItemChatLink().ToString(); item.Prices = this.GetItemPrices(itemID); // Since there is no need to use ALL details right now, we'll just get what we need... // TODO: Finish this up, get all details, such as Type, SkinID } } catch (GW2NET.Common.ServiceException ex) { // Don't crash, just return null logger.Warn("Error finding item with id {0}: {1}", itemID, ex); } return item; }