From fb405b28dd3af7b6e1f569d62dccbe0db1f0bcf4 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Wed, 30 Aug 2023 10:39:37 +0800 Subject: [PATCH] up --- .../host/SettleAccount.HttpApi.Host/Startup.cs | 2 ++ .../ImportExcelCommon/ExportImporter.cs | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs index 08f12964..05b8e06a 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs @@ -17,6 +17,7 @@ using SettleAccount.Job.SignalR; //using ShardingCore; using Win.Sfs.SettleAccount.Entities.BQ; using Win.Sfs.SettleAccount.Entities.BQ.Syncs; +using Win.Sfs.SettleAccount.ExcelImporter; namespace Win.Sfs.SettleAccount; @@ -73,6 +74,7 @@ public class Startup public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { + ExportImporter.ServiceProvider = app.ApplicationServices; app.UseCors("Default"); app.UseResponseCompression(); app.UseRouting(); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs index 8110cc2b..04a31bae 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs @@ -36,13 +36,14 @@ using Magicodes.ExporterAndImporter.Core.Filters; using OfficeOpenXml.Attributes; using Win.Sfs.SettleAccount.Attributes; using Magicodes.ExporterAndImporter.Core.Extension; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.BlobStoring; namespace Win.Sfs.SettleAccount.ExcelImporter { public class ExportImporter { - - + public static IServiceProvider ServiceProvider { get; set; } private readonly IExporter _csvExporter = new Magicodes.ExporterAndImporter.Csv.CsvExporter();//导出CSV private readonly IExcelImporter _importer = new Magicodes.ExporterAndImporter.Excel.ExcelImporter();//导入Excel @@ -51,6 +52,8 @@ namespace Win.Sfs.SettleAccount.ExcelImporter public virtual async Task> UploadExcelImport([FromForm] IFormFileCollection files, IExcelImportAppService _excelImportService) where T : class, new() { + using var fs = ServiceProvider.CreateScope(); + var fc = fs.ServiceProvider.GetRequiredService>(); Type type = typeof(T).GetType(); var ImportList = new List(); ExcelImportResult returnResult = new ExcelImportResult();