コード例 #1
0
 protected virtual void LocalSaveData(string CurrentTableName)
 {
     // 로컬에 저장한다.
     log.Warn(string.Format("{0} LocalSaveData started", CurrentTableName));
     try
     {
         var objBulk = new BulkUploadToSql <T>()
         {
             InternalStore    = buffer,
             TableName        = CurrentTableName,
             CommitBatchSize  = 1000,
             ConnectionString = config.GetConnectionString(InitialCatalog.Repository)
         };
         objBulk.Commit();
     }
     catch (Exception e)
     {
         log.Error(string.Format("{0}, {1}", e.Message, e.StackTrace));
     }
     finally
     {
         buffer.Clear();
         InternalRepositorySaveCnt++;
     }
 }
コード例 #2
0
 private void Save()
 {
     lock (Lock)
     {
         try
         {
             var objBulk = new BulkUploadToSql <PerfmonData>()
             {
                 InternalStore    = buffer,
                 TableName        = CounterDataOriginCurrentTableName,
                 CommitBatchSize  = 1000,
                 ConnectionString = config.GetConnectionString(InitialCatalog.Repository)
             };
             objBulk.Commit();
         }
         catch (Exception ex)
         {
             log.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace));
         }
         finally
         {
             buffer.Clear();
             InternalRepositorySaveCnt++;
         }
     }
 }
コード例 #3
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);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Roger0x1/CSV2List
        static void Main(string[] args)
        {
            Console.WriteLine("OK ... Firing it up");
            string path    = @"C:\GISdata\BOA\WeeklyData\GIS_Extract.txt";              //  Pass in the path to the text file as an arg
            var    parcels = ProcessFile(path);                                         //  Process the export file for use as attributes

            Console.WriteLine("The text file is processed, starting the real work...");

            var context = new BOAContext();                                             //  Connect to the database

            Console.WriteLine("Dropping the old data from staging and Tax Parcels tables ....");
            context.Database.ExecuteSqlCommand("Truncate table dbo.BOA_Staging");       //  Truncating because its faster
            context.Database.ExecuteSqlCommand("Truncate table BOA.BOA_Tax_Parcels");

            Console.WriteLine("Loading the staging table with the shiny new data ...");
            var objBulk = new BulkUploadToSql <BOA_Staging>()                            // Bulk insert or we wait forever ...
            {
                InternalStore    = parcels.ToList(),
                TableName        = "BOA_Staging",
                CommitBatchSize  = 50000,
                ConnectionString = "Data Source=YourDBServerHere;Initial catalog=YourCatalogHere;UID=YourUIDHere; PWD=YourPasswordHere;"
            };

            objBulk.Commit();
            Console.WriteLine("Loaded ... doing the Tax parcel table update");
            context.Database.ExecuteSqlCommand("dbo.UpdateTaxParcels");
            Console.WriteLine("Done ... doing the Current parcel table update");
            context.Database.ExecuteSqlCommand("Truncate table BOA.BOA_Parcels_Current");
            context.Database.ExecuteSqlCommand("dbo.UpdateCurrentParcels");             //  Stored procedure does the update because the join won't work outside
                                                                                        //  the db -- ESRI won't update correctly otherwise
            Console.WriteLine("This process is complete.  Have a nice day.");
        }
コード例 #5
0
        static void Main(string[] args)
        {
            string path           = Environment.CurrentDirectory;
            string fileName       = "data.tsv";
            string pathToFilename = path + @"\Data\" + fileName;

            using (StreamReader s = new StreamReader(pathToFilename))
            {
                BulkUploadToSql myData = BulkUploadToSql.Load(s);
                myData.Flush();
            }
        }
コード例 #6
0
        public static void testImport <T>(List <T> listData, string tableName)
        {
            var objBulk = new BulkUploadToSql <T>()
            {
                InternalStore    = listData,
                TableName        = tableName,
                CommitBatchSize  = 1000,
                ConnectionString = GetDBConnectionStringImport()
            };

            objBulk.Commit();
        }
コード例 #7
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="connectionString">The connection string</param>
        /// <param name="tableName">Table name</param>
        /// <param name="batchSize">Batch size</param>
        public SqlBulkUploader(
            string connectionString,
            string tableName,
            int batchSize = 100)
        {
            connectionString.NotNullOrEmpty(nameof(connectionString));
            tableName.NotNullOrEmpty(nameof(tableName));

            ConnectionString =
                ConfigurationManager.ConnectionStrings[connectionString].ConnectionString;

            Uploader = new BulkUploadToSql <TEntity>(tableName, batchSize);

            Uploader.Initialise(GetDataTableMapping());
        }
コード例 #8
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);
        }