WakeMachineHandler fix
parent
9af7aea208
commit
7be1fd6a69
|
@ -1,9 +1,11 @@
|
|||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NetworkResurrector.Api.Domain.Constants;
|
||||
using NetworkResurrector.Api.Domain.Repositories;
|
||||
using NetworkResurrector.Api.PublishedLanguage.Commands;
|
||||
using NetworkResurrector.Api.PublishedLanguage.Events;
|
||||
using NetworkResurrector.Server.Wrapper.Services;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -26,11 +28,22 @@ namespace NetworkResurrector.Api.Application.CommandHandlers
|
|||
{
|
||||
_logger.LogDebug($"Start pinging machine {command.MachineId}");
|
||||
var machine = await _repository.GetMachine(command.MachineId);
|
||||
var powerConfiguration = await _repository.GetPowerActionConfiguration(command.MachineId, PowerActions.PING);
|
||||
|
||||
//log activity
|
||||
|
||||
MachinePinged result;
|
||||
switch (powerConfiguration.Performer.PerformerCode)
|
||||
{
|
||||
case PowerActionPerformers.NETWORK_RESURRECTOR_SERVER:
|
||||
var pingResult = await _resurrectorService.Ping(machine.IPv4Address ?? machine.MachineName);
|
||||
var result = new MachinePinged(pingResult.Success, pingResult.Status);
|
||||
result = new MachinePinged(pingResult.Success, pingResult.Status);
|
||||
_logger.LogDebug($"Machine {command.MachineId} pinging finished. Success: {result.Success}; Status: {result.Status}");
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception($"Power action performer {powerConfiguration.Performer.PerformerCode} is not implemented.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NetworkResurrector.Api.Domain.Constants;
|
||||
using NetworkResurrector.Api.Domain.Repositories;
|
||||
using NetworkResurrector.Api.PublishedLanguage.Commands;
|
||||
using NetworkResurrector.Api.PublishedLanguage.Events;
|
||||
using NetworkResurrector.Server.Wrapper.Services;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -26,11 +28,22 @@ namespace NetworkResurrector.Api.Application.CommandHandlers
|
|||
{
|
||||
_logger.LogDebug($"Start waking up machine {command.MachineId}");
|
||||
var machine = await _repository.GetMachine(command.MachineId);
|
||||
var powerConfiguration = await _repository.GetPowerActionConfiguration(command.MachineId, PowerActions.WAKE);
|
||||
|
||||
//log activity
|
||||
|
||||
MachineWaked result;
|
||||
switch (powerConfiguration.Performer.PerformerCode)
|
||||
{
|
||||
case PowerActionPerformers.NETWORK_RESURRECTOR_SERVER:
|
||||
var wakeResult = await _resurrectorService.Wake(machine.MACAddress);
|
||||
var result = new MachineWaked(wakeResult.Success, wakeResult.Status);
|
||||
result = new MachineWaked(wakeResult.Success, wakeResult.Status);
|
||||
_logger.LogDebug($"Machine {command.MachineId} wake up finished. Success: {result.Success}; Status: {result.Status}");
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception($"Power action performer {powerConfiguration.Performer.PerformerCode} is not implemented.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue