public void DispatchDxaBillLog( [EventHubTrigger(Const.MessageSchemaId.MS014, Connection = Const.ConnectionString.EventHubsConnectionStringMs014)] string eventData, ILogger log) { log.EnterJson("EventData: {0}", new object[] { eventData }); Result result = null; DispatchedEvent[] dispatchedEvents = null; void actionIfFailedWhenStoreUnexpected(Exception ex, string json) => log.Error(ex, nameof(Resources.CO_DSP_DDB_003), new object[] { json }); try { try { dispatchedEvents = GetDispatchedEvents(eventData, log); } catch (Exception e) { // イベント情報が正常に読み解けなかった場合 log.Error(e, nameof(Resources.CO_DSP_DDB_006)); StoreUnexpectedEvent(Const.MessageSchemaId.MS014, eventData, actionIfFailedWhenStoreUnexpected); return; } foreach (DispatchedEvent dispatchedEvent in dispatchedEvents) { var messageId = dispatchedEvent?.MessageId; try { RmsEvent rmsEvent = ConvertEventDataToRmsEvent(dispatchedEvent); if (rmsEvent == null) { // イベントに必要なデータが不足している場合 log.Error(nameof(Resources.CO_DSP_DDB_006)); StoreUnexpectedEvent(Const.MessageSchemaId.MS014, dispatchedEvent.RawBody, actionIfFailedWhenStoreUnexpected, messageId); continue; } result = _service.StoreDxaBillLog(rmsEvent); if (!result.IsSuccess()) { StoreUnexpectedEvent(Const.MessageSchemaId.MS014, dispatchedEvent.RawBody, actionIfFailedWhenStoreUnexpected, messageId); } } catch (Exception e) { log.Error(e, nameof(Resources.CO_DSP_DDB_001)); StoreUnexpectedEvent(Const.MessageSchemaId.MS014, dispatchedEvent.RawBody, actionIfFailedWhenStoreUnexpected, messageId); } } } finally { log.LeaveJson("Response: {0}", result); } }
/// <summary> /// InstallResultを保存する。 /// </summary> /// <param name="eventData">イベントデータ</param> /// <returns>結果</returns> public Result StoreInstallResult(RmsEvent eventData) { string myName = MethodBase.GetCurrentMethod().Name; if (_exceptionMethods.ContainsKey(myName) && _exceptionMethods[myName]) { throw _exception; } return(_service.StoreInstallResult(eventData)); }
public void DispatchTwinChanged( [EventHubTrigger(Const.EventHubNames.TwinChanged, Connection = Const.ConnectionString.EventHubsConnectionStringTwinChanged)] EventData[] eventData, ILogger log) { log.EnterJson("EventData: {0}", new object[] { eventData }); Result result = null; void actionIfFailedWhenStoreUnexpected(Exception ex, string json) => log.Error(ex, nameof(Resources.CO_DSP_DTC_003), new object[] { json }); try { foreach (EventData eachEventData in eventData) { RmsEvent dispatchEvent = null; string rawBody = null; try { // ログ出力用のJSON文字列を取得する rawBody = GetRawBodyForDeviceTwinChanged(eachEventData); // イベントクラスに変換 dispatchEvent = ConvertTwinChanged(eachEventData); } catch (Exception e) { // EventDataがnullまたはEdgeIDをEventDataから取得できない log.Error(e, nameof(Resources.CO_DSP_DTC_006)); StoreUnexpectedEvent(Const.EventHubNames.TwinChanged, rawBody, actionIfFailedWhenStoreUnexpected); continue; // returnせずに次のEventを処理する } try { result = _service.StoreTwinChanged(dispatchEvent); if (!result.IsSuccess()) { StoreUnexpectedEvent(Const.EventHubNames.TwinChanged, rawBody, actionIfFailedWhenStoreUnexpected); } } catch (Exception e) { log.Error(e, nameof(Resources.CO_DSP_DTC_001)); StoreUnexpectedEvent(Const.EventHubNames.TwinChanged, rawBody, actionIfFailedWhenStoreUnexpected); } } } finally { log.LeaveJson("Response: {0}", result); } }
/// <summary> /// IoT Hubによるデバイスツイン更新イベントを受けて処理を行う端末データテーブルを更新する /// </summary> /// <param name="eventData">イベントデータ</param> /// <returns>結果</returns> public Result StoreTwinChanged(RmsEvent eventData) { return(_service.StoreTwinChanged(eventData)); }