コード例 #1
0
        public void LoadData_should_read_excel_data()
        {
            var spreadsheet = new LocalitiesSpreadsheet();
            var results     = spreadsheet.LoadData();
            var collection  = results as Locality[] ?? results.ToArray();

            Assert.NotEmpty(collection);

            var data = collection.Single(x => x.Postcode == "6023");

            data.Suburb.Should().Be("DUNCRAIG");
        }
コード例 #2
0
ファイル: DataImporter.cs プロジェクト: lulzzz/vita
        private void ImportLocalities()
        {
            var ss = new LocalitiesSpreadsheet();

            foreach (var item in ss.LoadData().Where(x => !string.IsNullOrEmpty(x.Suburb)))
            {
                var found = _localitiesRepository.Find(x =>
                                                       !string.IsNullOrWhiteSpace(x.Suburb) && x.Suburb.Trim() == item.Suburb.Trim());
                var xxx = found.ToList();
                if (xxx.Any())
                {
                    Log.Debug("Locality skipped {desc}", item.Suburb);
                    continue;
                }

                item.Id = Guid.NewGuid();
                Log.Information(item.ToString());
                _busControl.Publish(new LocalityRequest
                {
                    Locality = item.TrimAllStrings()
                });
                _localitiesRepository.Save(item);
            }
        }