Example #1
0
        public ActionResult SearchTest(QueryParams queryParams)
        {
            EquipmentResult result = new EquipmentResult();
            Z_Room          room   = ZRoomService.GetEntity(u => u.F_RoomNo == queryParams.classroom).FirstOrDefault();
            //获取该教室所有的设备
            var       zeList    = ZEquipmentService.GetEntity(u => u.F_RoomId == room.F_Id).ToList();
            byte      fun       = (byte)Convert.ToInt32(AppSettingUtils.GetValue("Search"));
            ClassRoom classRoom = PortService.GetReturnDataTest(queryParams.classroom);

            if (classRoom != null)
            {
                classRoom.Name    = room?.F_FullName;
                classRoom.ClassNo = room.F_EnCode;  //教室编码
                classRoom.Id      = room.F_RoomNo;
                var list = classRoom.SonserList;
                classRoom.AbnormalSonserList = classRoom.SonserList.Where(u => u.Online == StateType.Offline).ToList();
                classRoom.NormalSonserList   = classRoom.SonserList.Where(u => u.Online == StateType.Online).ToList();
                result.Count          = zeList.Count;
                result.ExceptionCount = classRoom.AbnormalSonserList.Count;
                result.NormalCount    = classRoom.NormalSonserList.Count;
                result.AppendData     = classRoom;
            }
            else
            {
                result.Message = "查询设备信息失败!请重试";
            }
            return(Json(result));
        }
