Example #1
0
 /// <summary>
 /// 更新报警已处理
 /// </summary>
 public bool UpdateAlarmData(AlarmInfo alarmInfo, ref string errMsg)
 {
     try
     {
         var sb = new StringBuilder();
         sb.Append(" update z40_loc_err_log");
         sb.Append(" set err_end_time = getdate(),");
         sb.Append(" err_seconds = datediff(SECOND, ERR_BEGIN_TIME, getdate())");
         sb.Append(" where objid = @objid");
         var param = new DynamicParameters();
         param.Add("objid", alarmInfo.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);
     }
 }
Example #2
0
 /// <summary>
 /// 初始化配置项信息
 /// </summary>
 public bool InitDb()
 {
     try
     {
         var dt = DbAction.Instance.GetAlarmOpcItems();
         if (dt == null || dt.Rows.Count == 0)
         {
             ShowFormData.Instance.ShowFormInfo(new ShowInfoData("未获取到配置项信息"));
             return(false);
         }
         foreach (DataRow row in dt.Rows)
         {
             var alarmInfo = new AlarmInfo();
             alarmInfo.LocPlcNo    = row["loc_plc_no"].ToString();
             alarmInfo.TagName     = row["tagname"].ToString();
             alarmInfo.TagIndex    = row["tagindex"].ToString();
             alarmInfo.Discrip     = row["discrip"].ToString();
             alarmInfo.TagLongName = row["taglongname"].ToString();
             alarmInfos.Add(alarmInfo.TagLongName, alarmInfo);
         }
         ShowFormData.Instance.ShowFormInfo(new ShowInfoData("初始化数据库配置成功"));
         return(true);
     }
     catch (Exception ex)
     {
         ShowFormData.Instance.ShowFormInfo(new ShowInfoData($"[异常]初始化数据库配置,[原因]{ex.Message}"));
         return(false);
     }
 }
Example #3
0
 /// <summary>
 /// 保存报警
 /// </summary>
 public bool SaveAlarmData(AlarmInfo alarmInfo, ref string errMsg)
 {
     try
     {
         var sb = new StringBuilder();
         sb.Append(" insert into z40_loc_err_log");
         sb.Append(" (objid, loc_plc_no, err_desc, err_begin_time)");
         sb.Append(" values");
         sb.Append(" (@objid, @loc_plc_no, @err_desc, getdate())");
         var param = new DynamicParameters();
         param.Add("objid", alarmInfo.Objid);
         param.Add("loc_plc_no", alarmInfo.LocPlcNo);
         param.Add("err_desc", alarmInfo.Discrip);
         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);
     }
 }
Example #4
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);
     }
 }