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) { }