From 9d30648152977c7d8d78568cfae0fea1ee4d4541 Mon Sep 17 00:00:00 2001 From: TLeoDev <115005885+TLeoDev@users.noreply.github.com> Date: Mon, 11 Dec 2023 16:37:20 +0100 Subject: [PATCH] Fix issue #2574 (#2688) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Léo TUAILLON --- 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)