Example #1
0
        public ActionResult Delete(string ids)
        {
            if (string.IsNullOrEmpty(ids))
            {
                return(Content("请选中要删除的数据!"));
            }
            //正常处理
            string[]   strIds = ids.Split(',');
            List <int> idList = new List <int>();

            foreach (var strId in strIds)
            {
                idList.Add(int.Parse(strId));
            }
            DeviceInfoService.DeleteListByLogical(idList);

            foreach (var id in idList)
            {
                var deviceId = DeviceInfoService.GetEntities(d => d.Id == id).Select(d => d.DeviceId).FirstOrDefault();
                //写操作日志
                OperationLogService.Add("删除设备", "设备管理", LoginInfo, deviceId, "");
            }

            return(Content("ok"));
        }
Example #2
0
        // GET: Device

        /// <summary>
        /// 添加设备信息
        /// </summary>
        /// <param name="deviceInfo"></param>
        /// <returns></returns>
        public ActionResult Add(DeviceInfo deviceInfo)
        {
            var deviceId = DeviceInfoService.GetEntities(u => (u.DeviceId == deviceInfo.DeviceId && u.IsDeleted == false)).FirstOrDefault();

            if (deviceId == null)
            {
                deviceInfo.SubTime = DateTime.Now;
                int id = DeviceInfoService.Add(deviceInfo).Id;
                DeviceParameterInfo deviceParameterInfo = new DeviceParameterInfo
                {
                    DeviceInfoId = id,
                    StatusFlag   = Glove.IOT.Model.Enum.StatusFlagEnum.未连接.ToString(),
                    SubTime      = DateTime.Now,
                };
                DeviceParameterInfoService.Add(deviceParameterInfo);
                //写操作日志
                OperationLogService.Add("添加设备", "设备管理", LoginInfo, deviceInfo.DeviceId, "");
                return(Content("Ok"));
            }
            else
            {
                return(Content("fail"));
            }
        }