private void HandleCreateServices_Click(EnvironmentType environment) { if (IsWorking) { return; } IsWorking = true; IsDeleting = false; Cursor = Cursors.WaitCursor; InitializeUi(environment); try { AzureServicesHelper azureServices = new AzureServicesHelper(environment); var queueExists = azureServices.CreateQueue(); var topicExists = azureServices.CreateTopic(); ShowQueueCreationSuccess(queueExists, environment); ShowTopicCreationSuccess(topicExists, environment); Application.DoEvents(); if (topicExists) { foreach (string subscriptionName in azureServices.SubscriptionNames) { bool subscriptionExists = azureServices.CreateSubscription(subscriptionName); UpdateUiForSubscriptionSuccess(subscriptionExists, subscriptionName, environment); Application.DoEvents(); } } else { foreach (string subscriptionName in azureServices.SubscriptionNames) { UpdateUiForSubscriptionSuccess(false, subscriptionName, environment); } } } catch (Exception ex) { string caption = $"Create Services for {environment.ShortName()}"; string message = $"{ex.Message}{Environment.NewLine}{new String('*', 80)}{ex.StackTrace}"; MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { IsWorking = false; UpdateUiWithActionMessage(environment); Cursor = Cursors.Default; } }
private void HandleDeleteServices_Click(EnvironmentType environment) { if (IsWorking) { return; } string prompt = "Are you certain you want to DELETE all of the services on this Azure Service Bus?"; string caption = $"Delete Services for {environment.ShortName()}"; if (MessageBox.Show(prompt, caption, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) != DialogResult.Yes) { return; } IsWorking = true; IsDeleting = true; bool topicDeleted = false; Cursor = Cursors.WaitCursor; InitializeUi(environment); try { AzureServicesHelper azureServices = new AzureServicesHelper(environment); var queueDeleted = azureServices.DeleteQueue(); topicDeleted = !azureServices.TopicExists; ShowQueueCreationSuccess(queueDeleted, environment); Application.DoEvents(); if (!topicDeleted) { foreach (string subscriptionName in azureServices.SubscriptionNames) { bool subscriptionDeleted = azureServices.DeleteSubscription(subscriptionName); UpdateUiForSubscriptionSuccess(subscriptionDeleted, subscriptionName, environment); Application.DoEvents(); } topicDeleted = azureServices.DeleteTopic(); } else { foreach (string subscriptionName in azureServices.SubscriptionNames) { UpdateUiForSubscriptionSuccess(true, subscriptionName, environment); } } } catch (Exception ex) { string message = $"{ex.Message}{Environment.NewLine}{new String('*', 80)}{ex.StackTrace}"; MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { ShowTopicCreationSuccess(topicDeleted, environment); IsWorking = false; UpdateUiWithActionMessage(environment); Cursor = Cursors.Default; } }