Example #1
0
        /// <summary>
        /// True if there are manual changes and we overwrote the profile, otherwise false.
        /// If true, it will also set that as the active profile.</summary>
        private static bool DoManualChangesOverwrite(MefinoProfile active)
        {
            if (IsProfileDifferentToEnabledPackages(active))
            {
                List <string> uninstalled = new List <string>();
                foreach (var pkg in active.packages)
                {
                    if (LocalPackageManager.TryGetInstalledPackage(pkg) == null)
                    {
                        uninstalled.Add(pkg);
                    }
                }
                if (uninstalled.Any())
                {
                    var msg = "";
                    foreach (var entry in uninstalled)
                    {
                        msg += $"\n{entry}";
                    }

                    var msgResult = MessageBox.Show($"The following packages from the profile '{active.name}' are no longer installed:" +
                                                    $"\n{msg}" +
                                                    $"\n\n" +
                                                    $"Do you want to reinstall them?",
                                                    "Missing packages!",
                                                    MessageBoxButtons.YesNo);
                    if (msgResult == DialogResult.Yes)
                    {
                        foreach (var entry in uninstalled)
                        {
                            LocalPackageManager.TryInstallWebPackage(entry, true);
                        }
                    }
                }

                active.packages.Clear();
                active.packages.AddRange(LocalPackageManager.s_enabledPackages.Keys);

                SetChangesSinceSave(true);
                SetActiveProfile(active, true);

                return(true);
            }

            return(false);
        }
Example #2
0
        internal static void Cmd_Install(params string[] args)
        {
            if (!Folders.IsCurrentOutwardPathValid())
            {
                Console.WriteLine("You need to set the Outward path first!");
                return;
            }

            foreach (var guid in args)
            {
                if (WebManifestManager.s_webManifests.ContainsKey(guid))
                {
                    LocalPackageManager.TryInstallWebPackage(guid);
                }
                else
                {
                    Console.WriteLine($"Could not find package by name '{guid}', maybe need to refresh the list?");
                }
            }
        }
Example #3
0
        /// <summary>
        /// Enable all packages in this profile, and disable all other packages.
        /// </summary>
        public void EnableProfile()
        {
            if (this.packages == null || this.packages.Count == 0)
            {
                if (LocalPackageManager.s_enabledPackages.Any())
                {
                    LocalPackageManager.DisableAllPackages();
                }
                return;
            }

            // Try enable all packages (does nothing if already OK)
            // its possible our 'packages' list will change during this process, so copy it now.
            //var copy = packages.ToList();
            List <string> missing = new List <string>();

            for (int i = 0; i < packages.Count; i++)
            {
                var pkg = packages[i];
                if (LocalPackageManager.TryGetInstalledPackage(pkg) == null)
                {
                    missing.Add(pkg);
                }
                else
                {
                    if (!LocalPackageManager.TryEnablePackage(pkg))
                    {
                        LocalPackageManager.TryDisablePackage(pkg, true);
                        packages.Remove(pkg);
                    }
                }
            }

            if (missing.Any())
            {
                string miss = "";
                foreach (var entry in missing)
                {
                    miss += $"\n{entry}";
                }

                var msgResult = MessageBox.Show($"The following packages in your profile are missing and need to be re-installed:" +
                                                $"\n{miss}" +
                                                $"\n\n" +
                                                $"Do you want to re-install them?",
                                                "Missing packages!",
                                                MessageBoxButtons.YesNo);
                if (msgResult == DialogResult.Yes)
                {
                    foreach (var entry in missing)
                    {
                        LocalPackageManager.TryInstallWebPackage(entry);
                    }
                }
            }

            // Disable currently enabled packages which are not in this profile
            if (LocalPackageManager.s_enabledPackages.Any())
            {
                for (int i = LocalPackageManager.s_enabledPackages.Count - 1; i >= 0; i--)
                {
                    var pkg = LocalPackageManager.s_enabledPackages.ElementAt(i);

                    if (!packages.Any(it => it == pkg.Key))
                    {
                        LocalPackageManager.TryDisablePackage(pkg.Key, true);
                    }
                }
            }
        }