public void DispatchDeviceDisconnected( [EventHubTrigger(Const.EventHubNames.DeviceDisconnected, Connection = Const.ConnectionString.EventHubsConnectionStringDeviceDisconnected)] string eventData, ILogger log) { log.EnterJson("EventData: {0}", new object[] { eventData }); Result result = null; DeviceConnectionEvent[] events = null; void actionIfFailedWhenStoreUnexpected(Exception ex, string json) => log.Error(ex, nameof(Resources.CO_DSP_DDV_003), new object[] { json }); try { try { events = GetDeviceConnectionEvents(eventData); } catch (Exception e) { // イベント情報が正常に読み解けなかった場合 log.Error(e, nameof(Resources.CO_DSP_DDV_006)); StoreUnexpectedEvent(Const.EventHubNames.DeviceDisconnected, eventData, actionIfFailedWhenStoreUnexpected); return; } foreach (DeviceConnectionEvent deviceConnectionEvent in events) { try { if (!deviceConnectionEvent.HasNecessary()) { log.Error(nameof(Resources.CO_DSP_DDV_006)); StoreUnexpectedEvent(Const.EventHubNames.DeviceDisconnected, deviceConnectionEvent.RawBody, actionIfFailedWhenStoreUnexpected); continue; } Guid edgeId = deviceConnectionEvent.EdgeId; DateTime eventTime = deviceConnectionEvent.EventTime; result = _service.StoreDeviceDisconnected(edgeId, eventTime); if (!result.IsSuccess()) { // DeviceDisconnectedイベントにはメッセージIDが存在しない StoreUnexpectedEvent(Const.EventHubNames.DeviceDisconnected, deviceConnectionEvent.RawBody, actionIfFailedWhenStoreUnexpected); } } catch (Exception e) { log.Error(e, nameof(Resources.CO_DSP_DDV_001)); StoreUnexpectedEvent(Const.EventHubNames.DeviceDisconnected, deviceConnectionEvent.RawBody, actionIfFailedWhenStoreUnexpected); } } } finally { log.LeaveJson("Response: {0}", result); } }