/// <summary>
 /// Verifies the exists.
 /// </summary>
 private void VerifyExists()
 {
     if (!Shops.Exists(_databasePath, _shopsName, out _errOut))
     {
         bool value = Shops.Add(_databasePath, _shopsName, out _errOut);
     }
 }
        public void AddQuickTest()
        {
            VerifyDoesntExist();
            bool value = Shops.Add(_databasePath, _shopsName, out _errOut);

            General.HasTrueValue(value, _errOut);
        }
Example #3
0
        /// <summary>
        /// 店数変更処理されたときに通知を受け取る。
        /// </summary>
        /// <param name="sender">送信元オブジェクト</param>
        /// <param name="e">イベントオブジェクト</param>
        private void OnButtonChangeShopCountClick(object sender, EventArgs e)
        {
            FormNumberInput form = new FormNumberInput();

            form.Number = Shops.Count - 1;
            if (form.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            int newCount = form.Number + 1;

            if (newCount >= Shops.Count)
            {
                while (Shops.Count < newCount)
                {
                    int id = Shops.Count;
                    Shops.Add(new DataShop()
                    {
                        Id = id
                    });
                }
            }
            else if (newCount < Shops.Count)
            {
                while (Shops.Count > newCount)
                {
                    Shops.RemoveAt(Shops.Count - 1);
                }
            }

            ModelToUI();
        }
Example #4
0
        private async Task ParceSite(string url, ChromeDriver catchedChromeDriver)
        {
            try
            {
                var shop = new Shop()
                {
                    RRLink   = url,
                    Category = Category
                };

                var doc = new HtmlDocument();
                lock (catchedChromeDriver)
                {
                    catchedChromeDriver.Url = url;
                    doc.LoadHtml(catchedChromeDriver.PageSource);
                }

                var storeLabelNode = doc.DocumentNode.SelectSingleNode("//*[@id=\"store-label\"]/h1/a");
                if (storeLabelNode != null)
                {
                    shop.Name = storeLabelNode.InnerText;
                    shop.Link = storeLabelNode.GetAttributeValue("href", string.Empty);
                }
                var reviewsLabelNode = doc.DocumentNode.SelectSingleNode("//*[@id=\"store-label\"]/div[3]/div[2]/span/strong/span");
                if (reviewsLabelNode != null)
                {
                    shop.Reviews = int.Parse(reviewsLabelNode.InnerText.Replace(",", ""));
                }
                var descriptionLabelNode = doc.DocumentNode.SelectSingleNode("//*[@id=\"store_view\"]/section/div/div/div[2]/div/div[3]/div[2]/h6");
                if (descriptionLabelNode != null)
                {
                    shop.Description = descriptionLabelNode.InnerText;
                }
                var addressLabelNode = doc.DocumentNode.SelectSingleNode("//*[@id=\"store_view\"]/section/div/div/div[2]/div/div[3]/div[5]/div[3]/h5[2]");
                if (addressLabelNode != null)
                {
                    shop.Address = addressLabelNode.InnerHtml;
                }

                shop.Merch = await GetMerch(shop.Link);

                using (var httpClient = new HttpClient())
                {
                    var response = await httpClient.GetAsync(shop.Link);

                    if (!response.IsSuccessStatusCode)
                    {
                        Dead++;
                        shop.AccessibleFromUa = false;
                    }
                }
                Shops.Add(shop);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Example #5
0
 public void CreateShop(int id, string name)
 {
     if (!Shops.TryGetValue(id, out var outShop))
     {
         var shop = new Shop(id, name);
         Shops.Add(shop.Id, shop);
     }
 }
Example #6
0
        /// <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
                });
            }
        }
Example #7
0
 public ShopService AddFurniture(string location, ShopItemInfo shopItemInfo)
 {
     if (!ShopFurniture.TryGetValue(location, out var items))
     {
         ShopFurniture.Add(location, items = new List <ShopItemInfo>());
     }
     items.Add(shopItemInfo);
     Shops.Add(location);
     return(this);
 }
        public static void SortShops()
        {
            var shops = Shops.ToList();

            shops.Sort(new ShopComparer());
            Shops.Clear();
            foreach (var shop in shops)
            {
                Shops.Add(shop);
            }
        }
