Example #1
0
 protected override void BeginProcessing()
 {
     criteria = new MessageQueueCriteria();
     if (Category != null)
     {
         criteria.Category = Category.Value;
     }
     if (CreatedAfter != null)
     {
         criteria.CreatedAfter = CreatedAfter.Value;
     }
     if (CreatedBefore != null)
     {
         criteria.CreatedBefore = CreatedBefore.Value;
     }
     if (!String.IsNullOrEmpty(Label))
     {
         criteria.Label = Label;
     }
     if (!String.IsNullOrEmpty(MachineName))
     {
         criteria.MachineName = MachineName;
     }
     if (ModifiedAfter != null)
     {
         criteria.ModifiedAfter = ModifiedAfter.Value;
     }
     if (ModifiedBefore != null)
     {
         criteria.ModifiedBefore = ModifiedBefore.Value;
     }
 }
        //**************************************************
        // Iterates through message queues and displays the
        // path of each queue that was created in the last
        // day and that exists on the computer "MyComputer".
        //**************************************************

        public void ListPublicQueuesByCriteria()
        {
            uint numberQueues = 0;

            // Specify the criteria to filter by.
            MessageQueueCriteria myCriteria = new
                                              MessageQueueCriteria();

            myCriteria.MachineName  = "MyComputer";
            myCriteria.CreatedAfter = DateTime.Now.Subtract(new
                                                            TimeSpan(1, 0, 0, 0));


            // Get a cursor into the queues on the network.
            MessageQueueEnumerator myQueueEnumerator =
                MessageQueue.GetMessageQueueEnumerator(myCriteria);

            // Move to the next queue and read its path.
            while (myQueueEnumerator.MoveNext())
            {
                // Increase the count if priority is Lowest.
                Console.WriteLine(myQueueEnumerator.Current.Path);
                numberQueues++;
            }

            // Handle no queues matching the criteria.
            if (numberQueues == 0)
            {
                Console.WriteLine("No public queues match criteria.");
            }

            return;
        }
