/// <summary> /// Refreshes the active queue. /// </summary> public void RefreshActiveQueue() { if (_primaryControls.HasActiveDocument) { MessageBrowser messageBrowser = _primaryControls.GetActiveMessageBrowser(); if (messageBrowser != null) { messageBrowser.Refresh(); } } }
/// <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); } }