Beispiel #1
0
        public async Task <ActionResult <BaseResponse> > UpdateDevicePosition(string GroupId, string DeviceSn, [FromBody] DeviceCardPositionUpdateDto req)
        {
            var account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value;
            var rm      = await _dcs.UpdateDeviceCardPositionAsync(account, DeviceSn, req);

            return(rm);
        }
Beispiel #2
0
        /// <summary>
        /// 更新流量卡的定位、IMEI和ICCID数据
        /// </summary>
        /// <param name="account">操作人</param>
        /// <param name="DeviceSn">设备序列号</param>
        /// <param name="req">流量卡的定位等信息</param>
        /// <returns>返回是否更新成功</returns>
        public async Task <BaseResponse> UpdateDeviceCardPositionAsync(string account, string DeviceSn, DeviceCardPositionUpdateDto req)
        {
            try
            {
                var d = await _dcr.Find(a => a.DeviceSn == DeviceSn).FirstOrDefaultAsync();

                if (d == null)
                {
                    //不存在,就添加
                    var entity = _mapper.Map <DeviceCardModel>(req);
                    entity.DeviceSn = DeviceSn;
                    entity.Create   = account;
                    await _dcr.AddAsync(entity);

                    _log.LogInformation($"修改流量卡数据时不存在,{account}添加标示为{entity.Id}的流量卡成功");
                    return(new BaseResponse {
                        Success = true, Message = "修改数据成功"
                    });
                }
                else
                {
                    var entity = _mapper.Map(req, d);
                    entity.Modify     = account;
                    entity.ModifyTime = DateTime.Now;
                    await _dcr.SaveAsync(entity);

                    _log.LogInformation($"{account}修改标示为{entity.Id}的流量卡信息成功");
                    return(new BaseResponse {
                        Success = true, Message = "修改数据成功"
                    });
                }
            }
            catch (Exception ex)
            {
                _log.LogError($"{account}修改流量卡失败,失败原因:{ex.Message}->{ex.StackTrace}->{ex.InnerException}");
                return(new BaseResponse {
                    Success = false, Message = "修改流量卡失败,请联系管理员"
                });
            }
        }