@ -280,18 +280,17 @@ namespace Alarm.DomainService.DahAlarm
/// <param name="name"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task < DaHApiResult < SubscriptionMap Dto > > GetEventList ( string name = "alarm" )
public async Task < DaHApiResult < SubscribeData Dto > > GetEventList ( string name = "alarm" )
{
var clientId = _ configuration [ "DahuaAuth:ClientId" ] ;
var token = await _ tokenProviderService . GetTokenAsync ( clientId ! ) ;
if ( ! _ tokenProviderService . IsTokenValid ( token ) )
{
_l ogger . LogWarning ( "获取事件列表:token无效" ) ;
return new DaHApiResult < SubscriptionMap Dto > { Success = false , Code = "1009" , Msg = "token无效" } ;
return new DaHApiResult < SubscribeData Dto > { Success = false , Code = "1009" , Msg = "token无效" } ;
}
// var url = $"https://{_configuration["DahuaAuth:Host"]}/evo-apigw/evo-brm/1.0.0/device/1000021 ";
// var url = $"http://demo.weienergy.cn:15230/open-api/token/v1/oauth/token?client_id=69591850&client_secret=WHcpAryKFc28suzL&grant_type=client_credentials ";
var url = $"https://{_configuration[" DahuaAuth : Host "]}/evo-apigw/evo-event/1.0.0/subscribe/subscribe-list?monitorType=url&category={name}" ;
try
{
var request = new HttpRequestMessage ( HttpMethod . Get , url ) ;
@ -304,14 +303,14 @@ namespace Alarm.DomainService.DahAlarm
if ( ! resp . IsSuccessStatusCode )
{
_l ogger . LogWarning ( "实时流请求 HTTP 失败: {Status}, Body: {Body}" , ( int ) resp . StatusCode , body ) ;
return new DaHApiResult < SubscriptionMap Dto > { Success = false , Code = "1010" , Msg = $"HTTP错误 {(int)resp.StatusCode}" } ;
return new DaHApiResult < SubscribeData Dto > { Success = false , Code = "1010" , Msg = $"HTTP错误 {(int)resp.StatusCode}" } ;
}
var result = JsonSerializer . Deserialize < DaHApiResult < SubscriptionMap Dto > > ( body ) ;
var result = JsonSerializer . Deserialize < DaHApiResult < SubscribeData Dto > > ( body ) ;
if ( result = = null | | ! result . Success )
{
_l ogger . LogWarning ( "实时流请求业务失败: {Body}" , body ) ;
return new DaHApiResult < SubscriptionMap Dto > { Success = false , Code = "1010" , Msg = "实时流请求失败" } ;
return new DaHApiResult < SubscribeData Dto > { Success = false , Code = "1010" , Msg = "实时流请求失败" } ;
}
return result ;
@ -319,7 +318,7 @@ namespace Alarm.DomainService.DahAlarm
catch ( Exception ex )
{
_l ogger . LogError ( ex , "大华实时流请求出错" ) ;
return new DaHApiResult < SubscriptionMap Dto > { Success = false , Code = "1010" , Msg = "实时流请求失败" } ;
return new DaHApiResult < SubscribeData Dto > { Success = false , Code = "1010" , Msg = "实时流请求失败" } ;
}
}