|
|
|
|
@ -46,7 +46,7 @@ namespace Video.DomainService |
|
|
|
|
if (dto == null || string.IsNullOrWhiteSpace(dto.Data.ChannelId)) |
|
|
|
|
{ |
|
|
|
|
_logger.LogError("录像请求失败:通道ID不能为空"); |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1007", Msg = "通道ID不能为空" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像回放请求异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
@ -56,7 +56,7 @@ namespace Video.DomainService |
|
|
|
|
if (!_tokenProviderService.IsTokenValid(token)) |
|
|
|
|
{ |
|
|
|
|
_logger.LogWarning("hls等录像回放:token无效"); |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1009", Msg = "token无效" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像回放请求异常" }; |
|
|
|
|
} |
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/video/stream/record"; |
|
|
|
|
if (ipaddress != null) |
|
|
|
|
@ -79,14 +79,14 @@ namespace Video.DomainService |
|
|
|
|
if (!resp.IsSuccessStatusCode) |
|
|
|
|
{ |
|
|
|
|
_logger.LogWarning("录像请求 HTTP 失败: {Status}, Body: {Body}", (int)resp.StatusCode, body); |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = $"HTTP错误 {(int)resp.StatusCode}" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = $"录像回放请求异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var result = JsonSerializer.Deserialize<DaHApiResult<UrlDataDto>>(body); |
|
|
|
|
if (result == null || !result.Success) |
|
|
|
|
{ |
|
|
|
|
_logger.LogWarning("录像请求业务失败: {Body}", body); |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = "录像请求失败" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像请求失败" }; |
|
|
|
|
} |
|
|
|
|
result.Data!.Url = UrlHostReplacer.ReplaceHost( |
|
|
|
|
result.Data.Url, |
|
|
|
|
@ -99,7 +99,7 @@ namespace Video.DomainService |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
_logger.LogError(ex, "大华录像请求出错"); |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = "录像请求失败" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像请求失败" }; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -114,14 +114,14 @@ namespace Video.DomainService |
|
|
|
|
// 0) 参数校验 + 早退(按需增加更多必填校验) |
|
|
|
|
if (dto == null) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<RecordsResDto> { Success = false, Code = "1009", Msg = "请求参数不能为空" }; |
|
|
|
|
return new DaHApiResult<RecordsResDto> { Success = false, Code = "2005", Msg = "查询普通录像信息列表异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var clientId = _configuration["DahuaAuth:ClientId"]; |
|
|
|
|
var token = await _tokenProviderService.GetTokenAsync(clientId!); |
|
|
|
|
if (!_tokenProviderService.IsTokenValid(token)) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<RecordsResDto> { Success = false, Code = "1009", Msg = "token无效" }; |
|
|
|
|
return new DaHApiResult<RecordsResDto> { Success = false, Code = "2005", Msg = "查询普通录像信息列表异常" }; |
|
|
|
|
} |
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/SS/Record/QueryRecords"; |
|
|
|
|
|
|
|
|
|
@ -142,13 +142,13 @@ namespace Video.DomainService |
|
|
|
|
|
|
|
|
|
if (!resp.IsSuccessStatusCode) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<RecordsResDto> { Success = false, Code = "1008", Msg = $"HTTP错误 {(int)resp.StatusCode}" }; |
|
|
|
|
return new DaHApiResult<RecordsResDto> { Success = false, Code = "2005", Msg = $"查询普通录像信息列表异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var result = JsonSerializer.Deserialize<DaHApiResult<RecordsResDto>>(body); |
|
|
|
|
if (result == null || !result.Success) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<RecordsResDto> { Success = false, Code = "1008", Msg = "查询录像信息失败" }; |
|
|
|
|
return new DaHApiResult<RecordsResDto> { Success = false, Code = "2005", Msg = "查询普通录像信息列表异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
@ -156,7 +156,7 @@ namespace Video.DomainService |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
_logger.LogError(ex, "查询大华录像信息出错"); |
|
|
|
|
return new DaHApiResult<RecordsResDto> { Success = false, Code = "1008", Msg = "查询录像信息失败" }; |
|
|
|
|
return new DaHApiResult<RecordsResDto> { Success = false, Code = "2005", Msg = "查询普通录像信息列表异常" }; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -171,14 +171,14 @@ namespace Video.DomainService |
|
|
|
|
{ |
|
|
|
|
if (dto == null) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<PageInfoDto> { Success = false, Code = "1009", Msg = "请求参数不能为空" }; |
|
|
|
|
return new DaHApiResult<PageInfoDto> { Success = false, Code = "2005", Msg = "设备通道分页查询异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var clientId = _configuration["DahuaAuth:ClientId"]; |
|
|
|
|
var token = await _tokenProviderService.GetTokenAsync(clientId!); |
|
|
|
|
if (!_tokenProviderService.IsTokenValid(token)) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<PageInfoDto> { Success = false, Code = "1009", Msg = "token无效" }; |
|
|
|
|
return new DaHApiResult<PageInfoDto> { Success = false, Code = "2005", Msg = "设备通道分页查询异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/evo-brm/1.2.0/device/channel/subsystem/page"; |
|
|
|
|
@ -200,13 +200,13 @@ namespace Video.DomainService |
|
|
|
|
|
|
|
|
|
if (!resp.IsSuccessStatusCode) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<PageInfoDto> { Success = false, Code = "1007", Msg = $"HTTP错误 {(int)resp.StatusCode}" }; |
|
|
|
|
return new DaHApiResult<PageInfoDto> { Success = false, Code = "2005", Msg = $"设备通道分页查询异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var result = JsonSerializer.Deserialize<DaHApiResult<PageInfoDto>>(body); |
|
|
|
|
if (result == null || !result.Success) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<PageInfoDto> { Success = false, Code = "1007", Msg = $"通道分页查询失败" }; |
|
|
|
|
return new DaHApiResult<PageInfoDto> { Success = false, Code = "2005", Msg = $"设备通道分页查询异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
@ -214,7 +214,7 @@ namespace Video.DomainService |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
_logger.LogError(ex, "获取大华设备通道分页查询出错"); |
|
|
|
|
return new DaHApiResult<PageInfoDto> { Success = false, Code = "1007", Msg = "获取大华设备通道分页查询失败" }; |
|
|
|
|
return new DaHApiResult<PageInfoDto> { Success = false, Code = "2005", Msg = "获取大华设备通道分页查询失败" }; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -230,7 +230,7 @@ namespace Video.DomainService |
|
|
|
|
if (dto == null || dto.Data == null) |
|
|
|
|
{ |
|
|
|
|
_logger.LogWarning("实时流请求失败:请求参数不能为空"); |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1009", Msg = "请求参数不能为空" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "实时预览请求异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
@ -241,7 +241,7 @@ namespace Video.DomainService |
|
|
|
|
if (!_tokenProviderService.IsTokenValid(token)) |
|
|
|
|
{ |
|
|
|
|
_logger.LogWarning(" HLS实时流请求失败:token无效"); |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1009", Msg = "token无效" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "实时预览请求异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/video/stream/realtime"; |
|
|
|
|
@ -250,7 +250,7 @@ namespace Video.DomainService |
|
|
|
|
{ |
|
|
|
|
url = $"https://{ipaddress}/evo-apigw/admin/API/video/stream/realtime"; |
|
|
|
|
} |
|
|
|
|
dto.Data.StreamType = "2"; |
|
|
|
|
|
|
|
|
|
// 3) 用 HttpRequestMessage 发送,才能带上自定义头 |
|
|
|
|
using var req = new HttpRequestMessage(HttpMethod.Post, url) |
|
|
|
|
{ |
|
|
|
|
@ -267,14 +267,14 @@ namespace Video.DomainService |
|
|
|
|
if (!resp.IsSuccessStatusCode) |
|
|
|
|
{ |
|
|
|
|
_logger.LogWarning("实时流请求 HTTP 失败: {Status}, Body: {Body}", (int)resp.StatusCode, body); |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1010", Msg = $"HTTP错误 {(int)resp.StatusCode}" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = $"实时预览请求异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var result = JsonSerializer.Deserialize<DaHApiResult<UrlDataDto>>(body); |
|
|
|
|
if (result == null || !result.Success) |
|
|
|
|
{ |
|
|
|
|
_logger.LogWarning("实时流请求业务失败: {Body}", body); |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1010", Msg = "实时流请求失败" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "实时预览请求异常" }; |
|
|
|
|
} |
|
|
|
|
result.Data!.Url = UrlHostReplacer.ReplaceHost( |
|
|
|
|
result.Data.Url, |
|
|
|
|
@ -287,7 +287,7 @@ namespace Video.DomainService |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
_logger.LogError(ex, "大华实时流请求出错"); |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1010", Msg = "实时流请求失败" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "实时流请求失败" }; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -322,8 +322,8 @@ namespace Video.DomainService |
|
|
|
|
return new DaHApiResult<object> |
|
|
|
|
{ |
|
|
|
|
Success = false, |
|
|
|
|
Code = ((int)resp.StatusCode).ToString(), |
|
|
|
|
Msg = $"HTTP错误 {(int)resp.StatusCode}", |
|
|
|
|
Code = "2005", |
|
|
|
|
Msg = $"注销登录失败", |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -332,7 +332,7 @@ namespace Video.DomainService |
|
|
|
|
if (result == null) |
|
|
|
|
{ |
|
|
|
|
_logger.LogWarning("注销登录反序列化失败: {Body}", body); |
|
|
|
|
return new DaHApiResult<object> { Success = false, Code = "1011", Msg = "注销登录返回无效" }; |
|
|
|
|
return new DaHApiResult<object> { Success = false, Code = "2005", Msg = "注销登录失败" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 只有 Success==false 或 Code != "0" 才视为失败 |
|
|
|
|
@ -340,8 +340,8 @@ namespace Video.DomainService |
|
|
|
|
{ |
|
|
|
|
_logger.LogWarning("注销登录失败: {Body}", body); |
|
|
|
|
result.Success = false; |
|
|
|
|
result.Code = result.Code ?? "1011"; |
|
|
|
|
result.Msg ??= "注销登录失败"; |
|
|
|
|
result.Code = "2005"; |
|
|
|
|
result.Msg = "注销登录失败"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
@ -352,8 +352,8 @@ namespace Video.DomainService |
|
|
|
|
return new DaHApiResult<object> |
|
|
|
|
{ |
|
|
|
|
Success = false, |
|
|
|
|
Code = "1011", |
|
|
|
|
Msg = $"注销登录异常:{ex.Message}" |
|
|
|
|
Code = "2005", |
|
|
|
|
Msg = $"注销登录异常" |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -370,7 +370,7 @@ namespace Video.DomainService |
|
|
|
|
// 参数校验 + 早退 |
|
|
|
|
if (dto == null || string.IsNullOrWhiteSpace(dto.Data.ChannelId)) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1007", Msg = "通道ID不能为空" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像回放异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 先用缓存里的 token,不足5分钟过期再刷新 |
|
|
|
|
@ -378,7 +378,7 @@ namespace Video.DomainService |
|
|
|
|
var token = await _tokenProviderService.GetTokenAsync(clientId!); |
|
|
|
|
if (!_tokenProviderService.IsTokenValid(token)) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1009", Msg = "token无效" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像回放异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查询普通录像信息,这块是为了知道recordType=多少 |
|
|
|
|
@ -414,7 +414,7 @@ namespace Video.DomainService |
|
|
|
|
var resultRecord = JsonSerializer.Deserialize<DaHApiResult<RecordDataResDto>>(bodys); |
|
|
|
|
if (resultRecord == null || !resultRecord.Success) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = "查询普通录像信息" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像回放异常" }; |
|
|
|
|
} |
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime"; |
|
|
|
|
if (ipaddress != null) |
|
|
|
|
@ -439,13 +439,13 @@ namespace Video.DomainService |
|
|
|
|
|
|
|
|
|
if (!resp.IsSuccessStatusCode) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = $"HTTP错误 {(int)resp.StatusCode}" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005 ", Msg = $"录像回放异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var result = JsonSerializer.Deserialize<DaHApiResult<UrlDataDto>>(body); |
|
|
|
|
if (result == null || !result.Success) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = "录像请求失败" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像回放异常" }; |
|
|
|
|
} |
|
|
|
|
result.Data!.Url = UrlHostReplacer.ReplaceHost( |
|
|
|
|
result.Data.Url, |
|
|
|
|
@ -459,7 +459,7 @@ namespace Video.DomainService |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
_logger.LogError(ex, "录像请求异常"); |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1008", Msg = "录像请求失败" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像回放异常" }; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -474,7 +474,7 @@ namespace Video.DomainService |
|
|
|
|
{ |
|
|
|
|
if (dto == null || dto.Data == null) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1005", Msg = "请求参数不能为空" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像回放异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var clientId = _configuration["DahuaAuth:ClientId"]; |
|
|
|
|
@ -482,7 +482,7 @@ namespace Video.DomainService |
|
|
|
|
|
|
|
|
|
if (!_tokenProviderService.IsTokenValid(token)) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1009", Msg = "token无效" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像回放异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/MTS/Video/StartVideo"; |
|
|
|
|
@ -507,13 +507,13 @@ namespace Video.DomainService |
|
|
|
|
var body = await reader.ReadToEndAsync(); |
|
|
|
|
if (!resp.IsSuccessStatusCode) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1014", Msg = $"HTTP错误 {(int)resp.StatusCode}" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = $"录像回放异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var result = JsonSerializer.Deserialize<DaHApiResult<UrlDataDto>>(body); |
|
|
|
|
if (result == null || !result.Success) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1013", Msg = "实时流请求业务反序列化失败" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = "录像回放异常" }; |
|
|
|
|
} |
|
|
|
|
result.Data!.Url = UrlHostReplacer.ReplaceHost( |
|
|
|
|
result.Data.Url, |
|
|
|
|
@ -527,7 +527,7 @@ namespace Video.DomainService |
|
|
|
|
{ |
|
|
|
|
_logger.LogError(ex, $"大华实时流请求出错{ex.Message}"); |
|
|
|
|
|
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "1012", Msg = $"实时流请求失败{ex.Message}" }; |
|
|
|
|
return new DaHApiResult<UrlDataDto> { Success = false, Code = "2005", Msg = $"录像回放异常" }; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -568,7 +568,7 @@ namespace Video.DomainService |
|
|
|
|
|
|
|
|
|
if (!_tokenProviderService.IsTokenValid(token)) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<SnapshotResDto> { Success = false, Code = "1009", Msg = "token无效" }; |
|
|
|
|
return new DaHApiResult<SnapshotResDto> { Success = false, Code = "2005", Msg = "抓拍异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/EVO/invoke/DMS"; |
|
|
|
|
@ -590,17 +590,17 @@ namespace Video.DomainService |
|
|
|
|
var body = await reader.ReadToEndAsync(); |
|
|
|
|
if (!resp.IsSuccessStatusCode) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<SnapshotResDto> { Success = false, Code = "1014", Msg = $"抓拍错误 {(int)resp.StatusCode}" }; |
|
|
|
|
return new DaHApiResult<SnapshotResDto> { Success = false, Code = "2005", Msg = $"抓拍异常" }; |
|
|
|
|
} |
|
|
|
|
var outer = JsonSerializer.Deserialize<DaHApiResult<string>>(body); |
|
|
|
|
if (outer == null || !outer.Success || outer.Data == null) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<SnapshotResDto> { Success = false, Code = "1013", Msg = "抓拍请求失败" }; |
|
|
|
|
return new DaHApiResult<SnapshotResDto> { Success = false, Code = "2005", Msg = "抓拍异常" }; |
|
|
|
|
} |
|
|
|
|
var result = JsonSerializer.Deserialize<SnapResponseVO>(outer.Data); |
|
|
|
|
if (result == null) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<SnapshotResDto> { Success = false, Code = "1013", Msg = "抓拍反序列化失败" }; |
|
|
|
|
return new DaHApiResult<SnapshotResDto> { Success = false, Code = "2005", Msg = "抓拍异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
apiResult.Data!.PicUrl = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/evo-oss/" + result.Params?.PicInfo + $"?token={token.Replace("bearer ", string.Empty)}"; |
|
|
|
|
@ -612,7 +612,7 @@ namespace Video.DomainService |
|
|
|
|
{ |
|
|
|
|
_logger.LogError(ex, $"抓拍请求出错{ex.Message}"); |
|
|
|
|
|
|
|
|
|
return new DaHApiResult<SnapshotResDto> { Success = false, Code = "1012", Msg = $"抓拍请求失败{ex.Message}" }; |
|
|
|
|
return new DaHApiResult<SnapshotResDto> { Success = false, Code = "2005", Msg = $"抓拍异常{ex.Message}" }; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -630,7 +630,7 @@ namespace Video.DomainService |
|
|
|
|
|
|
|
|
|
if (!_tokenProviderService.IsTokenValid(token)) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "1009", Msg = "token无效" }; |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "2005", Msg = "控制云台镜头失败" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/DMS/Ptz/OperateCamera"; |
|
|
|
|
@ -651,17 +651,17 @@ namespace Video.DomainService |
|
|
|
|
var body = await reader.ReadToEndAsync(); |
|
|
|
|
if (!resp.IsSuccessStatusCode) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "1014", Msg = $"控制云台镜头错误 {(int)resp.StatusCode}" }; |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "2005", Msg = $"控制云台镜头异常" }; |
|
|
|
|
} |
|
|
|
|
var outer = JsonSerializer.Deserialize<DaHApiResult<CameraControlResDto>>(body); |
|
|
|
|
if (outer == null || !outer.Success || outer.Data == null) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "1013", Msg = "控制云台镜头请求失败" }; |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "2005", Msg = "控制云台镜头异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (outer.Data == null) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "1013", Msg = "控制云台镜头反序列化失败" }; |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "2005", Msg = "控制云台镜头异常" }; |
|
|
|
|
} |
|
|
|
|
apiResult.Data = outer.Data; |
|
|
|
|
return apiResult; |
|
|
|
|
@ -670,7 +670,7 @@ namespace Video.DomainService |
|
|
|
|
{ |
|
|
|
|
_logger.LogError(ex, $"控制云台镜头请求出错{ex.Message}"); |
|
|
|
|
|
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "1012", Msg = $"控制云台镜头请求失败{ex.Message}" }; |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "2005", Msg = $"控制云台镜头异常" }; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -688,7 +688,7 @@ namespace Video.DomainService |
|
|
|
|
|
|
|
|
|
if (!_tokenProviderService.IsTokenValid(token)) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "1009", Msg = "token无效" }; |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "2005", Msg = "云台方向控制" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/admin/API/DMS/Ptz/OperateDirect"; |
|
|
|
|
@ -709,17 +709,17 @@ namespace Video.DomainService |
|
|
|
|
var body = await reader.ReadToEndAsync(); |
|
|
|
|
if (!resp.IsSuccessStatusCode) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "1014", Msg = $"云台方向控制错误 {(int)resp.StatusCode}" }; |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "2005", Msg = $"云台方向控制" }; |
|
|
|
|
} |
|
|
|
|
var outer = JsonSerializer.Deserialize<DaHApiResult<CameraControlResDto>>(body); |
|
|
|
|
if (outer == null || !outer.Success || outer.Data == null) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "1013", Msg = "云台方向控制请求失败" }; |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "2005", Msg = "控制云台镜头异常" }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (outer.Data == null) |
|
|
|
|
{ |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "1013", Msg = "云台方向控制反序列化失败" }; |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "2005", Msg = "云台方向控制反序列化失败" }; |
|
|
|
|
} |
|
|
|
|
apiResult.Data = outer.Data; |
|
|
|
|
return apiResult; |
|
|
|
|
@ -728,7 +728,7 @@ namespace Video.DomainService |
|
|
|
|
{ |
|
|
|
|
_logger.LogError(ex, $"云台方向控制请求出错{ex.Message}"); |
|
|
|
|
|
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "1012", Msg = $"云台方向控制请求失败{ex.Message}" }; |
|
|
|
|
return new DaHApiResult<CameraControlResDto> { Success = false, Code = "2005", Msg = $"云台方向控制请求失败" }; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|