示例#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);
            }
        }
示例#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);
            }
        }
示例#3
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            SplitterPanel parent = (SplitterPanel)splitContainer2.Panel1;

            if (parent.Controls.Count == 1)
            {
                IMigratorUserControl migrator = (IMigratorUserControl)parent.Controls[0];
                object alert = dataGridView1.Rows[e.RowIndex].Cells["SourceObject"].Value;
                migrator.SeekAlertSource(alert);
            }
        }
示例#4
0
        private void btnRefreshOutput_Click(object sender, EventArgs e)
        {
            SplitterPanel parent = (SplitterPanel)splitContainer2.Panel1;

            if (parent.Controls.Count == 1)
            {
                IMigratorUserControl migrator = (IMigratorUserControl)parent.Controls[0];

                migrator.TemplateGenerator.SerializeStreams();

                foreach (TabPage tabPage in tabOutputResults.TabPages)
                {
                    if (!migrator.TemplateGenerator.TemplateStreams.ContainsKey(tabPage.Name))
                    {
                        tabOutputResults.TabPages.Remove(tabPage);
                    }
                }

                foreach (var templateStream in migrator.TemplateGenerator.TemplateStreams)
                {
                    TabPage tabPage = null;
                    if (!tabOutputResults.TabPages.ContainsKey(templateStream.Key))
                    {
                        tabPage      = new TabPage(templateStream.Key);
                        tabPage.Name = templateStream.Key;
                        tabOutputResults.TabPages.Add(tabPage);

                        if (templateStream.Key.EndsWith(".html"))
                        {
                            WebBrowser webBrowser = new WebBrowser();
                            webBrowser.Width             = tabOutputResults.Width - 15;
                            webBrowser.Height            = tabOutputResults.Height - 30;
                            webBrowser.AllowNavigation   = false;
                            webBrowser.ScrollBarsEnabled = true;
                            tabPage.Controls.Add(webBrowser);
                        }
                        else if (templateStream.Key.EndsWith(".json"))
                        {
                            TextBox textBox = new TextBox();
                            textBox.Width      = tabOutputResults.Width - 15;
                            textBox.Height     = tabOutputResults.Height - 30;
                            textBox.ReadOnly   = true;
                            textBox.Multiline  = true;
                            textBox.WordWrap   = false;
                            textBox.ScrollBars = ScrollBars.Both;
                            tabPage.Controls.Add(textBox);
                        }
                    }
                    else
                    {
                        tabPage = tabOutputResults.TabPages[templateStream.Key];
                    }

                    if (tabPage.Controls[0].GetType() == typeof(TextBox))
                    {
                        TextBox textBox = (TextBox)tabPage.Controls[0];
                        templateStream.Value.Position = 0;
                        textBox.Text = new StreamReader(templateStream.Value).ReadToEnd();
                    }
                    else if (tabPage.Controls[0].GetType() == typeof(WebBrowser))
                    {
                        WebBrowser webBrowser = (WebBrowser)tabPage.Controls[0];
                        templateStream.Value.Position = 0;
                        webBrowser.DocumentText       = new StreamReader(templateStream.Value).ReadToEnd();
                    }
                }

                lblLastOutputRefresh.Text = "Last Refresh Completed: " + DateTime.Now.ToString();
                btnRefreshOutput.Enabled  = false;
            }
        }
