/// <summary>
        /// アラーム定義を取得する
        /// </summary>
        /// <param name="temperatureSensorLog">温度センサログ</param>
        /// <param name="messageId">メッセージID</param>
        /// <param name="models">DBから取得したパラメータ</param>
        /// <returns>成功した場合true、失敗した場合falseを返す</returns>
        public bool ReadAlarmDefinition(TemperatureSensorLog temperatureSensorLog, string messageId, out IEnumerable <DtAlarmDefTemperatureSensorLogMonitor> models)
        {
            models = null;

            try
            {
                _logger.EnterJson("{0}", new { temperatureSensorLog, messageId });

                // Sq1.1.1: 温度センサ監視アラーム定義を取得
                models = _dtAlarmDefTemperatureSensorLogMonitorRepository.ReadDtAlarmDefTemperatureSensorLogMonitor(temperatureSensorLog);

                return(true);
            }
            catch (RmsException e)
            {
                // DBにアクセスできない(基本設計書 5.1.2.4 エラー処理)
                _logger.Error(e, nameof(Resources.UT_TSM_TSM_003), new object[] { messageId });
                return(false);
            }
            finally
            {
                _logger.LeaveJson("{0}", new { models });
            }
        }
        /// <summary>
        /// アラーム情報を作成しQueueStorageへ登録する
        /// </summary>
        /// <param name="temperatureSensorLog">温度センサログ</param>
        /// <param name="messageId">メッセージID</param>
        /// <param name="alarmDef">アラーム定義</param>
        /// <returns>成功した場合true、失敗した場合falseを返す</returns>
        public bool CreateAndEnqueueAlarmInfo(TemperatureSensorLog temperatureSensorLog, string messageId, IEnumerable <DtAlarmDefTemperatureSensorLogMonitor> alarmDef)
        {
            bool result = true;

            _logger.EnterJson("{0}", new { temperatureSensorLog, messageId, alarmDef });

            int index      = 1;
            int alarmCount = alarmDef.Count();

            foreach (var alarm in alarmDef)
            {
                string message = null;
                try
                {
                    string alarmDescription = alarm.AlarmDescription;
                    if (!string.IsNullOrEmpty(alarmDescription))
                    {
                        if (alarmDescription.Contains("{0}"))
                        {
                            if (alarmDescription.Contains("{1}"))
                            {
                                alarmDescription = string.Format(alarmDescription, temperatureSensorLog.SetupLocation, temperatureSensorLog.Temperature);
                            }
                            else
                            {
                                alarmDescription = string.Format(alarmDescription, temperatureSensorLog.SetupLocation);
                            }
                        }
                    }

                    // Sq1.1.3: アラームキューを生成する
                    var alarmInfo = new AlarmInfo
                    {
                        SourceEquipmentUid = temperatureSensorLog.SourceEquipmentUid,
                        TypeCode           = temperatureSensorLog.TypeCode,
                        ErrorCode          = temperatureSensorLog.ErrorCode,
                        AlarmLevel         = alarm.AlarmLevel,
                        AlarmTitle         = alarm.AlarmTitle,
                        AlarmDescription   = alarmDescription,
                        AlarmDatetime      = _timeProvider.UtcNow.ToString(Utility.Const.AlarmQueueDateTimeFormat),
                        EventDatetime      = temperatureSensorLog.EventDt,
                        AlarmDefId         = $"{_settings.SystemName}_{_settings.SubSystemName}_{alarm.Sid.ToString()}",
                        MessageId          = alarmCount <= 1 ? messageId : $"{messageId}_{index}"
                    };
                    index++;

                    message = JsonConvert.SerializeObject(alarmInfo);

                    // Sq1.1.4: キューを登録する
                    _queueRepository.SendMessageToAlarmQueue(message);
                }
                catch (Exception e)
                {
                    // アラーム生成エラー or アラームキューにアラーム情報を送信できない(基本設計書 5.1.2.4 エラー処理)
                    _logger.Error(e, string.IsNullOrEmpty(message) ? nameof(Resources.UT_TSM_TSM_005) : nameof(Resources.UT_TSM_TSM_006), new object[] { messageId });
                    result = false;
                }
            }

            _logger.Leave();
            return(result);
        }
        /// <summary>
        /// DT_ALARM_DEF_TEMPERATURE_SENSOR_LOG_MONITORテーブルからDtAlarmDefTemperatureSensorLogMonitorを取得する
        /// </summary>
        /// <param name="temperatureSensorLog">温度センサログ</param>
        /// <returns>取得したデータ</returns>
        public IEnumerable <DtAlarmDefTemperatureSensorLogMonitor> ReadDtAlarmDefTemperatureSensorLogMonitor(TemperatureSensorLog temperatureSensorLog)
        {
            IEnumerable <DtAlarmDefTemperatureSensorLogMonitor> models = null;

            try
            {
                _logger.EnterJson("{0}", temperatureSensorLog);

                List <DBAccessor.Models.DtAlarmDefTemperatureSensorLogMonitor> entities = null;
                _dbPolly.Execute(() =>
                {
                    using (DBAccessor.Models.RmsDbContext db = new DBAccessor.Models.RmsDbContext(_appSettings))
                    {
                        entities = db.DtAlarmDefTemperatureSensorLogMonitor
                                   .Where(x => string.IsNullOrEmpty(x.TypeCode) || x.TypeCode == temperatureSensorLog.TypeCode)
                                   .Where(x => string.IsNullOrEmpty(x.ErrorCode) || x.ErrorCode == temperatureSensorLog.ErrorCode)
                                   .ToList();
                    }
                });

                if (entities != null)
                {
                    models = entities.Select(x => x.ToModel());
                }

                return(models);
            }
            catch (Exception e)
            {
                throw new RmsException("DT_ALARM_DEF_TEMPERATURE_SENSOR_LOG_MONITORテーブルのSelectに失敗しました。", e);
            }
            finally
            {
                _logger.LeaveJson("{0}", models);
            }
        }