public async Task <ObservableCollection <OrgViewModel> > FetchChildren() { var newOrgsList = new ObservableCollection <OrgViewModel>(); var orgsResponse = await CloudFoundryService.GetOrgsForCfInstanceAsync(CloudFoundryInstance); if (orgsResponse.Succeeded) { var orgs = new ObservableCollection <CloudFoundryOrganization>(orgsResponse.Content); foreach (CloudFoundryOrganization org in orgs) { var newOrg = new OrgViewModel(org, this, ParentTasExplorer, Services); newOrgsList.Add(newOrg); } } else if (orgsResponse.FailureType == Toolkit.Services.FailureType.InvalidRefreshToken) { IsExpanded = false; ParentTasExplorer.AuthenticationRequired = true; } else { _dialogService.DisplayErrorDialog(_getOrgsFailureMsg, orgsResponse.Explanation); } return(newOrgsList); }
public async Task <ObservableCollection <AppViewModel> > FetchChildren() { var newAppsList = new ObservableCollection <AppViewModel>(); var appsResult = await CloudFoundryService.GetAppsForSpaceAsync(Space); if (appsResult.Succeeded) { foreach (CloudFoundryApp app in appsResult.Content) { var newOrg = new AppViewModel(app, Services); newAppsList.Add(newOrg); } } else if (appsResult.FailureType == Toolkit.Services.FailureType.InvalidRefreshToken) { Parent.Parent.IsExpanded = false; ParentTasExplorer.AuthenticationRequired = true; } else { _dialogService.DisplayErrorDialog(_getAppsFailureMsg, appsResult.Explanation); } return(newAppsList); }
public async Task <ObservableCollection <SpaceViewModel> > FetchChildren() { var newSpacesList = new ObservableCollection <SpaceViewModel>(); var spacesResponse = await CloudFoundryService.GetSpacesForOrgAsync(Org); if (spacesResponse.Succeeded) { var spaces = new ObservableCollection <CloudFoundrySpace>(spacesResponse.Content); foreach (CloudFoundrySpace space in spaces) { var newSpace = new SpaceViewModel(space, this, ParentTasExplorer, Services); newSpacesList.Add(newSpace); } } else if (spacesResponse.FailureType == Toolkit.Services.FailureType.InvalidRefreshToken) { Parent.IsExpanded = false; ParentTasExplorer.AuthenticationRequired = true; } else { _dialogService.DisplayErrorDialog(_getSpacesFailureMsg, spacesResponse.Explanation); } return(newSpacesList); }
private async void Execute(object sender, EventArgs e) { try { // Ensure project file access happens on the main thread await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var dte = (DTE2)await _package.GetServiceAsync(typeof(DTE)); Assumes.Present(dte); var activeProjects = (Array)dte.ActiveSolutionProjects; foreach (Project proj in activeProjects) { string projectDirectory = Path.GetDirectoryName(proj.FullName); string tfm = proj.Properties.Item("TargetFrameworkMoniker").Value.ToString(); if (tfm.StartsWith(".NETFramework") && !File.Exists(Path.Combine(projectDirectory, "Web.config"))) { string msg = $"This project appears to target .NET Framework; pushing it to Tanzu Application Service requires a 'Web.config' file at it's base directory, but none was found in {projectDirectory}"; _dialogService.DisplayErrorDialog("Unable to push to Tanzu Application Service", msg); } else { var viewModel = new DeploymentDialogViewModel(_services, proj.Name, projectDirectory, tfm); var view = new DeploymentDialogView(viewModel, new ThemeService()); view.ShowDialog(); // * Actions to take after modal closes: if (viewModel.DeploymentInProgress) // don't open tool window if modal was closed via "X" button { viewModel.OutputView.Show(); } } } } catch (Exception ex) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); _dialogService.DisplayErrorDialog("Unable to push to Tanzu Application Service", ex.Message); } }
public async Task DeleteApp(object window = null) { try { var deleteResult = await CloudFoundryService.DeleteAppAsync(CfApp, removeRoutes : DeleteRoutes); if (!deleteResult.Succeeded) { Logger.Error(_deleteAppErrorMsg + " {AppName}. {DeleteResult}", CfApp.AppName, deleteResult.ToString()); _errorDialogService.DisplayErrorDialog($"{_deleteAppErrorMsg} {CfApp.AppName}.", deleteResult.Explanation); } } catch (Exception ex) { Logger.Error(_deleteAppErrorMsg + " {AppName}. {AppDeletionException}", CfApp.AppName, ex.Message); _errorDialogService.DisplayErrorDialog($"{_deleteAppErrorMsg} {CfApp.AppName}.", $"Something unexpected happened while deleting {CfApp.AppName}"); } CfApp = null; DialogService.CloseDialog(window, true); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); var logFilePath = _fileService.PathToLogsFile; var tmpFilePath = GenerateTmpFileName(logFilePath); var alreadyOpen = Dte.ItemOperations.IsFileOpen(tmpFilePath); if (alreadyOpen) { var doc = Dte.Documents.Item(tmpFilePath); var win = doc.ActiveWindow; doc.Activate(); } else { try { CloneFile(logFilePath, tmpFilePath); } catch (Exception ex) { _logger.Error($"An error occurred in OpenLogsCommand while trying to generate a tmp log file to display. {ex.Message}"); _dialogService.DisplayErrorDialog("Unable to open log file.", ex.Message); } if (tmpFilePath != null) { Window logsWindow = Dte.ItemOperations.OpenFile(tmpFilePath); logsWindow.Document.ReadOnly = true; WindowEvents windowEvents = Dte.Events.get_WindowEvents(logsWindow); windowEvents.WindowClosing += OnWindowClosing; void OnWindowClosing(Window window) { try { RemoveTmpLogFile(tmpFilePath); } catch (Exception ex) { string errorMsg = $"Unable to delete tmp log file '${tmpFilePath}'.{Environment.NewLine}{ex.Message}"; _logger.Error(errorMsg); } } } } }