コード例 #1
0
        public void saveAlarmInfo(List <Model.RQPeriodInfo> djs)
        {
            double thresh = 25;//燃气超标上线

            foreach (RQPeriodInfo rq in djs)
            {
                if (Double.Parse(rq.STRENGTH) >= thresh)
                {
                    AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();
                    alarmRecordInfo.ACTIVE           = true;
                    alarmRecordInfo.DEVICE_CODE      = rq.ADDRESS;
                    alarmRecordInfo.DEVICE_ID        = Convert.ToInt32(new BLL.Device().getDeviceIdByCode(rq.ADDRESS));
                    alarmRecordInfo.DEVICE_TYPE_NAME = TypeName;
                    alarmRecordInfo.MESSAGE          = (int)RQAlarmEnum.OVER_THRESH + "";
                    alarmRecordInfo.ITEMNAME         = "浓度超标";
                    alarmRecordInfo.ITEMVALUE        = rq.STRENGTH;
                    alarmRecordInfo.MESSAGE_STATUS   = 0;
                    alarmRecordInfo.RECORDCODE       = "";
                    alarmRecordInfo.RECORDDATE       = System.DateTime.Now;

                    List <int> devStatusList = new List <int>();
                    devStatusList.Add((int)RQAlarmEnum.OVER_THRESH);
                    new BLL.AlarmRecord().deleteByMessage(rq.ADDRESS, devStatusList);

                    new BLL.AlarmRecord().save(alarmRecordInfo);
                }
            }
        }
コード例 #2
0
        public void add(AlarmRecordInfo alarm)
        {
            OracleTransaction tran = null;

            using (OracleConnection conn = new OracleConnection(OracleHelper.ConnectionStringOrderDistributedTransaction))
            {
                try
                {
                    conn.Open();
                    tran = conn.BeginTransaction();
                    if (alarm.DEVICE_ID == null)
                    {
                        throw new Exception(alarm.ITEMNAME + ":设备ID为空!");
                    }
                    OracleParameter[] parms = GetAdapterParameters();
                    SetAdapterParameters(parms, alarm);
                    OracleHelper.ExecuteNonQuery(tran, CommandType.Text, SQL_INSERT_ALARM_RECORD, parms);
                    tran.Commit();
                }
                catch (Exception e)
                {
                    if (null != tran)
                    {
                        tran.Rollback();
                    }
                    throw (e);
                }
            }
        }
コード例 #3
0
        public void saveSZAlarmInfo(List <Model.DjLiquidInfo> djs)
        {
            AlarmRecord alarmRecordDal        = new SensorHub.BLL.AlarmRecord();
            List <Model.AlarmRecordInfo> list = new List <Model.AlarmRecordInfo>();

            BLL.Device deviceBLL = new SensorHub.BLL.Device();

            foreach (Model.DjLiquidInfo dj in djs)
            {
                AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();
                alarmRecordInfo.ACTIVE           = true;
                alarmRecordInfo.DEVICE_CODE      = dj.DEVID;
                alarmRecordInfo.DEVICE_ID        = Convert.ToInt32(deviceBLL.getDeviceIdByCode(dj.DEVID));
                alarmRecordInfo.DEVICE_TYPE_NAME = deviceBLL.getDevTypeByCode(dj.DEVID);
                alarmRecordInfo.ITEMNAME         = "液位值";
                alarmRecordInfo.ITEMVALUE        = dj.LIQUIDDATA;
                alarmRecordInfo.MESSAGE_STATUS   = 0;
                alarmRecordInfo.RECORDCODE       = "";
                alarmRecordInfo.RECORDDATE       = System.DateTime.Now;
                alarmRecordInfo.MESSAGE          = "液位超限";

                list.Add(alarmRecordInfo);
            }
            alarmRecordDal.insert(list);
        }
