/// <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 = root.DataSource.Value; try { Task <Operation> operationTask = datasource.UpdateVersionServingStatus(status, _owner.Service.Id, version.Id); Func <Operation, Task <Operation> > fetch = (o) => datasource.GetOperationAsync(o.GetOperationId()); Predicate <Operation> stopPolling = (o) => o.Done ?? false; Operation operation = await Polling <Operation> .Poll(await operationTask, fetch, stopPolling); if (operation.Error != null) { throw new DataSourceException(operation.Error.Message); } version = await datasource.GetVersionAsync(_owner.Service.Id, version.Id); EventsReporterWrapper.ReportEvent( GaeVersionServingStatusUpdatedEvent.Create(CommandStatus.Success, statusMessage)); } catch (Exception ex) when(ex is DataSourceException || ex is TimeoutException || ex is OperationCanceledException) { EventsReporterWrapper.ReportEvent( GaeVersionServingStatusUpdatedEvent.Create(CommandStatus.Failure, statusMessage)); 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; } } finally { IsLoading = false; // Re-initialize the instance as it will have a new version. if (!IsError) { Initialize(); } else { Caption = GetCaption(); } } }
/// <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; } } }
/// <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; } } }