コード例 #1
0
        //[DisableRequestSizeLimit]
        public async Task <IActionResult> FileInsert(IFormFile file, string uploadType)
        {
            #region testw
            if (file == null || file.Length == 0)
            {
                return(RedirectToAction("Index"));
            }
            //var list = await _importer.Upload<ExcelImport>(file);
            var table = await _importer.Upload(file);

            StringBuilder sb     = new StringBuilder();
            var           name   = file.Name;
            CRUDOption    option = new CRUDOption()
            {
                TableName       = "ExcelImport",
                BatchSize       = 10000,
                BulkCopyTimeout = 600,
                NotifyAfter     = 10000,
                ColumnMapping   = TableMapDict.Mapping
            };

            //_insertObject.RowsCopied += OnSqlRowsCopied;
            Stopwatch watch = new Stopwatch();
            watch.Start();
            _crudObject.Insert <ExcelImport>(table, option);
            watch.Stop();
            string executedTime = watch.ElapsedMilliseconds.ToString();
            return(Content("执行共:" + executedTime + "毫秒"));

            #endregion
        }