コード例 #4
0
        public AlarmRecordInfo getAlarmRecordByTime(AlarmRuleInfo alarmRuleInfo, SlNoiseInfo slNoiseInfo)
        {
            if (alarmRuleInfo != null)
            {
                string days     = System.Configuration.ConfigurationSettings.AppSettings["SL_ALARM_DAYS"];
                int    num_days = Convert.ToInt32(days);

                float curValue = float.Parse(slNoiseInfo.DENSEDATA);
                if (alarmRuleInfo.HighValue != 0 && curValue > alarmRuleInfo.HighValue)
                {
                    IDevice         deviceDal       = SensorHub.DALFactory.Device.Create();
                    AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();
                    alarmRecordInfo.ACTIVE           = true;
                    alarmRecordInfo.DEVICE_CODE      = slNoiseInfo.SRCID;
                    alarmRecordInfo.DEVICE_ID        = alarmRuleInfo.DeviceId;
                    alarmRecordInfo.DEVICE_TYPE_NAME = deviceDal.getDevTypeByCode(slNoiseInfo.SRCID);
                    alarmRecordInfo.ITEMNAME         = "噪声值";
                    alarmRecordInfo.ITEMVALUE        = curValue.ToString();
                    alarmRecordInfo.MESSAGE_STATUS   = 0;
                    alarmRecordInfo.RECORDCODE       = "";
                    alarmRecordInfo.RECORDDATE       = System.DateTime.Now;
                    alarmRecordInfo.MESSAGE          = "管线泄漏";
                    return(alarmRecordInfo);
                    //TODO LIST:查询过去7天的报警记录

                    /*
                     * DateTime endTime = slNoiseInfo.UPTIME;
                     * DateTime startTime = endTime.AddDays(-num_days);
                     *
                     * ISlNoise slNoiseDal = SensorHub.DALFactory.SlNoise.Create();
                     *
                     * int nums = slNoiseDal.getAlarmNumsByArrange(alarmRuleInfo.HighValue,
                     *  startTime, endTime, slNoiseInfo.SRCID);
                     * if (nums == num_days)
                     * {
                     *  IDevice deviceDal = SensorHub.DALFactory.Device.Create();
                     *
                     *  AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();
                     *  alarmRecordInfo.ACTIVE = true;
                     *  alarmRecordInfo.DEVICE_CODE = slNoiseInfo.SRCID;
                     *  alarmRecordInfo.DEVICE_ID = alarmRuleInfo.DeviceId;
                     *  alarmRecordInfo.DEVICE_TYPE_NAME = deviceDal.getDevTypeByCode(slNoiseInfo.SRCID);
                     *  alarmRecordInfo.ITEMNAME = "噪声值";
                     *  alarmRecordInfo.ITEMVALUE = curValue.ToString();
                     *  alarmRecordInfo.MESSAGE_STATUS = false;
                     *  alarmRecordInfo.RECORDCODE = "";
                     *  alarmRecordInfo.RECORDDATE = System.DateTime.Now;
                     *  alarmRecordInfo.MESSAGE = "管线泄漏";
                     *  return alarmRecordInfo;
                     * }
                     * */
                }
            }
            return(null);
        }
コード例 #5
0
        //保存腐蚀速率报警数据
        public void saveAlarmInfo(List <Model.AKFSSLInfo> djs)
        {
            List <Model.AlarmRecordInfo> list = new List <Model.AlarmRecordInfo>();


            foreach (Model.AKFSSLInfo dj in djs)
            {
                float errosionRate = float.Parse(dj.ErrosionRat);
                if (errosionRate < 0.025)
                {
                    //TODO LIST:清除原有腐蚀
                    new BLL.AlarmRecord().removeByDevCode(dj.DEVCODE);
                    continue;
                }

                AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();
                alarmRecordInfo.ACTIVE           = true;
                alarmRecordInfo.DEVICE_CODE      = dj.DEVCODE;
                alarmRecordInfo.DEVICE_ID        = Convert.ToInt32(new BLL.Device().getDeviceIdByCode(dj.DEVCODE));
                alarmRecordInfo.DEVICE_TYPE_NAME = new BLL.Device().getDevTypeByCode(dj.DEVCODE);
                alarmRecordInfo.ITEMNAME         = "腐蚀速率";
                alarmRecordInfo.ITEMVALUE        = errosionRate.ToString();
                alarmRecordInfo.MESSAGE_STATUS   = 0;
                alarmRecordInfo.RECORDCODE       = "";
                alarmRecordInfo.RECORDDATE       = System.DateTime.Now;

                if (errosionRate >= 0.025 && errosionRate < 0.13)
                {
                    alarmRecordInfo.MESSAGE = "中度腐蚀";
                }
                else if (errosionRate >= 0.13 && errosionRate < 0.25)
                {
                    alarmRecordInfo.MESSAGE = "严重腐蚀";
                }
                else
                {
                    alarmRecordInfo.MESSAGE = "极严重腐蚀";
                }

                if (null != alarmRecordInfo)
                {
                    list.Add(alarmRecordInfo);
                }
            }
            if (list.Count > 0)
            {
                new BLL.AlarmRecord().insert(list);
            }
        }
