Esempio n. 1
0
        /// <summary>
        ///      Uninstall the deployed package
        /// </summary>
        /// <param name="sender">Unused</param>
        /// <param name="e">Unused</param>
        private void ButtonUninstall_Click(object sender, EventArgs e)
        {
            string deploymentDir = textBoxUninstallDirectory.Text;

            // Check if the user is an administrator
            if (!Utils.IsUserAdministrator())
            {
                MessageBox.Show("You must be running this application as administrator to deploy a package", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Ensure the directory exists
            if (!Directory.Exists(deploymentDir))
            {
                MessageBox.Show("Selected directory does not exist");
                return;
            }

            // Callback for dialog
            Action <ProcessDialog> task = new Action <ProcessDialog>((dlg) => Uninstall(dlg, deploymentDir));

            // Install
            using (ProcessDialog dlg = new ProcessDialog("Uninstalling Package...", task))
                dlg.ShowDialog();
        }
Esempio n. 2
0
        /// <summary>
        ///      Deploy a package ZIP
        /// </summary>
        /// <param name="sender">Unused</param>
        /// <param name="e">Unused</param>
        private void ButtonDeploy_Click(object sender, EventArgs e)
        {
            string deploymentDir = textBoxDeploymentDirectory.Text;

            // Check if the user is an administrator
            if (!Utils.IsUserAdministrator())
            {
                MessageBox.Show("You must be running this application as administrator to deploy a package", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Get the ZIP file
            string zipFile = null;

            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.FileName = "Package.zip";
                dlg.Filter   = "ZIP Files (*.zip)|*.zip";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    zipFile = Path.GetFullPath(dlg.FileName);
                }
            }

            // Exit if no zip chosen
            if (string.IsNullOrEmpty(zipFile))
            {
                return;
            }

            // Update the saved path if altered manually
            if (deploymentDir != Properties.Settings.Default.DeployDir)
            {
                // Update other text box
                textBoxUninstallDirectory.Text = deploymentDir;

                // Remember
                Properties.Settings.Default.DeployDir = deploymentDir;
            }

            // Update the internal state
            bool inLEADOverride = checkBoxInLEAD.Checked;

            Properties.Settings.Default.InLEADOverride = inLEADOverride;
            Properties.Settings.Default.Save();

            // Create the temporary directory for unzipping
            string tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(tempDir);

            // Callbacks for dialog
            bool target64               = comboBoxTargetBitness.SelectedIndex == 1;
            bool dualInstall            = checkBoxDualInstall.Checked;
            Action <ProcessDialog> task = new Action <ProcessDialog>((dlg) => Install(dlg, tempDir, deploymentDir, zipFile, target64, dualInstall, inLEADOverride));
            Action cleanup              = new Action(() =>
            {
                if (Directory.Exists(tempDir))
                {
                    new DirectoryInfo(tempDir).Attributes &= ~FileAttributes.ReadOnly;
                    Directory.Delete(tempDir, true);
                }
            });

            // Install
            using (ProcessDialog dlg = new ProcessDialog("Deploying Package...", task, cleanup))
                dlg.ShowDialog();
        }