解决了uaserver初始化失败的问题

This commit is contained in:
dd 2021-12-24 16:18:00 +08:00
parent 724c46a9f1
commit cb00bed893
4 changed files with 5 additions and 5 deletions

Binary file not shown.

View File

@ -73,14 +73,14 @@ namespace IoTGateway
services.AddHostedService<IoTBackgroundService>();
services.AddSingleton<UAService>();
services.AddSingleton<DeviceService>();
services.AddSingleton<DrvierService>();
services.AddSingleton<UAService>();
services.AddSingleton<MyMqttClient>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IOptionsMonitor<Configs> configs, UAService uAService, DeviceService deviceService)
public void Configure(IApplicationBuilder app, IOptionsMonitor<Configs> configs, DeviceService deviceService)
{
IconFontsHelper.GenerateIconFont();

View File

@ -30,7 +30,7 @@ namespace Plugin
private DBTypeEnum DBType = IoTBackgroundService.DBType;
private Interpreter interpreter = new();
public DeviceService(IConfiguration ConfigRoot, DrvierService drvierManager, MyMqttClient myMqttClient, IMqttServer mqttServer)
public DeviceService(IConfiguration ConfigRoot, DrvierService drvierManager, MyMqttClient myMqttClient, UAService uAService, IMqttServer mqttServer )
{
_DrvierManager = drvierManager;
_MyMqttClient = myMqttClient;

View File

@ -2777,11 +2777,11 @@ namespace Quickstarts.ReferenceServer
#region IoTGatewayDevice
using (var DC = new DataContext(IoTBackgroundService.connnectSetting, IoTBackgroundService.DBType))
{
foreach (var group in DC.Set<Device>().Where(x => x.DeviceTypeEnum == DeviceTypeEnum.Group).OrderBy(x => x.Index))
foreach (var group in DC.Set<Device>().AsNoTracking().Where(x => x.DeviceTypeEnum == DeviceTypeEnum.Group).OrderBy(x => x.Index).ToList())
{
FolderState deviceGroupFolder = CreateFolder(root, group.DeviceName, group.DeviceName);
foreach (var device in DC.Set<Device>().Where(x => x.ParentId == group.ID).Include(x => x.DeviceVariables).Include(x => x.DeviceConfigs).OrderBy(x => x.Index))
foreach (var device in DC.Set<Device>().AsNoTracking().Where(x => x.ParentId == group.ID).Include(x => x.DeviceVariables).Include(x => x.DeviceConfigs).OrderBy(x => x.Index).ToList())
{
FolderState staticFolder = CreateFolder(deviceGroupFolder, device.DeviceName, device.DeviceName);
foreach (var variable in device.DeviceVariables)