Example #9
0
    protected override void Inititalize <T>(IShop type, Transform thisGO)
    {
        Shops.Add(this);

        Cells = new List <Cell>();

        Path = "Shop/ProteinShop";

        base.Inititalize <T>(type, thisGO);

        PlayerAttributes.Properties.OnLevelChanged += LevelChanged_OnLevelChanged;
    }
 public void AddNewBuilding(Location l)
 {
     if (l.Building is Warehouse)
     {
         Warehouses.Add(l);
     }
     else if (l.Building is Shop)
     {
         Shops.Add(l);
         applyShopRadiusToCells(l);
     }
 }
Example #11
0
        public DataContext()
        {
            Database.EnsureCreated();
            Instance = this;

            Products.Add(new Product());
            Checks.Add(new Check());
            Customers.Add(new Customer());
            Employees.Add(new Employee());
            DailyReports.Add(new DailyReport());
            ProductUnits.Add(new ProductUnit());
            Shops.Add(new Shop());
        }
Example #12
0
        public async void OpenNewShopAcion()
        {
            try
            {
                //await Navigation.PushAsync(new AddShopPage());
                PromptResult result = await UserDialogs.Instance.PromptAsync(new PromptConfig
                {
                    Message       = "Wprowadź nazwę sklepu",
                    CancelText    = "Anuluj",
                    InputType     = InputType.Name,
                    IsCancellable = true,
                    OkText        = "Dodaj",
                    Placeholder   = "wprowadź nazwę",
                    Title         = "Nowy sklep",
                });

                if (result.Ok)
                {
                    if (!string.IsNullOrEmpty(result.Text))
                    {
                        //string text = result.Text.First().ToString().ToUpper() + result.Text.Substring(1);
                        Shop checkShop = await App.Database.GetShopByName(result.Text.First().ToString().ToUpper() + result.Text.Substring(1));

                        if (checkShop != null)
                        {
                            UserDialogs.Instance.Alert("Sklep o podanej nazwie już istnieje!", "Błąd", "OK");
                            return;
                        }

                        await App.Database.SaveShopAsync(new Shop { Name = result.Text.First().ToString().ToUpper() + result.Text.Substring(1) });

                        Shop shop = (await App.Database.GetShopsAsync()).LastOrDefault();
                        shop.Number            = Shops.Count + 1;
                        shop.NumberOfPositions = "0 pozycji";
                        Shops.Add(shop);
                        UserDialogs.Instance.Toast("Dodano nowy sklep.");
                        //MessagingCenter.Send(this, "Refresh");
                        //await Navigation.PopToRootAsync();
                    }
                    else
                    {
                        UserDialogs.Instance.Alert("Wprowadź poprawną nazwę sklepu!", "Błąd", "OK");
                    }
                }
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.Alert("Bład!\r\n\r\n" + ex.ToString(), "Błąd", "OK");
            }
        }
Example #13
0
        /// <summary>
        /// Adds a new <c>Shop</c>-Object to the <c>Shops</c>-Collection.
        /// </summary>
        /// <param name="shop">The <c>Shop</c>-Object that should added to the <c>Shops</c>-Collection.</param>
        public void AddShop(Shop shop)
        {
            // Add Shop to collection
            Shops.Add(shop);

            // Save shops to isolated storage
            SaveShops();

            // Notify for change
            this.RaisePropertyChanged(() => Shops);

            // Create new Geofence
            ServiceLocator.Current.GetInstance <GeoHelper>().AddGeofence(shop);
        }
Example #14
0
        private void ReadShops(string shopsPath)
        {
            List <string> buffer = new List <string>();

            using (StreamReader sr = new StreamReader(shopsPath))
                while (!sr.EndOfStream)
                {
                    buffer.Add(sr.ReadLine());
                }

            foreach (string s in buffer)
            {
                Shops.Add(new Shop(s.Split(';')[0], s.Split(';')[1], s.Split(';')[2]));
            }
        }
