Beispiel #1
0
        public StoreForm()
        {
            InitializeComponent();

            selectedPackagesId = new List <string>();

            store = new Store();
            store.PluginsUpdated += (sender, e) => { PluginsUpdated?.Invoke(sender, e); };
            var size = store.CalculateCacheFolderSize();

            tsbCleanCacheFolder.ToolTipText = string.Format("Clean XrmToolBox Plugins Store cache folder\r\n\r\nCurrent cache folder size: {0}MB", size);
        }
        public bool PerformInstallation(PluginUpdates updates, Form form)
        {
            if (updates.Plugins.Any(p => p.RequireRestart))
            {
                XmlSerializerHelper.SerializeToFile(updates, Path.Combine(Paths.XrmToolBoxPath, "Update.xml"));

                if (form is StoreFormFromPortal storeForm)
                {
                    form.Invoke(new Action(() =>
                    {
                        if (DialogResult.Yes == MessageBox.Show(form,
                                                                @"This application needs to restart to install updated tools (or new tools that share some files with already installed tools). Click Yes to restart this application now",
                                                                @"Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                        {
                            storeForm.AskForPluginsClosing();

                            Application.Restart();
                        }
                    }));
                }

                return(false);
            }

            foreach (var pu in updates.Plugins)
            {
                try
                {
                    // Can install plugin directly
                    var destinationDirectory = Path.GetDirectoryName(pu.Destination);
                    if (destinationDirectory == null)
                    {
                        continue;
                    }

                    if (!Directory.Exists(destinationDirectory))
                    {
                        Directory.CreateDirectory(destinationDirectory);
                    }
                    File.Copy(pu.Source, pu.Destination, true);
                }
                catch (Exception error)
                {
                    MessageBox.Show("An error occured while copying files: " + error.Message +
                                    "\r\n\r\nCopy has been aborted", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }

            PluginsUpdated?.Invoke(this, new EventArgs());
            return(true);
        }
Beispiel #3
0
        public StoreFormFromPortal()
        {
            InitializeComponent();

            SetStyle(
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint |
                ControlStyles.DoubleBuffer,
                true);

            selectedPackagesId = new List <string>();

            store = new StoreFromPortal();
            store.PluginsUpdated += (sender, e) => { PluginsUpdated?.Invoke(sender, e); };
            var size = store.CalculateCacheFolderSize();

            tsbCleanCacheFolder.ToolTipText = $@"Clean XrmToolBox Plugins Store cache folder\r\n\r\nCurrent cache folder size: {size}MB";
        }
Beispiel #4
0
        public void PerformInstallation(PluginUpdates updates)
        {
            if (updates.Plugins.Any(p => p.RequireRestart))
            {
                XmlSerializerHelper.SerializeToFile(updates, Path.Combine(applicationDataFolder, "Update.xml"));

                if (DialogResult.Yes == MessageBox.Show(
                        "This application needs to restart to install updated plugins (or new plugins that share some files with already installed plugins). Click Yes to restart this application now",
                        "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                {
                    Application.Restart();
                }
            }
            else
            {
                foreach (var pu in updates.Plugins)
                {
                    try
                    {
                        // Can install plugin directly
                        var destinationDirectory = Path.GetDirectoryName(pu.Destination);
                        if (!Directory.Exists(destinationDirectory))
                        {
                            Directory.CreateDirectory(destinationDirectory);
                        }
                        File.Copy(pu.Source, pu.Destination, true);
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show(this,
                                        "An error occured while copying files: " + error.Message +
                                        "\r\n\r\nCopy has been aborted", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                PluginsUpdated?.Invoke(this, new EventArgs());

                // Refresh plugins list when installation is done
                RefreshPluginsList();
                CalculateCacheFolderSize();
                MessageBox.Show("Installation done!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #5
0
        public StoreFormFromPortal(bool allowConnectionControlPrerelease)
        {
            InitializeComponent();

            SetStyle(
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint |
                ControlStyles.DoubleBuffer,
                true);

            selectedPackagesId = new List <string>();

            store = new StoreFromPortal(allowConnectionControlPrerelease);
            store.OnDownloadingTool += Store_OnDownloadingTool;
            store.LoadNuget();
            store.PluginsUpdated += (sender, e) => { PluginsUpdated?.Invoke(sender, e); };
            var size = store.CalculateCacheFolderSize();

            tsbCleanCacheFolder.ToolTipText = $@"Clean XrmToolBox Tool Library cache folder

Current cache folder size: {size}MB";
        }