public static ComponentTask InstallWithChoco( Architectures architecture, string displayName, string pkgName, string searchMask, bool force) { Func <bool> isChocoInstalledAction = () => ChocoUtil.IsChocoInstalled(); Func <bool> isInternetConnected = () => Network.TestInternetConnection(); List <Func <bool> > prereqFuncs = new List <Func <bool> >() { isInternetConnected, isChocoInstalledAction }; Action installProgramAction = () => ChocoUtil.ChocoUpgrade(pkgName, displayName, false, searchMask, ChocoUtil.DefaultArgs); Func <bool> isProgramInstalledAction = () => ProgramInstaller.IsSoftwareInstalled(architecture, searchMask); return(new ComponentTask(new SetupTask(prereqFuncs, installProgramAction, isProgramInstalledAction, force), null)); }
private void ShowUpdateBalloon(List <ChocoPackage> packages) { var updates = ChocoUtil.CleanPackageList(packages.Where(p => p.IsOutdatedAndUpdateable).ToList()); if (updates.Count <= 5) { var msg = string.Join("\n", updates.Select(p => $"{p.PackageName} ({p.CurrentVersion} -> {p.AvailableVersion})")); NotifyIcon.ShowBalloonTip("The following packages have new versions available", msg, BalloonIcon.Info); } else { NotifyIcon.ShowBalloonTip("New Updates", $"There are {updates.Count(p => p.UpdateAvailable && p.Pinned != true)} new updates available", BalloonIcon.Info); } }
private ComponentTask ChocolateyInstallation() { Func <bool> prequisiteFunc = () => Network.TestInternetConnection(); Action action = () => { string command = @"@powershell -NoProfile -ExecutionPolicy Bypass -Command ""iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"; SystemUtil.ExecuteCMDCommand(command); }; Func <bool> actionValidation = () => ChocoUtil.IsChocoInstalled(); return(new ComponentTask(new SetupTask(prequisiteFunc, action, actionValidation, false), null)); }
private ComponentTask JavaX86Installation() { Func <bool> isChocoInstalled = () => ChocoUtil.IsChocoInstalled(); /* Update to use non-default argument list to specifically get x86 version */ Action installJavaX86 = () => ComponentTaskPresets.InstallWithChoco(Architectures.X86, "Java 8 (32-bit)", "jre8", "Java 8 Update *$", false); Func <bool> isX86Java8Installed = () => JavaInstallUtil.IsJavaInstalled(Architectures.X86, 8); return(new ComponentTask( new SetupTask( isChocoInstalled, installJavaX86, isX86Java8Installed, false), null)); }
public async void ChocoRefresh(bool manual) { var win = Application.Current.MainWindow as MainWindow; var vm = win?.StatusVM; try { State.AppStatus = AppStatus.Refreshing; if (manual && vm != null) { vm.Packages.Clear(); } var chocoresult = await ChocoQueryExecutor.QueryFull(); if (GAS.Settings.SortUpdatesToTop) { chocoresult = chocoresult .OrderByDescending(p => p.IsOutdatedAndUpdateable) .ThenBy(p => p.Pinned) .ThenBy(p => p.PackageName) .ToList(); } else { chocoresult = chocoresult .OrderBy(p => p.PackageName) .ToList(); } if (vm != null) { vm.Packages.Clear(); if (GAS.Settings.SimplifyPackageDisplayList) { foreach (var pkg in ChocoUtil.CleanPackageList(chocoresult)) { vm.Packages.Add(pkg); } } else { foreach (var pkg in chocoresult) { vm.Packages.Add(pkg); } } } var updates = chocoresult.Where(p => p.IsOutdatedAndUpdateable).ToList(); if (updates.Any()) { if (!manual && GAS.Settings.ShowBalloonOnChocoUpdatesFound && updates.Any(u => State.LastUpdateList.All(p => p.PackageName != u.PackageName))) { ShowUpdateBalloon(chocoresult); } State.AppStatus = AppStatus.UpdatesAvailable; } else { State.AppStatus = AppStatus.Okay; } GAS.Inst.LastUpdateList = updates; GAS.Inst.LastRefreshResult = chocoresult; } catch (Exception e) { GAS.Log.AddError("ManualRefresh failed", e); if (manual) { MessageBox.Show("Refresh failed, see Log for more Information"); } else { NotifyIcon.ShowBalloonTip("Error", "Refresh failed, see Log for more Information", BalloonIcon.Error); } State.AppStatus = AppStatus.Error; } }