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 HandleRequestToCopyText(EnvironmentType environment, bool copySuccesses) { string entriesList = GetSuccessListForEnvironment(environment, copySuccesses); string success = copySuccesses ? "Successful" : "Failed"; string action = IsDeleting ? "deleted" : "created"; string caption = $"{success} {action} Subscription value(s) for {environment.ShortName()}"; string clipboardText = $"{caption}{Environment.NewLine}{entriesList}"; Clipboard.Clear(); Clipboard.SetText(clipboardText); }
private void UpdateUiWithPrefixForEnvironment(EnvironmentType environment) { switch (environment) { case EnvironmentType.Development: txtPrefixDev.Text = environment.ShortName(); break; case EnvironmentType.UserAcceptanceTesting: txtPrefixUAT.Text = environment.ShortName(); break; case EnvironmentType.Staging: txtPrefixSTG.Text = environment.ShortName(); break; case EnvironmentType.Production: txtPrefixPRD.Text = environment.ShortName(); break; } }
/// <summary> /// Get the name of the Key, from the app.config file, required for connecting to an Azure Service Bus. /// </summary><remarks> /// This is a required parameter for creating the ConnectionString. /// </remarks> public static string AzureServiceKeyName(this EnvironmentType environment) { string configKeyName = $"ASB_KeyName_{environment.ShortName()}"; return(ConfigurationManager.AppSettings[configKeyName]); }
/// <summary> /// The name of the Message Queue for the specified Environment Type. /// </summary> public static string MessageQueueName(this EnvironmentType environment) => $"GetFeesRequests.{environment.ShortName()}";
/// <summary> /// The name of the Topic for the specified Environment Type. /// </summary> public static string AzureTopicName(this EnvironmentType environment) => $"GetFees.{environment.ShortName()}";
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; } }