Example #15
0
        public int RegisterShop(ShopSystem.Shop shop)
        {
            var findShop = (from s in Shops select s.ShopID);
            int lastShop = 0;

            if ((findShop != null) && (findShop.Count() > 0))
            {
                lastShop = findShop.Max();
            }

            shop.ShopID = lastShop + 1;
            Shops.Add(shop);
            Save(true);
            return(shop.ShopID);
        }
Example #16
0
        private void InitializeShopDataTable()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn()
            {
                DataType   = typeof(string),
                ColumnName = "id",
            });
            dataGridViewShops.DataSource = dt;

            Shops.Add(null);
            Shops.Add(new DataShop()
            {
                Id = 1
            });
        }
        /// <summary>
        ///     Adds a shop with the specified properties.
        /// </summary>
        /// <param name="owner">The owner, which must not be <c>null</c>.</param>
        /// <param name="name">The name, which must not be <c>null</c> and logged in.</param>
        /// <param name="x">The first X coordinate.</param>
        /// <param name="y">The first Y coordinate.</param>
        /// <param name="x2">The second X coordinate, which must be at least the first.</param>
        /// <param name="y2">The second Y coordinate, which must be at least the second.</param>
        /// <param name="chestX">The chest X coordinate.</param>
        /// <param name="chestY">The chest Y coordinate.</param>
        /// <returns>The resulting shop.</returns>
        public override Shop AddShop(TSPlayer owner, string name, int x, int y, int x2, int y2, int chestX, int chestY)
        {
            Debug.Assert(name != null, "Name must not be null.");
            Debug.Assert(owner != null, "Owner must not be null.");
            Debug.Assert(owner.User != null, "Owner must be logged in.");
            Debug.Assert(x2 >= x, "Second X coordinate must be at least the first.");
            Debug.Assert(y2 >= y, "Second Y coordinate must be at least the first.");

            lock ( locker )
            {
                NonQuery(
                    "INSERT INTO Shops (OwnerName, Name, WorldId, X, Y, X2, Y2, ChestX, ChestY, IsOpen)" +
                    "VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9)",
                    owner.User.Name, name, Main.worldID, x, y, x2, y2, chestX, chestY, 0);
                var shop = new Shop(owner.User.Name, name, x, y, x2, y2, chestX, chestY);
                Shops.Add(shop);
                return(shop);
            }
        }
        public ShopController(string shopName) // Определяет текущий магазин. Если такого нет, то создает новый.
        {
            Shops = GetShopsData();

            CurrentShop = Shops.SingleOrDefault(s => s.Name == shopName);

            if (CurrentShop == null)
            {
                CurrentShop = new Shop(shopName);
                Shops.Add(CurrentShop);
                IsNewShop = true;
                SaveShops();
            }

            else
            {
                CurrentShop.Products = GetAllProducts();
            }
        }
 public void AddNewShop(string name) // Добавляю новый магазин. Либо, если такой уже есть, то делаю его текущим.
 {
     if (String.IsNullOrWhiteSpace(name))
     {
         Console.WriteLine("Название магазина не заполнено. Вернитесь в меню и повторите попытку.\n");
     }
     else
     {
         CurrentShop = Shops.SingleOrDefault(s => s.Name == name);
         if (CurrentShop == null)
         {
             CurrentShop = new Shop(name);
             Shops.Add(CurrentShop);
             IsNewShop = true;
             SaveShops();
         }
         else
         {
             CurrentShop.Products = GetAllProducts();
         }
     }
 }
