From cd462b9523a7cd531612e801fc76ceef0e5df0ed Mon Sep 17 00:00:00 2001 From: Kimdiego2098 <2248356998@qq.com> Date: Tue, 28 Nov 2023 09:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=AF=BC=E5=87=BA=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E8=A1=A8=E7=9A=84sheet=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Device/CollectDeviceService.cs | 2 ++ .../Services/Device/DeviceService.cs | 8 ++++---- .../Services/Device/UploadDeviceService.cs | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/CollectDeviceService.cs b/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/CollectDeviceService.cs index 9b0cc3783..6cd351850 100644 --- a/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/CollectDeviceService.cs +++ b/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/CollectDeviceService.cs @@ -26,6 +26,8 @@ namespace ThingsGateway.Gateway.Application; [Injection(Proxy = typeof(OperDispatchProxy))] public class CollectDeviceService : DeviceService, ITransient { + protected override string DeviceSheetName => ExportHelpers.CollectDeviceSheetName; + public CollectDeviceService(IServiceScopeFactory serviceScopeFactory, IFileService fileService) : base(serviceScopeFactory, fileService) { } diff --git a/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/DeviceService.cs b/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/DeviceService.cs index c7045fffe..fd66c6b60 100644 --- a/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/DeviceService.cs +++ b/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/DeviceService.cs @@ -206,7 +206,7 @@ public abstract class DeviceService : DbRepository where T : Device, new() var data = await query.ToListAsync(); return await ExportFileAsync(data); } - + protected abstract string DeviceSheetName { get; } /// [OperDesc("导出采集设备表", IsRecordPar = false)] public async Task ExportFileAsync(List devDatas = null) @@ -277,7 +277,7 @@ public abstract class DeviceService : DbRepository where T : Device, new() } //添加设备页 - sheets.Add(ExportHelpers.CollectDeviceSheetName, devExports); + sheets.Add(DeviceSheetName, devExports); //添加插件属性页 @@ -321,7 +321,7 @@ public abstract class DeviceService : DbRepository where T : Device, new() var collectDevices = new List(); foreach (var item in input) { - if (item.Key == ExportHelpers.CollectDeviceSheetName) + if (item.Key == DeviceSheetName) { var collectDeviceImports = ((ImportPreviewOutput)item.Value).Data; collectDevices = collectDeviceImports.Values.Adapt>(); @@ -362,7 +362,7 @@ public abstract class DeviceService : DbRepository where T : Device, new() //单页数据 var rows = stream.Query(useHeaderRow: true, sheetName: sheetName).Cast>(); #region 采集设备sheet - if (sheetName == ExportHelpers.CollectDeviceSheetName) + if (sheetName == DeviceSheetName) { int row = 1; ImportPreviewOutput importPreviewOutput = new(); diff --git a/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/UploadDeviceService.cs b/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/UploadDeviceService.cs index 8b8f93a08..1d62c0462 100644 --- a/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/UploadDeviceService.cs +++ b/framework/gateway/ThingsGateway.Gateway.Application/Services/Device/UploadDeviceService.cs @@ -21,6 +21,7 @@ namespace ThingsGateway.Gateway.Application; [Injection(Proxy = typeof(OperDispatchProxy))] public class UploadDeviceService : DeviceService, ITransient { + protected override string DeviceSheetName => ExportHelpers.UploadDeviceSheetName; public UploadDeviceService(IServiceScopeFactory serviceScopeFactory, IFileService fileService) : base(serviceScopeFactory, fileService) { }