Example #2
0
        public ActionResult SearchAll(QueryParams queryParams)
        {
            EquipmentResult result = new EquipmentResult();

            try
            {
                //查询该教室
                Z_Room room = ZRoomService.GetEntity(u => u.F_RoomNo == queryParams.classroom).FirstOrDefault();

                if (room == null) //没有该教室
                {
                    result.Message = "教室地址有误!";
                }
                else
                {
                    ClassRoom classRoom = PortService.Search(room, ref result);
                    //PortService.CloseConnect();
                    result.AppendData = classRoom;
                }
            }
            catch (Exception exception)
            {
                result.ErrorData = exception.ToString();
                result.Message   = "查询设备信息失败";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        /// <summary>
        /// 初始化设备节点
        /// </summary>
        /// <param name="classroom">教室地址</param>
        /// <returns></returns>
        public ActionResult Init(string classroom)
        {
            byte b   = 0x00;
            byte fun = 0x1f;

            EResult         = PortService.SendConvertCmd(fun, classroom, "00", b);
            EResult.Message = EResult.Status ? "查询设备信息成功" : "查询设备信息失败";
            ClassRoom          classRoom = PortService.GetReturnData(classroom);
            var                list      = classRoom.SonserList;
            List <Z_Equipment> zeList    = new List <Z_Equipment>();
            Z_Room             room      = ZRoomService.GetEntity(u => u.F_RoomNo == classroom).FirstOrDefault();

            ZEquipmentService.DeleteEntitys(ZEquipmentService.GetEntity(u => u.F_RoomId == room.F_Id).ToList());
            if (room != null)
            {
                foreach (var item in list)
                {
                    var zEquipment = new Z_Equipment
                    {
                        F_Id            = Guid.NewGuid().ToString(),
                        F_RoomId        = room.F_Id,
                        F_FullName      = item.Name,
                        F_EquipmentType = item.Type + "",
                        F_EnabledMark   = true,
                        F_EquipmentNo   = item.Id.IndexOf('_') != -1 ? item.Id.Split('_')[0] : item.Id
                    };
                    zeList.Add(zEquipment);
                }
            }
            ZEquipmentService.AddEntitys(zeList);
            EResult.AppendData = list;
            return(Json(EResult, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        /// <summary>
        /// 操作后
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);
            if (!isCheck)
            {
                return;
            }
            string token;

            token = filterContext.HttpContext.Request.Headers["Access"];
            token = token ?? filterContext.HttpContext.Request["Access"];
            token = token ?? filterContext.HttpContext.Request.Cookies["Access"]?.Value;

            var payload = Cache.GetCache <Payload>(token);
            //操作日志记录
            JsonResult jsonResult = filterContext.Result as JsonResult;
            string     roomId     = filterContext.HttpContext.Request["classroom"];
            string     nodeId     = filterContext.HttpContext.Request["nodeAdd"] ?? "00";

            if (nodeId?.IndexOf("_") != -1)
            {
                nodeId = nodeId.Split('_')[0];
            }
            string onoff = filterContext.HttpContext.Request["onoff"];

            onoff = string.IsNullOrEmpty(onoff) ? "" : onoff;
            EquipmentResult equipmentResult = jsonResult?.Data as EquipmentResult;

            if (equipmentResult != null)
            {
                //开启线程处理后续日志操作
                ThreadPool.QueueUserWorkItem(oo =>
                {
                    Z_EquipmentLog zEquipmentLog = new Z_EquipmentLog();
                    zEquipmentLog.F_Id           = Guid.NewGuid().ToString();
                    zEquipmentLog.F_Account      = payload.Account;
                    zEquipmentLog.F_Date         = DateTime.Now;
                    zEquipmentLog.F_RoomNo       = roomId;
                    string roomName = ZRoomService.GetEntity(z => z.F_RoomNo.ToLower() == roomId.ToLower()).Select(z => z.F_FullName).FirstOrDefault();
                    string nodeName = ZEquipmentService.GetEntity(e => e.F_EquipmentNo.ToLower() == nodeId.ToLower())
                                      .Select(e => e.F_FullName).FirstOrDefault();
                    var user = SysUserService.GetEntity(u => u.F_Account == payload.Account).Select(o => new { o.F_NickName, o.F_RealName })
                               .FirstOrDefault();
                    zEquipmentLog.F_EquipmentNo      = nodeId;
                    zEquipmentLog.F_Description      = equipmentResult.Message;
                    zEquipmentLog.F_EquipmentLogType = onoff == StateType.OPEN ? EQUOPEN : onoff == StateType.CLOSE ? EQUCLOSE : EQUSEARCH;
                    zEquipmentLog.F_RoomName         = roomName;
                    zEquipmentLog.F_EquipmentName    = nodeName;
                    zEquipmentLog.F_NickName         = user?.F_NickName;
                    zEquipmentLog.F_FullName         = user?.F_RealName;

                    ZEquipmentLogService.AddEntity(zEquipmentLog);
                });
            }
        }
Example #5
0
        /// <summary>
        /// 模糊查询教室信息,通过教室名称和编号
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public ActionResult SearchClassListByNameOrNo(string name)
        {
            var room = ZRoomService.GetEntity(u => u.F_FullName.Contains(name) || u.F_EnCode.Contains(name)).Select(u => new
            {
                value = u.F_FullName + "(" + u.F_EnCode + ")",
                u.F_FullName,
                u.F_EnCode,
                u.F_RoomNo,
            }).ToList();

            return(Json(room, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        /// <summary>
        /// 报警信息
        /// </summary>
        /// <returns></returns>
        public ActionResult AlarmInformation()
        {
            int    value;
            string classId = PortService.QueryAlarmData(out value);

            //PortService.CloseConnect();
            if (classId != null) //有报警数据
            {
                Z_Room room = ZRoomService.GetEntity(r => r.F_RoomNo == classId).FirstOrDefault();
                return(Json(new { ResultCode = ResultCode.Error, ClassName = room.F_FullName, AppendData = value, ClassNo = room.F_EnCode }));
            }
            return(Json(new { ResultCode = ResultCode.Ok }));
        }
Example #7
0
        public ActionResult SearchAllClass()
        {
            List <Buildings> list;

            list = new List <Buildings>();
            var buildings  = ZRoomService.GetEntity(u => u.F_RoomType == "Building").ToList();
            var Floors     = ZRoomService.GetEntity(u => u.F_RoomType == "Floor").ToList();
            var ClassRooms = ZRoomService.GetEntity(u => u.F_RoomType == "ClassRoom").ToList();

            foreach (var item in buildings)
            {
                Buildings building = new Buildings();
                building.Name = item.F_FullName;
                List <Floors> FList = new List <Floors>();
                foreach (var f in Floors)
                {
                    if (f.F_ParentId != item.F_Id)
                    {
                        continue;
                    }
                    Floors floors = new Floors();
                    floors.Name = f.F_FullName;
                    List <ClassRoom> classRooms = new List <ClassRoom>();
                    foreach (var rooms in ClassRooms)
                    {
                        if (rooms.F_ParentId != f.F_Id)
                        {
                            continue;
                        }
                        ClassRoom classRoom = new ClassRoom();
                        AutoMapperConfig.Map(building, classRoom);
                        AutoMapperConfig.Map(floors, classRoom);
                        AutoMapperConfig.Map(rooms, classRoom);
                        classRooms.Add(classRoom);
                    }
                    floors.ClassRooms = classRooms;
                    FList.Add(floors);
                }
                building.Floors = FList;
                list.Add(building);
            }
            Cache.AddCache("AllClasses", list, DateTime.Now.AddDays(1));
            return(Json(list, JsonRequestBehavior.AllowGet));
        }