コード例 #6
0
        public void setDeviceStatus(String devCode, String state)
        {
            AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();

            alarmRecordInfo.ACTIVE           = true;
            alarmRecordInfo.DEVICE_CODE      = devCode;
            alarmRecordInfo.DEVICE_ID        = Convert.ToInt32(new BLL.Device().getDeviceIdByCode(devCode));;
            alarmRecordInfo.DEVICE_TYPE_NAME = TYPENAME;
            alarmRecordInfo.ITEMNAME         = "设备状态上报";
            alarmRecordInfo.MESSAGE          = state == "0" ? "-1" : state;
            alarmRecordInfo.MESSAGE_STATUS   = 0;
            alarmRecordInfo.RECORDCODE       = "";
            alarmRecordInfo.RECORDDATE       = System.DateTime.Now;

            new BLL.AlarmRecord().save(alarmRecordInfo);
        }
コード例 #7
0
        public void saveAlarmInfo(List <Model.DjLiquidInfo> djs)
        {
            IAlarmRule alarmRuleDal = SensorHub.DALFactory.AlarmRule.Create();

            foreach (Model.DjLiquidInfo dj in djs)
            {
                AlarmRuleInfo   alarmRuleInfo   = alarmRuleDal.getAlarmRule(dj.DEVID);
                AlarmRecordInfo alarmRecordInfo = getAlarmRecord(alarmRuleInfo, dj);
                if (null != alarmRecordInfo)
                {
                    List <int> devStates = new List <int>();
                    devStates.Add((int)LiquidAlarmEnum.OVER_THRESH);
                    new BLL.AlarmRecord().deleteByMessage(alarmRecordInfo.DEVICE_CODE, devStates);
                    new BLL.AlarmRecord().save(alarmRecordInfo);
                }
            }
        }
コード例 #8
0
ファイル: DjNoise.cs プロジェクト: predatorZhang/SensorHubEY
        private AlarmRecordInfo getAlarmRecord(AlarmRuleInfo alarmRuleInfo, DjNoiseInfo slNoiseInfo)
        {
            if (null != alarmRuleInfo)
            {
                float    curValue   = float.Parse(slNoiseInfo.DDATA);
                IDevice  deviceDal  = SensorHub.DALFactory.Device.Create();
                IDjNoise slNoiseDal = SensorHub.DALFactory.DjNoise.Create();

                AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();
                alarmRecordInfo.ACTIVE           = true;
                alarmRecordInfo.DEVICE_CODE      = slNoiseInfo.DEVID;
                alarmRecordInfo.DEVICE_ID        = alarmRuleInfo.DeviceId;
                alarmRecordInfo.DEVICE_TYPE_NAME = deviceDal.getDevTypeByCode(slNoiseInfo.DEVID);
                alarmRecordInfo.ITEMNAME         = "噪声值";
                alarmRecordInfo.ITEMVALUE        = curValue.ToString();
                alarmRecordInfo.MESSAGE_STATUS   = 0;
                alarmRecordInfo.RECORDCODE       = "";
                alarmRecordInfo.RECORDDATE       = System.DateTime.Now;

                if (alarmRuleInfo.HighValue != 0 && curValue > alarmRuleInfo.HighValue)
                {
                    alarmRecordInfo.MESSAGE = "管线泄漏";
                    return(alarmRecordInfo);
                }

                if (alarmRuleInfo.LowValue != 0 && curValue < alarmRuleInfo.LowValue)
                {
                    alarmRecordInfo.MESSAGE = "噪声低于下限";
                    //return alarmRecordInfo;
                    return(null);
                }

                if (alarmRuleInfo.Saltation != 0)
                {
                    float lastData = slNoiseDal.getLastData(slNoiseInfo);
                    if (-100 != lastData && Math.Abs(curValue - lastData) > alarmRuleInfo.Saltation)
                    {
                        alarmRecordInfo.MESSAGE = "噪声异常";
                        // return alarmRecordInfo;
                        return(null);
                    }
                }
            }
            return(null);
        }
