public async Task <ApiResult> Init(bool?safeMode) { if (_status != LaunchStatus.NotLaunched && _status != LaunchStatus.LaunchFailed) { return(ApiResult(409, $"The EOS is under {_status} status.")); } Task.Factory.StartNew(() => { using (var serviceScope = HttpContext.RequestServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { var eos = serviceScope.ServiceProvider.GetService <OneBoxService>(); _status = LaunchStatus.Launching; if (eos.Launch(safeMode.HasValue ? safeMode.Value : false)) { _status = LaunchStatus.Active; } else { _status = LaunchStatus.LaunchFailed; } } }); return(ApiResult(201, "Lauching...")); }
private void timer_typePasswordIfNeeded_Tick(object sender, EventArgs e) { this.timer_typePasswordIfNeeded.Enabled = false; try { bool startMonitoring = false; switch (lastKnownStatus) { case LaunchStatus.DoNothing: switch (launchToken.Status) { case LaunchStatus.MonitorForP: startMonitoring = true; lastKnownStatus = LaunchStatus.MonitorForP; break; } break; } if (startMonitoring) { keyboardHook.KeyboardPressed += (s, ev) => { var key = (Keys)ev.KeyboardData.VirtualCode; if (key == Keys.P) { //Type in the password: Util.TryTo("Type in password", () => { for (int i = 0; i < 10; i++) { SendKeys.SendWait("{BS}"); Thread.Sleep(50); } foreach (var letter in textBox_password.Text) { SendKeys.SendWait(letter.ToString()); Thread.Sleep(100); } for (int i = 0; i < 3; i++) { SendKeys.SendWait("{Enter}"); Thread.Sleep(100); } keyboardHook.Dispose(); Application.Exit(); }); } }; } } catch (Exception) { //We don't display this as it's in the timer and would spam the user. } finally { this.timer_typePasswordIfNeeded.Enabled = true; } }
public async Task <ApiResult> Init(bool?safeMode) { if (_status != LaunchStatus.未启动 && _status != LaunchStatus.启动失败) { return(ApiResult(409, $"The EOS is under {_status} status.")); } Task.Factory.StartNew(() => { using (var serviceScope = HttpContext.RequestServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) using (var eos = serviceScope.ServiceProvider.GetService <EosService>()) { _status = LaunchStatus.正在启动; if (eos.Launch(safeMode.HasValue ? safeMode.Value : false)) { _status = LaunchStatus.正在运行; } else { _status = LaunchStatus.启动失败; } } }); var instances = JsonConvert.DeserializeObject <Config>(System.IO.File.ReadAllText("config.json")).dapp; await Task.Factory.StartNew(() => { using (var serviceScope = HttpContext.RequestServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) using (var ins = serviceScope.ServiceProvider.GetService <DappService>()) { if (instances == null) { return; } foreach (var x in instances) { ins.DownloadAndStartInstanceAsync( System.IO.Path.GetFileNameWithoutExtension(x), InstanceUploadMethod.Git, x); } } }); return(ApiResult(201, "Lauching...")); }
public ApiResult Stop(bool?safeMode, [FromServices] EosService eos) { if (_status != LaunchStatus.正在运行 && _status != LaunchStatus.正在启动) { return(ApiResult(409, $"The EOS is under {_status} status.")); } if (safeMode.HasValue && safeMode.Value) { eos.GracefulShutdown(); } else { eos.ForceShutdown(); } _status = LaunchStatus.未启动; return(ApiResult(200, "Succeeded")); }
public ApiResult Stop(bool?safeMode, [FromServices] OneBoxService eos) { if (_status != LaunchStatus.Active && _status != LaunchStatus.Launching) { return(ApiResult(409, $"The EOS is under {_status} status.")); } if (safeMode.HasValue && safeMode.Value) { eos.GracefulShutdown(); } else { eos.ForceShutdown(); } _status = LaunchStatus.NotLaunched; return(ApiResult(200, "Succeeded")); }
public static string GetLaunchStatusStringById(LaunchStatus status) { switch (status) { case LaunchStatus.Go: return "Launch is Go"; case LaunchStatus.Hold: return "Launch time TBD"; case LaunchStatus.Success: return "Launch was a success"; case LaunchStatus.Failed: return "Launch failed"; case LaunchStatus.Unknown: return "Unknown"; default: throw new ArgumentOutOfRangeException(); } }
public static string GetLaunchStatusStringById(LaunchStatus status, DateTime net) { switch (status) { case LaunchStatus.Go: return "Launch is Go"; case LaunchStatus.Hold: return DateTime.Now > TimeConverter.DetermineTimeSettings(net, App.Settings.UseLocalTime).AddDays(-1) ? "Launch in Hold" : "Launch time TBD"; case LaunchStatus.Success: return "Launch was a success"; case LaunchStatus.Failed: return "Launch failed"; case LaunchStatus.Unknown: return "Unknown"; default: throw new ArgumentOutOfRangeException(); } }
public static void Main() { LaunchStatus okToLaunch = GetFuelLaunchStatus() && GetNavigationLaunchStatus(); Console.WriteLine(okToLaunch ? "Ready to go!" : "Wait!"); }
private async Task <DeploymentResult> DeploymentProgressWrapper(IAsyncOperationWithProgress <DeploymentResult, DeploymentProgress> t, LaunchStatus status) { TaskCompletionSource <int> src = new TaskCompletionSource <int>(); t.Progress += (v, p) => { if (LaunchInfo.Status != status) { LaunchInfo.Status = status; } LaunchInfo.LaunchCurrent = p.percentage; Trace.WriteLine("Deployment progress: " + p.state + " " + p.percentage + "%"); }; t.Completed += (v, p) => { Trace.WriteLine("Deployment done: " + p); src.SetResult(1); }; await src.Task; return(t.GetResults()); }