using HighWayIot.Log4net; using HighWayIot.Repository.domain; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; namespace HighWayIot.Repository.service { public class ZxReaderSettingService { private static readonly Lazy lazy = new Lazy(() => new ZxReaderSettingService()); public static ZxReaderSettingService Instance { get { return lazy.Value; } } private LogHelper log = LogHelper.Instance; Repository _repository => new Repository("sqlserver"); /// /// 查询所有RFID设备信息 /// /// public List GetReaderInfos(Expression> expression = null) { try { List entity; if (expression != null) { entity = _repository.GetList(expression); } else { entity = _repository.GetList(); } return entity; } catch (Exception ex) { log.Error("RFID设备信息获取异常", ex); return null; } } /// /// 根据IP查询读写器工位信息 /// /// public string GetWorkstateNoByIp(string ip) { try { ZxReaderSettingEntity entity; entity = _repository.GetFirst(x => x.RfidIp == ip); return entity.WorkstationNo; } catch (Exception ex) { log.Error("RFID设备信息获取异常", ex); return null; } } /// /// 修改信息 /// /// /// public bool UpdateReaderInfo(ZxReaderSettingEntity entity) { try { return _repository.Update(entity); } catch (Exception ex) { log.Error("RFID信息修改异常", ex); return false; } } /// /// 修改信息 /// /// /// public bool UpdateRangeReaderInfo(List entitys) { try { return _repository.UpdateRange(entitys); } catch (Exception ex) { log.Error("RFID集合信息修改异常", ex); return false; } } } }