private async Task InitializeDialogState() { try { // Show the loading message while the project is being validated and the // data being loaded. LoadingProject = true; Task <bool> validateTask = ValidateGcpProject(); PublishDialog.TrackTask(validateTask); if (await validateTask) { Task <IEnumerable <Instance> > instancesTask = GetAllWindowsInstancesAsync(); PublishDialog.TrackTask(instancesTask); Instances = await instancesTask; } } catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex)) { CanPublish = false; GeneralError = true; } finally { LoadingProject = false; } }
protected void Publish([NotNull] DatabaseUri databaseUri) { Debug.ArgumentNotNull(databaseUri, nameof(databaseUri)); Execute(databaseUri); if (AppHost.Settings.Options.HidePublishingDialog) { return; } var d = new PublishDialog { Caption = Resources.PublishCommand_Execute_Publishing, PublishingText = PublishingText }; if (AppHost.Shell.ShowDialog(d) != true) { return; } if (!AppHost.Settings.Options.ShowJobViewer) { return; } AppHost.Windows.OpenJobViewer(databaseUri.Site); }
private async Task OnSetAppRegionCommandAsync() { if (await GaeUtils.SetAppRegionAsync(CredentialsStore.Default.CurrentProjectId, CurrentDataSource)) { PublishDialog.TrackTask(ValidateGcpProjectState()); } }
public override void Execute(object parameter) { var context = parameter as IItemSelectionContext; if (context == null) { return; } AppHost.Statusbar.SetText(PublishingText); IItem lastItem = null; context.Items.First().ItemUri.Site.DataService.PublishItem(context.Items.Select(i => i.ItemUri), Deep, CompareRevisisions); foreach (var item in context.Items) { Notifications.RaisePublishingItem(this, item.ItemUri, Deep, CompareRevisisions); lastItem = item; } if (lastItem == null || AppHost.Settings.Options.HidePublishingDialog) { return; } var d = new PublishDialog { Caption = Resources.PublishItemCommand_Execute_Publishing, PublishingText = PublishingText }; if (AppHost.Shell.ShowDialog(d) != true) { return; } if (AppHost.Settings.Options.ShowJobViewer) { AppHost.Windows.OpenJobViewer(lastItem.ItemUri.Site); } }
private async Task InitializeDialogState() { try { // Mark that the project is being loaded and verified. LoadingProject = true; if (string.IsNullOrEmpty(DeploymentName)) { DeploymentName = PublishDialog.Project.Name.ToLower(); } if (string.IsNullOrEmpty(DeploymentVersion)) { DeploymentVersion = GcpPublishStepsUtils.GetDefaultVersion(); } Task <bool> validateTask = ValidateGcpProjectState(); PublishDialog.TrackTask(validateTask); if (await validateTask) { Task <IEnumerable <Cluster> > clustersTask = GetAllClustersAsync(); PublishDialog.TrackTask(clustersTask); Clusters = await clustersTask; } } catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex)) { CanPublish = false; GeneralError = true; } finally { LoadingProject = false; } }
private void InitializeDialogState() { LoadingProjectTask = ValidateGcpProjectState(); PublishDialog.TrackTask(LoadingProjectTask); }
public override async void Publish() { if (!ValidateInput()) { Debug.WriteLine("Invalid input cancelled the operation."); return; } IParsedProject project = PublishDialog.Project; try { ShellUtils.SaveAllFiles(); var verifyGcloudTask = GCloudWrapperUtils.VerifyGCloudDependencies(); PublishDialog.TrackTask(verifyGcloudTask); if (!await verifyGcloudTask) { Debug.WriteLine("Gcloud dependencies not met, aborting publish operation."); return; } var context = new GCloudContext { CredentialsPath = CredentialsStore.Default.CurrentAccountPath, ProjectId = CredentialsStore.Default.CurrentProjectId, AppName = GoogleCloudExtensionPackage.ApplicationName, AppVersion = GoogleCloudExtensionPackage.ApplicationVersion, }; var options = new AppEngineFlexDeployment.DeploymentOptions { Version = Version, Promote = Promote, Context = context }; GcpOutputWindow.Activate(); GcpOutputWindow.Clear(); GcpOutputWindow.OutputLine(string.Format(Resources.FlexPublishStepStartMessage, project.Name)); PublishDialog.FinishFlow(); TimeSpan deploymentDuration; AppEngineFlexDeploymentResult result; using (StatusbarHelper.Freeze()) using (StatusbarHelper.ShowDeployAnimation()) using (ProgressBarHelper progress = StatusbarHelper.ShowProgressBar(Resources.FlexPublishProgressMessage)) using (ShellUtils.SetShellUIBusy()) { DateTime startDeploymentTime = DateTime.Now; result = await AppEngineFlexDeployment.PublishProjectAsync( project, options, progress, VsVersionUtils.ToolsPathProvider, GcpOutputWindow.OutputLine); deploymentDuration = DateTime.Now - startDeploymentTime; } if (result != null) { GcpOutputWindow.OutputLine(string.Format(Resources.FlexPublishSuccessMessage, project.Name)); StatusbarHelper.SetText(Resources.PublishSuccessStatusMessage); string url = result.GetDeploymentUrl(); GcpOutputWindow.OutputLine(string.Format(Resources.PublishUrlMessage, url)); if (OpenWebsite) { Process.Start(url); } EventsReporterWrapper.ReportEvent(GaeDeployedEvent.Create(CommandStatus.Success, deploymentDuration)); } else { GcpOutputWindow.OutputLine(string.Format(Resources.FlexPublishFailedMessage, project.Name)); StatusbarHelper.SetText(Resources.PublishFailureStatusMessage); EventsReporterWrapper.ReportEvent(GaeDeployedEvent.Create(CommandStatus.Failure)); } } catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex)) { GcpOutputWindow.OutputLine(string.Format(Resources.FlexPublishFailedMessage, project.Name)); StatusbarHelper.SetText(Resources.PublishFailureStatusMessage); EventsReporterWrapper.ReportEvent(GaeDeployedEvent.Create(CommandStatus.Failure)); } }
private async Task OnEnableApiCommandAsync() { await CurrentApiManager.EnableServicesAsync(s_requiredApis); PublishDialog.TrackTask(ValidateGcpProjectState()); }
private void OnGkeChoiceCommand() { var nextStep = GkeStepViewModel.CreateStep(); PublishDialog.NavigateToStep(nextStep); }
private void OnAppEngineChoiceCommand() { var nextStep = FlexStepViewModel.CreateStep(); PublishDialog.NavigateToStep(nextStep); }
public override async void Publish() { IParsedProject project = PublishDialog.Project; try { ShellUtils.SaveAllFiles(); GcpOutputWindow.Activate(); GcpOutputWindow.Clear(); GcpOutputWindow.OutputLine(string.Format(Resources.GcePublishStepStartMessage, project.Name)); PublishDialog.FinishFlow(); string progressBarTitle = string.Format(Resources.GcePublishProgressMessage, SelectedInstance.Name); TimeSpan deploymentDuration; bool result; using (StatusbarHelper.Freeze()) using (StatusbarHelper.ShowDeployAnimation()) using (ShellUtils.SetShellUIBusy()) using (ProgressBarHelper progress = StatusbarHelper.ShowProgressBar(progressBarTitle)) { DateTime startDeploymentTime = DateTime.Now; result = await WindowsVmDeployment.PublishProjectAsync( project, SelectedInstance, SelectedCredentials, progress, VsVersionUtils.ToolsPathProvider, GcpOutputWindow.OutputLine); deploymentDuration = DateTime.Now - startDeploymentTime; } if (result) { GcpOutputWindow.OutputLine(string.Format(Resources.GcePublishSuccessMessage, project.Name, SelectedInstance.Name)); StatusbarHelper.SetText(Resources.PublishSuccessStatusMessage); string url = SelectedInstance.GetDestinationAppUri(); GcpOutputWindow.OutputLine(string.Format(Resources.PublishUrlMessage, url)); if (OpenWebsite) { Process.Start(url); } EventsReporterWrapper.ReportEvent(GceDeployedEvent.Create(CommandStatus.Success, deploymentDuration)); if (LaunchRemoteDebugger) { AttachDebuggerDialog.AttachDebuggerWindow.PromptUser(SelectedInstance); } } else { GcpOutputWindow.OutputLine(string.Format(Resources.GcePublishFailedMessage, project.Name)); StatusbarHelper.SetText(Resources.PublishFailureStatusMessage); EventsReporterWrapper.ReportEvent(GceDeployedEvent.Create(CommandStatus.Failure)); } } catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex)) { GcpOutputWindow.OutputLine(string.Format(Resources.GcePublishFailedMessage, project.Name)); StatusbarHelper.SetText(Resources.PublishFailureStatusMessage); EventsReporterWrapper.ReportEvent(GceDeployedEvent.Create(CommandStatus.Failure)); } }
/// <summary> /// Start the publish operation. /// </summary> public override async void Publish() { if (!ValidateInput()) { Debug.WriteLine("Invalid input cancelled the operation."); return; } var project = PublishDialog.Project; try { ShellUtils.SaveAllFiles(); var verifyGCloudTask = GCloudWrapperUtils.VerifyGCloudDependencies(GCloudComponent.Kubectl); PublishDialog.TrackTask(verifyGCloudTask); if (!await verifyGCloudTask) { Debug.WriteLine("Aborting deployment, no kubectl was found."); return; } var gcloudContext = new GCloudContext { CredentialsPath = CredentialsStore.Default.CurrentAccountPath, ProjectId = CredentialsStore.Default.CurrentProjectId, AppName = GoogleCloudExtensionPackage.ApplicationName, AppVersion = GoogleCloudExtensionPackage.ApplicationVersion, }; var kubectlContextTask = GCloudWrapper.GetKubectlContextForClusterAsync( cluster: SelectedCluster.Name, zone: SelectedCluster.Zone, context: gcloudContext); PublishDialog.TrackTask(kubectlContextTask); using (var kubectlContext = await kubectlContextTask) { var deploymentExistsTask = KubectlWrapper.DeploymentExistsAsync(DeploymentName, kubectlContext); PublishDialog.TrackTask(deploymentExistsTask); if (await deploymentExistsTask) { if (!UserPromptUtils.ActionPrompt( String.Format(Resources.GkePublishDeploymentAlreadyExistsMessage, DeploymentName), Resources.GkePublishDeploymentAlreadyExistsTitle, actionCaption: Resources.UiUpdateButtonCaption)) { return; } } var options = new GkeDeployment.DeploymentOptions { Cluster = SelectedCluster.Name, Zone = SelectedCluster.Zone, DeploymentName = DeploymentName, DeploymentVersion = DeploymentVersion, ExposeService = ExposeService, ExposePublicService = ExposePublicService, GCloudContext = gcloudContext, KubectlContext = kubectlContext, Replicas = int.Parse(Replicas), WaitingForServiceIpCallback = () => GcpOutputWindow.OutputLine(Resources.GkePublishWaitingForServiceIpMessage) }; GcpOutputWindow.Activate(); GcpOutputWindow.Clear(); GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishDeployingToGkeMessage, project.Name)); PublishDialog.FinishFlow(); TimeSpan deploymentDuration; GkeDeploymentResult result; using (StatusbarHelper.Freeze()) using (StatusbarHelper.ShowDeployAnimation()) using (var progress = StatusbarHelper.ShowProgressBar(Resources.GkePublishDeploymentStatusMessage)) using (ShellUtils.SetShellUIBusy()) { var deploymentStartTime = DateTime.Now; result = await GkeDeployment.PublishProjectAsync( project, options, progress, VsVersionUtils.ToolsPathProvider, GcpOutputWindow.OutputLine); deploymentDuration = DateTime.Now - deploymentStartTime; } if (result != null) { OutputResultData(result, options); StatusbarHelper.SetText(Resources.PublishSuccessStatusMessage); if (OpenWebsite && result.ServiceExposed && result.PublicServiceIpAddress != null) { Process.Start($"http://{result.PublicServiceIpAddress}"); } EventsReporterWrapper.ReportEvent(GkeDeployedEvent.Create(CommandStatus.Success, deploymentDuration)); } else { GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishDeploymentFailureMessage, project.Name)); StatusbarHelper.SetText(Resources.PublishFailureStatusMessage); EventsReporterWrapper.ReportEvent(GkeDeployedEvent.Create(CommandStatus.Failure)); } } } catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex)) { GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishDeploymentFailureMessage, project.Name)); StatusbarHelper.SetText(Resources.PublishFailureStatusMessage); PublishDialog.FinishFlow(); EventsReporterWrapper.ReportEvent(GkeDeployedEvent.Create(CommandStatus.Failure)); } }
private void OnRefreshClustersListCommand() { Task <IEnumerable <Cluster> > refreshTask = GetAllClustersAsync(); PublishDialog.TrackTask(refreshTask); }