Пример #1
0
        internal void Import()
        {
            var repo = new AddressRepository();
            using (var engine = new FileHelperAsyncEngine<REDPostalAddressImport>())
            {
                engine.BeginReadFile(_fileName);

                var swWrite = Stopwatch.StartNew();
                var processed = 0L;

                var postalAddresses = new List<PostalAddress>();
                foreach (REDPostalAddressImport postalAddress in engine)
                {
                    postalAddresses.Add(Convert(postalAddress));
                    if (postalAddresses.Count == 100000)
                    {
                        processed += postalAddresses.Count;

                        repo.Write(postalAddresses);
                        postalAddresses.Clear();

                        Console.WriteLine("Processed {0} in {1}", processed, swWrite.Elapsed);
                        swWrite.Restart();
                    }
                }
                if (postalAddresses.Count > 0)
                {
                    repo.Write(postalAddresses);
                    processed += postalAddresses.Count;
                    Console.WriteLine("Processed {0} in {1}", processed, swWrite.Elapsed);
                }
            }
        }
Пример #2
0
 public AddressController()
 {
     _addressRepo = new AddressRepository() { GetExplanations = bool.Parse(ConfigurationManager.AppSettings["GetExplanations"] ?? "false") };
 }