27 lines
923 B
C#
27 lines
923 B
C#
using Heimdall.Application.Common;
|
|||
|
|
using Heimdall.Application.DTOs;
|
||
|
|
using Heimdall.Application.Services;
|
||
|
|
using MediatR;
|
||
|
|
|
||
|
|
namespace Heimdall.Application.Discovery.Commands.ScanSubnet;
|
||
|
|
|
||
|
|
public record ScanSubnetCommand(
|
||
|
|
Guid SiteId,
|
||
|
|
string SubnetCidr,
|
||
|
|
int TimeoutMs = 30000) : IRequest<ServiceResult<IReadOnlyList<ProbeResponse>>>;
|
||
|
|
|
||
|
|
public class ScanSubnetCommandHandler : IRequestHandler<ScanSubnetCommand, ServiceResult<IReadOnlyList<ProbeResponse>>>
|
||
|
|
{
|
||
|
|
private readonly ICameraDiscoveryService _discovery;
|
||
|
|
|
||
|
|
public ScanSubnetCommandHandler(ICameraDiscoveryService discovery)
|
||
|
|
{
|
||
|
|
_discovery = discovery;
|
||
|
|
}
|
||
|
|
|
||
|
|
public async Task<ServiceResult<IReadOnlyList<ProbeResponse>>> Handle(ScanSubnetCommand request, CancellationToken ct)
|
||
|
|
{
|
||
|
|
var dto = new ScanRequest(request.SiteId, request.SubnetCidr, request.TimeoutMs);
|
||
|
|
return await _discovery.ScanSubnetAsync(dto, ct);
|
||
|
|
}
|
||
|
|
}
|