コード例 #9
0
        public void saveAlarmInfo(List <Model.DjPressInfo> djs)
        {
            IAlarmRule alarmRuleDal = SensorHub.DALFactory.AlarmRule.Create();
            // IAlarmRecord alarmRecordDal = SensorHub.DALFactory.AlarmRecord.Create();
            AlarmRecord alarmRecordDal        = new SensorHub.BLL.AlarmRecord();
            List <Model.AlarmRecordInfo> list = new List <Model.AlarmRecordInfo>();

            foreach (Model.DjPressInfo dj in djs)
            {
                AlarmRuleInfo   alarmRuleInfo   = alarmRuleDal.getAlarmRule(dj.DEVID, PRESS_TYPE);
                AlarmRecordInfo alarmRecordInfo = getAlarmRecord(alarmRuleInfo, dj);
                if (null != alarmRecordInfo)
                {
                    list.Add(alarmRecordInfo);
                }
            }
            if (list.Count > 0)
            {
                alarmRecordDal.insert(list);
            }
        }
コード例 #10
0
        private AlarmRecordInfo getAlarmRecord(AlarmRuleInfo alarmRuleInfo, DjLiquidInfo liquidInfo)
        {
            if (null != alarmRuleInfo)
            {
                float     curValue  = float.Parse(liquidInfo.LIQUIDDATA);
                IDevice   deviceDal = SensorHub.DALFactory.Device.Create();
                IDjLiquid liquidDal = SensorHub.DALFactory.DjLiquid.Create();

                AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();
                alarmRecordInfo.ACTIVE           = true;
                alarmRecordInfo.DEVICE_CODE      = liquidInfo.DEVID;
                alarmRecordInfo.DEVICE_ID        = alarmRuleInfo.DeviceId;
                alarmRecordInfo.DEVICE_TYPE_NAME = deviceDal.getDevTypeByCode(liquidInfo.DEVID);
                alarmRecordInfo.ITEMNAME         = "液位值";
                alarmRecordInfo.ITEMVALUE        = curValue.ToString();
                alarmRecordInfo.MESSAGE_STATUS   = 0;
                alarmRecordInfo.MESSAGE          = (int)LiquidAlarmEnum.OVER_THRESH + "";

                alarmRecordInfo.RECORDCODE = "";
                alarmRecordInfo.RECORDDATE = System.DateTime.Now;

                if (alarmRuleInfo.HighValue != null && curValue > alarmRuleInfo.HighValue)
                {
                    alarmRecordInfo.MESSAGE = (int)LiquidAlarmEnum.OVER_THRESH + "";
                    return(alarmRecordInfo);
                }

                if (alarmRuleInfo.Saltation != null)
                {
                    float lastData = liquidDal.getLastData(liquidInfo);
                    if (-1 != lastData && Math.Abs(curValue - lastData) > alarmRuleInfo.Saltation)
                    {
                        alarmRecordInfo.MESSAGE = "液位突变";
                        //   return alarmRecordInfo;
                        return(null);
                    }
                }
            }
            return(null);
        }
コード例 #11
0
ファイル: AlarmDB.cs プロジェクト: hx215267863/src
        private void insertAlarmRecordInfo(AlarmRecordInfo info)
        {
            string sql = string.Format(@"insert alarm_record (
	                                        rule_did,
	                                        facility_did,
	                                        alarm_time,
	                                        alarm_count,
	                                        dispose_state,
	                                        dispose_time,
	                                        handler,
	                                        duration,
	                                        address,
	                                        remark)
                                        values(
                                        '{0}', {1}, '{2}', {3}, {4}, '{5}', '{6}', {7}, '{8}', '{9}');"
                                       , info.RuleDID, info.FacilityDID, info.AlarmTime, info.AlarmCount, info.DisposeState, info.DisposeTime
                                       , info.Handler, info.Duration, info.Address, info.Remark);

            Database equipDB = dataProvider.EQUIPDataBase;

            equipDB.ExecuteNonQuery(CommandType.Text, sql);
        }
