Beispiel #1
0
 private void Update()
 {
     if (this._prevCityParser == this.CityParser)
     {
         return;
     }
     this._unsubscriber.Dispose();
     this._unsubscriber   = this.CityParser.Subscribe(this);
     this._prevCityParser = this.CityParser;
 }
Beispiel #2
0
        static void Main(string[] args)
        {
#if TEST
            string path = "e:\\Projects\\Others\\CityParser\\ImportConsole\\bin\\Debug\\netcoreapp2.1\\CitiesData.json";
#else
            Console.Write("Full path to the file:");
            string path = Console.ReadLine();
#endif

            Console.WriteLine("");
            Console.Write("Start processing..");

            CityParser cityParser = new CityParser(path);
            cityParser.Parse();

            Console.WriteLine(" and finished successfully");
            Console.WriteLine("Press any key pls");
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            ServicePointManager.DefaultConnectionLimit = int.MaxValue;

            //ProxyHelper.VerifyProxies();
            var website = new Website();

            //var bucket = SouqApi.GetProductBucket("xiaomi-redmi-6-dual-sim-32-gb-3-gb-ram-4g-lte-gold-international-version-36234912");
            //var productReviews = SouqApi.GetProductReview("36234912");
            //var sellerReviews = SouqApi.GetSellerReview("alafreetshop");
            //var cookies = SouqApi.GetProductAccessTokens("xd-design-bobby-anti-theft-backpack-black-24168110");
            CityParser             cityParser             = new CityParser();
            CategoryParser         categoryParser         = new CategoryParser();
            CategoryProductsParser categoryProductsParser = new CategoryProductsParser();
            ProductParser          productParser          = new ProductParser();
            SellerParser           sellerParser           = new SellerParser();

            cityParser.Process(website);
            categoryParser.Process(website);
            categoryProductsParser.Process(website);
            productParser.Process(website);
            sellerParser.Process(website);

            var x = JsonConvert.SerializeObject(website);

            File.WriteAllText("dump.json", x);
            Console.WriteLine("Dump Done");

            Console.ReadLine();



            //ExcelStore store = new ExcelStore();
            //store.Store(website);

            //var product = website.CategoryGroups.FlattenCategories().FlattenProducts().First();

            //var token = SouqApi.GetProductAccessTokens(product.Url.ExtractProductFullId()).First().Value;
            //var countryObj = website.Cities.First();
            //SouqApi.GetDeliveryInfo(countryObj.Code, countryObj.Name, product.UnitId, token.hitsCfs, token.hitsCfsMeta);
        }
Beispiel #4
0
        public void MakeCity()
        {
            var file = new XmlDocument();

            file.LoadXml("<City>\n\n" +
                         "<Roads>\n<Road Start=\"3,10\" End=\"42,35\" Width=\"20\" MaxSpeed=\"50\"></Road>\n</Roads>\n\n" +
                         "<Buildings>\n<Building Location=\"12,42\" Size=\"5\"></Building>\n</Buildings>\n\n" +
                         "<Intersections>\n<Intersection Location =\"35,13\" Size=\"5\"></Intersection>\n</Intersections>\n\n" +
                         "</City>");

            var city = CityParser.MakeCity(file, "Test City");

            Assert.AreEqual(1, city.Roads.Count);
            Assert.AreEqual(1, city.Buildings.Count);

            Assert.AreEqual(new Vector(3, 10), city.Roads[0].Start);
            Assert.AreEqual(new Vector(42, 35), city.Roads[0].End);
            Assert.AreEqual(20, city.Roads[0].Width);
            Assert.AreEqual(50, city.Roads[0].MaxSpeed);

            Assert.AreEqual(new Vector(12, 42), city.Buildings[0].Location);
            Assert.AreEqual(5, city.Buildings[0].Size);
        }
Beispiel #5
0
        public void LoadButtonClick()
        {
            // Loads the city file and parses the information into a City.
            var file = new XmlDocument();

            try
            {
                file.Load(SelectedFilePath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please select a City", "No city selected!", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            try
            {
                var cityname = Screen.TBCity.Text;
                CityParser.MakeCity(file, cityname.First().ToString().ToUpper() + cityname.Substring(1));
            }
            catch (Exception ex)
            {
                MessageBox.Show("There is an error in the city file.", "Invalid City File", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var city = CitySystem.City.Instance;

            Screen.CityRenderHandler.DrawCity(city);

            Screen.PropertyDisplayHandler.UpdateProperties();

            EnableButtonsAndTabs();
            UpdateCountLabels(city);

            SimulationLoad?.Invoke(this, new SimulationEventArgs(CitySystem.City.Instance));
        }
Beispiel #6
0
 void Start()
 {
     this._unsubscriber   = this.CityParser.Subscribe(this);
     this._prevCityParser = this.CityParser;
 }
Beispiel #7
0
 public MainWindow() : base(Gtk.WindowType.Toplevel)
 {
     Build();
     cities = CityParser.ParseCities();
 }