public int OnExecute(IConsole console, CommandLineApplication app) { if (InstallSOS || UninstallSOS) { try { var sosInstaller = new InstallHelper((message) => console.WriteLine(message)); if (SOSSourcePath != null) { sosInstaller.SOSSourcePath = SOSSourcePath; } if (UninstallSOS) { sosInstaller.Uninstall(); } else { sosInstaller.Install(); } } catch (SOSInstallerException ex) { console.Error.WriteLine(ex.Message); return(1); } } return(0); }
private void btnSave_Click(object sender, RoutedEventArgs e) { //PrivateIsOutBlockedNotif is also valid for public and domain status.PublicIsOutBlockedNotif = status.PrivateIsOutBlockedNotif; status.DomainIsOutBlockedNotif = status.PrivateIsOutBlockedNotif; if (status.PrivateIsOutBlockedNotif == false) { //if not blocked, allowed must be true if (status.PrivateIsOutBlocked == false) { status.PrivateIsOutAllowed = true; } if (status.PublicIsOutBlocked == false) { status.PublicIsOutAllowed = true; } if (status.DomainIsOutBlocked == false) { status.DomainIsOutAllowed = true; } } status.Save(); bool checkResult(Func <bool> boolFunction, string okMsg, string errorMsg) { try { bool success = boolFunction.Invoke(); LastMessage = success ? okMsg : errorMsg; LogHelper.Debug($"{boolFunction.Method.Name}: {LastMessage}"); return(success); } catch (Exception ex) { LogHelper.Error(ex.Message, ex); LastMessage = $"{errorMsg}: {ex.Message}"; return(false); } } if (!isInstalled) { if (!InstallHelper.Install(checkResult)) { return; } } else if (isInstalled) { if (!InstallHelper.InstallCheck(checkResult)) { return; } } init(); }
private static Task <int> InvokeAsync(IConsole console, Architecture?architecture, bool install) { try { var sosInstaller = new InstallHelper((message) => console.Out.WriteLine(message), architecture); if (install) { sosInstaller.Install(); } else { sosInstaller.Uninstall(); } } catch (SOSInstallerException ex) { console.Error.WriteLine(ex.Message); return(Task.FromResult(1)); } return(Task.FromResult(0)); }