/// <summary> /// データファイルを読み込む。 /// /// </summary> /// <param name="dir">フォルダ</param> private void ReadDataFiles(string dir) { string itemsPath = System.IO.Path.Combine(dir, "Items.json"); if (System.IO.File.Exists(itemsPath)) { items = DataItemListParser.Read(itemsPath); } string weaponsPath = System.IO.Path.Combine(dir, "Weapons.json"); if (System.IO.File.Exists(weaponsPath)) { weapons = DataWeaponListParser.Read(weaponsPath); } string armorsPath = System.IO.Path.Combine(dir, "Armors.json"); if (System.IO.File.Exists(armorsPath)) { armors = DataArmorListParser.Read(armorsPath); } Shops.Clear(); string shopPath = System.IO.Path.Combine(dir, "Shops.json"); if (System.IO.File.Exists(shopPath)) { Shops = DataShopListReader.Read(shopPath); if (!Shops.Contains(null)) { Shops.Add(null); } Shops.Sort((a, b) => { if (a == null) { return(-1); } else if (b == null) { return(1); } else { return(a.Id - b.Id); } }); } else { Shops.Add(null); Shops.Add(new DataShop() { Id = 1 }); } }
public static void SortShops() { var shops = Shops.ToList(); shops.Sort(new ShopComparer()); Shops.Clear(); foreach (var shop in shops) { Shops.Add(shop); } }
private void LoadShopsWorker_DoWork(object sender, DoWorkEventArgs e) { Application.Current.Dispatcher.BeginInvoke(new Action(delegate { Mouse.OverrideCursor = Cursors.Wait; }), null); Application.Current.Dispatcher.BeginInvoke(new Action(delegate { Shops.Clear(); }), null); IsBusy = true; LoadingStep = "Chargement des boutiques ..."; Model.Prestashop.PsShopRepository PsShopRepository = new Model.Prestashop.PsShopRepository(); foreach (var shop in PsShopRepository.List()) { if (shop.IDShop == Global.CurrentShop.IDShop) { LoadShopsWorker.ReportProgress(0, shop); } } }
public async Task Loading() { try { Shops.Clear(); List <Shop> allShops = await App.Database.GetShopsAsync(); for (int i = 0; i < allShops.Count; i++) { allShops[i].Number = i + 1; string quantity = (await App.Database.GetItemsByShopAsync(allShops[i].ShopID)).Count.ToString(); switch (quantity) { case "1": quantity = quantity + " pozycja"; break; case "2": case "3": case "4": quantity = quantity + " pozycje"; break; default: quantity = quantity + " pozycji"; break; } allShops[i].NumberOfPositions = quantity; Shops.Add(allShops[i]); } } catch (Exception ex) { UserDialogs.Instance.Alert("Bład!\r\n\r\n" + ex.ToString(), "Błąd", "OK"); } }
async void GetShops() { //IsBusy = true; try { Shops.Clear(); var shopList = await remoteService.GetAllProperty(); foreach (var item in shopList) { if (item.ItemType.ToLower() == "shop") { if (Shops.Count < 3) { Shops.Add(item); } } } } catch (Exception ex) { Debug.WriteLine(ex); } }
/// <summary> /// Loads the houses and shops. /// </summary> public override void Load() { lock ( locker ) { Houses.Clear(); using (var connection = new MySqlConnection(ConnectionString)) using (var command = QueryCommand(connection, "SELECT * FROM Houses WHERE WorldId = @0", Main.worldID)) using (var reader = command.ExecuteReader()) { while (reader.Read()) { var ownerName = reader.Get <string>("OwnerName"); var name = reader.Get <string>("Name"); var x = reader.Get <int>("X"); var y = reader.Get <int>("Y"); var x2 = reader.Get <int>("X2"); var y2 = reader.Get <int>("Y2"); var debt = (decimal)reader.Get <long>("Debt"); var lastTaxed = DateTime.Parse(reader.Get <string>("LastTaxed")); var forSale = reader.Get <int>("ForSale") == 1; var salePrice = reader.Get <string>("SalePrice"); var house = new House(ownerName, name, x, y, x2, y2) { Debt = debt, LastTaxed = lastTaxed, ForSale = forSale, SalePrice = salePrice }; using (var connection2 = new MySqlConnection(ConnectionString)) using (var command2 = QueryCommand(connection2, "SELECT Username FROM HouseHasUser " + "WHERE OwnerName = @0 AND HouseName = @1 AND WorldId = @2", ownerName, name, Main.worldID)) using (var reader2 = command2.ExecuteReader()) { while (reader2.Read()) { var username = reader2.Get <string>("Username"); house.AllowedUsernames.Add(username); } } Houses.Add(house); } } Shops.Clear(); using (var connection = new MySqlConnection(ConnectionString)) using (var command = QueryCommand(connection, "SELECT * FROM Shops WHERE WorldID = @0", Main.worldID)) using (var reader = command.ExecuteReader()) { while (reader.Read()) { var ownerName = reader.Get <string>("OwnerName"); var name = reader.Get <string>("Name"); var x = reader.Get <int>("X"); var y = reader.Get <int>("Y"); var x2 = reader.Get <int>("X2"); var y2 = reader.Get <int>("X2"); var chestX = reader.Get <int>("ChestX"); var chestY = reader.Get <int>("ChestY"); var isOpen = reader.Get <int>("IsOpen") == 1; var message = reader.Get <string>("Message"); var shop = new Shop(ownerName, name, x, y, x2, y2, chestX, chestY) { IsOpen = isOpen, Message = message }; using (var connection2 = new MySqlConnection(ConnectionString)) using (var command2 = QueryCommand(connection2, "SELECT * FROM ShopHasItem WHERE OwnerName = @0 AND ShopName = @1 AND WorldId = @2", ownerName, name, Main.worldID)) using (var reader2 = command2.ExecuteReader()) { while (reader2.Read()) { var index = reader2.Get <int>("ItemIndex"); var itemId = reader2.Get <int>("ItemId"); var stackSize = reader2.Get <int>("StackSize"); var prefixId = (byte)reader2.Get <int>("PrefixId"); shop.Items.Add(new ShopItem(index, itemId, stackSize, prefixId)); } } using (var connection2 = new MySqlConnection(ConnectionString)) using (var command2 = QueryCommand(connection2, "SELECT * FROM ShopHasPrice WHERE OwnerName = @0 AND ShopName = @1 AND WorldId = @2", ownerName, name, Main.worldID)) using (var reader2 = command2.ExecuteReader()) { while (reader2.Read()) { var itemId = reader2.Get <int>("ItemId"); var unitPriceString = reader2.Get <string>("UnitPrice"); shop.UnitPrices[itemId] = new PriceInfo(unitPriceString); } } Shops.Add(shop); } } //load in tax collectors. TaxCollectors.Clear(); TaxCollectorNames.Clear(); using (var connection = new MySqlConnection(ConnectionString)) using (var command = QueryCommand(connection, "SELECT * FROM TaxCollectors WHERE WorldID = @0", Main.worldID)) using (var reader = command.ExecuteReader()) { while (reader.Read()) { var playerName = reader.Get <string>("PlayerName"); var tc = new TaxCollector(playerName); TaxCollectors.Add(tc); TaxCollectorNames.Add(playerName); } } } }