public Zevms027Controller(ILogger <Zevms027Controller> logger, IOptions <AppSettings> appSettings, WZFile wzFile, WzData wzData, zevms027Context dbContext) { _logger = logger; _appSettings = appSettings.Value; _wzFile = wzFile; _wzData = wzData; _context = dbContext; }
public WzData GetWzData() { var wzData = new WzData(); var dic = new Dictionary <int, string>(); try { var stringDir = WZFile.MainDirectory.SingleOrDefault(d => d.Name == "String"); var itemImgFile = stringDir.SingleOrDefault(f => f.Name == "Item.img"); foreach (var imgDir in itemImgFile) { if (imgDir.Name == "Eqp") { foreach (var subImgDir in imgDir) { foreach (var item in subImgDir) { var hasNameNode = item.HasChild("name"); var name = hasNameNode ? item["name"].ValueOrDefault("NO-NAME") : "NO-NAME"; dic.Put(Convert.ToInt32(item.Name), name); } } } else { foreach (var item in imgDir) { var hasNameNode = item.HasChild("name"); var name = hasNameNode ? item["name"].ValueOrDefault("NO-NAME") : "NO-NAME"; dic.Put(Convert.ToInt32(item.Name), name); } } } } catch (Exception ex) { throw ex; } wzData.ItemIdAndNameDic = dic; return(wzData); }
//UNKNOWN(0), //EQUIP(1), //USE(2), //SETUP(3), //ETC(4), //CASH(5), //EQUIPPED(-1); public async Task <IActionResult> LWN_Auction( int inventoryType, string sortOrder, string currentFilter, string searchString, int?pageNumber) { if (inventoryType <= 0) { inventoryType = 1; } ViewData["InventoryType"] = inventoryType; ViewData["CurrentSort"] = sortOrder; ViewData["ItemIdSortParm"] = string.IsNullOrEmpty(sortOrder) ? "id_desc" : ""; ViewData["PriceSortParm"] = sortOrder == "price" ? "price_desc" : "price"; if (searchString != null) { pageNumber = 1; } else { searchString = currentFilter; } ViewData["CurrentFilter"] = searchString; var searchItems = new List <int>(); if (!string.IsNullOrWhiteSpace(searchString)) { searchItems = _wzData.ItemIdAndNameDic.Where(i => i.Value.Contains(searchString)).Select(i => i.Key).ToList(); } var auctionItems = from o in _context.Auctionitems where o.Inventorytype == inventoryType select o; if (!string.IsNullOrEmpty(searchString)) { if (searchItems.Count > 0) { auctionItems = auctionItems.Where(o => searchItems.Contains(o.Itemid.Value)); } } switch (sortOrder) { case "id_desc": auctionItems = auctionItems.OrderByDescending(o => o.Itemid); break; case "price_desc": auctionItems = auctionItems.OrderByDescending(o => o.Price); break; case "price": auctionItems = auctionItems.OrderBy(o => o.Price); break; default: auctionItems = auctionItems.OrderBy(o => o.Itemid); break; } int pageSize = 50; return(View(await PaginatedList <InventoryItemViewModel> .CreateAsync(auctionItems.AsNoTracking().Select(o => new InventoryItemViewModel { Id = o.Id, InventoryType = o.Inventorytype.Value, ItemImageBase64String = WzData.GetImageBase64String(o.Itemid.Value, o.Inventorytype.Value, _wzFile), ItemId = o.Itemid.Value, ItemName = _wzData.ItemIdAndNameDic.ContainsKey(o.Itemid.Value) ? _wzData.ItemIdAndNameDic[o.Itemid.Value] : "", Price = o.Price.Value, Quantity = o.Quantity.Value, OwnerCharacterId = o.Characterid.Value, OwnerCharacterName = o.Character.Name, Strong = o.Str.Value, Dexterity = o.Dex.Value, Intelligence = o.Int.Value, Luck = o.Luk.Value, WAtk = o.Watk.Value, WDef = o.Wdef.Value, MAtk = o.Matk.Value, MDef = o.Mdef.Value, Speed = o.Speed.Value, Jump = o.Jump.Value, DakongCount = ZevmsUtils.GetDakongCount(o.Options), FumoDesc = ZevmsUtils.GetFumoDescription(o.Options), }), pageNumber ?? 1, pageSize))); }