コード例 #1
0
 public GeolocationDetailsManager(GeolocationContext context, ILogger logger, IIpStackConfiguration ipStackConfiguration, IGeolocationDetailsProvider geolocationDetailsProvider)
 {
     db          = context;
     this.logger = logger;
     this.ipStackConfiguration       = ipStackConfiguration;
     this.geolocationDetailsProvider = geolocationDetailsProvider;
 }
 public GetIpDetailsHandler(IMapper mapper, IIPInfoProvider ipInfoProvider, GeolocationContext geolocationContext,
                            ICacheProvider cacheProvider)
 {
     _mapper             = mapper;
     _ipInfoProvider     = ipInfoProvider;
     _geolocationContext = geolocationContext;
     _cacheProvider      = cacheProvider;
 }
コード例 #3
0
        public static void ImportCSV(string csvFile)
        {
            var      context  = new GeolocationContext();
            Assembly assembly = Assembly.GetExecutingAssembly();

            using (var reader = new StreamReader(csvFile, Encoding.UTF8))
            {
                CsvReader csvReader = new CsvReader(reader, CultureInfo.InvariantCulture);
                csvReader.Configuration.HasHeaderRecord = true;
                csvReader.Configuration.Delimiter       = ",";
                csvReader.Configuration.IgnoreQuotes    = true;
                csvReader.Configuration.RegisterClassMap <CSVMap>();
                var addresses = csvReader.GetRecords <Address>().ToArray();
                context.Addresses.RemoveRange(context.Addresses);
                context.AddRange(addresses);
                context.SaveChanges();
            }
        }
コード例 #4
0
        public static void ImportCSV(string csvFile)
        {
            var      context  = new GeolocationContext();
            Assembly assembly = Assembly.GetExecutingAssembly();

            using (var reader = new StreamReader(csvFile, Encoding.UTF8))
            {
                CsvReader csvReader = new CsvReader(reader, CultureInfo.InvariantCulture);
                csvReader.Configuration.HasHeaderRecord = true;
                csvReader.Configuration.Delimiter       = ",";
                csvReader.Configuration.IgnoreQuotes    = true;
                csvReader.Configuration.RegisterClassMap <CSVMap>();
                var geolocations = csvReader.GetRecords <Geolocation>().ToArray();
                context.Database.ExecuteSqlCommand("Delete from \"Geolocations\"");
                context.AddRange(geolocations);
                context.SaveChanges();
            }
        }
コード例 #5
0
 public AddressesController(GeolocationContext context)
 {
     _context = context;
 }
コード例 #6
0
 public GeolocationsController(GeolocationContext context)
 {
     _context = context;
 }