예제 #1
0
        public List <AddressDTO> ProcessDataToDictionary(CityAddressCollecton data)
        {
            var addressBook = new List <AddressDTO>();

            Parallel.ForEach(data.AddressBook, addressDataItem =>
            {
                var addressdata         = new AddressDTO();
                var JsonData            = JsonConvert.SerializeObject(addressDataItem);
                var addressDictionary   = JsonConvert.DeserializeObject <Dictionary <string, string> >(JsonData);
                addressdata.AddressData = addressDictionary;
                addressdata.Key         = addressDataItem.HASH;
                addressBook.Add(addressdata);
            });
            return(addressBook);
        }
예제 #2
0
        public CityAddressCollecton ProcessDataCsv(string filepath)
        {
            var book = new CityAddressCollecton();

            book.City = filepath;
            using (TextReader fileReader = File.OpenText(filepath))
            {
                var csv = new CsvReader(fileReader);
                csv.Configuration.HasHeaderRecord = false;
                csv.Read();
                book.AddressBook = csv.GetRecords <AddressModel>().ToList();
            }



            return(book);
        }