コード例 #12
0
        private AlarmRecordInfo getAlarmRecord(AlarmRuleInfo alarmRuleInfo, Model.DjPressInfo pressInfo)
        {
            if (null != alarmRuleInfo)
            {
                float    curValue  = float.Parse(pressInfo.PRESSDATA);
                IDevice  deviceDal = SensorHub.DALFactory.Device.Create();
                IDjPress pressDal  = SensorHub.DALFactory.DjPress.Create();

                AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();
                alarmRecordInfo.ACTIVE           = true;
                alarmRecordInfo.DEVICE_CODE      = pressInfo.DEVID;
                alarmRecordInfo.DEVICE_ID        = alarmRuleInfo.DeviceId;
                alarmRecordInfo.DEVICE_TYPE_NAME = deviceDal.getDevTypeByCode(pressInfo.DEVID);
                alarmRecordInfo.ITEMNAME         = "压力值";
                alarmRecordInfo.ITEMVALUE        = curValue.ToString();
                alarmRecordInfo.MESSAGE_STATUS   = 0;
                alarmRecordInfo.RECORDCODE       = "";
                alarmRecordInfo.RECORDDATE       = System.DateTime.Now;

                if (alarmRuleInfo.HighValue != 0 && curValue > alarmRuleInfo.HighValue)
                {
                    alarmRecordInfo.MESSAGE = "压力超限";
                    return(alarmRecordInfo);
                }

                if (alarmRuleInfo.Saltation != 0)
                {
                    float lastData = pressDal.getLastData(pressInfo);
                    if (-1 != lastData && Math.Abs(curValue - lastData) > alarmRuleInfo.Saltation)
                    {
                        alarmRecordInfo.MESSAGE = "压力突变";
                        // return alarmRecordInfo;
                        return(null);
                    }
                }
            }
            return(null);
        }
コード例 #13
0
ファイル: AlarmDB.cs プロジェクト: hx215267863/src
        /// <summary>
        /// 用户操作完后,将当前报警信息清除,并将当前用户操作的报警信息增加到历史报警记录里面
        /// </summary>
        /// <param name="alarmTemporaryDID"></param>
        /// <param name="handlerId"></param>
        public void UpdateAlarmTemporaryHandled(int alarmTemporaryDID, int handlerId)
        {
            AlarmTemporaryInfo entity = GetAlarmTemporaryByID(alarmTemporaryDID);

            UserDB   u    = new UserDB();
            UserInfo user = u.GetUserByUserID(handlerId);

            AlarmRecordInfo info = new AlarmRecordInfo();

            info.Address      = entity.Address;
            info.AlarmCount   = 0;
            info.AlarmTime    = entity.AlarmTime;
            info.DisposeState = 2;
            info.DisposeTime  = DateTime.Now;
            info.Duration     = (int)DateTime.Now.Subtract(entity.AlarmTime).TotalMinutes;
            info.FacilityDID  = entity.FacilityDID;
            info.Handler      = user.Name;
            info.Remark       = entity.Remark;
            info.RuleDID      = entity.RuleDID;

            insertAlarmRecordInfo(info);
            removeFromAlarmTemporaryByID(alarmTemporaryDID);
        }
コード例 #14
0
        private AlarmRecordInfo getAlarmRecord(AlarmRuleInfo alarmRuleInfo, Model.CasicTemp tempInfo)
        {
            if (null != alarmRuleInfo)
            {
                float      curValue  = float.Parse(tempInfo.Data);
                IDevice    deviceDal = SensorHub.DALFactory.Device.Create();
                ICasicTemp tempDal   = SensorHub.DALFactory.CasicTemp.Create();

                AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();
                alarmRecordInfo.ACTIVE           = true;
                alarmRecordInfo.DEVICE_CODE      = tempInfo.DEVCODE;
                alarmRecordInfo.DEVICE_ID        = alarmRuleInfo.DeviceId;
                alarmRecordInfo.DEVICE_TYPE_NAME = deviceDal.getDevTypeByCode(tempInfo.DEVCODE);
                alarmRecordInfo.ITEMNAME         = "温度值";
                alarmRecordInfo.ITEMVALUE        = curValue.ToString();
                alarmRecordInfo.MESSAGE_STATUS   = 0;
                alarmRecordInfo.RECORDCODE       = "";
                alarmRecordInfo.RECORDDATE       = System.DateTime.Now;

                if (alarmRuleInfo.HighValue != 0 && curValue > alarmRuleInfo.HighValue)
                {
                    alarmRecordInfo.MESSAGE = "温度超限";
                    return(alarmRecordInfo);
                }

                if (alarmRuleInfo.Saltation != 0)
                {
                    float lastData = tempDal.getLastData(tempInfo);
                    if (-1 != lastData && Math.Abs(curValue - lastData) > alarmRuleInfo.Saltation)
                    {
                        alarmRecordInfo.MESSAGE = "温度突变";
                        return(alarmRecordInfo);
                    }
                }
            }
            return(null);
        }
