private void CountQueueMessages(QSetQueueItem queueItem) { //first of all, ensure we have a node to work with QueueItemListViewItemPair itemPair = null; if (_itemPairHashTable.ContainsKey(queueItem.ID)) { itemPair = (QSetMonitorWorker.QueueItemListViewItemPair)_itemPairHashTable[queueItem.ID]; } else { //TODO create icon itemPair = new QueueItemListViewItemPair(queueItem, new ListViewItem(queueItem.Name, (int)Images.IconType.Queue)); for (int subItemCounter = 0; subItemCounter < _COLUMNS; subItemCounter++) { itemPair.ListViewItem.SubItems.Add(string.Empty); } _itemPairHashTable.Add(itemPair.QSetQueueItem.ID, itemPair); Action x = delegate { _monitorListView.Items.Add(itemPair.ListViewItem); }; _monitorListView.Invoke(x); } ManagementObject counter = null; try { counter = new ManagementObject(String.Format("Win32_PerfRawdata_MSMQ_MSMQQueue.name='{0}'", itemPair.QSetQueueItem.Name)); counter.Get(); uint outgoingMessageCount = Convert.ToUInt32(counter.GetPropertyValue("MessagesInQueue")); uint outgoingBytes = Convert.ToUInt32(counter.GetPropertyValue("BytesInQueue")); Action herewegoagain = () => { if (itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingMessageCount].Text != outgoingMessageCount.ToString()) //note: only do if necessary, to avoid flicker { itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingMessageCount].Text = outgoingMessageCount.ToString(); } if (itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingBytes].Text != outgoingBytes.ToString()) //note: only do if necessary, to avoid flicker { itemPair.ListViewItem.SubItems[(int)SubItemList.OutgoingBytes].Text = outgoingBytes.ToString(); } }; _monitorListView.Invoke(herewegoagain); } catch { //exception will occur when cannot get access to performance counters } finally { if (counter != null) { counter.Dispose(); } } }
public void AddTabbedDocumentMessageBrowser(QSetQueueItem qsetQueueItem, PrimaryObjects primaryObjects) { var messageForm = new MessageBrowserForm(); messageForm.MessageBrowser.UserSettings = primaryObjects.UserSettings; messageForm.MessageBrowser.ImageList = this.GetSize16Icons(); //messageForm.MessageBrowser.MaxRowShow =this.m try { messageForm.Show(_dockPanel, DockState.Document); messageForm.MessageBrowser.QSetQueueItem = qsetQueueItem; MessageBrowserCollection.Add(qsetQueueItem.ID.ToString(), messageForm.MessageBrowser); if (_wireupActionForTabbedDocuments != null) { _wireupActionForTabbedDocuments(messageForm); } messageForm.FormClosed += MessageForm_FormClosed; } catch (Exception exc) { primaryObjects.ProcessVisualizer.SeizeCursor(Cursors.Arrow); MessageBox.Show(exc.Message, Locale.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning); primaryObjects.ProcessVisualizer.ReleaseCursor(); messageForm.Close(); } }
private void AddQueueItemToRecipientsList(QSetQueueItem queueItem) { ListViewItem recipientItem = new ListViewItem(queueItem.Name, (int)Resources.Images.IconType.Queue); recipientItem.Tag = queueItem; recipientsListView.Items.Add(recipientItem); }
/// <summary> /// Displays the new message form to send a message. /// </summary> /// <param name="queue">Initial queue to show in the recipients list.</param> public void SendNewMessage(QSetQueueItem queue) { NewMessageForm form = new NewMessageForm(_primaryObjects.License, this, queue); form.SmallImageList = _primaryControls.GetSize16Icons(); form.Show(); }
/// <summary> /// Constructs the object. /// </summary> public MessageBrowser() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); _qSetQueueItem = null; base.Disposed += new EventHandler(MessageBrowser_Disposed); }
/// <summary> /// Purges the queue which is currently selected in the QSetExplorer. /// </summary> public void PurgeActiveQSetExplorerQueue() { if (_primaryControls.HasActiveDocument) { QSetQueueItem queueItem = _primaryControls.GetQSetExplorerActiveItem() as QSetQueueItem; if (queueItem != null) { QueueTaskManager.PurgeQueue(queueItem); } } }
/// <summary> /// Pugres the queue contents from the QSetQueueItem. /// </summary> /// <param name="queueItem">Item which contains the quue to be purged.</param> public void PurgeQueue(QSetQueueItem queueItem) { QSetMessageQueue queue = queueItem.QSetMessageQueue; string confirmationMessage = string.Format(Locale.UserMessages.ConfirmQueuePurge, string.Format(@"{0}\{1}", queue.MachineName, queue.QueueName)); if (WindowsForms.MessageBox.Show(_primaryForms.EnvironmentForm, confirmationMessage, Locale.ApplicationName, WindowsForms.MessageBoxButtons.YesNoCancel, WindowsForms.MessageBoxIcon.Question, WindowsForms.MessageBoxDefaultButton.Button3) == WindowsForms.DialogResult.Yes) { PurgeQueueWithoutPrompt(queueItem); } }
/// <summary> /// Opens a new queue in the environment for browsing. /// </summary> /// <param name="queueName">QSetQueueItem which contains the queue to be opened.</param> public void OpenQueue(QSetQueueItem qsetQueueItem) { if (!IsItemOpen(qsetQueueItem)) { _primaryControls.AddTabbedDocumentMessageBrowser(qsetQueueItem, _primaryObjects); } else { BringDocumentToFront(qsetQueueItem); } if (qsetQueueItem.ParentItem == null && _primaryControls.GetQSetExplorerSet() != null) { AddActiveQueueToQSet(); } }
/// <summary> /// Displays a new message. /// </summary> /// <param name="qsetMessageQueue">Queue that the message belongs to.</param> /// <param name="message">Message to display.</param> public void DisplayMessage(QSetQueueItem qsetQueueItem, System.Messaging.Message message) { //set the memeber level message reference _message = message; //check if an xslt is assigned to the queue if (qsetQueueItem.MessageViewerXslt != null && qsetQueueItem.MessageViewerXslt.Length > 0) { //is this xslt already loaded? if (_currentXsltPath != qsetQueueItem.MessageViewerXslt) { //load the new xslt StreamReader sr = null; try { sr = new StreamReader(new FileStream(qsetQueueItem.MessageViewerXslt, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); _transfomer = new Transformer(sr.ReadToEnd()); _currentXsltPath = qsetQueueItem.MessageViewerXslt; } catch { _currentXsltPath = null; _transfomer = null; } finally { if (sr != null) { sr.Close(); } } } } else { _currentXsltPath = null; _transfomer = null; } //now display the message DoDisplayMessage(); ConfigureButtons(); }
/// <summary> /// Pugres the queue contents from the QSetQueueItem. /// </summary> /// <param name="queueItem">Item which contains the quue to be purged.</param> public void PurgeQueueWithoutPrompt(QSetQueueItem queueItem) { QSetMessageQueue queue = queueItem.QSetMessageQueue; VisualizableProcess process = new VisualizableProcess(Locale.UserMessages.PurgingQueue, false); try { _primaryObjects.ProcessVisualizer.ProcessStarting(process); queue.Purge(); } catch (Exception exc) { WindowsForms.MessageBox.Show(_primaryForms.EnvironmentForm, string.Format(Locale.UserMessages.UnableToPurgeQueue, exc.Message), Locale.ApplicationName, WindowsForms.MessageBoxButtons.OK, WindowsForms.MessageBoxIcon.Exclamation); } finally { _primaryObjects.ProcessVisualizer.ProcessCompleted(process); } }
/// <summary> /// Attempts to delete a MSMQ message queue. /// </summary> public void DeleteActiveQueue() { if (_primaryControls.GetQSetExplorerActiveItem() != null) { QSetQueueItem queueItem = _primaryControls.GetQSetExplorerActiveItem() as QSetQueueItem; if (queueItem != null) { //confirm the delete if (WindowsForms.MessageBox.Show(_primaryForms.EnvironmentForm, string.Format(Locale.UserMessages.ConfirmQueueDelete, queueItem.Name), Locale.ApplicationName, WindowsForms.MessageBoxButtons.YesNoCancel, WindowsForms.MessageBoxIcon.Question, WindowsForms.MessageBoxDefaultButton.Button3) == WindowsForms.DialogResult.Yes) { try { MessageQueue.Delete(queueItem.Name); if (queueItem.ParentItem != null) { queueItem.ParentItem.ChildItems.Remove(queueItem.Name); } } catch (Exception exc) { WindowsForms.MessageBox.Show( _primaryForms.EnvironmentForm, string.Format(Locale.UserMessages.UnableToDeleteQueue, exc.Message), Locale.ApplicationName, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } } } } }
/// <summary> /// Given a QSetItemBase, marks the corresponding QueueItemListViewItemPair for deletion, /// and repeats for any children of the QSetItemBase object. /// </summary> /// <param name="item">QSetItemBase to delete.</param> private void RecursivelyMarkListItemsForDeletion(QSetItemBase item) { //if we have a queue, remove it QSetQueueItem queueItem = item as QSetQueueItem; if (queueItem != null) { if (_itemPairHashTable.ContainsKey(queueItem.ID)) { _deleteItemPairQueue.Enqueue(_itemPairHashTable[queueItem.ID]); } } //if we have a folder, check children QSetFolderItem folderItem = item as QSetFolderItem; if (folderItem != null) { foreach (QSetItemBase childItem in folderItem.ChildItems) { RecursivelyMarkListItemsForDeletion(childItem); } } }
public void DisplayQSetMessage(QSetQueueItem qSetQueueItem, System.Messaging.Message message) { _messageViewerForm.MessageViewer.DisplayMessage(qSetQueueItem, message); }
/// <summary> /// Copies or moves messages from one queue to another. /// </summary> /// <param name="fromQueueItem">Source queue.</param> /// <param name="toQueueItem">Destination queue.</param> /// <param name="messages">Messages to move or copy.</param> /// <param name="deleteSourceMessagesOnComplete">Set to true to move the messages, false to copy the messages.</param> public void CopyMessages(QSetQueueItem fromQueueItem, QSetQueueItem toQueueItem, Message[] messages, bool deleteSourceMessagesOnComplete) { try { //validate license if (_primaryObjects.License.ValidateFeatureUse(Licensing.Feature.DragAndDropMessage)) { if (fromQueueItem.QSetMessageQueue.CanRead) { if (toQueueItem.QSetMessageQueue.CanWrite) { //attempt to get message browsers for the queues MessageBrowser fromMessageBrowser = null; MessageBrowser toMessageBrowser = null; foreach (MessageBrowser messageBrowser in _primaryControls.MessageBrowserCollection) { if (messageBrowser.QSetQueueItem == fromQueueItem) { fromMessageBrowser = messageBrowser; } else if (messageBrowser.QSetQueueItem == toQueueItem) { toMessageBrowser = messageBrowser; } if (toMessageBrowser != null && (fromMessageBrowser != null || !deleteSourceMessagesOnComplete)) { break; } } //move/copy the messages foreach (Message message in messages) { SendMessage((MessageQueue)toQueueItem.QSetMessageQueue, fromQueueItem.QSetMessageQueue.PeekById(message.Id)); //SendMessage((MessageQueue)toQueueItem.QSetMessageQueue, DuplicateMessage(fromQueueItem.QSetMessageQueue, message.Id)); if (deleteSourceMessagesOnComplete) { fromQueueItem.QSetMessageQueue.ReceiveById(message.Id); } } //update the message browsers if (toMessageBrowser != null) { toMessageBrowser.Refresh(); } if (fromMessageBrowser != null && deleteSourceMessagesOnComplete && toMessageBrowser != fromMessageBrowser) { fromMessageBrowser.Refresh(); } } else { //TODO use locale WindowsForms.MessageBox.Show( _primaryForms.EnvironmentForm, "Insufficient permissions to write to the target queue.", Locale.ApplicationName, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } } else { //TODO use locale WindowsForms.MessageBox.Show( _primaryForms.EnvironmentForm, "Insufficient permissions to read from queue.", Locale.ApplicationName, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } } } catch (Exception exc) { //TODO use locale and have a message that can distinguish between move and copy WindowsForms.MessageBox.Show( _primaryForms.EnvironmentForm, string.Format("Encountered an error during move.\n\n{0}", exc.Message), Locale.ApplicationName, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } }
private void Initialize(Licensing.License license, QueueTaskManager queueTaskManager, QSetQueueItem initialRecipient, System.Messaging.Message[] messages, QSetQueueItem sourceQueueItem) { _license = license; InitializeComponent(); if (messages != null && messages.Length > 0) { _mode = Mode.ExistingMessage; } else { _mode = Mode.NewMessage; } _queueTaskManager = queueTaskManager; _sourceQueueItem = sourceQueueItem; base.Closing += new CancelEventHandler(NewMessageForm_Closing); numberOfCopiesComboBoxItem.ToolTipText = "Select the number of copies to send to each recipient queue."; numberOfCopiesComboBoxItem.ComboBox.SelectedIndex = 0; numberOfCopiesComboBoxItem.ComboBox.KeyPress += new KeyPressEventHandler(ComboBox_KeyPress); numberOfCopiesComboBoxItem.ComboBox.MaxLength = 4; _messageViewer = new MessageViewer { License = license }; _messageViewer.Dock = DockStyle.Fill; _messageViewerHostPanel.Controls.Add(_messageViewer); recipientsListView.Items.Clear(); messagesListView.Items.Clear(); if (_mode == Mode.NewMessage) { FormatterComboItem[] formatterItems = new FormatterComboItem[3]; formatterItems[0] = new FormatterComboItem(_FORMATTER_ACTIVEX, MessageFormatterType.ActiveX); formatterItems[1] = new FormatterComboItem(_FORMATTER_BINARY, MessageFormatterType.Binary); formatterItems[2] = new FormatterComboItem(_FORMATTER_XML, MessageFormatterType.Xml); formatterComboBoxItem.ComboBox.DisplayMember = "Name"; formatterComboBoxItem.ComboBox.ValueMember = "FormatterType"; formatterComboBoxItem.ComboBox.DataSource = formatterItems; formatterComboBoxItem.ComboBox.SelectedIndex = 2; formatterComboBoxItem.ComboBox.DropDownStyle = ComboBoxStyle.DropDownList; foreach (ToolStripItem item in optionsPriorityMenuItem.DropDownItems) { var menuItem = item as ToolStripMenuItem; if (menuItem != null) { menuItem.Checked = false; } } priorityNormalMenuItem.Checked = true; ConfigureMessagePriorityMenuItems(); SelectMessagePriorityMenuItem(System.Messaging.MessagePriority.Normal); } else { if (messages.Length == 1) { existingMessagesLabel.Text = "Message:"; } else { existingMessagesLabel.Text = "Messages:"; } foreach (System.Messaging.Message message in messages) { ListViewItem item = new ListViewItem(message.Label, (int)Resources.Images.IconType.Message); item.Tag = message; messagesListView.Items.Add(item); } messagesListView.Items[0].Selected = true; } //TODO when multiple messages are supplied leave all the options blank so that the existing message properties take effect // but let the options be selectable so they can be overridde. When a single message is passed into the form all // of the options can be defaulted to that messages options sendAndKeepOpenButtonItem.Visible = _mode == Mode.NewMessage; formatterComboBoxItem.Visible = _mode == Mode.NewMessage; optionsDropDownMenuItem.Visible = _mode == Mode.NewMessage; labelLabel.Visible = _mode == Mode.NewMessage; labelTextBox.Visible = _mode == Mode.NewMessage; newMessagePanel.Visible = _mode == Mode.NewMessage; existingMessagePanel.Visible = _mode == Mode.ExistingMessage; ConfigureControls(); SetupToolTips(); if (initialRecipient != null) { AddQueueItemToRecipientsList(initialRecipient); } }
public NewMessageForm(Licensing.License license, QueueTaskManager queueTaskManager, QSetQueueItem initialRecipient) { Initialize(license, queueTaskManager, initialRecipient, null, null); }
public NewMessageForm(Licensing.License license, QueueTaskManager queueTaskManager, System.Messaging.Message[] messages, QSetQueueItem sourceQueueItem) { Initialize(license, queueTaskManager, null, messages, sourceQueueItem); }
/// <summary> /// Constructs the event arguments. /// </summary> /// <param name="fromQueueItem">Queue where messages were dragged from.</param> /// <param name="toQueueItem">Queue where messages were dragged to.</param> /// <param name="messages">Messages which were dragged.</param> public MessagesDragDropEventArgs(QSetQueueItem fromQueueItem, QSetQueueItem toQueueItem, Message[] messages) { _fromQueueItem = fromQueueItem; _toQueueItem = toQueueItem; _messages = messages; }
/// <summary> /// Constructs the object. /// </summary> /// <param name="ownerQueueItem">Queue which the messages belong to.</param> /// <param name="messages">Messages which are being dragged.</param> public MessageDragContainer(QSetQueueItem ownerQueueItem, Message[] messages) { _ownerQueueItem = ownerQueueItem; _messages = messages; }
/// <summary> /// Constructs object, setting required properties. /// </summary> /// <param name="qsetMessageQueue">The queue set queue item which the message belongs to.</param> /// <param name="process">Process associated with the event.</param> /// <param name="message">Message being selected.</param> public SelectedMessageChangedEventArgs(QSetQueueItem qsetQueueItem, System.Messaging.Message message) : base() { _message = message; _qsetQueueItem = qsetQueueItem; }
/// <summary> /// Constructs the pair. /// </summary> /// <param name="qsetQueueItem">QSetQueueItem of the pair.</param> /// <param name="listViewItem">ListViewItem of the pair.</param> public QueueItemListViewItemPair(QSetQueueItem qsetQueueItem, ListViewItem listViewItem) { _qsetQueueItem = qsetQueueItem; _listViewItem = listViewItem; }