From aeb45bfd3a702644caf625e95d423e16376361b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20TUAILLON?= Date: Mon, 11 Dec 2023 15:07:52 +0100 Subject: [PATCH] Fix issue #2574 --- src/IoTHub.Portal.Infrastructure/Jobs/SyncEdgeDeviceJob.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/IoTHub.Portal.Infrastructure/Jobs/SyncEdgeDeviceJob.cs b/src/IoTHub.Portal.Infrastructure/Jobs/SyncEdgeDeviceJob.cs index 3df0973f2..269011dc8 100644 --- a/src/IoTHub.Portal.Infrastructure/Jobs/SyncEdgeDeviceJob.cs +++ b/src/IoTHub.Portal.Infrastructure/Jobs/SyncEdgeDeviceJob.cs @@ -12,6 +12,7 @@ namespace IoTHub.Portal.Infrastructure.Jobs using IoTHub.Portal.Domain; using IoTHub.Portal.Domain.Entities; using IoTHub.Portal.Domain.Repositories; + using Microsoft.Azure.Devices; using Microsoft.Azure.Devices.Shared; using Microsoft.Extensions.Logging; using Quartz; @@ -130,12 +131,16 @@ private async Task CreateOrUpdateDevice(Twin twin) var twinWithModule = await this.externalDeviceService.GetDeviceTwinWithModule(twin.DeviceId); var twinWithClient = await this.externalDeviceService.GetDeviceTwinWithEdgeHubModule(twin.DeviceId); + var connectionState = twin.ConnectionState == DeviceConnectionState.Connected ? "Connected" : "Disconnected"; + var device = this.mapper.Map(twin,opts => { opts.Items["TwinModules"] = twinWithModule; opts.Items["TwinClient"] = twinWithClient; }) ; + device.ConnectionState = connectionState; + var deviceEntity = await this.edgeDeviceRepository.GetByIdAsync(device.Id, d => d.Tags); if (deviceEntity == null)