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