sleep fix
parent
6411f29723
commit
69ce2bfc53
|
@ -1,8 +1,6 @@
|
||||||
using AutoMapper;
|
using MediatR;
|
||||||
using MediatR;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NetworkResurrector.Agent.Application.Services.Abstractions;
|
using NetworkResurrector.Agent.Application.Services.Abstractions;
|
||||||
using NetworkResurrector.Agent.Domain.Models;
|
|
||||||
using NetworkResurrector.Agent.PublishedLanguage.Commands;
|
using NetworkResurrector.Agent.PublishedLanguage.Commands;
|
||||||
using NetworkResurrector.Agent.PublishedLanguage.Events;
|
using NetworkResurrector.Agent.PublishedLanguage.Events;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -16,14 +14,12 @@ namespace NetworkResurrector.Agent.Application.CommandHandlers
|
||||||
private readonly ILogger<SleepHandler> _logger;
|
private readonly ILogger<SleepHandler> _logger;
|
||||||
private readonly IPowerService _powerService;
|
private readonly IPowerService _powerService;
|
||||||
private readonly IValidationService _validationService;
|
private readonly IValidationService _validationService;
|
||||||
private readonly IMapper _mapper;
|
|
||||||
|
|
||||||
public SleepHandler(ILogger<SleepHandler> logger, IPowerService powerService, IValidationService validationService, IMapper mapper)
|
public SleepHandler(ILogger<SleepHandler> logger, IPowerService powerService, IValidationService validationService)
|
||||||
{
|
{
|
||||||
_logger=logger;
|
_logger=logger;
|
||||||
_powerService=powerService;
|
_powerService=powerService;
|
||||||
_validationService=validationService;
|
_validationService=validationService;
|
||||||
_mapper=mapper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SleepResult> Handle(Sleep command, CancellationToken cancellationToken)
|
public async Task<SleepResult> Handle(Sleep command, CancellationToken cancellationToken)
|
||||||
|
@ -40,8 +36,7 @@ namespace NetworkResurrector.Agent.Application.CommandHandlers
|
||||||
var stopWatch = new Stopwatch();
|
var stopWatch = new Stopwatch();
|
||||||
stopWatch.Start();
|
stopWatch.Start();
|
||||||
|
|
||||||
var options = _mapper.Map<PowerOptions>(command.Options);
|
_powerService.Sleep();
|
||||||
_powerService.Sleep(options);
|
|
||||||
|
|
||||||
stopWatch.Stop();
|
stopWatch.Stop();
|
||||||
_logger.LogDebug($"System sleeping finished - {stopWatch.ElapsedMilliseconds:N0} ms");
|
_logger.LogDebug($"System sleeping finished - {stopWatch.ElapsedMilliseconds:N0} ms");
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace NetworkResurrector.Agent.Application.Services.Abstractions
|
||||||
{
|
{
|
||||||
void Shutdown(PowerOptions options);
|
void Shutdown(PowerOptions options);
|
||||||
void Restart(PowerOptions options);
|
void Restart(PowerOptions options);
|
||||||
void Sleep(PowerOptions options);
|
void Sleep();
|
||||||
void Logout();
|
void Logout();
|
||||||
void Lock();
|
void Lock();
|
||||||
void Cancel();
|
void Cancel();
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace NetworkResurrector.Agent.Application.Services.Linux
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sleep(PowerOptions options)
|
public void Sleep()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,10 +81,9 @@ namespace NetworkResurrector.Agent.Application.Services.Windows
|
||||||
ManageExecutionResponse(result);
|
ManageExecutionResponse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sleep(PowerOptions options)
|
public void Sleep()
|
||||||
{
|
{
|
||||||
var arguments = "-h";
|
var arguments = "-h";
|
||||||
arguments = SetOptions(arguments, options);
|
|
||||||
_logger.LogInformation($"Sleep arguments: {arguments}");
|
_logger.LogInformation($"Sleep arguments: {arguments}");
|
||||||
var result =_cliService.Shutdown(arguments);
|
var result =_cliService.Shutdown(arguments);
|
||||||
ManageExecutionResponse(result);
|
ManageExecutionResponse(result);
|
||||||
|
|
|
@ -7,6 +7,5 @@ namespace NetworkResurrector.Agent.PublishedLanguage.Commands
|
||||||
public class Sleep : Command<SleepResult>
|
public class Sleep : Command<SleepResult>
|
||||||
{
|
{
|
||||||
public ActionOwner Owner { get; set; }
|
public ActionOwner Owner { get; set; }
|
||||||
public ActionOptions Options { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue