Esempio n. 1
0
        public void TestgetCoordinates()
        {
            Listing TestListing = new Listing("Jomfru Ane Gade", "28", 9000);
              string StreetNameTest = string.Empty;
              string HouseNumberTest = string.Empty;
              int AreaCodeTest = 0;
              string address = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + TestListing.AddressForUrl + "&sensor=false";

              var result = new System.Net.WebClient().DownloadString(address);
              XmlDocument doc = new XmlDocument();
              doc.LoadXml(result);

              XmlNodeList AddressComponents = doc.GetElementsByTagName("address_component");
              //  XmlNodeList houseNumberNode = doc.GetElementsByTagName("./address_component[type = 'street_number']");
              //XmlNodeList areaCodeNode = doc.GetElementsByTagName("./address_component[type = 'postal_code']");
              foreach (XmlNode childNode in AddressComponents)
              {
            if (childNode.SelectSingleNode("type").InnerText == "route")
            {
              StreetNameTest = childNode.SelectSingleNode("long_name").InnerText;
            }
            else if (childNode.SelectSingleNode("type").InnerText == "street_number")
            {
              HouseNumberTest = childNode.SelectSingleNode("long_name").InnerText;
            }
            else if (childNode.SelectSingleNode("type").InnerText == "postal_code")
            {
              AreaCodeTest = int.Parse(childNode.SelectSingleNode("long_name").InnerText);
            }
              }
              Assert.AreEqual(TestListing.StreetName, StreetNameTest);
              Assert.AreEqual(TestListing.HouseNumber, HouseNumberTest);
              Assert.AreEqual(TestListing.AreaCode, AreaCodeTest);
        }
Esempio n. 2
0
        public void getCoordinates(Listing listing)
        {
            System.Threading.Thread.Sleep(250);

              string address = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + listing.AddressForUrl + "&sensor=false";

              var result = new System.Net.WebClient().DownloadString(address);
              XmlDocument doc = new XmlDocument();
              doc.LoadXml(result);
              string status = doc.DocumentElement.SelectSingleNode("/GeocodeResponse/status").InnerText;
              XmlNodeList parentNode = doc.GetElementsByTagName("location");

              if (status == "OK")
              {
            foreach (XmlNode childrenNode in parentNode)
            {
              System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
              customCulture.NumberFormat.NumberDecimalSeparator = ".";
              System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;
              listing.Lat = Convert.ToDouble(childrenNode.SelectSingleNode("lat").InnerText);
              listing.Lng = Convert.ToDouble(childrenNode.SelectSingleNode("lng").InnerText);
            }
              }
              else if (status == "ZERO_RESULTS")
              {
            _windowManager.ShowDialog(new bogipopupViewModel("Adressen kunne ikke findes."));
              }
              else if (status == "OVER_QUERY_LIMIT")
              {
            _windowManager.ShowDialog(new bogipopupViewModel("Kvoten af lookups er opbrugt."));
              }
        }
Esempio n. 3
0
 public IsFlyoutOpenMsg(bool isOpen, Listing selectedListing)
 {
     SelectedListing = selectedListing;
       IsOpen = isOpen;
 }
Esempio n. 4
0
 public PropertyInfoViewModel(Listing ls, IWindowManager windowManager)
 {
     _windowManager = windowManager;
       _propertyToShow = ls;
 }