示例#5
0
        private async void btnRefreshOutput_Click(object sender, EventArgs e)
        {
            SplitterPanel parent = (SplitterPanel)splitContainer2.Panel1;

            if (parent.Controls.Count == 1)
            {
                IMigratorUserControl migrator = (IMigratorUserControl)parent.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;
                }

                await migrator.TemplateGenerator.GenerateStreams();

                await migrator.TemplateGenerator.SerializeStreams();

                foreach (TabPage tabPage in tabOutputResults.TabPages)
                {
                    if (!migrator.TemplateGenerator.TemplateStreams.ContainsKey(tabPage.Name))
                    {
                        tabOutputResults.TabPages.Remove(tabPage);
                    }
                }

                foreach (var templateStream in migrator.TemplateGenerator.TemplateStreams)
                {
                    TabPage tabPage = null;
                    if (!tabOutputResults.TabPages.ContainsKey(templateStream.Key))
                    {
                        tabPage      = new TabPage(templateStream.Key);
                        tabPage.Name = templateStream.Key;
                        tabOutputResults.TabPages.Add(tabPage);

                        if (templateStream.Key.EndsWith(".html"))
                        {
                            WebBrowser webBrowser = new WebBrowser();
                            webBrowser.Width             = tabOutputResults.Width - 15;
                            webBrowser.Height            = tabOutputResults.Height - 30;
                            webBrowser.AllowNavigation   = false;
                            webBrowser.ScrollBarsEnabled = true;
                            tabPage.Controls.Add(webBrowser);
                        }
                        else if (templateStream.Key.EndsWith(".json") || templateStream.Key.EndsWith(".ps1"))
                        {
                            TextBox textBox = new TextBox();
                            textBox.Width      = tabOutputResults.Width - 15;
                            textBox.Height     = tabOutputResults.Height - 30;
                            textBox.ReadOnly   = true;
                            textBox.Multiline  = true;
                            textBox.WordWrap   = false;
                            textBox.ScrollBars = ScrollBars.Both;
                            tabPage.Controls.Add(textBox);
                        }
                    }
                    else
                    {
                        tabPage = tabOutputResults.TabPages[templateStream.Key];
                    }

                    if (tabPage.Controls[0].GetType() == typeof(TextBox))
                    {
                        TextBox textBox = (TextBox)tabPage.Controls[0];
                        templateStream.Value.Position = 0;
                        textBox.Text = new StreamReader(templateStream.Value).ReadToEnd();
                    }
                    else if (tabPage.Controls[0].GetType() == typeof(WebBrowser))
                    {
                        WebBrowser webBrowser = (WebBrowser)tabPage.Controls[0];
                        templateStream.Value.Position = 0;

                        if (webBrowser.Document == null)
                        {
                            webBrowser.DocumentText = new StreamReader(templateStream.Value).ReadToEnd();
                        }
                        else
                        {
                            webBrowser.Document.OpenNew(true);
                            webBrowser.Document.Write(new StreamReader(templateStream.Value).ReadToEnd());
                        }
                    }
                }

                if (tabOutputResults.TabPages.Count != migrator.TemplateGenerator.TemplateStreams.Count)
                {
                    throw new ArgumentException("Count mismatch between tabOutputResults TabPages and Migrator TemplateStreams.  Counts should match after addition/removal above.  tabOutputResults. TabPages Count: " + tabOutputResults.TabPages.Count + "  Migration TemplateStream Count: " + migrator.TemplateGenerator.TemplateStreams.Count);
                }

                // Ensure Tabs are in same order as output streams
                int streamIndex = 0;
                foreach (string templateStreamKey in migrator.TemplateGenerator.TemplateStreams.Keys)
                {
                    int rotationCounter = 0;

                    // This while loop is to bubble the tab to the end, as to rotate the tab sequence to ensure they match the order returned from the stream outputs
                    // The addition/removal of Streams may result in order of existing tabPages being "out of order" to the streams generated, so we may need to consider reordering
                    while (tabOutputResults.TabPages[streamIndex].Name != templateStreamKey)
                    {
                        TabPage currentTabpage = tabOutputResults.TabPages[streamIndex];
                        tabOutputResults.TabPages.Remove(currentTabpage);
                        tabOutputResults.TabPages.Add(currentTabpage);

                        rotationCounter++;

                        if (rotationCounter > migrator.TemplateGenerator.TemplateStreams.Count)
                        {
                            throw new ArgumentException("Rotated through all tabs, unabled to locate tab '" + templateStreamKey + "' while ensuring tab order/sequencing.");
                        }
                    }

                    streamIndex++;
                }


                lblLastOutputRefresh.Text = "Last Refresh Completed: " + DateTime.Now.ToString();
                btnRefreshOutput.Enabled  = false;

                // post Telemetry Record to ASMtoARMToolAPI
                if (AppSettingsProvider.AllowTelemetry)
                {
                    StatusProvider.UpdateStatus("BUSY: saving telemetry information");
                    migrator.PostTelemetryRecord();
                }
            }
        }
示例#6
0
        private void btnRefreshOutput_Click(object sender, EventArgs e)
        {
            SplitterPanel parent = (SplitterPanel)splitContainer2.Panel1;

            if (parent.Controls.Count == 1)
            {
                IMigratorUserControl migrator = (IMigratorUserControl)parent.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.SerializeStreams();

                foreach (TabPage tabPage in tabOutputResults.TabPages)
                {
                    if (!migrator.TemplateGenerator.TemplateStreams.ContainsKey(tabPage.Name))
                    {
                        tabOutputResults.TabPages.Remove(tabPage);
                    }
                }

                foreach (var templateStream in migrator.TemplateGenerator.TemplateStreams)
                {
                    TabPage tabPage = null;
                    if (!tabOutputResults.TabPages.ContainsKey(templateStream.Key))
                    {
                        tabPage      = new TabPage(templateStream.Key);
                        tabPage.Name = templateStream.Key;
                        tabOutputResults.TabPages.Add(tabPage);

                        if (templateStream.Key.EndsWith(".html"))
                        {
                            WebBrowser webBrowser = new WebBrowser();
                            webBrowser.Width             = tabOutputResults.Width - 15;
                            webBrowser.Height            = tabOutputResults.Height - 30;
                            webBrowser.AllowNavigation   = false;
                            webBrowser.ScrollBarsEnabled = true;
                            tabPage.Controls.Add(webBrowser);
                        }
                        else if (templateStream.Key.EndsWith(".json"))
                        {
                            TextBox textBox = new TextBox();
                            textBox.Width      = tabOutputResults.Width - 15;
                            textBox.Height     = tabOutputResults.Height - 30;
                            textBox.ReadOnly   = true;
                            textBox.Multiline  = true;
                            textBox.WordWrap   = false;
                            textBox.ScrollBars = ScrollBars.Both;
                            tabPage.Controls.Add(textBox);
                        }
                    }
                    else
                    {
                        tabPage = tabOutputResults.TabPages[templateStream.Key];
                    }

                    if (tabPage.Controls[0].GetType() == typeof(TextBox))
                    {
                        TextBox textBox = (TextBox)tabPage.Controls[0];
                        templateStream.Value.Position = 0;
                        textBox.Text = new StreamReader(templateStream.Value).ReadToEnd();
                    }
                    else if (tabPage.Controls[0].GetType() == typeof(WebBrowser))
                    {
                        WebBrowser webBrowser = (WebBrowser)tabPage.Controls[0];
                        templateStream.Value.Position = 0;
                        webBrowser.DocumentText       = new StreamReader(templateStream.Value).ReadToEnd();
                    }
                }

                lblLastOutputRefresh.Text = "Last Refresh Completed: " + DateTime.Now.ToString();
                btnRefreshOutput.Enabled  = false;

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