Exemplo n.º 1
0
 /// <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;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 处理四色灯
 /// </summary>
 /// <param name="relayId"></param>
 /// <returns></returns>
 public bool HandleRelay(string relayId, string regionCode)
 {
     try
     {
         int id = int.Parse(relayId);
         //查找四色灯信息
         BaseRelayConfigModel baseRelayConfigModel = GetRelayConfigById(id);
         RelayMsgModel        relayMsg             = new RelayMsgModel();
         relayMsg.regionCode = regionCode;
         relayMsg.controlId  = baseRelayConfigModel.control_id;
         relayMsg.op         = (int)EnumClass.Operation.打开;
         string message = JsonHelper.ObjectToString(relayMsg);
         // HttpHelper.PostJsonData(SubSystemRouteBLL.GetRelayControlRoute(), message, Encoding.UTF8);
         sendRelayCmdDele.BeginInvoke(SubSystemRouteBLL.GetRelayControlRoute(), message, Encoding.UTF8, null, null);
         Log4NetHelp.Info("调用四色灯接口成功!信息:" + message);
         return(true);
     }
     catch (Exception ex)
     {
         Log4NetHelp.Info("调用四色灯接口失败!控制编号:" + relayId + ex.Message);
         return(false);
     }
 }