Esempio n. 1
0
        /// <summary>
        /// Finds a list item which holds a message.
        /// </summary>
        /// <param name="message">Message to search for.</param>
        /// <returns>Message which contains the message if found, else null</returns>
        private MessageListViewItem FindListItem(System.Messaging.Message message)
        {
            MessageListViewItem result = null;

            foreach (ListViewItem item in messagesListView.Items)
            {
                MessageListViewItem messageItem = item as MessageListViewItem;
                if (messageItem != null && messageItem.Message == message)
                {
                    result = messageItem;
                    break;
                }
            }

            return(result);
        }
Esempio n. 2
0
		/// <summary>
		/// Adds a message to the list view.
		/// </summary>
		/// <param name="messageItem">Message to add.</param>
		private void AddMessageItemToListView(MessageListViewItem messageItem)
		{
			messagesListView.Items.Add(messageItem);
		}
Esempio n. 3
0
		/// <summary>
		/// Gets a snap shot of the current queue, and loads in the the list view.
		/// </summary>						
		private void GetSnapShotCallBack(object state)
		{									
			bool isTaskAborted = false;			

			//set up reference to worker thread before releasing initiating thread
			_messageLoadThread = Thread.CurrentThread;			
			_startedEvent.Set();			

			try
			{																																													
				if (_userSettings.MessageBrowserColumnListCollection.Count > 0)
				{
				
					//set the read filter and matching column headers
					PropertyInfo[] messagePropertyInfoArray;
					PrepareReadPropertyFilterAndListViewColumns(out messagePropertyInfoArray);				

					//check we are OK for load
					if (_qSetQueueItem != null)
					{
						//if (_qSetQueueItem.QSetMessageQueue.CanRead)
						//{					
						System.Messaging.Message[] messagesSnapShot;
						try
						{
							//retrieve all messages
							messagesSnapShot = _qSetQueueItem.QSetMessageQueue.GetAllMessages();
						}
						catch (System.Messaging.MessageQueueException mQexc)
						{
							throw new UnableToReadQueueException(string.Format(Locale.UserMessages.UnableToReadQueueDueToError, 
								string.Format("{0} HRESULT/MSMQ Error: {1}/{2}.", mQexc.Message, mQexc.ErrorCode, mQexc.MessageQueueErrorCode) ));						
						}
						catch (Exception exc)
						{
							throw new UnableToReadQueueException(string.Format(Locale.UserMessages.UnableToReadQueueDueToError, exc.Message));						
						}
						
						//load all of the messages into the list view
						Action ffs = () => workingPanel.Visible = false;
                        workingPanel.Invoke(ffs);                        
						foreach (System.Messaging.Message message in messagesSnapShot)
						{						
							//create the list view item
							object propertyValue = "Not Available";
							try
							{
								//TODO fine tune this, so we 'black list' properties which fail
								//		(some are not available on workgroup machines)
								propertyValue = messagePropertyInfoArray[0].GetValue(message, null);
							}
							catch {}
							string propertyValueString = propertyValue == null ? "" : propertyValue.ToString();
							MessageListViewItem messageItem = 
								new MessageListViewItem(message, propertyValueString, (int)Images.IconType.Message);	

							//add all of the column data
							if (_userSettings.MessageBrowserColumnListCollection.Count > 1)
							{
								for (int i = 1; i <= messagePropertyInfoArray.GetUpperBound(0); i ++)
								{
									string subItemPropertyValue = "Not available";
									try
									{
										//TODO fine tune this, so we 'black list' properties which fail
										//		(some are not available on workgroup machines)
										subItemPropertyValue = messagePropertyInfoArray[i].GetValue(message, null).ToString();
									}
									catch {}
									messageItem.SubItems.Add(subItemPropertyValue);
								}
							}

							//add the item into the list on a safe thread
							if (messagesListView.InvokeRequired)
								messagesListView.Invoke(new AddMessageItemToListViewDelegate(AddMessageItemToListView), new object[] {messageItem});
							else
								AddMessageItemToListView(messageItem);																						
						}
						//}
						//else
						//{						
							//insufficient access to read queue
						//	throw new UnableToReadQueueException(Locale.UserMessages.UnableToReadQueueDueToInsufficientAccessRights);						
						//}
					}
				}
				
			}				
			catch (Exception exc)
			{				
				if (exc is ThreadAbortException)
					isTaskAborted = true;									
				else if (exc is UnableToReadQueueException)
					OnMessageLoadException(new MessageLoadExceptionEventArgs(exc));
				else
					OnMessageLoadException(new MessageLoadExceptionEventArgs(new UnableToReadQueueException(string.Format(Locale.UserMessages.UnableToReadQueueDueToError, exc.Message), exc)));											
			}
			finally
			{
				if (!isTaskAborted)
					FinishMessageLoad(false);
			}
		}