コード例 #15
0
        public void SaveZZAlarmInfo(List <Model.SlNoiseInfo> djsAll)
        {
            List <Model.SlNoiseInfo> djs = this.Filter(djsAll);

            if (djs.Count == 0)
            {
                return;
            }
            String        devCode       = djs[0].SRCID;
            IAlarmRule    alarmRuleDal  = SensorHub.DALFactory.AlarmRule.Create();
            AlarmRuleInfo alarmRuleInfo = alarmRuleDal.getAlarmRule(devCode);

            if (alarmRuleInfo == null || alarmRuleInfo.HighValue == 0)
            {
                return;
            }

            AlarmRecord alarmRecordDal = new SensorHub.BLL.AlarmRecord();

            //如果最新一条消息没报警的话就清楚报警
            if (float.Parse(djs[djs.Count - 1].DENSEDATA) < alarmRuleInfo.HighValue)
            {
                alarmRecordDal.removeByDevCode(devCode);
                return;
            }

            //判断是否都超过报警
            bool isAllOverThresh = true;

            foreach (SlNoiseInfo slNoiseInfo in djs)
            {
                if (float.Parse(slNoiseInfo.DENSEDATA) < alarmRuleInfo.HighValue)
                {
                    isAllOverThresh = false;
                    break;
                }
            }

            //如果超过连续报警次数,将最新的数据插入到报警列表中
            if (isAllOverThresh && IsOverMaxSLAlarm(devCode, alarmRuleInfo))
            {
                IDevice deviceDal = SensorHub.DALFactory.Device.Create();

                AlarmRecordInfo alarmRecordInfo = new AlarmRecordInfo();
                alarmRecordInfo.ACTIVE           = true;
                alarmRecordInfo.DEVICE_CODE      = devCode;
                alarmRecordInfo.DEVICE_ID        = alarmRuleInfo.DeviceId;
                alarmRecordInfo.DEVICE_TYPE_NAME = deviceDal.getDevTypeByCode(devCode);
                alarmRecordInfo.ITEMNAME         = "噪声值";
                alarmRecordInfo.ITEMVALUE        = djs[djs.Count - 1].DENSEDATA;
                alarmRecordInfo.MESSAGE_STATUS   = 0;
                alarmRecordInfo.RECORDCODE       = "";
                alarmRecordInfo.RECORDDATE       = System.DateTime.Now;
                alarmRecordInfo.MESSAGE          = (int)SlNoiseAlarmEnum.OVER_THRESH + "";

                List <int> devStates = new List <int>();
                devStates.Add((int)SlNoiseAlarmEnum.OVER_THRESH);
                new BLL.AlarmRecord().deleteByMessage(alarmRecordInfo.DEVICE_CODE, devStates);

                List <Model.AlarmRecordInfo> list = new List <Model.AlarmRecordInfo>();
                list.Add(alarmRecordInfo);
                alarmRecordDal.insert(list);
            }
        }
コード例 #16
0
 public void save(AlarmRecordInfo alarm)
 {
     IDAL.IAlarmRecord dal = SensorHub.DALFactory.AlarmRecord.Create();
     dal.add(alarm);//增加设备状态
 }
