Exemplo n.º 1
0
 /// <summary>
 /// 根据园区ID获取报警灯配置
 /// </summary>
 /// <param name="regionId"></param>
 /// <returns></returns>
 public List <BaseRelayConfigModel> GetAlarmLampByRegion(int regionId)
 {
     try
     {
         List <BaseRelayConfigModel>  retRelayList = new List <BaseRelayConfigModel>();
         BaseRelayConfigModel         relay        = null;
         BaseRegionConfigDAL          regionDal    = new BaseRegionConfigDAL();
         List <BaseRegionConfigModel> regionList   = regionDal.GetAllRegionConfig();
         List <BaseRelayConfigModel>  relayList    = relayDal.GetAlarmLampByRegion(regionId);
         for (int i = 0; i < relayList.Count; i++)
         {
             relay               = new BaseRelayConfigModel();
             relay.control_id    = relayList[i].control_id;
             relay.ext3          = regionList.Where(n => n.id == relayList[i].region_id).FirstOrDefault() == null ? "" : regionList.Where(n => n.id == relayList[i].region_id).FirstOrDefault().region_code;
             relay.id            = relayList[i].id;
             relay.region_id     = relayList[i].region_id;
             relay.relay_content = relayList[i].relay_content;
             relay.relay_type    = relayList[i].relay_type;
             retRelayList.Add(relay);
         }
         return(retRelayList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model"></param>
 public int UpdateBaseRelayConfigById(BaseRelayConfigModel model)
 {
     try
     {
         int result = mapContext.Update("UpdateBaseRelayConfigById", model);
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="entity"></param>
 public int AddEntity(BaseRelayConfigModel entity)
 {
     try
     {
         int id = (int)mapContext.Insert("InsertBaseRelayConfig", entity);
         return(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 新增报警灯配置
 /// </summary>
 /// <param name="color"></param>
 /// <param name="relayType"></param>
 /// <param name="controlId"></param>
 /// <param name="regionId"></param>
 /// <returns></returns>
 public bool AddRelayConfig(string color, int relayType, int controlId, int regionId)
 {
     try
     {
         BaseRelayConfigModel model = new BaseRelayConfigModel();
         model.control_id    = controlId;
         model.region_id     = regionId;
         model.relay_content = color;
         model.relay_type    = relayType;
         int res = relayDal.AddEntity(model);
         return(res > 0 ? true : false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
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);
     }
 }
Exemplo n.º 6
0
 public bool UpdateEntity(int id, BaseRelayConfigModel newentity)
 {
     throw new NotImplementedException();
 }