示例#1
0
        /// <summary>
        /// アラーム情報を作成しQueueStorageへ登録する
        /// </summary>
        /// <param name="panelDischargeBreakdownPredictiveResutLog">パネル放電破壊予兆結果ログ</param>
        /// <param name="messageId">メッセージID</param>
        /// <param name="alarmDef">アラーム定義</param>
        /// <returns>成功した場合true、失敗した場合falseを返す</returns>
        public bool CreateAndEnqueueAlarmInfo(PanelDischargeBreakdownPredictiveResutLog panelDischargeBreakdownPredictiveResutLog, string messageId, IEnumerable <DtAlarmDefPanelDischargeBreakdownPremonitor> alarmDef)
        {
            bool result = true;

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

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

            foreach (var alarm in alarmDef)
            {
                string message = null;
                try
                {
                    // Sq1.1.3: アラームキューを生成する
                    var alarmInfo = new AlarmInfo
                    {
                        SourceEquipmentUid = panelDischargeBreakdownPredictiveResutLog.SourceEquipmentUid,
                        TypeCode           = panelDischargeBreakdownPredictiveResutLog.TypeCode,
                        ErrorCode          = panelDischargeBreakdownPredictiveResutLog.ErrorCode,
                        AlarmLevel         = alarm.AlarmLevel,
                        AlarmTitle         = alarm.AlarmTitle,
                        AlarmDescription   = alarm.AlarmDescription,
                        AlarmDatetime      = _timeProvider.UtcNow.ToString(Utility.Const.AlarmQueueDateTimeFormat),
                        EventDatetime      = panelDischargeBreakdownPredictiveResutLog.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_PBP_PBP_005) : nameof(Resources.UT_PBP_PBP_006), new object[] { messageId });
                    result = false;
                }
            }

            _logger.Leave();
            return(result);
        }
示例#2
0
        /// <summary>
        /// アラーム定義を取得する
        /// </summary>
        /// <param name="panelDischargeBreakdownPredictiveResutLog">パネル放電破壊予兆結果ログ</param>
        /// <param name="messageId">メッセージID</param>
        /// <param name="models">DBから取得したパラメータ</param>
        /// <returns>成功した場合true、失敗した場合falseを返す</returns>
        public bool ReadAlarmDefinition(PanelDischargeBreakdownPredictiveResutLog panelDischargeBreakdownPredictiveResutLog, string messageId, out IEnumerable <DtAlarmDefPanelDischargeBreakdownPremonitor> models)
        {
            models = null;

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

                // Sq1.1.1: パネル放電破壊予兆監視アラーム定義を取得
                models = _dtAlarmDefPanelDischargeBreakdownPremonitorRepository.ReadDtAlarmDefPanelDischargeBreakdownPremonitor(panelDischargeBreakdownPredictiveResutLog);

                return(true);
            }
            catch (RmsException e)
            {
                // DBにアクセスできない(基本設計書 5.1.2.4 エラー処理)
                _logger.Error(e, nameof(Resources.UT_PBP_PBP_003), new object[] { messageId });
                return(false);
            }
            finally
            {
                _logger.LeaveJson("{0}", new { models });
            }
        }
        /// <summary>
        /// DT_ALARM_DEF_PANEL_DISCHARGE_BREAKDOWN_PREMONITORテーブルからDtAlarmDefPanelDischargeBreakdownPremonitorを取得する
        /// </summary>
        /// <param name="panelDischargeBreakdownPredictiveResutLog">パネル放電破壊予兆結果ログ</param>
        /// <returns>取得したデータ</returns>
        public IEnumerable <DtAlarmDefPanelDischargeBreakdownPremonitor> ReadDtAlarmDefPanelDischargeBreakdownPremonitor(PanelDischargeBreakdownPredictiveResutLog panelDischargeBreakdownPredictiveResutLog)
        {
            IEnumerable <DtAlarmDefPanelDischargeBreakdownPremonitor> models = null;

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

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

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

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