Beispiel #1
0
        public string GetDeviceListByArea(QueryDevice query)
        {
            StringBuilder sbTree = new StringBuilder();
            //  var result = new ResultDevice();
            //  result.DeviceUnitList = new List<DeviceUnit>();
            List <Device> deviceList;

            if (query.ItemCode == "00000")
            {
                deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and areaid=" + query.AreaID, " order by deviceid");
            }
            else
            {
                string itemCodeAll       = query.ItemCode;
                var    itemcodeList      = new NTS.WEB.BLL.Itemcode().GetItemcodeList("  and ItemCodeNumber='" + query.ItemCode + "'", " order by itemcodeid")[0];
                var    itemcodeListChild = new NTS.WEB.BLL.Itemcode().GetItemcodeList("  and ParentID=" + itemcodeList.ParentID, " order by itemcodeid");
                itemCodeAll = itemcodeListChild.Aggregate(itemCodeAll, (current, itemcode) => current + ("," + itemcode.ItemcodeID));
                deviceList  = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and ItemCodeID in (" + itemCodeAll + ") and areaid=" + query.AreaID, " order by deviceid");
            }
            sbTree.Append("[");
            for (var device = 0; device < deviceList.Count; device++)
            {
                sbTree.Append("{\"text\": \"" + deviceList[device].DeviceName + "\",\"id\": " + deviceList[device].DeviceID + ",\"classes\": \"equip\"}");
                sbTree.Append(device == deviceList.Count - 1 ? "" : ",");
            }
            sbTree.Append("]");
            return(sbTree.ToString());
        }
Beispiel #2
0
        public string GetDeviceListByArea(QueryDevice query)
        {
            StringBuilder sbTree = new StringBuilder();
            //  var result = new ResultDevice();
            //  result.DeviceUnitList = new List<DeviceUnit>();
            List <NTS.WEB.Model.Device> deviceList;

            if (query.ItemCode == "00000" || string.IsNullOrEmpty(query.ItemCode))
            {
                deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and areaid=" + query.AreaID, " order by deviceid");
            }
            else
            {
                string itemCodeAll       = query.ItemCode;
                string tempCode          = string.Empty;
                var    itemcodeList      = new NTS.WEB.BLL.Itemcode().GetItemcodeList("  and ItemCodeNumber='" + query.ItemCode + "'", " order by itemcodeid")[0];
                var    itemcodeListChild = new NTS.WEB.BLL.Itemcode().GetItemcodeList("  and ParentID=" + itemcodeList.ItemcodeID, " order by itemcodeid");
                foreach (NTS.WEB.Model.Itemcode itemcode in itemcodeListChild)
                {
                    tempCode += ",'" + itemcode.ItemCodeNumber + "'";
                }
                itemCodeAll = tempCode.Length > 0 ? tempCode.Substring(1) : "'" + itemCodeAll + "'";
                deviceList  = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and ItemCodeID in (" + itemCodeAll + ") and areaid=" + query.AreaID, " order by deviceid");
            }
            sbTree.Append("[");
            for (var device = 0; device < deviceList.Count; device++)
            {
                sbTree.Append("{\"text\": \"" + deviceList[device].DeviceName + "\",\"id\": " + deviceList[device].DeviceID + ",\"classes\": \"equip\"}");
                sbTree.Append(device == deviceList.Count - 1 ? "" : ",");
            }
            sbTree.Append("]");
            return(sbTree.ToString());
        }
Beispiel #3
0
        public async Task <IEnumerable <DeviceWithGatewayResources> > ListGatewaysWithDevicesAsync([FromQuery] QueryDeviceResource queryResource)
        {
            QueryDevice query       = _mapper.Map <QueryDevice>(queryResource);
            var         queryResult = await _deviceService.FindAsync(query);

            var resource = _mapper.Map <IEnumerable <Device>, IEnumerable <DeviceWithGatewayResources> >(queryResult);

            return(resource);
        }
Beispiel #4
0
        public async Task <IEnumerable <Device> > FindAsync(QueryDevice queryDevice)
        {
            var q = _context.Devices.Include(d => d.Gateway).AsNoTracking();

            if (queryDevice.Id.HasValue)
            {
                q = q.Where(d => d.Id == queryDevice.Id);
            }

            if (!String.IsNullOrEmpty(queryDevice.Vendor))
            {
                q = q.Where(d => d.Vendor == queryDevice.Vendor);
            }

            return(await q.ToListAsync());
        }
Beispiel #5
0
 public string GetDeviceListByArea(QueryDevice query)
 {
     return(new NTS.WEB.BLL.BaseTree().GetDeviceListByArea(query));
 }
Beispiel #6
0
 public Task <IEnumerable <Device> > FindAsync(QueryDevice queryDevice)
 {
     return(_deviceRepo.FindAsync(queryDevice));
 }