コード例 #1
0
        private void uxUpdateAll_Click(object sender, EventArgs e)
        {
            ListViewItem[] Items = new ListViewItem[uxUpdatePackages.Items.Count];
            uxUpdatePackages.Items.CopyTo(Items, 0);

            for (int i = 0; i < Items.Length; i++)
            {
                var pack = Items[i].Tag as IPackage;
                try
                {
                    foreach (PackageDependency dependency in pack.Dependencies)
                    {
                        if (packages.GetLocalPackage(dependency.Id) == null)
                        {
                            packages.Update(packages.Repo.FindPackage(dependency.Id));
                        }
                    }

                    Updates.UpdatePackage(pack);
                }
                catch
                {
                    MessageBox.Show("Failed to update " + pack.GetFullName());
                }
            }

            uxUpdate.Enabled = true;
            DisplayPackagesAndUpdates();
            showUpdateComplete();
        }
コード例 #2
0
        //autoUpdate any packages found in current feed.
        internal List <String> autoUpdate()
        {
            List <String> updatesOccurred = new List <String>();

            getAllAvailableUpdates();

            if (list != null && list.Count() > 0)
            {
                DialogResult dialogResult = MessageBox.Show("       " + list.Count() + " Updates available.\n\n" +
                                                            "Do you want to install them now?", "Updates available", MessageBoxButtons.YesNo);

                if (dialogResult == DialogResult.Yes)
                {
                    foreach (IPackage p in list)
                    {
                        if ((p.Tags == null) || (!p.Tags.Contains(HideFromAutoUpdate)))
                        {
                            foreach (PackageDependency dependency in p.Dependencies)
                            {
                                if (packages.GetLocalPackage(dependency.Id) == null)
                                {
                                    packages.Update(packages.Repo.FindPackage(dependency.Id));
                                }
                            }

                            try
                            {
                                UpdatePackage(p);
                                updatesOccurred.Add(p.GetFullName());
                            }
                            catch
                            {
                                MessageBox.Show("Error updating " + p.GetFullName());
                            }
                        }
                    }
                }
            }
            return(updatesOccurred);
        }
コード例 #3
0
        private void uxUpdate_Click(object sender, EventArgs e)
        {
            var pack = uxPackages.SelectedItem as IPackage;

            if (pack != null)
            {
                // deactivate the old version and mark for uninstall
                var extension = App.EnsureDeactivated(pack.Id);

                if (IsPackageInstalled(pack))
                {
                    App.MarkPackageForRemoval(GetPackagePath(pack));
                }
                else
                {
                    // todo: consider removing unneeded dependencies.
                    App.MarkExtensionForRemoval(GetExtensionPath(extension));
                }

                App.ProgressHandler.Progress(null, 0, "Updating " + pack.Title);

                // get new version
                packages.Update(pack);

                App.RefreshExtensions();

                // Activate the extension(s) that was installed.
                // it is difficult to determine which version is newest, so we go and look at the when the file was
                // placed on disk.
                var newExtension = App.Extensions.Where(a => a.Name == pack.Id).OrderBy(b => File.GetCreationTime(GetExtensionPath(b))).FirstOrDefault();
                if (newExtension != null)
                {
                    newExtension.Activate();
                }

                // hack: we might need to refresh the installed list to show new version numbers
                // or dependencies that were retrieved with the new version.
                App.ProgressHandler.Progress(null, 0, "Ready.");
            }
        }