Example #20
0
        void LoadDataFromXML()
        {
            List <string> productGroupNames = new List <string>();
            XDocument     document          = DataLoader.LoadXmlFromResources("/Data/Sales.xml");

            if (document != null)
            {
                foreach (XElement element in document.Element("Sales").Elements())
                {
                    string shopName    = element.Element("ShopName").Value;
                    string shopAddress = element.Element("ShopAddr").Value;
                    string shopPhone   = element.Element("ShopPhone").Value;
                    string shopFax     = element.Element("ShopFax").Value;
                    var    sw          = new Stopwatch();
                    sw.Start();
                    ShopInfoViewModel info = ViewModelSource.Create(() => new ShopInfoViewModel(shopName, shopAddress, shopPhone, shopFax));
                    sw.Stop();
                    foreach (XElement statElement in element.Element("ShopStatistics").Elements())
                    {
                        string groupName = statElement.Element("ProductsGroupName").Value;
                        if (!productGroupNames.Contains(groupName))
                        {
                            productGroupNames.Add(groupName);
                        }
                        double sales = Convert.ToDouble(statElement.Element("ProductGroupSales").Value, CultureInfo.InvariantCulture);
                        info.AddProductGroup(groupName, sales);
                    }
                    GeoPoint geoPoint = new GeoPoint(Convert.ToDouble(element.Element("Latitude").Value, CultureInfo.InvariantCulture), Convert.ToDouble(element.Element("Longitude").Value, CultureInfo.InvariantCulture));
                    info.ShopLocation = geoPoint;
                    Shops.Add(info);
                }
            }
            foreach (string groupName in productGroupNames)
            {
                ActualStatistics.Add(ViewModelSource.Create(() => new ProductGroupViewModel(0.0, groupName)));
            }
            UpdateTotalStatistics();
        }
Example #21
0
        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");
            }
        }
Example #22
0
        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);
            }
        }
Example #23
0
 public void ProcessUserInput(Shop shop)
 {
     Shops.Add(shop);
 }
Example #24
0
        public void UpdateDefaults()
        {
            bool needSave = false;

            if (Admins.Count == 0)
            {
                logger.Info("Adding default admin");
                Admins.AddAdmin("76561198003534614", 100);
                needSave = true;
            }
            GlobalShop = (from s in Shops where s.ShopID == 0 select s).FirstOrDefault();
            if ((GlobalShop != null) && !EnableProtection)
            {
                logger.Info("Removing global shop (EnableProtection = false)");
                Shops.Remove(GlobalShop);
                GlobalShop = null;
                needSave   = true;
            }
            else
            if ((GlobalShop == null) && EnableProtection)
            {
                logger.Info("Adding global shop");
                GlobalShop = new Shop
                {
                    ShopName     = "Serverwide Shop",
                    ShopRestocks = false,
                    ShopID       = 0,
                };
                GlobalShop.RegisterItem(new ShopItem
                {
                    ItemName      = "One RL Day Protection",
                    SellPrice     = ProtectionPriceOneDay,
                    StockAmount   = 100,
                    RestockAmount = -1,
                    BuyPrice      = 1,
                    HandlerName   = "ProtectionShopHandler"
                });
                GlobalShop.RegisterItem(new ShopItem
                {
                    ItemName      = "One RL week Protection",
                    SellPrice     = ProtectionPriceOneWeek,
                    StockAmount   = 100,
                    RestockAmount = -1,
                    BuyPrice      = 7,
                    HandlerName   = "ProtectionShopHandler"
                });
                GlobalShop.RegisterItem(new ShopItem
                {
                    ItemName      = "One RL Month Protection",
                    SellPrice     = ProtectionPriceOneMonth,
                    StockAmount   = 100,
                    RestockAmount = -1,
                    BuyPrice      = 30,
                    HandlerName   = "ProtectionShopHandler"
                });
                Shops.Add(GlobalShop);
                needSave = true;
            }
            if (GlobalShop != null)
            {
                GlobalShop.GlobalShop = true;
            }
            if (needSave)
            {
                Save(true);
            }
        }
Example #25
0
 public void AddShop(Shop shop)
 {
     Shops.Add(shop);
 }
Example #26
0
 private void LoadShopsWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(
                                                    delegate { Shops.Add(e.UserState as Model.Prestashop.PsShop); }), null);
 }
        /// <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);
                            }
                        }
            }
        }