private void btnAction_Click(object sender, EventArgs e) { try { if (serviceBusHelper == null) { return; } if (btnAction.Text == DeleteText) { var deleteForm = new DeleteForm(topic.Path, TopicEntity.ToLower()); if (deleteForm.ShowDialog() == DialogResult.OK) { serviceBusHelper.DeleteTopic(topic); } } else { if (string.IsNullOrEmpty(txtPath.Text)) { writeToLog(PathCannotBeNull); return; } var topicDescription = new TopicDescription(txtPath.Text); if (!string.IsNullOrEmpty(txtMaxTopicSizeInMegabytes.Text)) { long value; if (long.TryParse(txtMaxTopicSizeInMegabytes.Text, out value)) { topicDescription.MaxSizeInMegabytes = value; } else { writeToLog(MaxTopicSizeInBytesMustBeANumber); return; } } var days = 0; var hours = 0; var minutes = 0; var seconds = 0; var milliseconds = 0; if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveDays.Text) || !string.IsNullOrEmpty(txtDefaultMessageTimeToLiveHours.Text) || !string.IsNullOrEmpty(txtDefaultMessageTimeToLiveMinutes.Text) || !string.IsNullOrEmpty(txtDefaultMessageTimeToLiveSeconds.Text) || !string.IsNullOrEmpty(txtDefaultMessageTimeToLiveMilliseconds.Text)) { if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveDays.Text)) { if (!int.TryParse(txtDefaultMessageTimeToLiveDays.Text, out days)) { writeToLog(DefaultMessageTimeToLiveDaysMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveHours.Text)) { if (!int.TryParse(txtDefaultMessageTimeToLiveHours.Text, out hours)) { writeToLog(DefaultMessageTimeToLiveHoursMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveMinutes.Text)) { if (!int.TryParse(txtDefaultMessageTimeToLiveMinutes.Text, out minutes)) { writeToLog(DefaultMessageTimeToLiveMinutesMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveSeconds.Text)) { if (!int.TryParse(txtDefaultMessageTimeToLiveSeconds.Text, out seconds)) { writeToLog(DefaultMessageTimeToLiveSecondsMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveMilliseconds.Text)) { if (!int.TryParse(txtDefaultMessageTimeToLiveMilliseconds.Text, out milliseconds)) { writeToLog(DefaultMessageTimeToLiveMillisecondsMustBeANumber); return; } } topicDescription.DefaultMessageTimeToLive = new TimeSpan(days, hours, minutes, seconds, milliseconds); } days = 0; hours = 0; minutes = 0; seconds = 0; milliseconds = 0; if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowDays.Text) || !string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowHours.Text) || !string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowMinutes.Text) || !string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowSeconds.Text) || !string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowMilliseconds.Text)) { if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowDays.Text)) { if (!int.TryParse(txtDuplicateDetectionHistoryTimeWindowDays.Text, out days)) { writeToLog(DuplicateDetectionHistoryTimeWindowDaysMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowHours.Text)) { if (!int.TryParse(txtDuplicateDetectionHistoryTimeWindowHours.Text, out hours)) { writeToLog(DuplicateDetectionHistoryTimeWindowHoursMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowMinutes.Text)) { if (!int.TryParse(txtDuplicateDetectionHistoryTimeWindowMinutes.Text, out minutes)) { writeToLog(DuplicateDetectionHistoryTimeWindowMinutesMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowSeconds.Text)) { if (!int.TryParse(txtDuplicateDetectionHistoryTimeWindowSeconds.Text, out seconds)) { writeToLog(DuplicateDetectionHistoryTimeWindowSecondsMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowMilliseconds.Text)) { if (!int.TryParse(txtDuplicateDetectionHistoryTimeWindowMilliseconds.Text, out milliseconds)) { writeToLog(DuplicateDetectionHistoryTimeWindowMillisecondsMustBeANumber); return; } } topicDescription.DuplicateDetectionHistoryTimeWindow = new TimeSpan(days, hours, minutes, seconds, milliseconds); } topicDescription.EnableBatchedOperations = checkedListBox.GetItemChecked(EnableBatchedOperationsIndex); topicDescription.RequiresDuplicateDetection = checkedListBox.GetItemChecked(RequiresDuplicateDetectionIndex); topic = serviceBusHelper.CreateTopic(topicDescription); InitializeData(); } } catch (Exception ex) { HandleException(ex); } }
private void btnCreateDelete_Click(object sender, EventArgs e) { try { if (serviceBusHelper == null) { return; } if (btnCreateDelete.Text == DeleteText) { var deleteForm = new DeleteForm(topicDescription.Path, TopicEntity.ToLower()); if (deleteForm.ShowDialog() == DialogResult.OK) { serviceBusHelper.DeleteTopic(topicDescription); } } else { if (string.IsNullOrEmpty(txtPath.Text)) { writeToLog(PathCannotBeNull); return; } var description = new TopicDescription(txtPath.Text) { MaxSizeInMegabytes = serviceBusHelper.IsCloudNamespace ? trackBarMaxTopicSize.Value * 1024 : trackBarMaxTopicSize.Value == trackBarMaxTopicSize.Maximum ? SeviceBusForWindowsServerMaxTopicSize : trackBarMaxTopicSize.Value * 1024, UserMetadata = txtUserMetadata.Text }; var days = 0; var hours = 0; var minutes = 0; var seconds = 0; var milliseconds = 0; if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveDays.Text) || !string.IsNullOrEmpty(txtDefaultMessageTimeToLiveHours.Text) || !string.IsNullOrEmpty(txtDefaultMessageTimeToLiveMinutes.Text) || !string.IsNullOrEmpty(txtDefaultMessageTimeToLiveSeconds.Text) || !string.IsNullOrEmpty(txtDefaultMessageTimeToLiveMilliseconds.Text)) { if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveDays.Text)) { if (!int.TryParse(txtDefaultMessageTimeToLiveDays.Text, out days)) { writeToLog(DefaultMessageTimeToLiveDaysMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveHours.Text)) { if (!int.TryParse(txtDefaultMessageTimeToLiveHours.Text, out hours)) { writeToLog(DefaultMessageTimeToLiveHoursMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveMinutes.Text)) { if (!int.TryParse(txtDefaultMessageTimeToLiveMinutes.Text, out minutes)) { writeToLog(DefaultMessageTimeToLiveMinutesMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveSeconds.Text)) { if (!int.TryParse(txtDefaultMessageTimeToLiveSeconds.Text, out seconds)) { writeToLog(DefaultMessageTimeToLiveSecondsMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDefaultMessageTimeToLiveMilliseconds.Text)) { if (!int.TryParse(txtDefaultMessageTimeToLiveMilliseconds.Text, out milliseconds)) { writeToLog(DefaultMessageTimeToLiveMillisecondsMustBeANumber); return; } } description.DefaultMessageTimeToLive = new TimeSpan(days, hours, minutes, seconds, milliseconds); } days = 0; hours = 0; minutes = 0; seconds = 0; milliseconds = 0; if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowDays.Text) || !string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowHours.Text) || !string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowMinutes.Text) || !string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowSeconds.Text) || !string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowMilliseconds.Text)) { if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowDays.Text)) { if (!int.TryParse(txtDuplicateDetectionHistoryTimeWindowDays.Text, out days)) { writeToLog(DuplicateDetectionHistoryTimeWindowDaysMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowHours.Text)) { if (!int.TryParse(txtDuplicateDetectionHistoryTimeWindowHours.Text, out hours)) { writeToLog(DuplicateDetectionHistoryTimeWindowHoursMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowMinutes.Text)) { if (!int.TryParse(txtDuplicateDetectionHistoryTimeWindowMinutes.Text, out minutes)) { writeToLog(DuplicateDetectionHistoryTimeWindowMinutesMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowSeconds.Text)) { if (!int.TryParse(txtDuplicateDetectionHistoryTimeWindowSeconds.Text, out seconds)) { writeToLog(DuplicateDetectionHistoryTimeWindowSecondsMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtDuplicateDetectionHistoryTimeWindowMilliseconds.Text)) { if (!int.TryParse(txtDuplicateDetectionHistoryTimeWindowMilliseconds.Text, out milliseconds)) { writeToLog(DuplicateDetectionHistoryTimeWindowMillisecondsMustBeANumber); return; } } description.DuplicateDetectionHistoryTimeWindow = new TimeSpan(days, hours, minutes, seconds, milliseconds); } description.EnableBatchedOperations = checkedListBox.GetItemChecked(EnableBatchedOperationsIndex); description.EnableFilteringMessagesBeforePublishing = checkedListBox.GetItemChecked(EnableFilteringMessagesBeforePublishingIndex); description.RequiresDuplicateDetection = checkedListBox.GetItemChecked(RequiresDuplicateDetectionIndex); description.SupportOrdering = checkedListBox.GetItemChecked(SupportOrderingIndex); if (!serviceBusHelper.IsCloudNamespace) { description.IsAnonymousAccessible = checkedListBox.GetItemChecked(IsAnonymousAccessibleIndex); } topicDescription = serviceBusHelper.CreateTopic(description); InitializeData(); } } catch (Exception ex) { HandleException(ex); } }