Beispiel #1
0
        public static void SaveUpdateSold(ListingSold property)
        {
            using (StreamWriter tw = new StreamWriter(savefile + "DBListings.csv", true))
              {
            tw.WriteLine("{0};{1};{2};{3};{4}", property.ID, property.PropertyType, property.Size, property.Rooms, property.YearBuilt);
              }

              using (StreamWriter tw = new StreamWriter(savefile + "DBAddress.csv", true))
              {
               tw.WriteLine("{0};{1};{2};{3};{4};{5}", property.ID, property.StreetName, property.HouseNumber, property.AreaCode,
               property.Lat, property.Lng);
              }
              using (StreamWriter tw = new StreamWriter(savefile + "DBSalesInfoSold.csv", true))
              {
            tw.WriteLine("{0};{1};{2};{3};{4}", property.ID, property.SalesType, property.Price, property.Sqrprice, property.SalesDate);
              }
        }
Beispiel #2
0
        public static void importSold(Dictionary<int, ListingSold> dict)
        {
            var reader = new StreamReader(File.OpenRead(savefile + "HackSolgte.csv"), Encoding.UTF8);
              while (!reader.EndOfStream)
              {
                var line = reader.ReadLine();

            string[] values = line.Split(',');

            int room;
                if (values[0] == "-")
                {
                  room = 0;
                }
                else
                {
                  room = Convert.ToInt32(values[0]);
                }
                string salesType = values[1];
                int sizeHouse;
                if (values[2] == "-")
                {
                  sizeHouse = 0;
                }
                else
                {
                  sizeHouse = Convert.ToInt32(values[2]);
                }
                string uncleanSqrPrice;
                if (values[3] == "-")
                {
                  uncleanSqrPrice = "0";
                }
                else
                {
                  uncleanSqrPrice = values[3];
                }
                int cleansqrprice = Convert.ToInt32(uncleanSqrPrice.Replace(".", ""));
                int yearBuilt;
                if (values[4] == "-")
                {
                  yearBuilt = 0;
                }
                else
                {
                  yearBuilt = Convert.ToInt32(values[4]);
                }
                string uncleanPrice = values[5];
                if (values[5] == "-")
                {
                  uncleanPrice = "0";
                }
                else
                {
                  uncleanPrice = values[5];
                }
                int cleanPrice = Convert.ToInt32(uncleanPrice.Replace(".", ""));
                string salesDate = values[6];
                string adresse = values[7];
                string streetName = String.Empty;
                string houseNumber = String.Empty;
                Match regexMatch = Regex.Match(adresse, "\\d");
                if (regexMatch.Success)
                {
                    int digitStartIndex = regexMatch.Index;
                    streetName = adresse.Substring(0, digitStartIndex - 1);
                    string uncleanHouseNumber = adresse.Substring(digitStartIndex);
                    string[] uncleanHousenumber = uncleanHouseNumber.Split(' ');
                    houseNumber = uncleanHousenumber[0];
                }
                string propertyType = values[8];
                int areaCode = Convert.ToInt32(values[9]);

            ListingSold listing = new ListingSold(streetName, houseNumber, room, areaCode, cleanPrice, sizeHouse, yearBuilt, salesDate, cleansqrprice, salesType, propertyType);
            dict.Add(listing.ID, listing);
            }
        }