/// <summary> /// 页面发送模拟报警至转发层 /// </summary> /// <param name="alarmLevel"></param> /// <param name="deviceCode"></param> /// <param name="content"></param> /// <param name="eventCode"></param> /// <returns></returns> public JsonResult DeviceAlarm(string alarmName, int alarmLevel, string deviceCode, string content, string eventCode) { try { MapAlarmBLL mapAlarmBll = new MapAlarmBLL(); #region 旧版 //if (mapAlarmBll.AddDeviceAlarm(alarmName, alarmLevel, deviceCode, content, eventCode)) //{ // return Json(new { status = 0, msg = "页面报警成功!" }); //} //else //{ // return Json(new { status = 1, msg = "页面报警失败!" }); //} #endregion #region 新版 RetMsgModel retModel = mapAlarmBll.AddMapDeviceAlarm(alarmName, alarmLevel, deviceCode, content, eventCode); return(Json(new { status = retModel.status, msg = retModel.message })); #endregion } catch (Exception ex) { return(Json(new { status = 1, msg = ex.Message })); } }
/// <summary> /// 发送报警灯信息 /// </summary> /// <param name="regionCode"></param> /// <param name="content"></param> public RetMsgModel SendRelayMessage(string regionCode, int controlId, int op) { try { RetMsgModel retModel = new RetMsgModel(); RelayMsgModel ledMsgModel = new RelayMsgModel(); ledMsgModel.controlId = controlId; //控制器编号 ledMsgModel.regionCode = regionCode; ledMsgModel.op = op; //1:开,0:关,3:全开,4:全关 string param = CSM.Utils.JsonHelper.ObjectToString(ledMsgModel); string url = System.Configuration.ConfigurationManager.AppSettings["InterfaceUrl"] + "/api/Interface/RelayControlCommand"; string ret = Utils.HttpHelper.PostWebRequestBandError(url, param, "application/json;charset=utf-8", Encoding.UTF8); //RetMsgModel retModel = Utils.JsonHelper.StringToObject<RetMsgModel>(ret); if (string.IsNullOrEmpty(ret)) { retModel.status = 1; retModel.message = "调用中间件报警灯接口返回值为空!"; } else { retModel = Utils.JsonHelper.StringToObject <RetMsgModel>(ret); } return(retModel); } catch (Exception ex) { throw ex; } }
/// <summary> /// 发送LED信息 /// </summary> /// <param name="regionCode"></param> /// <param name="content"></param> public RetMsgModel SendLEDMessage(string regionCode, int location, string content) { try { RetMsgModel retModel = new RetMsgModel(); LEDMsgModel ledMsgModel = new LEDMsgModel(); ledMsgModel.message = content; ledMsgModel.regionCode = regionCode; ledMsgModel.type = location; //确警前默认中控室,确警后默认该园区户外LED string param = CSM.Utils.JsonHelper.ObjectToString(ledMsgModel); string url = System.Configuration.ConfigurationManager.AppSettings["InterfaceUrl"] + "/api/Interface/LEDControlCommand"; string ret = Utils.HttpHelper.PostWebRequestBandError(url, param, "application/json;charset=utf-8", Encoding.UTF8); if (string.IsNullOrEmpty(ret)) { retModel.status = 1; retModel.message = "调用中间件LED接口返回值为空!"; } else { retModel = Utils.JsonHelper.StringToObject <RetMsgModel>(ret); } return(retModel); } catch (Exception ex) { throw ex; } }
/// <summary> /// 页面发送模拟报警至转发层 /// </summary> /// <param name="alarmLevel"></param> /// <param name="deviceCode"></param> /// <param name="content"></param> /// <param name="eventCode"></param> /// <returns></returns> public RetMsgModel AddMapDeviceAlarm(string alarmName, int alarmLevel, string deviceCode, string content, string eventCode) { try { RetMsgModel retModel = new RetMsgModel(); sendAlarmPageDele = new SendAlarmPageDele(CSM.Utils.HttpHelper.PostJsonData); string url = System.Configuration.ConfigurationManager.AppSettings["InterfaceUrl"] + "/api/Interface/Forward"; ServDeviceInfoDAL deviceDal = new ServDeviceInfoDAL(); AlarmInfoModel alarmModel = new AlarmInfoModel(); InterfaceData data = new InterfaceData(); ServDeviceInfoModel deviceModel = deviceDal.GetDeviceByDeviceCode(deviceCode); alarmModel.alarm_cache_status = 0; alarmModel.alarm_event = eventCode; alarmModel.alarm_level = alarmLevel; alarmModel.alarm_location = ""; alarmModel.alarm_name = alarmName; alarmModel.alarm_subsystem = deviceModel.subsystem_id; alarmModel.alarm_text = content; alarmModel.alarm_time = DateTime.Now; alarmModel.alarm_type = (int)EnumClass.AlarmType.设备报警; alarmModel.code = deviceCode; data.data = alarmModel; data.dataType = 1; data.subSysType = deviceModel.subsystem_id; data.mark = "pageMoniter"; string param = CSM.Utils.JsonHelper.ObjectToString(data); //sendAlarmPageDele.BeginInvoke(url, param, Encoding.UTF8, null, null); string ret = Utils.HttpHelper.PostWebRequestBandError(url, param, "application/json;charset=utf-8", Encoding.UTF8); if (string.IsNullOrEmpty(ret)) { retModel.status = 1; retModel.message = "调用转发层返回值为空!"; } else { retModel = Utils.JsonHelper.StringToObject <RetMsgModel>(ret); } return(retModel); } catch (Exception ex) { throw ex; } }