private async void ButtonSourceControlRunbook_Click(object sender, RoutedEventArgs e) { try { JobCreateResponse sourceControlJob = await AutomationSourceControl.startSouceControlJob(iseClient.automationManagementClient, iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name); JobOutputWindow jobWindow = new JobOutputWindow(sourceControlJob.Job.Properties.Runbook.Name, sourceControlJob, iseClient); jobWindow.Show(); } catch (Exception ex) { MessageBox.Show("The source control job could not be started. " + ex.Message, "Error"); return; } }
private async void accountsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { AutomationAccount account = (AutomationAccount)accountsComboBox.SelectedValue; iseClient.currAccount = account; refreshTimer.Stop(); if (account != null) { /* Update Status */ UpdateStatusBox(configurationStatusTextBox, "Selected automation account: " + account.Name); if (iseClient.AccountWorkspaceExists()) { accountPathTextBox.Text = iseClient.currWorkspace; } /* Update Runbooks */ UpdateStatusBox(configurationStatusTextBox, "Getting runbook data..."); if (runbookListViewModel != null) { runbookListViewModel.Clear(); } runbookListViewModel = new ObservableCollection <AutomationRunbook>(await AutomationRunbookManager.GetAllRunbookMetadata(iseClient.automationManagementClient, iseClient.currWorkspace, iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name)); UpdateStatusBox(configurationStatusTextBox, "Done getting runbook data"); /* Update Assets */ //TODO: this is not quite checking what we need it to check if (!iseClient.AccountWorkspaceExists()) { UpdateStatusBox(configurationStatusTextBox, "Downloading assets..."); await downloadAllAssets(); UpdateStatusBox(configurationStatusTextBox, "Assets downloaded"); } /* Update PowerShell Module */ try { PSModuleConfiguration.UpdateModuleConfiguration(iseClient.currWorkspace); } catch { string message = "Could not configure the " + PSModuleConfiguration.ModuleData.ModuleName + " module.\r\n"; message += "This module is required for your runbooks to run locally.\r\n"; message += "Make sure it exists in your module path (env:PSModulePath)."; MessageBox.Show(message); } /* Update UI */ RunbooksListView.ItemsSource = runbookListViewModel; setRunbookSelectionButtonState(false); setRunbookAndAssetNonSelectionButtonState(true); assetsComboBox.SelectedValue = AutomationISE.Model.Constants.assetVariable; ButtonRefreshAssetList.IsEnabled = true; /* Enable source control sync in Azure Automation if it is set up for this automation account */ bool isSourceControlEnabled = await AutomationSourceControl.isSourceControlEnabled(iseClient.automationManagementClient, iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name); if (isSourceControlEnabled) { ButtonSourceControlRunbook.Visibility = Visibility.Visible; ButtonSourceControlRunbook.IsEnabled = true; } else { ButtonSourceControlRunbook.Visibility = Visibility.Collapsed; } /* Change current directory to new workspace location */ accountPathTextBox.Text = iseClient.currWorkspace; HostObject.CurrentPowerShellTab.Invoke("cd '" + iseClient.currWorkspace + "'"); refreshTimer.Start(); } } catch (Exception exception) { var detailsDialog = MessageBox.Show(exception.Message); } }