コード例 #1
0
        public async Task <BaseResponse> UpdateTypeHardwareConfigAsync(int typeId, TypeHardwareConfigUpdateDto req, string account)
        {
            var data = await _th.FindAsync(req.Id);

            if (data == null)
            {
                return(new BaseResponse {
                    Success = false, Message = "该类型下不存在该PLC配置数据"
                });
            }
            try
            {
                var entity = _mapper.Map(req, data);
                entity.Modify     = account;
                entity.ModifyTime = DateTime.Now;
                await _th.SaveAsync(entity);

                _log.LogInformation($"{account}修改标示为{req.Id}的PLC配置数据成功");
                return(new BaseResponse {
                    Success = true, Message = "修改数据成功"
                });
            }
            catch (Exception ex)
            {
                _log.LogError($"{account}修改标示为{req.Id}的PLC配置数据失败,失败原因:{ex.Message}->{ex.StackTrace}->{ex.InnerException}");
                return(new BaseResponse {
                    Success = false, Message = "修改类型PLC配置数据失败,请联系管理员"
                });
            }
        }
コード例 #2
0
        public async Task <ActionResult <BaseResponse> > TypeHardwareConfigUpdate(int typeId, TypeHardwareConfigUpdateDto req)
        {
            //string user = User.Identity.Name;
            //if (string.IsNullOrWhiteSpace(user))
            //{
            //    return Unauthorized("用户凭证缺失");
            //}
            //UserMessage um = JsonConvert.DeserializeObject<UserMessage>(user);
            //string GroupId;
            //bool bRet = _ts.IsExist(a => a.Id == typeId, out GroupId);
            //if (!bRet)
            //{
            //    return new BaseResponse { Success = false, Message = "输入的类型不存在" };
            //}
            //if (!(um.IsAdmin && (um.GroupId == GroupId || um.Code == _config["Group"])))
            //{
            //    return Unauthorized("用户没有权限");
            //}
            string Account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value;
            var    rm      = await _ths.UpdateTypeHardwareConfigAsync(typeId, req, Account);

            return(rm);
        }