public void DeleteSessionGroup() { var rtSessionGroup = m_context.RTSessionGroupSet.Where(g => g.GroupUniqueId == m_sessionGroupUniqueId).FirstOrDefault(); if (null == rtSessionGroup) { return; } switch (rtSessionGroup.State) { case (int)BusinessModelManager.SessionStateEnum.Completed: case (int)BusinessModelManager.SessionStateEnum.OneTimeCompleted: StartDeletion(rtSessionGroup); break; case (int)BusinessModelManager.SessionStateEnum.MarkedForDeletion: break; default: try { var pipeProxy = new MigrationServiceClient(); if (!pipeProxy.GetRunningSessionGroups().Contains(m_sessionGroupUniqueId)) { StartDeletion(rtSessionGroup); } else { throw new SessionGroupDeletionException( MigrationToolkitResources.ErrorDeletingActiveSessionGroup, m_sessionGroupUniqueId.ToString()); } } catch (MigrationServiceEndpointNotFoundException) { StartDeletion(rtSessionGroup); } break; } }
/// <summary>Snippet for BatchMigrateResourcesAsync</summary> public async Task BatchMigrateResourcesRequestObjectAsync() { // Snippet: BatchMigrateResourcesAsync(BatchMigrateResourcesRequest, CallSettings) // Additional: BatchMigrateResourcesAsync(BatchMigrateResourcesRequest, CancellationToken) // Create client MigrationServiceClient migrationServiceClient = await MigrationServiceClient.CreateAsync(); // Initialize request argument(s) BatchMigrateResourcesRequest request = new BatchMigrateResourcesRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), MigrateResourceRequests = { new MigrateResourceRequest(), }, }; // Make the request Operation <BatchMigrateResourcesResponse, BatchMigrateResourcesOperationMetadata> response = await migrationServiceClient.BatchMigrateResourcesAsync(request); // Poll until the returned long-running operation is complete Operation <BatchMigrateResourcesResponse, BatchMigrateResourcesOperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result BatchMigrateResourcesResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <BatchMigrateResourcesResponse, BatchMigrateResourcesOperationMetadata> retrievedResponse = await migrationServiceClient.PollOnceBatchMigrateResourcesAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result BatchMigrateResourcesResponse retrievedResult = retrievedResponse.Result; } // End snippet }