public ResultDevice GetDeviceList(QueryDevice2 query) { var pAction = new ExecuteProcess(); try { StringBuilder sbTree = new StringBuilder(); List<Device> deviceList; if (query.ItemCode == "00000") { if (query.ObjType == AreaType.Area) { deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and areaid=" + query.ObjectId, " order by deviceid"); } else { deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and areaid2=" + query.ObjectId, " order by deviceid"); } } else { string itemCodeAll = query.ItemCode; Itemcode objItem = new Itemcode(); var itemcodeList = objItem.GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by itemcodeid")[0]; var itemcodeListChild = objItem.GetItemcodeList(" and ParentID=" + itemcodeList.ItemcodeID, " order by itemcodeid"); itemCodeAll = itemcodeListChild.Aggregate("'" + itemCodeAll + "'", (current, itemcode) => current + ("," + "'" + itemcode.ItemCodeNumber + "'")); if (query.ObjType == AreaType.Area) { deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and ItemCodeID in (" + itemCodeAll + ") and areaid=" + query.ObjectId, " order by deviceid"); } else { deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and ItemCodeID in (" + itemCodeAll + ") and areaid2=" + query.ObjectId, " 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("]"); List<DeviceUnit> lstDvc = new List<DeviceUnit>(); foreach (var device in deviceList) { DeviceUnit du = new DeviceUnit(); du.DeviceID = device.DeviceID; du.DeviceName = device.DeviceName; lstDvc.Add(du); } ResultDevice result = new ResultDevice(); result.DeviceUnitList = lstDvc; pAction.Success = true; result.ActionInfo = pAction; return result; } catch (Exception ex) { pAction.Success = false; pAction.ExceptionMsg = ex.Message; return new ResultDevice() { ActionInfo = pAction }; } }
public ResultDevice GetDeviceList(QueryDevice2 query) { return new NTS.WEB.BLL.Charts().GetDeviceList(query); }