Exemple #1
0
        public async Task <BaseResponse> AddDeviceVideoAsync(string account, DeviceVideoAddDto req, string deviceSn)
        {
            var data = await _dvr.Find(a => a.DeviceSn == deviceSn && a.VideoName == req.VideoName).ToListAsync();

            if (data.Count > 0)
            {
                return(new BaseResponse {
                    Success = false, Message = "该设备已添加过相同名称的摄像头"
                });
            }
            try
            {
                var entity = _mapper.Map <DeviceVideoModel>(req);
                entity.DeviceSn = deviceSn;
                entity.Create   = account;
                await _dvr.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 = "添加摄像头失败,请联系管理员"
                });

                throw;
            }
        }
Exemple #2
0
        public async Task <ActionResult <BaseResponse> > AddDeviceVideo(string GroupId, string DeviceSn, DeviceVideoAddDto req)
        {
            string account = User.Claims.FirstOrDefault(a => a.Type == "Account").Value;
            var    rm      = await _dvs.AddDeviceVideoAsync(account, req, DeviceSn);

            return(rm);
        }