/// <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); } }
/// <summary> /// Creates a new step instance. This method will also create the necessary view and conect both /// objects together. /// </summary> public FlexStepContent( IPublishDialog publishDialog, IGaeDataSource dataSource = null, Func <Task <bool> > setAppRegionAsyncFunc = null) : this() { ViewModel = new FlexStepViewModel( dataSource, setAppRegionAsyncFunc, publishDialog); }
/// <summary> /// Creates a new step instance. This method will also create the necessary view and conect both /// objects together. /// </summary> internal static FlexStepViewModel CreateStep(IGaeDataSource dataSource = null, IApiManager apiManager = null) { var content = new FlexStepContent(); var viewModel = new FlexStepViewModel(content, dataSource: dataSource, apiManager: apiManager); content.DataContext = viewModel; return(viewModel); }
private FlexStepViewModel(FlexStepContent content, IGaeDataSource dataSource = null, IApiManager apiManager = null) : base(apiManager) { _content = content; _dataSource = dataSource; EnableApiCommand = new ProtectedAsyncCommand(OnEnableApiCommandAsync); SetAppRegionCommand = new ProtectedAsyncCommand(OnSetAppRegionCommandAsync); }
/// <summary> /// Constructor used for testing. /// </summary> internal AppEngineManagementViewModel(ICloseable owner, string projectId, IGaeDataSource dataSource) { _owner = owner; _dataSource = dataSource; Locations = new AsyncProperty <IEnumerable <string> >(ListAllLocationsAsync(), s_loadingPlaceholder); SelectedLocation = s_loadingPlaceholder.First(); ActionCommand = new ProtectedCommand(OnActionCommand); ProjectId = projectId; }
/// <summary> /// Creates a new step instance. This method will also create the necessary view and conect both /// objects together. /// </summary> public FlexStepContent( IPublishDialog publishDialog, IGaeDataSource dataSource = null, IApiManager apiManager = null, Func <Project> pickProjectPrompt = null, Func <Task <bool> > setAppRegionAsyncFunc = null) : this() { ViewModel = new FlexStepViewModel( dataSource, apiManager, pickProjectPrompt, setAppRegionAsyncFunc, publishDialog); }
/// <summary> /// Deletes 'this' service. /// </summary> private async Task DeleteServiceAsync() { IsLoading = true; Children.Clear(); UpdateContextMenu(); Caption = String.Format(Resources.CloudExplorerGaeServiceDeleteMessage, Service.Id); IGaeDataSource datasource = _owner.DataSource; try { await datasource.DeleteServiceAsync(Service.Id); EventsReporterWrapper.ReportEvent(GaeServiceDeletedEvent.Create(CommandStatus.Success)); } catch (Exception ex) when(ex is DataSourceException || ex is TimeoutException || ex is OperationCanceledException) { EventsReporterWrapper.ReportEvent(GaeServiceDeletedEvent.Create(CommandStatus.Failure)); IsError = true; if (ex is DataSourceException) { Caption = Resources.CloudExplorerGaeDeleteServiceErrorMessage; } else if (ex is TimeoutException) { Caption = Resources.CloudExploreOperationTimeoutMessage; } else if (ex is OperationCanceledException) { Caption = Resources.CloudExploreOperationCanceledMessage; } } finally { IsLoading = false; if (!IsError) { // Remove the deleted child. _owner.Children.Remove(this); } } }
/// <summary> /// Update the serving status of the version. /// </summary> /// <param name="status">The serving status to update the version to.</param> /// <param name="statusMessage">The message to display while updating the status</param> private async Task UpdateServingStatusAsync(string status, string statusMessage) { IsLoading = true; Children.Clear(); UpdateMenu(); Caption = statusMessage; IGaeDataSource dataSource = _owner.DataSource; try { await dataSource.UpdateVersionServingStatus(status, _service.Id, Version.Id); EventsReporterWrapper.ReportEvent( GaeVersionServingStatusUpdatedEvent.Create(CommandStatus.Success, statusMessage)); await _owner.InvalidateServiceAsync(_service.Id); } catch (Exception ex) when(ex is DataSourceException || ex is TimeoutException || ex is OperationCanceledException) { EventsReporterWrapper.ReportEvent( GaeVersionServingStatusUpdatedEvent.Create(CommandStatus.Failure, statusMessage)); IsLoading = false; IsError = true; switch (ex) { case DataSourceException _: Caption = Resources.CloudExplorerGaeUpdateServingStatusErrorMessage; break; case TimeoutException _: Caption = Resources.CloudExploreOperationTimeoutMessage; break; case OperationCanceledException _: Caption = Resources.CloudExploreOperationCanceledMessage; break; } } }