Esempio n. 4
0
        /// <summary>
        /// Gets a snap shot of the current queue, and loads in the the list view.
        /// </summary>
        private void GetSnapShotCallBack(object state)
        {
            bool isTaskAborted = false;

            //set up reference to worker thread before releasing initiating thread
            _messageLoadThread = Thread.CurrentThread;
            _startedEvent.Set();

            try
            {
                if (_userSettings.MessageBrowserColumnListCollection.Count > 0)
                {
                    //set the read filter and matching column headers
                    PropertyInfo[] messagePropertyInfoArray;
                    PrepareReadPropertyFilterAndListViewColumns(out messagePropertyInfoArray);

                    //check we are OK for load
                    if (_qSetQueueItem != null)
                    {
                        //if (_qSetQueueItem.QSetMessageQueue.CanRead)
                        //{
                        System.Messaging.Message[] messagesSnapShot;
                        try
                        {
                            //retrieve all messages
                            messagesSnapShot = _qSetQueueItem.QSetMessageQueue.GetAllMessages();
                        }
                        catch (System.Messaging.MessageQueueException mQexc)
                        {
                            throw new UnableToReadQueueException(string.Format(Locale.UserMessages.UnableToReadQueueDueToError,
                                                                               string.Format("{0} HRESULT/MSMQ Error: {1}/{2}.", mQexc.Message, mQexc.ErrorCode, mQexc.MessageQueueErrorCode)));
                        }
                        catch (Exception exc)
                        {
                            throw new UnableToReadQueueException(string.Format(Locale.UserMessages.UnableToReadQueueDueToError, exc.Message));
                        }

                        //load all of the messages into the list view
                        Action ffs = () => workingPanel.Visible = false;
                        workingPanel.Invoke(ffs);
                        List <MessageListViewItem> allMessageList = new List <MessageListViewItem>();
                        int messageCount = 0;
                        foreach (System.Messaging.Message message in messagesSnapShot)
                        {
                            //create the list view item
                            object propertyValue = "Not Available";
                            try
                            {
                                //TODO fine tune this, so we 'black list' properties which fail
                                //		(some are not available on workgroup machines)
                                propertyValue = messagePropertyInfoArray[0].GetValue(message, null);
                            }
                            catch {}
                            string propertyValueString      = propertyValue == null ? "" : propertyValue.ToString();
                            MessageListViewItem messageItem =
                                new MessageListViewItem(message, propertyValueString, (int)Images.IconType.Message);

                            //add all of the column data
                            if (_userSettings.MessageBrowserColumnListCollection.Count > 1)
                            {
                                for (int i = 1; i <= messagePropertyInfoArray.GetUpperBound(0); i++)
                                {
                                    string subItemPropertyValue = "Not available";
                                    try
                                    {
                                        //TODO fine tune this, so we 'black list' properties which fail
                                        //		(some are not available on workgroup machines)
                                        subItemPropertyValue = messagePropertyInfoArray[i].GetValue(message, null).ToString();
                                    }
                                    catch {}
                                    messageItem.SubItems.Add(subItemPropertyValue);
                                }
                            }

                            //add the item into the list on a safe thread

                            allMessageList.Add(messageItem);
                            messageCount++;
                            if (messageCount >= this.MaxRowShow)
                            {
                                break;
                            }
                        }
                        if (allMessageList.Count > 0)
                        {
                            if (messagesListView.InvokeRequired)
                            {
                                messagesListView.Invoke(new AddMessageItemToListViewDelegate(AddMessageItemToListView), new object[] { allMessageList.ToArray() });
                            }
                            else
                            {
                                AddMessageItemToListView(allMessageList.ToArray());
                            }
                        }

                        //}
                        //else
                        //{
                        //insufficient access to read queue
                        //	throw new UnableToReadQueueException(Locale.UserMessages.UnableToReadQueueDueToInsufficientAccessRights);
                        //}
                    }
                }
            }
            catch (Exception exc)
            {
                if (exc is ThreadAbortException)
                {
                    isTaskAborted = true;
                }
                else if (exc is UnableToReadQueueException)
                {
                    OnMessageLoadException(new MessageLoadExceptionEventArgs(exc));
                }
                else
                {
                    OnMessageLoadException(new MessageLoadExceptionEventArgs(new UnableToReadQueueException(string.Format(Locale.UserMessages.UnableToReadQueueDueToError, exc.Message), exc)));
                }
            }
            finally
            {
                if (!isTaskAborted)
                {
                    FinishMessageLoad(false);
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Adds a message to the list view.
 /// </summary>
 /// <param name="messageItem">Message to add.</param>
 private void AddMessageItemToListView(MessageListViewItem messageItem)
 {
     messagesListView.Items.Add(messageItem);
 }