Example #1
0
 private void tsbUpdate_Click(object sender, EventArgs e)
 {
     // Show progress dialog
     ProgressDialogForm form = new ProgressDialogForm();
     form.BeginDBUpdate(this);
     form.ShowDialog();
 }
Example #2
0
        // Begin importing some files
        private void tsbImport_Click(object sender, EventArgs e)
        {
            // File selection
            if (openFileDialog1.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel) return;
            OperationMode = "IMPORT";

            // Build form
            ProgressForm = new ProgressDialogForm();
            ProgressForm.Show();
            ProgressForm.pbImage.Image = (Image)tsbImport.Image.Clone();
            ProgressForm.label1.Text = "Importing...";
            CurrentObjects = new ArrayList();

            // For each file...
            foreach (string filename in openFileDialog1.FileNames)
            {
                CurrentObjects.Add(filename);
            }

            appWorker.RunWorkerAsync(CurrentObjects);
        }
Example #3
0
        private void mainForm_Shown(object sender, EventArgs e)
        {
            // An update of the app database is required
            if (UpdateWanted)
            {
                UpdateWanted = false;
                tsbUpdate_Click(sender, e);
            }

            // Are we importing a package from command-line?
            if (Program.FileImportWanted != null)
            {
                // We need a confirmation dialog in case the file was double clicked by mistake...
                if (MessageBox.Show("Are you sure you want to import this package?\n\""+Program.FileImportWanted+"\"\n\nSettings for this application will be replaced by the ones contained in this package.","Confirm",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) != DialogResult.OK) {
                    Program.FileImportWanted = null;
                    return;
                }

                OperationMode = "IMPORT";
                CurrentObjects = new ArrayList();

                // For each file...
                CurrentObjects.Add(Program.FileImportWanted);
                Program.FileImportWanted = null;

                // Build form
                ProgressForm = new ProgressDialogForm();
                ProgressForm.Show();
                ProgressForm.pbImage.Image = (Image)tsbImport.Image.Clone();
                ProgressForm.label1.Text = "Importing...";

                // Run worker
                appWorker.RunWorkerAsync(CurrentObjects);
            }
        }
Example #4
0
        private void tsbExport_Click(object sender, EventArgs e)
        {
            // Browse folder
            if (folderBrowserDialog1.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel) return;

            // Disable main form
            EnableMainForm(false);

            SelectedPath = folderBrowserDialog1.SelectedPath;
            OperationMode = "EXPORT";

            // begin the export
            CurrentObjects = (ArrayList) appListView.SelectedObjects;

            // Build form
            ProgressForm = new ProgressDialogForm();
            ProgressForm.Show();
            ProgressForm.pbImage.Image = (Image) tsbExport.Image.Clone();
            ProgressForm.label1.Text = "Exporting...";

            // Launch thread
            appWorker.RunWorkerAsync(CurrentObjects);
        }
Example #5
0
        // Export package
        public bool Export(string OutputFilePath, ProgressDialogForm progressForm, string zipPassword = null)
        {
            // 1. create folder to store temporary files
            string error = CreateAppFolder();
            if (error != "")
            {
                MessageBox.Show("Package creation failed for "+this.Name+": AppMigrate could not create a temporary directory.\n\nSystem error: "+error,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                EraseTempDirectory();
                return false;
            }

            // Do we want to cancel?
            if (progressForm.WantCancel) return false;

            // 2. export registry keys (if any)
            error = ExportRegistryKeys();
            if (error != "")
            {
                MessageBox.Show("Package creation failed for " + this.Name + ": AppMigrate could not export required registry data.\n\nSystem error: " + error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                EraseTempDirectory();
                return false;
            }

            // Do we want to cancel?
            if (progressForm.WantCancel) return false;

            // 3. copy concerned folders (zipped)
            error = GenerateZipPackage(zipPassword);
            if (error != "")
            {
                MessageBox.Show("Package creation failed for " + this.Name + ": AppMigrate could not read one or more of the required data files.\n\nSystem error: " + error+"\n\nSolution: make sure "+this.Name+" is not running while exporting settings.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                EraseTempDirectory();
                return false;
            }

            // Do we want to cancel?
            if (progressForm.WantCancel) return false;

            // 4. Rename file as .appmigrate to ensure it goes to the appropriate location
            error = MoveFileToDesiredLocation(OutputFilePath + "\\"+ Name + ".appmigrate");
            if (error != "")
            {
                MessageBox.Show("Package creation failed for " + this.Name + ": AppMigrate could not move the finalized package to your chosen destination.\n\nSystem error: " + error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                EraseTempDirectory();
                return false;
            }

            // Do we want to cancel?
            if (progressForm.WantCancel) return false;

            // 5. clean directory
            error = EraseTempDirectory();
            if (error != "")
            {
                //MessageBox.Show("Package creation failed for " + this.Name + ": AppMigrate could not remove temporary directory.\n\nSystem error: " + error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            // Success!
            return true;
        }