예제 #1
0
        /// <summary>
        /// Sets the app engine to the given project Id.
        /// </summary>
        public static async Task <bool> SetAppRegionAsync(string projectId, IGaeDataSource dataSource)
        {
            string selectedLocation = AppEngineManagementWindow.PromptUser(projectId);

            if (selectedLocation == null)
            {
                Debug.WriteLine("The user cancelled creating a new app.");
                return(false);
            }

            try
            {
                await ProgressDialogWindow.PromptUserAsync(
                    dataSource.CreateApplicationAsync(selectedLocation),
                    new ProgressDialogWindow.Options
                {
                    Title         = Resources.GaeUtilsSetAppEngineRegionProgressTitle,
                    Message       = Resources.GaeUtilsSetAppEngineRegionProgressMessage,
                    IsCancellable = false
                });

                return(true);
            }
            catch (DataSourceException ex)
            {
                UserPromptService.Default.ExceptionPrompt(ex);
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// This method will enable the list of services given.
        /// </summary>
        /// <param name="serviceNames">The list of services to enable.</param>
        /// <returns>A task that will be completed once the operation finishes.</returns>
        public async Task EnableServicesAsync(IEnumerable <string> serviceNames)
        {
            ServiceManagementDataSource dataSource = _dataSource.Value;

            if (dataSource == null)
            {
                return;
            }

            try
            {
                await ProgressDialogWindow.PromptUserAsync(
                    dataSource.EnableAllServicesAsync(serviceNames),
                    new ProgressDialogWindow.Options
                {
                    Title         = Resources.ApiManagerEnableServicesTitle,
                    Message       = Resources.ApiManagerEnableServicesProgressMessage,
                    IsCancellable = false
                });
            }
            catch (DataSourceException ex)
            {
                UserPromptService.Default.ErrorPrompt(
                    message: Resources.ApiManagerEnableServicesErrorMessage,
                    title: Resources.UiErrorCaption,
                    errorDetails: ex.Message);
            }
        }
예제 #3
0
        /// <summary>
        /// This method will check that all given services are enabled and if not will prompt the user to enable the
        /// necessary services.
        /// </summary>
        /// <param name="serviceNames">The services to check.</param>
        /// <param name="prompt">The prompt to use in the prompt dialog to ask the user for permission to enable the services.</param>
        /// <returns>A task that will be true if all services where enabled, false if the user cancelled or if the operation failed.</returns>
        public async Task <bool> EnsureAllServicesEnabledAsync(
            IEnumerable <string> serviceNames,
            string prompt)
        {
            ServiceManagementDataSource dataSource = _dataSource.Value;

            if (dataSource == null)
            {
                return(false);
            }

            try
            {
                // Check all services in parallel.
                IList <string> servicesToEnable = (await dataSource.CheckServicesStatusAsync(serviceNames))
                                                  .Where(x => !x.Enabled)
                                                  .Select(x => x.Name)
                                                  .ToList();
                if (servicesToEnable.Count == 0)
                {
                    Debug.WriteLine("All the services are already enabled.");
                    return(true);
                }

                // Need to enable the services, prompt the user.
                Debug.WriteLine($"Need to enable the services: {string.Join(",", servicesToEnable)}.");
                if (!UserPromptService.Default.ActionPrompt(
                        prompt: prompt,
                        title: Resources.ApiManagerEnableServicesTitle,
                        actionCaption: Resources.UiEnableButtonCaption))
                {
                    return(false);
                }

                // Enable all services in parallel.
                await ProgressDialogWindow.PromptUserAsync(
                    dataSource.EnableAllServicesAsync(servicesToEnable),
                    new ProgressDialogWindow.Options
                {
                    Title         = Resources.ApiManagerEnableServicesTitle,
                    Message       = Resources.ApiManagerEnableServicesProgressMessage,
                    IsCancellable = false
                });

                return(true);
            }
            catch (DataSourceException ex)
            {
                UserPromptService.Default.ErrorPrompt(
                    message: Resources.ApiManagerEnableServicesErrorMessage,
                    title: Resources.UiErrorCaption,
                    errorDetails: ex.Message);
                return(false);
            }
        }
        /// <summary>
        /// Open the source file, move to the source line and show tooltip.
        /// If git sha is present at the log entry, try to open the revision of the file.
        /// If the log item does not contain revision id,
        /// fallback to using the assembly version information.
        /// </summary>
        /// <param name="logItem">The log item to search for source file.</param>
        public static async Task NavigateToSourceLineCommandAsync(LogItem logItem)
        {
            await GoogleCloudExtensionPackage.Instance.JoinableTaskFactory.SwitchToMainThreadAsync();

            EnvDTE.Window window = null;
            try
            {
                if (logItem.Entry.Labels?.ContainsKey(SourceContextIdLabel) == true)
                {
                    string sha = logItem.Entry.Labels[SourceContextIdLabel];
                    if (!ValidateGitDependencyHelper.ValidateGitForWindowsInstalled())
                    {
                        return;
                    }
                    window = await ProgressDialogWindow.PromptUserAsync(
                        SearchGitRepoAndOpenFileAsync(sha, logItem.SourceFilePath),
                        s_gitOperationOption);
                }
                else
                {   // If the log item does not contain revision id,
                    // fallback to using assembly version information.
                    var project = FindOrOpenProject(logItem);
                    if (project == null)
                    {
                        Debug.WriteLine($"Failed to find project of {logItem.AssemblyName}");
                        return;
                    }

                    var locatedFilePath = project.FindSourceFile(logItem.SourceFilePath)?.FullName;
                    if (locatedFilePath != null)
                    {
                        window = ShellUtils.Default.Open(locatedFilePath);
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                FileItemNotFoundPrompt(ex.FilePath);
                return;
            }
            if (window == null)
            {
                FailedToOpenFilePrompt(logItem.SourceFilePath);
                return;
            }
            logItem.ShowToolTip(window);
        }
예제 #5
0
        private async Task OnAddCredentialsCommandAsync()
        {
            var request = AddWindowsCredentialWindow.PromptUser(_instance);

            if (request == null)
            {
                return;
            }

            WindowsInstanceCredentials credentials;

            if (request.GeneratePassword)
            {
                var resetCredentialsTask = CreateOrResetCredentialsAsync(request.User);
                credentials = await ProgressDialogWindow.PromptUserAsync(
                    resetCredentialsTask,
                    new ProgressDialogWindow.Options
                {
                    Title         = Resources.ResetPasswordProgressTitle,
                    Message       = String.Format(Resources.ResetPasswordProgressMessage, request.User),
                    IsCancellable = false
                });

                if (credentials != null)
                {
                    ShowPasswordWindow.PromptUser(
                        new ShowPasswordWindow.Options
                    {
                        Title    = String.Format(Resources.ShowPasswordWindowTitle, _instance.Name),
                        Message  = String.Format(Resources.ShowPasswordNewPasswordMessage, credentials.User),
                        Password = credentials.Password,
                    });
                }
            }
            else
            {
                credentials = new WindowsInstanceCredentials(request.User, request.Password);
            }

            if (credentials != null)
            {
                WindowsCredentialsStore.Default.AddCredentialsToInstance(_instance, credentials);
                CredentialsList = WindowsCredentialsStore.Default.GetCredentialsForInstance(_instance);

                EventsReporterWrapper.ReportEvent(AddWindowsCredentialEvent.Create());
            }
        }