Ejemplo n.º 1
0
 /// <summary>
 /// Deletes selected message from a queue, prompting the user before actioning.
 /// </summary>
 public void DeleteSelectedMessagesFromQueue()
 {
     //validate license
     if (_primaryObjects.License.ValidateFeatureUse(Licensing.Feature.DeleteMessage))
     {
         //check we have the correct control selected to work with
         if (_primaryControls.HasActiveDocument)
         {
             MessageBrowser messageBrowser = _primaryControls.GetActiveMessageBrowser();
             if (messageBrowser != null && messageBrowser.SelectedItems.Count > 0)
             {
                 //confirm the delete
                 if (WindowsForms.MessageBox.Show(_primaryForms.EnvironmentForm,
                                                  string.Format(Locale.UserMessages.ConfirmMessageDelete, messageBrowser.SelectedItems.Count > 1 ? "s" : ""),
                                                  Locale.ApplicationName,
                                                  WindowsForms.MessageBoxButtons.YesNoCancel,
                                                  WindowsForms.MessageBoxIcon.Question,
                                                  WindowsForms.MessageBoxDefaultButton.Button3) == WindowsForms.DialogResult.Yes)
                 {
                     DoDeleteSelectedMessagesFromQueue(messageBrowser);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the currently active queue to the Q Set.
        /// </summary>
        public void AddActiveQueueToQSet()
        {
            if (_primaryControls.GetQSetExplorerSet() != null)
            {
                if (_primaryControls.GetQSetExplorerActiveItem() == null)
                {
                    _primaryControls.SetQSetExplorerActiveItem(_primaryControls.GetQSetExplorerSet());
                }

                if (_primaryControls.HasActiveDocument)
                {
                    MessageBrowser messageBrowser = _primaryControls.GetActiveMessageBrowser();
                    if (messageBrowser != null)
                    {
                        QSetFolderItem folderItem = _primaryControls.GetQSetExplorerActiveItem() as QSetFolderItem;
                        if (folderItem != null)
                        {
                            if (!folderItem.ChildItems.Exists(messageBrowser.QSetQueueItem.Name))
                            {
                                folderItem.ChildItems.Add(messageBrowser.QSetQueueItem);
                            }
                        }
                        else
                        {
                            MessageBox.Show(_primaryForms.EnvironmentForm, "Cannot add the queue at this point.  Select a valid folder, or the top level Queue Set to add the queue.", Locale.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deletes selected messages from a queue without prompting the user.
        /// </summary>
        private void DoDeleteSelectedMessagesFromQueue(MessageBrowser messageBrowser)
        {
            //visualize
            VisualizableProcess process = new VisualizableProcess(
                string.Format(Locale.UserMessages.RetrievingMessages, messageBrowser.SelectedItems.Count > 1 ? "s" : ""), false);

            _primaryObjects.ProcessVisualizer.ProcessStarting(process);

            try
            {
                //delete all selected messages
                while (messageBrowser.SelectedItems.Count > 0)
                {
                    messageBrowser.QSetQueueItem.QSetMessageQueue.ReceiveById(((MessageListViewItem)messageBrowser.SelectedItems[0]).Message.Id);
                    messageBrowser.SelectedItems[0].Remove();
                }
            }
            catch (Exception exc)
            {
                WindowsForms.MessageBox.Show(_primaryForms.EnvironmentForm, string.Format(Locale.UserMessages.UnableToDeleteMessage, exc.Message), Locale.ApplicationName, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
            }

            //tidyup UI
            _taskManager.MenuStateManger.SetAllMenusState();
            _primaryObjects.ProcessVisualizer.ProcessCompleted(process);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Forwards the messages selected in the active message browser.
        /// </summary>
        /// <param name="delete">Set to true to delete the messages after they have been forwarded.</param>
        public void ForwardSelectedMessagesFromQueue(bool delete)
        {
            // Check we have the correct control selected to work with
            if (_primaryControls.HasActiveDocument)
            {
                MessageBrowser messageBrowser = _primaryControls.GetActiveMessageBrowser();

                if (messageBrowser != null && messageBrowser.SelectedItems.Count > 0)
                {
                    //get an array of all the messages we want to forward
                    Message[] messages = new Message[messageBrowser.SelectedItems.Count];
                    for (int i = 0; i < messageBrowser.SelectedItems.Count; i++)
                    {
                        messages[i] = ((MessageListViewItem)messageBrowser.SelectedItems[i]).Message;
                    }

                    NewMessageForm form = new NewMessageForm(_primaryObjects.License, this, messages, messageBrowser.QSetQueueItem);
                    form.SmallImageList = _primaryControls.GetSize16Icons();
                    if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        if (delete)
                        {
                            DoDeleteSelectedMessagesFromQueue(messageBrowser);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Purges the queue which is currently active in the focused MessageBrowser.
 /// </summary>
 public void PurgeActiveQueue()
 {
     if (_primaryControls.HasActiveDocument)
     {
         MessageBrowser messageBrowser = _primaryControls.GetActiveMessageBrowser();
         if (messageBrowser != null)
         {
             QueueTaskManager.PurgeQueue(messageBrowser.QSetQueueItem);
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Refreshes the active queue.
 /// </summary>
 public void RefreshActiveQueue()
 {
     if (_primaryControls.HasActiveDocument)
     {
         MessageBrowser messageBrowser = _primaryControls.GetActiveMessageBrowser();
         if (messageBrowser != null)
         {
             messageBrowser.Refresh();
         }
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Handles an exception whilst a message browser is loading messages.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="a"></param>
 private void MessageBrowser_MessageLoadException(MessageBrowser sender, MessageLoadExceptionEventArgs e)
 {
     base.PrimaryObjects.ProcessVisualizer.SeizeCursor(Cursors.Arrow);
     MessageBox.Show(e.Exception.Message, Locale.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     base.PrimaryObjects.ProcessVisualizer.ReleaseCursor();
 }
Ejemplo n.º 8
0
        /// <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);
            }
        }