private async void AzureControl_AfterContextChanged(UserControl sender) { IMigrationSourceUserControl migrationSourceUserControl = (IMigrationSourceUserControl)sender; targetAzureContextViewer.Enabled = migrationSourceUserControl.IsSourceContextAuthenticated; if (migrationSourceUserControl != null && migrationSourceUserControl.GetType() == typeof(MigrationAzureSourceContext)) { MigrationAzureSourceContext azureSourceContext = (MigrationAzureSourceContext)migrationSourceUserControl; targetAzureContextViewer.ExistingContext = azureSourceContext.AzureContext; } }
private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { OptionsDialog optionsDialog = new OptionsDialog(); optionsDialog.Bind(_AzureEnvironments, _UserDefinedAzureEnvironments); optionsDialog.ShowDialog(); IMigrationSourceUserControl sourceUserControl = this.MigrationSourceControl; if (sourceUserControl != null) { if (sourceUserControl.GetType() == typeof(MigrationAzureSourceContext)) { MigrationAzureSourceContext migrationAzureSourceContext = (MigrationAzureSourceContext)sourceUserControl; migrationAzureSourceContext.AzureContext.LoginPromptBehavior = app.Default.LoginPromptBehavior; } } }
private async Task <bool> RefreshOutput() { if (AssertHasTargetErrors()) { return(false); } IMigrationSourceUserControl migrationSourceControl = this.MigrationSourceControl; if (migrationSourceControl == null) { throw new ArgumentException("Unable to Refresh Output: NULL MigrationSourceControl Context"); } if (targetAzureContextViewer.ExistingContext == null) { throw new ArgumentException("Unable to Refresh Output: NULL Target Existing Azure Context"); } if (targetAzureContextViewer.ExistingContext.AzureSubscription == null) { throw new ArgumentException("Unable to Refresh Output: NULL Target Existing Azure Context"); } if (this.AzureGenerator == null) { throw new ArgumentException("Unable to Refresh Output: NULL TemplateGenerator"); } if (this.targetAzureContextViewer == null) { throw new ArgumentException("Unable to Refresh Output: NULL TargetAzureContextViewer"); } if (this.targetAzureContextViewer.SelectedAzureContext == null) { throw new ArgumentException("Unable to Refresh Output: NULL SelectedAzureContext on TargetAzureContextViewer"); } if (this.targetAzureContextViewer.SelectedAzureContext.TokenProvider == null) { throw new ArgumentException("Unable to Refresh Output: NULL TokenProvider on SelectedAzureContext"); } if (this.AzureGenerator != null) { this.AzureGenerator.AccessSASTokenLifetimeSeconds = app.Default.AccessSASTokenLifetimeSeconds; this.AzureGenerator.ExportArtifacts = this.targetTreeView1.ExportArtifacts; this.AzureGenerator.OutputDirectory = this.txtDestinationFolder.Text; this.AzureGenerator.TargetAzureTokenProvider = (AzureTokenProvider)this.targetAzureContextViewer.SelectedAzureContext.TokenProvider; await this.AzureGenerator.GenerateStreams(); foreach (TabPage tabPage in tabOutputResults.TabPages) { if (!this.AzureGenerator.TemplateStreams.ContainsKey(tabPage.Name)) { tabOutputResults.TabPages.Remove(tabPage); } } foreach (var templateStream in this.AzureGenerator.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 != this.AzureGenerator.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: " + this.AzureGenerator.TemplateStreams.Count); } // Ensure Tabs are in same order as output streams int streamIndex = 0; foreach (string templateStreamKey in this.AzureGenerator.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 > this.AzureGenerator.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"); _telemetryProvider.PostTelemetryRecord(_AppSessionGuid, this.MigrationSourceControl.MigrationSourceType, targetAzureContextViewer.ExistingContext.AzureSubscription, this.AzureGenerator); } } StatusProvider.UpdateStatus("Ready"); return(true); }