Ejemplo n.º 1
0
        public void ImportGeoIPCitiesList(List <IBulkCopyItem> geopIpBlocks, List <IBulkCopyItem> geoIpCities, List <ColumnDefinition> geoIpBlockDefinitions, List <ColumnDefinition> geoIpCityDefinitions, Action <double> setProgress)
        {
            using (var db = ApiDataContext.Create())
            {
                db.ExecuteCommand("Delete FROM GeoIPCityBlock");
                db.ExecuteCommand("Delete FROM GeoIPCity");
            }

            //Import geo ip city Blocks
            setProgress.Invoke(0);
            BulkCopyCollection bulkCopyCollection = BulkCopyCollection.Create("GeoIPCityBlock", geopIpBlocks.Count, geoIpBlockDefinitions);

            bulkCopyCollection.BulkCopyItems.AddRange(geopIpBlocks);

            BulkUploadToSql bulkUploadToSql = BulkUploadToSql.Load(bulkCopyCollection, setProgress);

            bulkUploadToSql.Flush();
            setProgress.Invoke(0);

            //Import geo ip city items
            bulkCopyCollection = BulkCopyCollection.Create("GeoIPCity", geoIpCities.Count, geoIpCityDefinitions);
            bulkCopyCollection.BulkCopyItems.AddRange(geoIpCities);

            bulkUploadToSql = BulkUploadToSql.Load(bulkCopyCollection, setProgress);
            bulkUploadToSql.Flush();
            setProgress.Invoke(1);
        }
Ejemplo n.º 2
0
        public void ImportGeoIPCountryList(List <IBulkCopyItem> geopIpCountries, List <ColumnDefinition> columnDefinitions, Action <double> setProgress)
        {
            setProgress.Invoke(0);
            using (var db = ApiDataContext.Create())
            {
                db.ExecuteCommand("TRUNCATE TABLE GeoIPCountry");
            }

            BulkCopyCollection bulkCopyCollection = BulkCopyCollection.Create("GeoIPCountry", geopIpCountries.Count, columnDefinitions);

            bulkCopyCollection.BulkCopyItems.AddRange(geopIpCountries);

            BulkUploadToSql bulkUploadToSql = BulkUploadToSql.Load(bulkCopyCollection, setProgress);

            bulkUploadToSql.Flush();
            setProgress.Invoke(1);
        }