public IResponsePayload <byte[]> Execute(Request request) { var psi = new ProcessStartInfo("shutdown", "/s /t 0"); psi.CreateNoWindow = true; psi.UseShellExecute = false; var process = Process.Start(psi); return(process.ExitCode == 0 ? BytesResponsePayload.NoPayloadSuccess(new ResponseMetadata(GetType())) : BytesResponsePayload.NoPayloadFailure(new ResponseMetadata(GetType()))); }
public IResponsePayload <byte[]> Execute(Request request) { if (!float.TryParse(request.Parameters[0], out float volumeChange)) { return(BytesResponsePayload.NoPayloadFailure(new ResponseMetadata(GetType()))); } if (defaultPlaybackDevice == null) { var enumerator = new MMDeviceEnumerator(); defaultPlaybackDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia); } defaultPlaybackDevice.AudioEndpointVolume.MasterVolumeLevelScalar = volumeChange; return(BytesResponsePayload.NoPayloadSuccess(new ResponseMetadata(GetType()))); }