Beispiel #1
0
        void parseLocalHelpData(string type, string jsonString)
        {
            try
            {
                JObject parsedData = JObject.Parse(jsonString.Replace("microsoftMapsNetworkCallback(", "").Replace(".d},'r229');", "}"));
                foreach (var data in parsedData)
                {
                    if (data.Key.Equals("response"))
                    {
                        if (nearbyPlaceList == null)
                        {
                            nearbyPlaceList = new List <NearByPlaceDetails>();
                        }
                        NearByPlaceDetails nearByPlaceDetails;
                        foreach (var result in data.Value)
                        {
                            foreach (var child in result.First["SearchResults"])
                            {
                                nearByPlaceDetails             = new NearByPlaceDetails();
                                nearByPlaceDetails.Name        = child["Name"].ToString();
                                nearByPlaceDetails.Vicinity    = child["Address"].ToString() + (!string.IsNullOrEmpty(child["City"].ToString()) ? "," : "") + child["City"].ToString() + (!string.IsNullOrEmpty(child["State"].ToString()) ? "," : "") + child["State"].ToString() + (!string.IsNullOrEmpty(child["PostalCode"].ToString()) ? "," : "") + child["PostalCode"].ToString() + (!string.IsNullOrEmpty(child["Country"].ToString()) ? "," : "") + child["Country"].ToString() + (!string.IsNullOrEmpty(child["Phone"].ToString()) ? "," : "") + child["Phone"].ToString();
                                nearByPlaceDetails.Latitude    = child["Location"]["Latitude"].ToString();
                                nearByPlaceDetails.Longitude   = child["Location"]["Longitude"].ToString();
                                nearByPlaceDetails.Category    = type;
                                nearByPlaceDetails.PhoneNumber = child["Phone"].ToString();
                                nearbyPlaceList.Add(nearByPlaceDetails);
                            }
                        }
                    }
                }

                if (nearbyPlaceList != null && nearbyPlaceList.Count > 0)
                {
                    NoDataMsgText.Visibility      = Visibility.Collapsed;
                    localhelpLongList.Visibility  = Visibility.Visible;
                    localhelpLongList.ItemsSource = nearbyPlaceList.OrderByDescending(a => a.Category).ToList();
                }
                else
                {
                    NoDataMsgText.Visibility     = Visibility.Visible;
                    localhelpLongList.Visibility = Visibility.Collapsed;
                }
                if (IsLocalHelpLoaded)
                {
                    ShowProgressBar(false);
                }
            }
            catch (Exception)
            {
                NoDataMsgText.Visibility     = Visibility.Visible;
                localhelpLongList.Visibility = Visibility.Collapsed;

                ShowProgressBar(false);
            }
        }
Beispiel #2
0
        public void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            List <NearByPlaceDetails> nearbyPlaceList = null;

            try
            {
                JObject parsedData = JObject.Parse(e.Result);

                foreach (var data in parsedData)
                {
                    if (data.Key.Equals("results"))
                    {
                        nearbyPlaceList = new List <NearByPlaceDetails>();
                        NearByPlaceDetails nearByPlaceDetails;
                        foreach (var result in data.Value)
                        {
                            nearByPlaceDetails           = new NearByPlaceDetails();
                            nearByPlaceDetails.Name      = result["name"].ToString();
                            nearByPlaceDetails.Vicinity  = result["vicinity"].ToString();
                            nearByPlaceDetails.Latitude  = result["geometry"]["location"]["lat"].ToString();
                            nearByPlaceDetails.Longitude = result["geometry"]["location"]["lng"].ToString();
                            nearByPlaceDetails.Category  = result["types"][0].ToString();
                            nearbyPlaceList.Add(nearByPlaceDetails);
                        }
                    }
                }

                if (nearbyPlaceList != null && nearbyPlaceList.Count > 0)
                {
                    NoDataMsgText.Visibility      = Visibility.Collapsed;
                    localhelpLongList.Visibility  = Visibility.Visible;
                    localhelpLongList.ItemsSource = nearbyPlaceList.OrderByDescending(a => a.Category).ToList();
                }
                else
                {
                    NoDataMsgText.Visibility     = Visibility.Visible;
                    localhelpLongList.Visibility = Visibility.Collapsed;
                }

                ShowProgressBar(false);
            }
            catch (Exception)
            {
                NoDataMsgText.Visibility     = Visibility.Visible;
                localhelpLongList.Visibility = Visibility.Collapsed;

                ShowProgressBar(false);
            }
        }