NetworkResurrector.Server.Wrapper.1.0.3.2

master
Tudor Stanciu 2022-01-13 13:30:25 +02:00
parent f997efbed1
commit d33d8cf71d
6 changed files with 50 additions and 3 deletions

View File

@ -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
#######################################################################################################################################################

View File

@ -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;
}
}
}

View File

@ -4,6 +4,7 @@
{
public const string
Wake = "resurrector/wake",
Ping = "resurrector/ping";
Ping = "resurrector/ping",
Shutdown = "resurrector/shutdown";
}
}

View File

@ -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>

View File

@ -7,5 +7,6 @@ namespace NetworkResurrector.Server.Wrapper.Services
{
Task<MachineWaked> Wake(string macAddress);
Task<MachinePinged> Ping(string ipAddressOrMachineName);
Task<MachineShutdown> Shutdown(string ipAddressOrMachineName);
}
}

View File

@ -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;
}
}
}