/// <summary> /// 启动报警,向KPI_OverLimitRecord表中添加数据 /// </summary> /// <param name="faultConfiguration">报警配置信息</param> /// <param name="alarmType">报警类型 1=超高限,2=超高高限,3=超更高</param> /// <param name="alarmTime">开始报警时间</param> /// <param name="maxValue">超标极值</param> /// <param name="standardValue">标准值</param> protected void AddOrUpdateOverLimitRecordToDB(OverLimitConfigEntity faultConfiguration, int alarmType, DateTime alarmTime, double standardValue, double maxValue) { try { KPI_OverLimitRecordEntity entity = new KPI_OverLimitRecordEntity(); entity.AlarmID = Guid.NewGuid() + ""; entity.UnitID = faultConfiguration.UnitID; entity.TagID = faultConfiguration.TagName; entity.AlarmType = alarmType; entity.AlarmStartTime = alarmTime; entity.StandardValue = Convert.ToDecimal(standardValue); entity.Offset = Convert.ToDecimal(maxValue - standardValue); entity.Duration = 0; entity.AlarmValue = Convert.ToDecimal(maxValue); String Period = ""; String Shift = ""; GetShiftAndPeriod(faultConfiguration.UnitID, out Shift, out Period, alarmTime); entity.Shift = Shift; entity.Period = Period; using (KPI_OverLimitRecordDal DataAccess = new KPI_OverLimitRecordDal()) { if (DataAccess.ExistsOverLimitRecord(entity)) { DataAccess.UpdateAlarmMaxValue(entity); return; } DataAccess.AddOverLimitRecord(entity); } } catch (Exception ex) { m_Logger.InfoFormat("AddOrUpdateOverLimitRecordToDB安全指标超限报警计算错误,错误信息是:{0},调用栈信息是:{1}", ex.Message, ex.StackTrace); m_Logger.Error(ex.Message, ex); } }
/// <summary> /// 启动报警,向KPI_OverLimitRecord表中添加数据 /// </summary> /// <param name="faultConfiguration">报警配置信息</param> /// <param name="alarmType">报警类型 1=超高限,2=超高高限,3=超更高</param> /// <param name="alarmTime">开始报警时间</param> /// <param name="maxValue">超标极值</param> /// <param name="standardValue">标准值</param> private void StartAlarm(OverLimitConfigEntity faultConfiguration, int alarmType, DateTime alarmTime, double standardValue, double maxValue) { //Console.WriteLine(String.Format("测点{0}的报警类型是:{1}报警值是:{2}", faultConfiguration.TagDesc, alarmType, maxValue)); try { KPI_OverLimitRecordEntity entity = new KPI_OverLimitRecordEntity(); entity.AlarmID = Guid.NewGuid() + ""; entity.UnitID = faultConfiguration.UnitID; entity.TagID = faultConfiguration.TagName; entity.AlarmType = alarmType; entity.AlarmStartTime = alarmTime; entity.StandardValue = Convert.ToDecimal(standardValue); entity.Offset = Convert.ToDecimal(maxValue - standardValue); entity.Duration = 0; entity.AlarmValue = Convert.ToDecimal(maxValue); String Period = ""; String Shift = ""; GetShiftAndPeriod(faultConfiguration.UnitID, out Shift, out Period); entity.Shift = Shift; entity.Period = Period; using (KPI_OverLimitRecordDal DataAccess = new KPI_OverLimitRecordDal()) { if (DataAccess.ExistsOverLimitRecord(entity)) return; DataAccess.AddOverLimitRecord(entity); } } catch (Exception ex) { LogUtil.LogMessage(string.Format("安全指标超限报警计算错误,错误信息是:{0},调用栈信息是:{1}", ex.Message, ex.StackTrace)); } }