Example #1
0
        private void btnExport_Click_1(object sender, EventArgs e)
        {
            if (splitContainer2.Panel1.Controls.Count == 1)
            {
                IMigratorUserControl migrator = (IMigratorUserControl)splitContainer2.Panel1.Controls[0];

                if (migrator.TemplateGenerator.HasErrors)
                {
                    MessageBox.Show("There are still one or more error(s) with the template generation.  Please resolve all errors before exporting.");
                    return;
                }

                // We are refreshing both the MemoryStreams and the Output Tabs via this call, prior to writing to files
                btnRefreshOutput_Click(this, null);

                migrator.TemplateGenerator.OutputDirectory = txtDestinationFolder.Text;
                migrator.TemplateGenerator.Write();

                // post Telemetry Record to ASMtoARMToolAPI
                if (AppSettingsProvider.AllowTelemetry)
                {
                    StatusProvider.UpdateStatus("BUSY: saving telemetry information");
                    migrator.PostTelemetryRecord();
                }

                StatusProvider.UpdateStatus("Ready");

                var exportResults = new ExportResultsDialog(migrator.TemplateGenerator);
                exportResults.ShowDialog(this);
            }
        }
Example #2
0
        private void btnExport_Click_1(object sender, EventArgs e)
        {
            if (splitContainer2.Panel1.Controls.Count == 1)
            {
                IMigratorUserControl migrator = (IMigratorUserControl)splitContainer2.Panel1.Controls[0];

                if (migrator.TemplateGenerator.HasErrors)
                {
                    tabMigAzMonitoring.SelectTab("tabMessages");
                    MessageBox.Show("There are still one or more error(s) with the template generation.  Please resolve all errors before exporting.");
                    return;
                }

                migrator.TemplateGenerator.OutputDirectory = txtDestinationFolder.Text;

                // We are refreshing both the MemoryStreams and the Output Tabs via this call, prior to writing to files
                btnRefreshOutput_Click(this, null);

                migrator.TemplateGenerator.Write();

                StatusProvider.UpdateStatus("Ready");

                var exportResults = new ExportResultsDialog(migrator.TemplateGenerator);
                exportResults.ShowDialog(this);
            }
        }
Example #3
0
        private async void btnExport_Click_1Async(object sender, EventArgs e)
        {
            // We are refreshing both the MemoryStreams and the Output Tabs via this call, prior to writing to files
            if (await RefreshOutput())
            {
                if (this.AzureGenerator != null)
                {
                    this.AzureGenerator.OutputDirectory = txtDestinationFolder.Text;

                    this.AzureGenerator.Write();

                    StatusProvider.UpdateStatus("Ready");

                    var exportResults = new ExportResultsDialog(this.AzureGenerator);
                    exportResults.ShowDialog(this);
                }
            }
        }
Example #4
0
        private async void btnExport_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(txtDestinationFolder.Text))
            {
                MessageBox.Show("Export path is required.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                btnChoosePath_Click(this, null);
                return;
            }

            if (TemplateResult.OutputFilesExist(txtDestinationFolder.Text))
            {
                if (MessageBox.Show("The target export path already contains export files.  Do you want proceed and overwrite the existing files?", "Overwrite Existing Export", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            btnExport.Enabled = false;
            btnCancel.Enabled = false;

            try
            {
                AsmToArmForm      parentForm        = (AsmToArmForm)this.Owner;
                TemplateGenerator templateGenerator = new TemplateGenerator(parentForm.LogProvider, parentForm.StatusProvider, parentForm.TelemetryProvider, parentForm.AppSettingsProviders);
                TemplateResult    templateResult    = await templateGenerator.GenerateTemplate(parentForm.AzureContextSourceASM.AzureSubscription, parentForm.AzureContextTargetARM.AzureSubscription, artifacts, parentForm.TargetResourceGroup, txtDestinationFolder.Text);

                var exportResults = new ExportResultsDialog(templateResult);
                exportResults.ShowDialog(this);
                this.Close();
            }
            catch (Exception ex)
            {
                parentForm.LogProvider.WriteLog("btnExport_Click", "Error generating template : " + ex.ToString());
                MessageBox.Show("Something went wrong when generating the template. Check the log file for details.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnExport.Enabled = true;
                btnCancel.Enabled = true;
            }
        }