public ActionResult ControlBuildingEquipment(string buildingName, string equipmentType, string onoff) { EquipmentResult equipmentResult = new EquipmentResult(); try { var classroom = ZRoomService.GetRoomsForBuildingName(buildingName); //查找出所有教室里的所有该设备编码的设备 var equis = ZEquipmentService.GetEntity(e => classroom.Any(r => e.F_RoomId == r.F_Id)).Where(e => e.F_EquipmentType == equipmentType); //筛选出教室编码和设备编码 var val = (from c in classroom join e in equis on c.F_Id equals e.F_RoomId select new EquipmentDto { F_RoomNo = c.F_RoomNo, F_EquipmentNo = e.F_EquipmentNo }).ToList(); PortService.ControlMultiEquipment(val, onoff, equipmentType); equipmentResult.Message = "控制整栋楼层设备成功"; equipmentResult.ResultCode = ResultCode.Ok; equipmentResult.Status = true; } catch (Exception ex) { equipmentResult.Message = "控制整栋楼层设备失败"; equipmentResult.ResultCode = ResultCode.Error; equipmentResult.Status = false; equipmentResult.ErrorData = ex.Message; } return(Json(equipmentResult)); }
public ActionResult ControlFloorEquipment(string buildingName, string floorName, string equipmentType, string onoff) { EquipmentResult equipmentResult = new EquipmentResult(); try { //Z_Room room = ZRoomService.GetEntity(u => u.F_FullName == buildingName).FirstOrDefault();//查找该楼栋 //var floor = ZRoomService.GetEntity(u => u.F_ParentId == room.F_Id).Where(u => u.F_FullName == floorName); //该楼栋的该楼层 //var classroom = ZRoomService.GetEntity(u => floor.Any(f => f.F_Id == u.F_ParentId)); //楼层中所有教室 var classroom = ZRoomService.GetRoomsForBuildingName(buildingName, floorName); //查询该楼层下的该设备型号的所有设备 var equis = ZEquipmentService.GetEntity(e => classroom.Any(r => e.F_RoomId == r.F_Id)).Where(e => e.F_EquipmentType == equipmentType); //筛选出教室编码和设备编码 var val = (from c in classroom join e in equis on c.F_Id equals e.F_RoomId select new EquipmentDto() { F_RoomNo = c.F_RoomNo, F_EquipmentNo = e.F_EquipmentNo }).ToList(); PortService.ControlMultiEquipment(val, onoff, equipmentType); PortService.ControlMultiEquipment(val, onoff, equipmentType); equipmentResult.Message = "控制整栋楼层设备成功"; equipmentResult.ResultCode = ResultCode.Ok; equipmentResult.Status = true; } catch (Exception ex) { equipmentResult.Message = "控制整栋楼层设备失败"; equipmentResult.ResultCode = ResultCode.Error; equipmentResult.Status = false; equipmentResult.ErrorData = ex.Message; } return(Json(equipmentResult)); }