コード例 #17
0
        //保存腐蚀环境报警数据
        public void saveAlarmInfo(List <Model.AKFSHJInfo> djs, String pipeType)
        {
            float tempThresh = 40;

            if (pipeType == "回水")
            {
                tempThresh = 20;
            }
            List <Model.AlarmRecordInfo> list = new List <Model.AlarmRecordInfo>();

            foreach (Model.AKFSHJInfo dj in djs)
            {
                String itemName  = "";
                String itemValue = "";

                /*
                 * // if (float.Parse(dj.OutterTemp1) > 40 || float.Parse(dj.OutterTemp2) > 40)
                 * if (Math.Abs(float.Parse(dj.UnderTemp2) - float.Parse(dj.UnderTemp1)) > tempThresh)
                 * {
                 *  itemName = itemName + "保温层内外温差过高"+",";
                 *  itemValue = itemValue + "(" + dj.UnderTemp2 + ":" + dj.UnderTemp1 + ")" + ",";
                 * }
                 * if (Math.Abs(float.Parse(dj.OutterTemp1) - float.Parse(dj.OutterTemp1)) > tempThresh)
                 * // if (float.Parse(dj.UnderTemp1) > 40 || float.Parse(dj.UnderTemp2) > 40)
                 * {
                 *  itemName = itemName + "保温层内外温差过高" + ",";
                 *  itemValue = itemValue + "(" + dj.OutterTemp1 + ":" + dj.OutterTemp1 + ")" + ",";
                 * }
                 *
                 * if (float.Parse(dj.UnderWaterIn1) != 0 || float.Parse(dj.UnderWaterIn2) != 0 || float.Parse(dj.UnderWaterIn3) != 0 ||
                 *  float.Parse(dj.UnderWaterIn4) != 0 || float.Parse(dj.UnderWaterIn5) != 0 || float.Parse(dj.UnderWaterIn6) != 0)
                 * {
                 *  itemName = itemName + "保温层下浸水" + ",";
                 *  itemValue = itemValue + "(" + dj.UnderWaterIn1 + ":" + dj.UnderWaterIn2+
                 *      ":" + dj.UnderWaterIn3 + ":" + dj.UnderWaterIn4 + ":" + dj.UnderWaterIn5 + ":" + dj.UnderWaterIn6+
                 *       ")" + ",";
                 * }
                 **/
                if (float.Parse(dj.UnderVo11) <= -300 || float.Parse(dj.UnderVo12) <= -300 || float.Parse(dj.UnderVo13) <= -300 ||
                    float.Parse(dj.UnderVo14) <= -300 || float.Parse(dj.UnderVo15) <= -300 || float.Parse(dj.UnderVo16) <= -300)
                {
                    itemName  = itemName + "电位异常" + ",";
                    itemValue = itemValue + "(" + dj.UnderVo11 + ":" + dj.UnderVo12 +
                                ":" + dj.UnderVo13 + ":" + dj.UnderVo14 + ":" + dj.UnderVo15 + ":" + dj.UnderVo16 +
                                ")" + ",";
                }
                else
                {
                    new BLL.AlarmRecord().removeByDevCode(dj.DEVCODE);
                    continue;
                }
                AlarmRecordInfo alarmRecordInfo = null;
                if (itemValue != "" || itemName != "")
                {
                    alarmRecordInfo                  = new AlarmRecordInfo();
                    alarmRecordInfo.ACTIVE           = true;
                    alarmRecordInfo.DEVICE_CODE      = dj.DEVCODE;
                    alarmRecordInfo.DEVICE_ID        = Convert.ToInt32(new BLL.Device().getDeviceIdByCode(dj.DEVCODE));
                    alarmRecordInfo.DEVICE_TYPE_NAME = new BLL.Device().getDevTypeByCode(dj.DEVCODE);
                    alarmRecordInfo.ITEMNAME         = itemName.Substring(0, itemName.Length - 1);
                    alarmRecordInfo.ITEMVALUE        = itemValue.Substring(0, itemValue.Length - 1);
                    alarmRecordInfo.MESSAGE          = itemName;
                    alarmRecordInfo.MESSAGE_STATUS   = 0;
                    alarmRecordInfo.RECORDCODE       = "";
                    alarmRecordInfo.RECORDDATE       = System.DateTime.Now;
                }
                if (null != alarmRecordInfo)
                {
                    list.Add(alarmRecordInfo);
                }
            }
            if (list.Count > 0)
            {
                new BLL.AlarmRecord().insert(list);
            }
        }