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"));
        }
        /// <summary>
        /// 获取设备参数详细信息
        /// </summary>
        /// <returns></returns>
        public ActionResult GetDeviceParameterInfo(string deviceId)
        {
            var deviceParameter  = DeviceParameterInfoService.GetDeviceParameter(deviceId);
            var parameterHistory = DeviceParameterInfoService.GetHistoryParameter(deviceId);
            var data             = new { deviceParameter, parameterHistory = parameterHistory.ToList() };

            //写操作日志
            OperationLogService.Add("查看设备", "设备管理", LoginInfo, deviceId, "");
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = txtUserName.Text.Trim();
            string password = CommonHelper.GetMD5(txtPassword.Text.Trim());

            OperatorService opsv = new OperatorService();
            Operator        op   = opsv.GetOperator(username);

            OperationLog        log   = new OperationLog();
            OperationLogService logsv = new OperationLogService();

            if (op == null || op.UserName != username)
            {
                log.OperatorId = Guid.Empty;
                log.ActionDate = DateTime.Now;
                log.ActionDesc = username + ":用户名不正确";
                CommonHelper.FailedReply("用户名错误!");
                this.DialogResult = DialogResult.Cancel;
            }
            else if (op.Password != password)
            {
                CommonHelper.FailedReply("密码错误!");
                this.DialogResult = DialogResult.Cancel;
            }
            else if (op.IsLocked == true)
            {
                CommonHelper.FailedReply("用户锁定!");
                this.DialogResult = DialogResult.Cancel;
            }
            else if (op.IsDeleted == true)
            {
                CommonHelper.FailedReply("用户不存在!");
                this.DialogResult = DialogResult.Cancel;
            }
            else
            {
                UserInfo ui = UserInfo.GetInstance();
                ui.Id       = op.Id;
                ui.UserName = op.UserName;
                ui.Password = op.Password;
                ui.RealName = op.RealName;

                log.OperatorId = op.Id;
                log.ActionDate = DateTime.Now;
                log.ActionDesc = username + "登录成功!";


                CommonHelper.SuccessReply("登陆成功!");
                this.DialogResult = DialogResult.OK;
            }
            logsv.Add(log);
        }
        /// <summary>
        /// 描述:添加操作日记
        /// <para>作    者:蔡亚康</para>
        /// <para>创建时间:2019-03-07</para>
        /// </summary>
        /// <param name="passport">用户账号信息</param>
        private void AddOperationLog(TblHssPassport passport)
        {
            OperationLogService operationLogService = new OperationLogService();
            TblDatOperationLog  log = new TblDatOperationLog()
            {
                BusinessId     = passport.PassporId,
                BusinessType   = (int)LogBusinessType.HssLogin,
                FlowStatus     = (int)OperationFlowStatus.Finish,
                OperationLogId = IdGenerator.NextId(),
                OperatorId     = "",
                OperatorName   = "",
                Remark         = $"用户{passport.UserCode} 于 {DateTime.Now} 登陆了家校互联",
                CreateTime     = DateTime.Now,
                SchoolId       = ""
            };

            operationLogService.Add(log);
        }
        // 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"));
            }
        }
        /// <summary>
        /// 获取所有设备信息
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAllDeviceInfos(string limit, string page, string schDeviceId, string schStatusFlag)
        {
            int pageSize  = int.Parse(limit ?? "10");
            int pageIndex = int.Parse(page ?? "1");

            //过滤的设备名 过滤备注schDeviceId schStatusFlag
            var queryParam = new DeviceQueryParam()
            {
                PageSize      = pageSize,
                PageIndex     = pageIndex,
                SchDeviceId   = schDeviceId,
                SchStatusFlag = schStatusFlag,
                Total         = 0
            };
            var pageData = DeviceInfoService.LoagDevicePageData(queryParam).ToList();
            var data     = new { code = 0, msg = "", count = queryParam.Total, data = pageData.ToList() };

            if (!string.IsNullOrEmpty(schDeviceId) || !string.IsNullOrEmpty(schStatusFlag))
            {
                //写操作日志
                OperationLogService.Add("查找设备", "设备管理", LoginInfo, schDeviceId, schStatusFlag);
            }
            return(Json(data, JsonRequestBehavior.AllowGet));
        }