|
@ -5,9 +5,11 @@ using System.IO; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Linq.Dynamic.Core; |
|
|
using System.Linq.Dynamic.Core; |
|
|
using System.Linq.Expressions; |
|
|
using System.Linq.Expressions; |
|
|
|
|
|
using System.Reflection; |
|
|
using System.Text.Json; |
|
|
using System.Text.Json; |
|
|
using System.Threading; |
|
|
using System.Threading; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using AutoMapper.Internal; |
|
|
using DocumentFormat.OpenXml.Math; |
|
|
using DocumentFormat.OpenXml.Math; |
|
|
using DocumentFormat.OpenXml.Spreadsheet; |
|
|
using DocumentFormat.OpenXml.Spreadsheet; |
|
|
using EFCore.BulkExtensions; |
|
|
using EFCore.BulkExtensions; |
|
@ -332,7 +334,9 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq |
|
|
HttpContextAccessor.HttpContext.Response.Headers.AccessControlExposeHeaders="X-Response"; |
|
|
HttpContextAccessor.HttpContext.Response.Headers.AccessControlExposeHeaders="X-Response"; |
|
|
HttpContextAccessor.HttpContext.Response.Headers.Add("X-Response", |
|
|
HttpContextAccessor.HttpContext.Response.Headers.Add("X-Response", |
|
|
JsonSerializer.Serialize(new { result.ExceptionMessage, result.FileName, result.FileCode, result })); |
|
|
JsonSerializer.Serialize(new { result.ExceptionMessage, result.FileName, result.FileCode, result })); |
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(@"导入错误信息:"+result.ExceptionMessage); |
|
|
|
|
|
|
|
|
var resultAction = new TestResult(bytes, ExportImportService.ContentType) { FileDownloadName = result.FileName }; |
|
|
var resultAction = new TestResult(bytes, ExportImportService.ContentType) { FileDownloadName = result.FileName }; |
|
|
resultAction.errorNum = result.ErrorNum; |
|
|
resultAction.errorNum = result.ErrorNum; |
|
|
resultAction.successNum = resultAction.successNum; |
|
|
resultAction.successNum = resultAction.successNum; |
|
@ -584,9 +588,28 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq |
|
|
{ |
|
|
{ |
|
|
var entityList = dict.Keys.ToList(); |
|
|
var entityList = dict.Keys.ToList(); |
|
|
var context = await _repository.GetDbContextAsync().ConfigureAwait(false); |
|
|
var context = await _repository.GetDbContextAsync().ConfigureAwait(false); |
|
|
|
|
|
var list = new List<TDetail>(); |
|
|
if (entityList.Count > 0) |
|
|
if (entityList.Count > 0) |
|
|
{ |
|
|
{ |
|
|
await context.BulkInsertOrUpdateAsync(entityList).ConfigureAwait(false); |
|
|
foreach (var entity in entityList) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var propertyInfo in entity.GetType().GetProperties()) |
|
|
|
|
|
{ |
|
|
|
|
|
if (propertyInfo.PropertyType.IsListType() && propertyInfo.Name == "Details") |
|
|
|
|
|
{ |
|
|
|
|
|
var entityDetails= propertyInfo.GetValue(entity, null); |
|
|
|
|
|
|
|
|
|
|
|
list.AddRange(((List<TDetail>)entityDetails)!); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
var bulkConfig = new BulkConfig() |
|
|
|
|
|
{ |
|
|
|
|
|
SetOutputIdentity = true, |
|
|
|
|
|
PreserveInsertOrder = true |
|
|
|
|
|
}; |
|
|
|
|
|
await context.BulkInsertOrUpdateAsync(entityList, bulkConfig).ConfigureAwait(false); |
|
|
|
|
|
await context.BulkInsertAsync(list).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -686,7 +709,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase<TEntity, TEntityDto, TReq |
|
|
{ |
|
|
{ |
|
|
foreach (var item in detailModels) |
|
|
foreach (var item in detailModels) |
|
|
{ |
|
|
{ |
|
|
var detail = ObjectMapper.Map<TImportInput, TDetail>(model); |
|
|
var detail = ObjectMapper.Map<TImportInput, TDetail>(item); |
|
|
masterEntity.Details.Add(detail); |
|
|
masterEntity.Details.Add(detail); |
|
|
if (detail is ISetId entityWithId) |
|
|
if (detail is ISetId entityWithId) |
|
|
{ |
|
|
{ |
|
|