public async Task <BaseResponse> AddDeviceInputDataAsync(string account, DeviceInputAddDto req, string deviceSn) { //一个设备只能添加一条 var d = await _dir.Find(a => a.DeviceSn == deviceSn).CountAsync(); if (d > 0) { return(new BaseResponse { Success = false, Message = "该设备已存在有输入数据" }); } try { var entity = _mapper.Map <DeviceInputDataModel>(req); entity.Create = account; entity.DeviceSn = deviceSn; await _dir.AddAsync(entity); _log.LogInformation($"{account}添加标示为{entity.Id}的设备输入数据成功"); return(new HandleResponse <int> { Success = true, Message = "添加数据成功", Key = entity.Id }); } catch (Exception ex) { _log.LogError($"{account}添加设备输入数据失败,失败原因{ex.Message}->{ex.StackTrace}->{ex.InnerException}"); return(new BaseResponse { Success = false, Message = "添加数据失败,请联系管理员" }); } }
public async Task <ActionResult <BaseResponse> > AddDeviceInputData(string GroupId, string DeviceSn, DeviceInputAddDto req) { string account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value; var rm = await _dis.AddDeviceInputDataAsync(account, req, DeviceSn); return(rm); }