Esempio n. 5
0
        private string SqlStringBuilderSold(SearchSettingModel input)
        {
            string sql = System.String.Format("SELECT address.IDAddress AS id, address.StreetName AS streetName, address.HouseNumber AS houseNumber, address.AreaCode AS areaCode, listings.PropertyType AS propertyType, listings.Size AS size, listings.NumberOfRooms AS numberOfRooms, listings.YearBuild AS yearBuilt, salesinfosold.SalesType AS salesType, salesinfosold.Price AS price, salesinfosold.PriceSqr AS priceSqr, salesinfosold.SalesDate AS salesDate FROM address, listings, salesinfosold WHERE address.IDAddress = listings.IDListings AND address.IDAddress = salesinfosold.IDSalesInfoSold AND ");

              string[] split = { "Unknown" };
              Listing SearchListing;
              string SearchAddress = string.Empty;
              if (input.SearchInput != null)
              {
            split = input.SearchInput.Split(' ');
            if (split.Length == 3)
            {
              SearchListing = new Listing(split[0].Trim(' '), split[1], int.Parse(split[2]));
            }
            else
            {
              for (int i = 0; i < split.Length - 3; i++)
              {
            SearchAddress += split[i] + " ";
              }
              SearchListing = new Listing(SearchAddress.Trim(' '), split[split.Length - 2], int.Parse(split[split.Length - 1]));
            }
            getCoordinates(SearchListing);

            if (input.AreaSliderLowerValue >= 0.0 && input.AreaSliderHigherValue > 0.0 && input.SameRoad == false && input.SameZipCode == false)
            {
              sql = System.String.Format("SELECT address.IDAddress AS id, address.StreetName AS streetName, address.HouseNumber AS houseNumber, address.AreaCode AS areaCode, listings.PropertyType AS propertyType, listings.Size AS size, listings.NumberOfRooms AS numberOfRooms, listings.YearBuild AS yearBuilt, salesinfosold.SalesType AS salesType, salesinfosold.Price AS price, salesinfosold.PriceSqr AS priceSqr, salesinfosold.SalesDate AS salesDate, 111.045 * DEGREES(ACOS(COS(RADIANS({0})) * COS(RADIANS(Lat)) * COS(RADIANS({1}) - RADIANS(Lng)) + SIN(RADIANS({0})) * SIN(RADIANS(Lat)))) * 1000 AS distance_in_m FROM address, listings, salesinfosold JOIN( SELECT  {0}  AS latpoint, {1} AS longpoint ) AS p ON 1 = 1 WHERE address.IDAddress = listings.IDListings AND address.IDAddress = salesinfosold.IDSalesInfoSold AND ", SearchListing.Lat, SearchListing.Lng);
            }
              }

              string sqlOr = "(";
              string AndOr = string.Empty;
              string proptype = "listings.PropertyType = ";
              List<bool> PropTypes = new List<bool> { input.Andelsbolig, input.Sommerhus, input.Lejlighed, input.Rækkehus, input.Villa, input.Andet };

              List<bool> PropTypeChecked = new List<bool>();
              foreach (var item in PropTypes)
              {
            if (item)
            {
              PropTypeChecked.Add(item);
            }
              }
              int count = PropTypeChecked.Count;

              if (input.Andelsbolig)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Andelsbolig\" " + AndOr;
            count--;
              }

              if (input.Villa)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Villa\" " + AndOr;
            count--;
              }

              if (input.Rækkehus)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Rækkehus\" " + AndOr;
            count--;
              }

              if (input.Lejlighed)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Lejlighed\" " + AndOr;
            count--;
              }
              if (input.Sommerhus)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Sommerhus\" " + AndOr;
            count--;
              }
              if (input.Andet)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Andet\" " + AndOr;
            count--;
              }

              sqlOr += ") AND ";

              if (PropTypeChecked.Count != 0)
              {
            sql += sqlOr;
              }

              if (input.PriceSliderHigherValue > 0.0)
              {
            sql += System.String.Format("salesinfosold.Price >= {0} AND salesinfosold.Price <= {1} AND ", input.PriceSliderLowerValue, input.PriceSliderHigherValue);
              }

              if (input.SizeSliderHigherValue > 0.0)
              {
            sql += System.String.Format("listings.Size >= {0} AND listings.Size <= {1} AND ", input.SizeSliderLowerValue, input.SizeSliderHigherValue);
              }

              if (input.SameRoad)
              {
            sql += System.String.Format("address.StreetName = \"{0}\" AND ", split[0].Trim(','));
              }

              if (input.SameZipCode)
              {
            sql += System.String.Format("address.AreaCode = {0} AND ", int.Parse(split[2]));
              }

              sql += System.String.Format("listings.NumberOfRooms >= {0} AND listings.NumberOfRooms <= {1} ",
              input.MinRoomCount, input.MaxRoomCount);

              if (input.AreaSliderLowerValue >= 0.0 && input.AreaSliderHigherValue > 0.0 && input.SameRoad == false && input.SameZipCode == false)
              {
            sql += System.String.Format("HAVING distance_in_m <= {0} ", input.AreaSliderHigherValue);
              }

              sql += "LIMIT 25";

              return sql;
        }