Esempio n. 1
0
        async private void LoadAllData(Geoposition pos, int radius, int page = 0)
        {
            String url = String.Format("{0}rows=50&categoryId=13927&categoryId=16373&categoryId=24414&categoryId=27022&categoryId=27642&categoryId=31917&location={1},{2}&radius={3}&key={4}&page={5}", this.sensisURL, pos.Coordinate.Latitude, pos.Coordinate.Longitude, radius, this.sensisToken, page);
            //System.Diagnostics.Debug.WriteLine("requesting url {0}", url);
            var request = HttpWebRequest.CreateHttp(url);
            var response = await request.GetResponseAsync();
            var stream = response.GetResponseStream();
            string str;
            using (var sr = new StreamReader(stream))
            {
                str = await sr.ReadToEndAsync();
            }
            var json = JsonObject.Parse(str);
            var statuscode = json.GetNamedNumber("code");
            if (statuscode >= 200 && statuscode < 300)
            {
                this.ShowInstructions = false;
                this.ShowLoader = false;
                this.StatusText = String.Empty;
                var results = json.GetNamedArray("results");
                var count = results.Count;
                for (uint i = 0; i < count; i++)
                {
                    var obj = results.GetObjectAt(i);
                    var newItem = new ShopDataItem(obj);
                    _allShops.Add(newItem);
                }
                addHeadlineShop(ShopCategory.Shoes);
                addHeadlineShop(ShopCategory.Handbags);
                addHeadlineShop(ShopCategory.Jewellery);
                addHeadlineShop(ShopCategory.Sleepwear);
                addHeadlineShop(ShopCategory.Watches);
                addHeadlineShop(ShopCategory.Womenswear);
                this.OnPropertyChanged("ShopsByCategory");

                //totalPages
                int totalPages = Convert.ToInt32(json.GetNamedNumber("totalPages"));
                if (page < totalPages)
                    LoadAllData(pos, radius, page + 1);
                else if (_allShops.Count < 100)
                    LoadAllData(pos, radius + 5);
                else
                    this.isLoading = false;
            }
            else
            {
                this.ShowLoader = false;
                this.StatusText = "Could not retrieve results. Please check your internet connection and try again.";
            }
        }
Esempio n. 2
0
        public void reportShopDisplay(ShopDataItem shop)
        {

        }