public Program() { invoker = new Invoker(); AsiaServer asiaServer = new AsiaServer(); EuroServer euroServer = new EuroServer(); USServer usServer = new USServer(); ShutdownCommand asiaShutdown = new ShutdownCommand( asiaServer ); RunDiagnosticsCommand asiaDiagnostics = new RunDiagnosticsCommand( asiaServer ); RebootCommand asiaReboot = new RebootCommand( asiaServer ); ShutdownCommand euroShutdown = new ShutdownCommand( euroServer ); RunDiagnosticsCommand euroDiagnostics = new RunDiagnosticsCommand( euroServer ); RebootCommand euroReboot = new RebootCommand( euroServer ); ShutdownCommand usShutdown = new ShutdownCommand( usServer ); RunDiagnosticsCommand usDiagnostics = new RunDiagnosticsCommand( usServer ); RebootCommand usReboot = new RebootCommand( usServer ); RunCommand( asiaShutdown ); RunCommand( asiaDiagnostics ); RunCommand( asiaReboot ); RunCommand( euroShutdown ); RunCommand( euroDiagnostics ); RunCommand( euroReboot ); RunCommand( usShutdown ); RunCommand( usDiagnostics ); RunCommand( usReboot ); }
public Program() { invoker = new Invoker(); AsiaServer asiaServer = new AsiaServer(); EuroServer euroServer = new EuroServer(); USServer usServer = new USServer(); ShutdownCommand asiaShutdown = new ShutdownCommand(asiaServer); RunDiagnosticsCommand asiaDiagnostics = new RunDiagnosticsCommand(asiaServer); RebootCommand asiaReboot = new RebootCommand(asiaServer); ShutdownCommand euroShutdown = new ShutdownCommand(euroServer); RunDiagnosticsCommand euroDiagnostics = new RunDiagnosticsCommand(euroServer); RebootCommand euroReboot = new RebootCommand(euroServer); ShutdownCommand usShutdown = new ShutdownCommand(usServer); RunDiagnosticsCommand usDiagnostics = new RunDiagnosticsCommand(usServer); RebootCommand usReboot = new RebootCommand(usServer); RunCommand(asiaShutdown); RunCommand(asiaDiagnostics); RunCommand(asiaReboot); RunCommand(euroShutdown); RunCommand(euroDiagnostics); RunCommand(euroReboot); RunCommand(usShutdown); RunCommand(usDiagnostics); RunCommand(usReboot); }
private static void HandleShutdown(ShutdownCommand concrete) { using (var process = Process.Start("shutdown", $"/s /t {concrete.Delay.Value?.TotalSeconds ?? 60}")) { process.StartInfo.CreateNoWindow = true; process.StartInfo.UseShellExecute = true; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; } }
public void TryExecuteCommand() { DraftManager draftManager = new DraftManager(); string input = Console.ReadLine(); while (true) { List <string> inputArgs = input.Split().ToList(); string commandName = inputArgs[0]; List <string> commandArgs = inputArgs.Skip(1).ToList(); Command cmdToBeExecuted = null; string result = string.Empty; switch (commandName) { case "RegisterHarvester": cmdToBeExecuted = new RegisterHarvesterCommand(draftManager, commandArgs); break; case "RegisterProvider": cmdToBeExecuted = new RegisterProviderCommand(draftManager, commandArgs); break; case "Day": cmdToBeExecuted = new StartDayCommand(draftManager, commandArgs); break; case "Mode": cmdToBeExecuted = new ChangeModeCommand(draftManager, commandArgs); break; case "Check": cmdToBeExecuted = new CheckStatusCommand(draftManager, commandArgs); break; case "Shutdown": cmdToBeExecuted = new ShutdownCommand(draftManager, commandArgs); Console.WriteLine(cmdToBeExecuted.Execute()); return; } // In case an invalid command is entered: if (cmdToBeExecuted == null) { throw new ArgumentException("Invalid command."); } result = cmdToBeExecuted.Execute(); Console.WriteLine(result); input = Console.ReadLine(); } }
public override void RaiseCanExecuteChanges() { base.RaiseCanExecuteChanges(); if (CheckFreestyleDatabaseCommand == null) { return; } CheckFreestyleDatabaseCommand.RaiseCanExecuteChanged(); LaunchCommand.RaiseCanExecuteChanged(); ShowFtpLogCommand.RaiseCanExecuteChanged(); ShutdownCommand.RaiseCanExecuteChanged(); }
public TwitchBot(string username, string oAuth) { irc = new IRCUtil("irc.twitch.tv", 6667, username, oAuth); this.botUsername = username; channels = new Dictionary <string, CommandDictionary>(); Live = true; globalCommands = new CommandDictionary("#GLOBAL#", irc); globalCommands["shutdown"] = new ShutdownCommand(this); globalCommands["leaveChannel"] = new LeaveChannelCommand(this, Level.LEVEL_MODERATOR); botUsername = username; this._logger = LogManager.GetCurrentClassLogger(); }
public async void ReadCommandSettings(MqttPublisher publisher) { while (this.CommandSettingsFileLocked) { await Task.Delay(500); } this.CommandSettingsFileLocked = true; List <ConfiguredCommand> commands = new List <ConfiguredCommand>(); using (var stream = new FileStream(Path.Combine(path, "configured-commands.json"), FileMode.Open)) { Log.Logger.Information($"reading configured commands from: {stream.Name}"); if (stream.Length > 0) { commands = await JsonSerializer.DeserializeAsync <List <ConfiguredCommand> >(stream); } stream.Close(); this.CommandSettingsFileLocked = false; } foreach (ConfiguredCommand configuredCommand in commands) { AbstractCommand command = null; switch (configuredCommand.Type) { case "ShutdownCommand": command = new ShutdownCommand(publisher, configuredCommand.Name, configuredCommand.Id); break; case "RestartCommand": command = new RestartCommand(publisher, configuredCommand.Name, configuredCommand.Id); break; case "LogOffCommand": command = new LogOffCommand(publisher, configuredCommand.Name, configuredCommand.Id); break; case "CustomCommand": command = new CustomCommand(publisher, configuredCommand.Command, configuredCommand.Name, configuredCommand.Id); break; default: Log.Logger.Error("unsupported command type in config"); break; } if (command != null) { this.ConfiguredCommands.Add(command); } } }
public MainWindowViewModel(IEventAggregator eventaggretor, EmployeeViewModel registerView, AccountViewModel accountView) { ea = eventaggretor; register = registerView; account = accountView; Shutdown = new ShutdownCommand(); switchView = new SwitchViewCommand(eventaggretor, this, register, account); selectedViewModel = new DashboardViewModel(ea); //Get the user ea.Subscribe(this); RunTask(); }
/// <summary> /// Adds a command to the configured commands. This properly initializes the class, subscribes to the command topic and writes it to the config file. /// </summary> /// <param name="commandType"></param> /// <param name="json"></param> public void AddCommand(AvailableCommands commandType, string json) { var serializerOptions = new JsonSerializerOptions { Converters = { new DynamicJsonConverter() } }; dynamic model = JsonSerializer.Deserialize <dynamic>(json, serializerOptions); AbstractCommand commandToCreate = null; switch (commandType) { case AvailableCommands.ShutdownCommand: commandToCreate = new ShutdownCommand(this._publisher, model.Name); break; case AvailableCommands.RestartCommand: commandToCreate = new RestartCommand(this._publisher, model.Name); break; case AvailableCommands.LogOffCommand: commandToCreate = new LogOffCommand(this._publisher, model.Name); break; case AvailableCommands.CustomCommand: commandToCreate = new CustomCommand(this._publisher, model.Command, model.Name); break; default: Log.Logger.Error("Unknown sensortype"); break; } if (commandToCreate != null) { this._configurationService.AddConfiguredCommand(commandToCreate); } }
public void DashShutdown() { IHalationCommand cmd = new ShutdownCommand(Halation.CurrentSelectedLine, this.GetIndent(Halation.CurrentSelectedLine), Halation.currentCodePackage); HalationInvoker.Dash(Halation.currentScriptName, cmd); }
public void Shutdown() { var command = new ShutdownCommand(); command.Execute(); }
private void Shutdown() { var command = new ShutdownCommand(); this.ExecuteCommand(command); }
public void Shutdown(int exitCode = 0) { var command = new ShutdownCommand(exitCode); this._onShutdown.OnNext(command); }