Esempio n. 1
0
        /// <summary>
        /// 获取综合报警页面统计信息
        /// </summary>
        /// <returns></returns>
        public AlarmRecordCount GetAlarmStatistics()
        {
            AlarmRecordCount   alarmCount         = new AlarmRecordCount();
            ServAlarmRecordDAL servAlarmRecordDal = new ServAlarmRecordDAL();

            try
            {
                alarmCount.nDay       = servAlarmRecordDal.GetAlarmCount(PeriodTimeHelper.GetQueryModel(EnumClass.PeriodType.Day));
                alarmCount.nWeek      = servAlarmRecordDal.GetAlarmCount(PeriodTimeHelper.GetQueryModel(EnumClass.PeriodType.Week));
                alarmCount.nMonth     = servAlarmRecordDal.GetAlarmCount(PeriodTimeHelper.GetQueryModel(EnumClass.PeriodType.Month));
                alarmCount.nQuarter   = servAlarmRecordDal.GetAlarmCount(PeriodTimeHelper.GetQueryModel(EnumClass.PeriodType.Quarter));
                alarmCount.fHalfMonth = servAlarmRecordDal.GetAlarmCount(PeriodTimeHelper.GetQueryModel(EnumClass.PeriodType.FHalfYear));
                alarmCount.sHalfMonth = servAlarmRecordDal.GetAlarmCount(PeriodTimeHelper.GetQueryModel(EnumClass.PeriodType.SHalfYear));
                alarmCount.nYear      = servAlarmRecordDal.GetAlarmCount(PeriodTimeHelper.GetQueryModel(EnumClass.PeriodType.Year));
                return(alarmCount);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 处理报警数据
        /// </summary>
        /// <param name="message">报警数据</param>
        /// <param name="mark">驱动标识</param>
        /// <param name="dataType">数据类型</param>
        /// <param name="subsystem">子系统类型</param>
        /// <returns></returns>
        protected virtual bool HandleAlarmData(object message, string mark, int dataType, int subsystem)
        {
            try
            {
                AlarmInfoModel alarmInfo = JsonHelper.StringToObject <AlarmInfoModel>(message.ToString());
                if (alarmInfo != null)
                {
                    ServAlarmRecordModel alarmRecord    = new ServAlarmRecordModel();
                    ServAlarmRecordDAL   alarmRecordDal = new ServAlarmRecordDAL();
                    InterfaceData        data           = new InterfaceData();
                    alarmRecord.alarm_cache_status = alarmInfo.alarm_cache_status;
                    alarmRecord.alarm_code         = alarmInfo.code;

                    #region  旧版
                    //if (string.IsNullOrEmpty(alarmInfo.alarm_event) || alarmInfo.alarm_event == "")
                    //{
                    //    alarmRecord.alarm_event = -1;
                    //}
                    //else
                    //{
                    //    alarmRecord.alarm_event = GetBaseEventType(alarmInfo.alarm_event);
                    //}

                    #endregion

                    #region  新版
                    alarmRecord.alarm_event = alarmInfo.alarm_event;
                    #endregion
                    alarmRecord.alarm_level        = alarmInfo.alarm_level;
                    alarmRecord.alarm_location     = alarmInfo.alarm_location;
                    alarmRecord.alarm_name         = alarmInfo.alarm_name;
                    alarmRecord.alarm_subsystem    = alarmInfo.alarm_subsystem;
                    alarmRecord.alarm_text         = alarmInfo.alarm_text;
                    alarmRecord.alarm_time         = alarmInfo.alarm_time.ToLocalTime();
                    alarmRecord.alarm_type         = alarmInfo.alarm_type;
                    alarmRecord.confirm_alarm_text = "";
                    alarmRecord.confirm_alarm_time = alarmInfo.alarm_time.ToLocalTime();//确警时间为报警时间(表示未确警)
                    alarmRecord.confirm_person_id  = -1;
                    alarmRecord.confirm_result     = -1;
                    alarmRecord.confirm_state      = (int)EnumClass.ConfirmAlarmState.未确警;
                    int id = alarmRecordDal.AddEntity(alarmRecord);
                    if (id > 0)
                    {
                        alarmRecord.id = id;
                        // string paramData = JsonHelper.ObjectToString(alarmRecord);
                        data.data       = alarmRecord;
                        data.dataType   = dataType;
                        data.mark       = mark;
                        data.subSysType = subsystem;
                        string jsonStr = JsonHelper.ObjectToString(data);
                        HttpHelper.PostJsonData(SubSystemRouteBLL.GetToLogicAlarmRoute(), jsonStr, Encoding.UTF8);
                        return(true);
                    }
                    else
                    {
                        //log:报警数据插入数据库失败+message+mark+dataType+subsystem

                        Log4NetHelp.Info("插入报警数据失败!" + "内容:" + message.ToString() + "驱动标识:" + mark + "数据类型:" + dataType + "子系统类型:" + subsystem);
                        return(false);
                    }
                }
                else
                {
                    Log4NetHelp.Info("数据体格式不正确" + message.ToString());
                    return(false);
                }
            }
            catch (Exception ex)
            {
                //log:处理报警数据失败+message+mark+dataType+subsystem+ex.message
                string msgStr = JsonHelper.ObjectToString(message);
                Log4NetHelp.Error("处理报警数据失败!" + "内容:" + msgStr + "驱动标识:" + mark + "数据类型:" + dataType + "子系统类型:" + subsystem + "错误信息:" + ex.Message);
                return(false);
            }
        }