NetworkResurrector.Server.Wrapper.1.0.3.2
parent
f997efbed1
commit
d33d8cf71d
|
@ -5,5 +5,5 @@ dotnet pack /*--include-symbols*/
|
|||
|
||||
# Server:
|
||||
dotnet nuget push NetworkResurrector.Server.PublishedLanguage.1.0.3.nupkg -k ***REMOVED*** -s https://toodle.ddns.net/public-nuget-server/nuget
|
||||
dotnet nuget push NetworkResurrector.Server.Wrapper.1.0.3.1.nupkg -k ***REMOVED*** -s https://toodle.ddns.net/public-nuget-server/nuget
|
||||
dotnet nuget push NetworkResurrector.Server.Wrapper.1.0.3.2.nupkg -k ***REMOVED*** -s https://toodle.ddns.net/public-nuget-server/nuget
|
||||
#######################################################################################################################################################
|
|
@ -0,0 +1,38 @@
|
|||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NetworkResurrector.Api.Domain.Repositories;
|
||||
using NetworkResurrector.Api.PublishedLanguage.Commands;
|
||||
using NetworkResurrector.Api.PublishedLanguage.Events;
|
||||
using NetworkResurrector.Server.Wrapper.Services;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NetworkResurrector.Api.Application.CommandHandlers
|
||||
{
|
||||
public class ShutdownMachineHandler : IRequestHandler<ShutdownMachine, MachineShutdown>
|
||||
{
|
||||
private readonly ILogger<ShutdownMachineHandler> _logger;
|
||||
private readonly IResurrectorService _resurrectorService;
|
||||
private readonly INetworkRepository _repository;
|
||||
|
||||
public ShutdownMachineHandler(ILogger<ShutdownMachineHandler> logger, IResurrectorService resurrectorService, INetworkRepository repository)
|
||||
{
|
||||
_logger=logger;
|
||||
_resurrectorService=resurrectorService;
|
||||
_repository=repository;
|
||||
}
|
||||
|
||||
public async Task<MachineShutdown> Handle(ShutdownMachine command, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogDebug($"Start shutdown machine {command.MachineId}");
|
||||
var machine = await _repository.GetMachine(command.MachineId);
|
||||
|
||||
//log activity
|
||||
var pingResult = await _resurrectorService.sh(machine.IPv4Address ?? machine.MachineName);
|
||||
var result = new MachineShutdown(pingResult.Success, pingResult.Status);
|
||||
_logger.LogDebug($"Machine {command.MachineId} shutdown finished. Success: {result.Success}; Status: {result.Status}");
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
{
|
||||
public const string
|
||||
Wake = "resurrector/wake",
|
||||
Ping = "resurrector/ping";
|
||||
Ping = "resurrector/ping",
|
||||
Shutdown = "resurrector/shutdown";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<PackageProjectUrl>https://dev.azure.com/tstanciu94/NetworkResurrector</PackageProjectUrl>
|
||||
<RepositoryUrl>https://dev.azure.com/tstanciu94/NetworkResurrector</RepositoryUrl>
|
||||
<RepositoryType>Git</RepositoryType>
|
||||
<Version>1.0.3.1</Version>
|
||||
<Version>1.0.3.2</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,5 +7,6 @@ namespace NetworkResurrector.Server.Wrapper.Services
|
|||
{
|
||||
Task<MachineWaked> Wake(string macAddress);
|
||||
Task<MachinePinged> Ping(string ipAddressOrMachineName);
|
||||
Task<MachineShutdown> Shutdown(string ipAddressOrMachineName);
|
||||
}
|
||||
}
|
|
@ -36,5 +36,12 @@ namespace NetworkResurrector.Server.Wrapper.Services
|
|||
var result = await _httpClient.ExecutePostRequest<MachinePinged, PingMachine>(ApiRoutes.Wake, body);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<MachineShutdown> Shutdown(string ipAddressOrMachineName)
|
||||
{
|
||||
var body = new ShutdownMachine(ipAddressOrMachineName);
|
||||
var result = await _httpClient.ExecutePostRequest<MachineShutdown, ShutdownMachine>(ApiRoutes.Shutdown, body);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue