示例#1
0
 /// <summary>
 /// 更新报警已处理
 /// </summary>
 public bool UpdateAlarmData(AlarmLoc alarmLoc, int alarmIndex, ref string errMsg)
 {
     try
     {
         var sb = new StringBuilder();
         sb.Append(" update z40_loc_err_log");
         sb.Append(" set err_end_time = sysdate,");
         sb.Append(" err_seconds = round((sysdate-err_begin_time)*24*60*60,2)");
         sb.Append(" where objid = :objid");
         var param = new DynamicParameters();
         param.Add("objid", alarmLoc.alarmInfo[alarmIndex].Objid);
         var result = Db.Connection.Execute(sb.ToString(), param);
         if (result > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         log.Error($"更新报警已处理失败:{ex.ToString()}");
         errMsg = ex.Message;
         return(false);
     }
 }
示例#2
0
 /// <summary>
 /// 保存报警
 /// </summary>
 public bool SaveAlarmData(AlarmLoc alarmLoc, int alarmIndex, ref string errMsg)
 {
     try
     {
         var sb = new StringBuilder();
         sb.Append(" insert into z40_loc_err_log");
         sb.Append(" (objid, loc_plc_no, err_desc)");
         sb.Append(" values");
         sb.Append(" (:objid, :loc_plc_no, :err_desc)");
         var param = new DynamicParameters();
         param.Add("objid", alarmLoc.alarmInfo[alarmIndex].Objid);
         param.Add("loc_plc_no", alarmLoc.LocPlcNo);
         param.Add("err_desc", alarmLoc.alarmInfo[alarmIndex].AlarmDesc);
         var result = Db.Connection.Execute(sb.ToString(), param);
         if (result > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         log.Error($"保存报警信息失败:{ex.ToString()}");
         errMsg = ex.Message;
         return(false);
     }
 }
示例#3
0
 /// <summary>
 /// 初始化站台信息
 /// </summary>
 public bool InitLoc()
 {
     try
     {
         //初始化站台信息
         var dtLoc = DbAction.Instance.GetAlarmLoc();
         if (dtLoc == null || dtLoc.Rows.Count == 0)
         {
             ShowFormData.Instance.ShowFormInfo(new ShowInfoData("未获取到站台信息"));
             return(false);
         }
         foreach (DataRow row in dtLoc.Rows)
         {
             var loc = new AlarmLoc();
             loc.LocPlcNo  = row["loc_plc_no"].ToString();
             loc.LocArea   = Convert.ToInt32(row["loc_area"]);
             loc.LocCode   = Convert.ToInt32(row["loc_code"]);
             loc.AlarmType = Convert.ToInt32(row["alarm_type"]);
             var dtAlarm = DbAction.Instance.GetAlarmInfo(loc.AlarmType);
             if (dtAlarm == null || dtAlarm.Rows.Count == 0)
             {
                 ShowFormData.Instance.ShowFormInfo(new ShowInfoData($"站台{loc.LocPlcNo}未获取到报警描述"));
                 locList.Add(loc);
                 continue;
             }
             foreach (DataRow descRow in dtAlarm.Rows)
             {
                 var alarmIndex = Convert.ToInt32(descRow["alarm_index"]);
                 var alarmInfo  = new AlarmInfo();
                 alarmInfo.Objid     = 0;
                 alarmInfo.AlarmDesc = descRow["alarm_desc"].ToString();
                 loc.alarmInfo.Add(alarmIndex, alarmInfo);
             }
             locList.Add(loc);
         }
         ShowFormData.Instance.ShowFormInfo(new ShowInfoData($"初始化站台故障描述成功"));
         return(true);
     }
     catch (Exception ex)
     {
         ShowFormData.Instance.ShowFormInfo(new ShowInfoData($"[异常]初始化站台故障描述,[原因]{ex.Message}"));
         return(false);
     }
 }
示例#4
0
        private bool CheckAlarmLoc(AlarmItem alarmItem, AlarmLoc alarmLoc, string currLocNo, int alarmIndex)
        {
            if (string.IsNullOrEmpty(alarmItem.AlarmLocNo))
            {
                return(false);
            }
            if (alarmItem.AlarmLocNo == currLocNo)
            {
                return(false);
            }
            var oldAlarmLoc = locList.FirstOrDefault(p => p.LocArea.ToString() + p.LocCode.ToString() == alarmItem.AlarmLocNo);

            if (oldAlarmLoc == null)
            {
                return(false);
            }
            ShowFormData.Instance.ShowFormInfo(new ShowInfoData(oldAlarmLoc.LocPlcNo, InfoType.locStatus));
            if (oldAlarmLoc.alarmInfo[alarmIndex].Objid <= 0)
            {
                return(false);
            }
            var errMsg = string.Empty;

            //更新报警已处理信息
            if (DbAction.Instance.UpdateAlarmData(oldAlarmLoc, alarmIndex, ref errMsg))
            {
                oldAlarmLoc.alarmInfo[alarmIndex].Objid = 0;
                ShowFormData.Instance.ShowFormInfo(new ShowInfoData($"[报警]下位机[{oldAlarmLoc.LocPlcNo}]变更[{alarmLoc?.LocPlcNo}]报警[{alarmLoc.alarmInfo[alarmIndex].AlarmDesc}]复位"));
            }
            else
            {
                ShowFormData.Instance.ShowFormInfo(new ShowInfoData($"[报警]下位机[{oldAlarmLoc.LocPlcNo}]变更[{alarmLoc?.LocPlcNo}]报警[{alarmLoc.alarmInfo[alarmIndex].AlarmDesc}]复位失败:{errMsg}"));
                return(false);
            }
            return(true);
        }