/// <summary> /// Creates the queues which xml definition is contained in the collection passed as a parameter. /// </summary> /// <param name="serviceBusHelper">A ServiceBusHelper object.</param> /// <param name="queues">The IEnumerable<XElement/> collection containing the xml definition of the queues to create.</param> private static void CreateQueues(ServiceBusHelper serviceBusHelper, IEnumerable <XElement> queues) { try { if (serviceBusHelper == null || queues == null) { return; } var fullName = typeof(QueueDescription).FullName; if (string.IsNullOrEmpty(fullName) || !propertyCache.ContainsKey(fullName)) { return; } var propertyDictionary = propertyCache[fullName]; foreach (var queue in queues) { try { var propertyValue = new Dictionary <string, object>(); var properties = queue.Elements(); foreach (var property in properties) { var xmlReader = property.CreateReader(); GetPropertyValue(propertyDictionary, propertyValue, xmlReader); } if (propertyValue.ContainsKey(Path)) { var queueDescription = new QueueDescription(propertyValue[Path] as string); SetPropertyValue(propertyDictionary, propertyValue, queueDescription); serviceBusHelper.CreateQueue(queueDescription); } } catch (Exception ex) { HandleException(ex); } } } catch (Exception ex) { HandleException(ex); } }
private void btnAction_Click(object sender, EventArgs e) { try { if (serviceBusHelper == null) { return; } if (btnAction.Text == DeleteText) { var deleteForm = new DeleteForm(queueDescription.Path, QueueEntity.ToLower()); if (deleteForm.ShowDialog() == DialogResult.OK) { serviceBusHelper.DeleteQueue(queueDescription); } } else { if (string.IsNullOrEmpty(txtPath.Text)) { writeToLog(PathCannotBeNull); return; } var description = new QueueDescription(txtPath.Text); if (!string.IsNullOrEmpty(txtMaxQueueSizeInMegabytes.Text)) { long value; if (long.TryParse(txtMaxQueueSizeInMegabytes.Text, out value)) { description.MaxSizeInMegabytes = value; } else { writeToLog(MaxQueueSizeInBytesMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtMaxDeliveryCount.Text)) { int value; if (int.TryParse(txtMaxDeliveryCount.Text, out value)) { description.MaxDeliveryCount = value; } else { writeToLog(MaxDeliveryCountMustBeANumber); 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; } } 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); } days = 0; hours = 0; minutes = 0; seconds = 0; milliseconds = 0; if (!string.IsNullOrEmpty(txtLockDurationDays.Text) || !string.IsNullOrEmpty(txtLockDurationHours.Text) || !string.IsNullOrEmpty(txtLockDurationMinutes.Text) || !string.IsNullOrEmpty(txtLockDurationSeconds.Text) || !string.IsNullOrEmpty(txtLockDurationMilliseconds.Text)) { if (!string.IsNullOrEmpty(txtLockDurationDays.Text)) { if (!int.TryParse(txtLockDurationDays.Text, out days)) { writeToLog(LockDurationDaysMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtLockDurationHours.Text)) { if (!int.TryParse(txtLockDurationHours.Text, out hours)) { writeToLog(LockDurationHoursMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtLockDurationMinutes.Text)) { if (!int.TryParse(txtLockDurationMinutes.Text, out minutes)) { writeToLog(LockDurationMinutesMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtLockDurationSeconds.Text)) { if (!int.TryParse(txtLockDurationSeconds.Text, out seconds)) { writeToLog(LockDurationSecondsMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtLockDurationMilliseconds.Text)) { if (!int.TryParse(txtLockDurationMilliseconds.Text, out milliseconds)) { writeToLog(LockDurationMillisecondsMustBeANumber); return; } } description.LockDuration = new TimeSpan(days, hours, minutes, seconds, milliseconds); } description.EnableBatchedOperations = checkedListBox.GetItemChecked(EnableBatchedOperationsIndex); description.EnableDeadLetteringOnMessageExpiration = checkedListBox.GetItemChecked(EnableDeadLetteringOnMessageExpirationIndex); description.RequiresDuplicateDetection = checkedListBox.GetItemChecked(RequiresDuplicateDetectionIndex); description.RequiresSession = checkedListBox.GetItemChecked(RequiresSessionIndex); queueDescription = serviceBusHelper.CreateQueue(description); 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(queueDescription.Path, QueueEntity.ToLower()); if (deleteForm.ShowDialog() == DialogResult.OK) { serviceBusHelper.DeleteQueue(queueDescription); } } else { if (txtPath.Text.Trim().ToLower() == txtForwardTo.Text.Trim().ToLower()) { writeToLog(CannotForwardToItself); txtForwardTo.Focus(); return; } if (string.IsNullOrEmpty(txtPath.Text)) { writeToLog(PathCannotBeNull); return; } var description = new QueueDescription(txtPath.Text) { UserMetadata = txtUserMetadata.Text, ForwardTo = txtForwardTo.Text, MaxSizeInMegabytes = serviceBusHelper.IsCloudNamespace ? trackBarMaxQueueSize.Value * 1024 : trackBarMaxQueueSize.Value == trackBarMaxQueueSize.Maximum ? SeviceBusForWindowsServerMaxQueueSize : trackBarMaxQueueSize.Value * 1024 }; if (!string.IsNullOrEmpty(txtMaxDeliveryCount.Text)) { int value; if (int.TryParse(txtMaxDeliveryCount.Text, out value)) { description.MaxDeliveryCount = value; } else { writeToLog(MaxDeliveryCountMustBeANumber); 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; } } 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); } days = 0; hours = 0; minutes = 0; seconds = 0; milliseconds = 0; if (!string.IsNullOrEmpty(txtLockDurationDays.Text) || !string.IsNullOrEmpty(txtLockDurationHours.Text) || !string.IsNullOrEmpty(txtLockDurationMinutes.Text) || !string.IsNullOrEmpty(txtLockDurationSeconds.Text) || !string.IsNullOrEmpty(txtLockDurationMilliseconds.Text)) { if (!string.IsNullOrEmpty(txtLockDurationDays.Text)) { if (!int.TryParse(txtLockDurationDays.Text, out days)) { writeToLog(LockDurationDaysMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtLockDurationHours.Text)) { if (!int.TryParse(txtLockDurationHours.Text, out hours)) { writeToLog(LockDurationHoursMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtLockDurationMinutes.Text)) { if (!int.TryParse(txtLockDurationMinutes.Text, out minutes)) { writeToLog(LockDurationMinutesMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtLockDurationSeconds.Text)) { if (!int.TryParse(txtLockDurationSeconds.Text, out seconds)) { writeToLog(LockDurationSecondsMustBeANumber); return; } } if (!string.IsNullOrEmpty(txtLockDurationMilliseconds.Text)) { if (!int.TryParse(txtLockDurationMilliseconds.Text, out milliseconds)) { writeToLog(LockDurationMillisecondsMustBeANumber); return; } } description.LockDuration = new TimeSpan(days, hours, minutes, seconds, milliseconds); } description.EnableBatchedOperations = checkedListBox.GetItemChecked(EnableBatchedOperationsIndex); description.EnableDeadLetteringOnMessageExpiration = checkedListBox.GetItemChecked(EnableDeadLetteringOnMessageExpirationIndex); description.RequiresDuplicateDetection = checkedListBox.GetItemChecked(RequiresDuplicateDetectionIndex); description.RequiresSession = checkedListBox.GetItemChecked(RequiresSessionIndex); description.SupportOrdering = checkedListBox.GetItemChecked(SupportOrderingIndex); if (!serviceBusHelper.IsCloudNamespace) { description.IsAnonymousAccessible = checkedListBox.GetItemChecked(IsAnonymousAccessibleIndex); } queueDescription = serviceBusHelper.CreateQueue(description); InitializeData(); } } catch (Exception ex) { HandleException(ex); } }