/// <summary> /// Deletes 'this' service. /// </summary> private async void DeleteService() { IsLoading = true; Children.Clear(); UpdateContextMenu(); Caption = String.Format(Resources.CloudExplorerGaeServiceDeleteMessage, Service.Id); GaeDataSource datasource = _owner.DataSource; try { var operation = await datasource.DeleteServiceAsync(Service.Id); await datasource.AwaitOperationAsync(operation); 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 void UpdateServingStatus(string status, string statusMessage) { IsLoading = true; Children.Clear(); UpdateMenu(); Caption = statusMessage; GaeDataSource dataSource = _owner.DataSource; try { var operation = await dataSource.UpdateVersionServingStatus(status, _service.Id, _version.Id); await dataSource.AwaitOperationAsync(operation); EventsReporterWrapper.ReportEvent( GaeVersionServingStatusUpdatedEvent.Create(CommandStatus.Success, statusMessage)); _owner.InvalidateService(_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; if (ex is DataSourceException) { Caption = Resources.CloudExplorerGaeUpdateServingStatusErrorMessage; } else if (ex is TimeoutException) { Caption = Resources.CloudExploreOperationTimeoutMessage; } else if (ex is OperationCanceledException) { Caption = Resources.CloudExploreOperationCanceledMessage; } } }