Example #3
0
        ///<summary>MessageQueuePublicQuery</summary>
        public static MessageQueue[] MessageQueuePublicQuery()
        {
            MessageQueueCriteria messageQueueCriteria = new MessageQueueCriteria();

            MessageQueue[] messageQueue = MessageQueue.GetPublicQueues(messageQueueCriteria);

            /*
             #if (DEBUG)
             * foreach( MessageQueue messageQueueCurrent in messageQueue )
             * {
             * System.Console.WriteLine
             * (
             * "Path: {0} | QueueName: {1} | MachineName: {2}",
             * messageQueueCurrent.Path,
             * messageQueueCurrent.QueueName,
             * messageQueueCurrent.MachineName
             * );
             * }
             #endif
             */

            return(messageQueue);
        }
        //**************************************************
        // Gets a list of all public queues that match
        // specified criteria. Displays the list on
        // screen.
        //**************************************************

        public void GetPublicQueuesByCriteria()
        {
            // Define criteria to filter the queues.
            MessageQueueCriteria myCriteria = new
                                              MessageQueueCriteria();

            myCriteria.CreatedAfter = DateTime.Now.Subtract(new
                                                            TimeSpan(1, 0, 0, 0));
            myCriteria.ModifiedBefore = DateTime.Now;
            myCriteria.MachineName    = ".";
            myCriteria.Label          = "My Queue";

            // Get a list of queues with that criteria.
            MessageQueue[] QueueList =
                MessageQueue.GetPublicQueues(myCriteria);

            // Display the paths of the queues in the list.
            foreach (MessageQueue queueItem in QueueList)
            {
                Console.WriteLine(queueItem.Path);
            }

            return;
        }
        private void btnConnect_Click(object sender, System.EventArgs e)
        {
            MessageQueue[] mqlist;
            MessageQueueCriteria mqCriteria;
            System.Windows.Forms.Cursor TempCursor;

            bDirectMode = radioDSDisabled.Checked;
            TempCursor = this.Cursor;
            this.Cursor = Cursors.WaitCursor;

            if (radioDSDisabled.Checked)
            { // User wants to use a private queue (direct connection).
                try
                {
                    qMe=MessageQueue.Create(@".\private$\" + strName);
                    qMe.Label = strName;
                    qMe.Category = new System.Guid(guidDraw);

                }
                catch(MessageQueueException MQE)
                {
                    qMe = new MessageQueue();
                    qMe.Path = @".\private$\" + strName;
                }
            }
            else
            { // The user wants to use a public queue (standard mode)
              // so query the direcotry service for a public queue with the
              // user-specified name.
                mqCriteria = new MessageQueueCriteria();
                mqCriteria.Label=strName;
                mqCriteria.Category = new System.Guid(guidDraw);
                try
                {
                    mqlist = MessageQueue.GetPublicQueues(mqCriteria);
                }
                catch(MessageQueueException MQE)
                {
                    MessageBox.Show("An error occurred in locating the queue. ("+MQE.Message+")","C#_Draw");
                    this.Close();
                    return;
                }
                // If no such queue then create one
                if (mqlist.Length == 0)
                {
                    try
                    {
                        MessageQueue.Create(@".\"+strName);
                    }
                    catch(MessageQueueException MQE)
                    {
                        MessageBox.Show("An error occurred in creating the queue. ("+MQE.Message+")","C#_Draw");
                        this.Close();
                        return;
                    }
                    qMe = new MessageQueue();
                    qMe.Path = @".\"+strName;
                    qMe.Label = strName;
                    qMe.Category = new System.Guid(guidDraw);
                }
                else
                {
                    qMe=mqlist[0];
                }
            }

            // Start receiving

            qMe.Formatter = new ActiveXMessageFormatter();
            qMe.ReceiveCompleted  += new ReceiveCompletedEventHandler(this.qMe_ReceiveCompleted);
            qMe.BeginReceive();

            groupConnectionMode.Visible = false;
            btnConnect.Visible=false;
            btnCancel.Visible=false;

            btnAttach.Visible=true;
            groupSendType.Visible=true;
            lblRemoteQueue.Visible=true;
            textFriendName.Visible=true;

            if (radioDSDisabled.Checked)
            {
                lblRemoteComputer.Visible=true;
                textFriendComputer.Visible=true;
            }

            this.Cursor = TempCursor;
            // Anyway, on the local computer, the connection to the Directory
            // service remains available
            lblDSConnection.Text = "MODE: Domain";
        }
        //
        // Start sending messages to a friend
        //
        private void btnAttach_Click(object sender, System.EventArgs e)
        {
            MessageQueue[] mqlist;
            MessageQueueCriteria mqCriteria;

            if (textFriendName.Text == "")
            {
                MessageBox.Show("Please fill in queue name.","Missing value");
                return;
            }

            textFriendName.Text = textFriendName.Text.ToUpper();

            if (!bDirectMode)
            {
                //
                // Standard Connection mode = Working with public queues
                //

                mqCriteria = new MessageQueueCriteria();
                mqCriteria.Label=textFriendName.Text;
                mqCriteria.Category = new System.Guid(guidDraw);
                try
                {
                    mqlist = MessageQueue.GetPublicQueues(mqCriteria);
                }
                catch(MessageQueueException MQE)
                {
                    MessageBox.Show("An error occurred in locating the queue. ("+MQE.Message+")","C#_Draw");
                    this.Close();
                    return;
                }
                if (mqlist.Length == 0)
                {
                    MessageBox.Show("Unable to locate queue.","C#_DRAW");
                    return;
                }
                qFriend = mqlist[0];
                this.Text= strName + " - Connected to " + textFriendName.Text;
            }
            else
            {

                if (textFriendComputer.Text == "")
                {
                    MessageBox.Show("Please fill in computer name.","Missing value");
                    return;
                }

                textFriendComputer.Text = textFriendComputer.Text.ToUpper();

                /*
                When working in direct mode, we must use private queues. We are unable
                to know whether a given private queue on another computer exists or not,
                so here we will just assume that it does. To make the application more robust,
                an acknowledgement queue should be created on the local computer, and
                a request for acknowledgement messages should be added to the messages sent.
                Then the application can notify the user when a negative acknoledgement (NACK)
                message is received.
                */

                qFriend = new MessageQueue("FormatName:DIRECT=OS:" +
                                           textFriendComputer.Text +
                                           @"\PRIVATE$\"+textFriendName.Text);
                this.Text = @".\PRIVATE$\"+strName + " - Connected to " +
                            textFriendComputer.Text + @"\PRIVATE$\"+textFriendName.Text;
            }
            textChars.Enabled = true;
            picture1.Enabled = true;
            btnAttach.Enabled = false;
            return;
        }
	public static MessageQueue[] GetPublicQueues(MessageQueueCriteria criteria) {}
	public static MessageQueueEnumerator GetMessageQueueEnumerator(MessageQueueCriteria criteria) {}
Example #9
0
 public static MessageQueue[] GetPublicQueues(MessageQueueCriteria criteria)
 {
 }
Example #10
0
 public static MessageQueueEnumerator GetMessageQueueEnumerator(MessageQueueCriteria criteria)
 {
 }
        private void btnConnect_Click(object sender, System.EventArgs e)
        {
            MessageQueue[]       mqlist;
            MessageQueueCriteria mqCriteria;

            System.Windows.Forms.Cursor TempCursor;

            bDirectMode = radioDSDisabled.Checked;
            TempCursor  = this.Cursor;
            this.Cursor = Cursors.WaitCursor;

            if (radioDSDisabled.Checked)
            {             // User wants to use a private queue (direct connection).
                try
                {
                    qMe          = MessageQueue.Create(@".\private$\" + strName);
                    qMe.Label    = strName;
                    qMe.Category = new System.Guid(guidDraw);
                }
                catch (MessageQueueException MQE)
                {
                    qMe      = new MessageQueue();
                    qMe.Path = @".\private$\" + strName;
                }
            }
            else
            {             // The user wants to use a public queue (standard mode)
                          // so query the direcotry service for a public queue with the
                          // user-specified name.
                mqCriteria          = new MessageQueueCriteria();
                mqCriteria.Label    = strName;
                mqCriteria.Category = new System.Guid(guidDraw);
                try
                {
                    mqlist = MessageQueue.GetPublicQueues(mqCriteria);
                }
                catch (MessageQueueException MQE)
                {
                    MessageBox.Show("An error occurred in locating the queue. (" + MQE.Message + ")", "C#_Draw");
                    this.Close();
                    return;
                }
                // If no such queue then create one
                if (mqlist.Length == 0)
                {
                    try
                    {
                        MessageQueue.Create(@".\" + strName);
                    }
                    catch (MessageQueueException MQE)
                    {
                        MessageBox.Show("An error occurred in creating the queue. (" + MQE.Message + ")", "C#_Draw");
                        this.Close();
                        return;
                    }
                    qMe          = new MessageQueue();
                    qMe.Path     = @".\" + strName;
                    qMe.Label    = strName;
                    qMe.Category = new System.Guid(guidDraw);
                }
                else
                {
                    qMe = mqlist[0];
                }
            }

            // Start receiving

            qMe.Formatter         = new ActiveXMessageFormatter();
            qMe.ReceiveCompleted += new ReceiveCompletedEventHandler(this.qMe_ReceiveCompleted);
            qMe.BeginReceive();

            groupConnectionMode.Visible = false;
            btnConnect.Visible          = false;
            btnCancel.Visible           = false;

            btnAttach.Visible      = true;
            groupSendType.Visible  = true;
            lblRemoteQueue.Visible = true;
            textFriendName.Visible = true;

            if (radioDSDisabled.Checked)
            {
                lblRemoteComputer.Visible  = true;
                textFriendComputer.Visible = true;
            }

            this.Cursor = TempCursor;
            // Anyway, on the local computer, the connection to the Directory
            // service remains available
            lblDSConnection.Text = "MODE: Domain";
        }
        //
        // Start sending messages to a friend
        //

        private void btnAttach_Click(object sender, System.EventArgs e)
        {
            MessageQueue[]       mqlist;
            MessageQueueCriteria mqCriteria;

            if (textFriendName.Text == "")
            {
                MessageBox.Show("Please fill in queue name.", "Missing value");
                return;
            }

            textFriendName.Text = textFriendName.Text.ToUpper();

            if (!bDirectMode)
            {
                //
                // Standard Connection mode = Working with public queues
                //

                mqCriteria          = new MessageQueueCriteria();
                mqCriteria.Label    = textFriendName.Text;
                mqCriteria.Category = new System.Guid(guidDraw);
                try
                {
                    mqlist = MessageQueue.GetPublicQueues(mqCriteria);
                }
                catch (MessageQueueException MQE)
                {
                    MessageBox.Show("An error occurred in locating the queue. (" + MQE.Message + ")", "C#_Draw");
                    this.Close();
                    return;
                }
                if (mqlist.Length == 0)
                {
                    MessageBox.Show("Unable to locate queue.", "C#_DRAW");
                    return;
                }
                qFriend   = mqlist[0];
                this.Text = strName + " - Connected to " + textFriendName.Text;
            }
            else
            {
                if (textFriendComputer.Text == "")
                {
                    MessageBox.Show("Please fill in computer name.", "Missing value");
                    return;
                }

                textFriendComputer.Text = textFriendComputer.Text.ToUpper();

                /*
                 * When working in direct mode, we must use private queues. We are unable
                 * to know whether a given private queue on another computer exists or not,
                 * so here we will just assume that it does. To make the application more robust,
                 * an acknowledgement queue should be created on the local computer, and
                 * a request for acknowledgement messages should be added to the messages sent.
                 * Then the application can notify the user when a negative acknoledgement (NACK)
                 * message is received.
                 */

                qFriend = new MessageQueue("FormatName:DIRECT=OS:" +
                                           textFriendComputer.Text +
                                           @"\PRIVATE$\" + textFriendName.Text);
                this.Text = @".\PRIVATE$\" + strName + " - Connected to " +
                            textFriendComputer.Text + @"\PRIVATE$\" + textFriendName.Text;
            }
            textChars.Enabled = true;
            picture1.Enabled  = true;
            btnAttach.Enabled = false;
            return;
        }