Example #1
0
 public void GetPublicQueues(ref GlobalVariables oVar, string MSMQServer)
 {
     MessageQueue[] PublicQueues = null;
     StructuredQueue oQueue = new StructuredQueue();
     QueueInfos QueueInfo = new QueueInfos();
     MessageInfo MyInfo = new MessageInfo();
     string sQueueOath = "";
     try
     {
         Application.DoEvents();
         oVar.bFlagProgressBar = true;
         PublicQueues = MessageQueue.GetPublicQueuesByMachine(MSMQServer);
         oVar.iProgressMax = PublicQueues.Length;
         oVar.iProgressValue = 0;
         for (int i = 0; i < PublicQueues.Length; i++)
         {
             oVar.sStatusMessage = "Get list of Queues .. Current Queue Name : " + PublicQueues[i].Path;
             Application.DoEvents();
             oQueue.sPath = PublicQueues[i].Path;
             oQueue.CountMessage = 0;//PublicQueues[i].GetAllMessages().Length;
             oQueue.sQueueName = PublicQueues[i].QueueName;
             //if (oVar.IsRemote)
             //{ oQueue.bTransactional = 1; }
             if (PublicQueues[i].Transactional)
             { oQueue.bTransactional = 2; }
             else
             { oQueue.bTransactional = 3; }
             //oQueue.bUseJournal = PrivateQueues[i].UseJournalQueue;
             // oQueue.sLabel = PrivateQueues[i].Label;
             oQueue.sPath = PublicQueues[i].Path;
             oQueue.sFormatName = PublicQueues[i].FormatName;
             //oQueue.bTransactional = PrivateQueues[i].Transactional;
             oQueue.iQueueId = i;
             oVar.iProgressValue = i;
             //oVar.oPrivateQueue_ARRAY.Insert(MyInfo.ID, oQueue);
             oVar.oPublicQueue_ARRAY.Add(oQueue);
         }
         oVar.bFlagProgressBar = false;
        // oVar.oPublicQueue_ARRAY.Sort();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\r\n" + sQueueOath,
             "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #2
0
        public MessageInfo PeekAllMessage(StructuredQueue oQueueTemp, int myID, int MaxQuery)
        {
            //Message messages = null;
            MessageInfo MyInfo = new MessageInfo();
            try
            {

                MessageQueue MessageInQueue = new System.Messaging.MessageQueue(oQueueTemp.sPath, QueueAccessMode.SendAndReceive);
                System.Messaging.Cursor cursor = MessageInQueue.CreateCursor();
                Message m = PeekWithoutTimeout(MessageInQueue, cursor, PeekAction.Current);
                Application.DoEvents();
                ArrayList MyMessage = new ArrayList();
                MessageInQueue.MessageReadPropertyFilter.Id = true;
                MessageInQueue.MessageReadPropertyFilter.Priority = true;
                MessageInQueue.MessageReadPropertyFilter.SentTime = true;
                MessageInQueue.MessageReadPropertyFilter.MessageType = true;
                MessageInQueue.MessageReadPropertyFilter.Label = true;
                MessageInQueue.MessageReadPropertyFilter.Body = true;
                MessageInQueue.BeginPeek(new TimeSpan(0, 0, 10, 0));
                //MessageEnumerator msgQenum = MessageInQueue.GetMessageEnumerator2();
                int index = 0;
                //  MyInfo.ID = MessageInQueue.GetAllMessages().Length;
                if (m != null)
                {
                    while ((m = PeekWithoutTimeout(MessageInQueue, cursor, PeekAction.Current)) != null)
                    //while (msgQenum.MoveNext())
                    {
                        Application.DoEvents();

                        if (!(index > MaxQuery))
                        {
                            //                       messages = msgQenum.Current;
                            QueueInfos QueueInfo = new QueueInfos();
                            //QueueInfo.ID = messages.Id;
                            //QueueInfo.SentTime = messages.SentTime.ToString();
                            //QueueInfo.Body = ReadMessageStream(messages.BodyStream);
                            //QueueInfo.Label = messages.Label;
                            //QueueInfo.Priority = messages.Priority.ToString();
                            //QueueInfo.MessageID = index.ToString();
                            //QueueInfo.Transact = oQueueTemp.bTransactional;
                            //QueueInfo.Queue = oQueueTemp.sQueueName;
                            QueueInfo.ID = m.Id;
                            QueueInfo.SentTime = m.SentTime.ToString();
                            QueueInfo.Body = ReadMessageStream(m.BodyStream);
                            QueueInfo.Label = m.Label;
                            QueueInfo.Priority = m.Priority.ToString();
                            QueueInfo.MessageID = index.ToString();
                            QueueInfo.Transact = oQueueTemp.bTransactional;

                            QueueInfo.Queue = oQueueTemp.sQueueName;
                            MyMessage.Add(QueueInfo);
                        }
                        index++;
                        PeekWithoutTimeout(MessageInQueue, cursor, PeekAction.Next);
                    }
                }
                MyInfo.ID = index;
                MyInfo.Message = MyMessage;

            }
            catch  {}

                return MyInfo;
        }
Example #3
0
        public void GetPrivateQueues(ref GlobalVariables oVar, string MSMQServer)
        {
            MessageQueue[] PrivateQueues = null;
            StructuredQueue oQueue = new StructuredQueue();
            QueueInfos QueueInfo = new QueueInfos();
            MessageInfo MyInfo = new MessageInfo();
            string sQueueOath = "";
            try
            {
                Application.DoEvents();
                oVar.bFlagProgressBar = true;
                PrivateQueues = MessageQueue.GetPrivateQueuesByMachine(MSMQServer);
                oVar.iProgressMax = PrivateQueues.Length;
                oVar.iProgressValue = 0;
                for (int i = 0; i < PrivateQueues.Length; i++)
                {
                    Application.DoEvents();
                    oVar.sStatusMessage = "Get list of Queues .. Current Queue Name : " + PrivateQueues[i].Path;
                    oQueue.sPath = PrivateQueues[i].Path;
                    PrivateQueues[i].MessageReadPropertyFilter.SetAll();
                    oQueue.sQueueName = PrivateQueues[i].QueueName.Replace("private$\\", "");
                 //   MessageQueue MessageInQueue = new System.Messaging.MessageQueue(oQueue.sPath, QueueAccessMode.SendAndReceive);
                    oQueue.CountMessage = 0;// GetQueueMessageCount(MSMQServer, PrivateQueues[i].QueueName);
                    if (oVar.IsRemote)
                    { oQueue.bTransactional = 1; }
                    else if (PrivateQueues[i].Transactional)
                    { oQueue.bTransactional = 2; }
                    else
                    { oQueue.bTransactional = 3;}
                    //oQueue.bUseJournal = PrivateQueues[i].UseJournalQueue;
                    // oQueue.sLabel = PrivateQueues[i].Label;
                    oQueue.sPath = PrivateQueues[i].Path;
                    oQueue.sFormatName = PrivateQueues[i].FormatName;
                    //oQueue.bTransactional = PrivateQueues[i].Transactional;
                    oQueue.iQueueId = i;
                    oVar.iProgressValue = i;
                    oVar.oPrivateQueue_ARRAY.Add(oQueue);
                }
                oVar.bFlagProgressBar = false;
               // oVar.oPrivateQueue_ARRAY.Sort();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + sQueueOath,
                    "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #4
0
        public ArrayList GetAllMessageInMSMQ(ref GlobalVariables oVar, ArrayList aTemp)
        {
            QueueInfos QueueInfo = new QueueInfos();
            MessageInfo MyInfo = new MessageInfo();
            ArrayList aTempReturn = new ArrayList();
            int MaxQuery = oVar.iMaxMessageToQuery;
            string sQueueOath = "";
            try
            {
                oVar.bFlagProgressBar = true;
               // ArrayList aTemp = new ArrayList(oVar.oPrivateQueue_ARRAY);
                //oVar.oPrivateQueue_ARRAY.Clear();
                oVar.iProgressMax = aTemp.Count;
                bool bQueryMessage =oVar.bQueryMessage;
                foreach (StructuredQueue oQueueTemp in aTemp)
                {
                    StructuredQueue oQueue = new StructuredQueue();
                    oQueue = oQueueTemp;
                    oVar.iProgressValue = oQueueTemp.iQueueId;
                    Application.DoEvents();
                    oVar.sStatusMessage = "Quering " + oQueueTemp.sPath + " Please wait...";
                    Thread newThread = new Thread(delegate()
                    {
                        Application.DoEvents();
                        if(bQueryMessage)
                            MyInfo = PeekAllMessage(oQueueTemp, oQueueTemp.iQueueId, MaxQuery);
                        else
                            MyInfo = GetAllMessage(oQueueTemp, oQueueTemp.iQueueId, MaxQuery);
                    });
                    newThread.Start();
                    while (newThread.IsAlive)
                    {
                        Application.DoEvents();
                        if (oVar.bCancelAllProcessFlag)
                        {
                            oVar.bCancelAllProcessFlag = false;
                            newThread.Abort();
                        }
                    }
                    oQueue.CountMessage = MyInfo.ID;
                    oQueue.Message = MyInfo.Message;
                    aTempReturn.Add(oQueue);
                }
                oVar.bFlagProgressBar = false;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + sQueueOath,
                    "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return null;
            }
            return aTempReturn;
        }
Example #5
0
        public MessageInfo GetAllMessage(StructuredQueue oQueueTemp, int myID, int MaxQuery)
        {
            MessageInfo MyInfo = new MessageInfo();
            try
            {
                Message[] messages = null;

                MessageQueue MessageInQueue = new System.Messaging.MessageQueue(oQueueTemp.sPath, QueueAccessMode.SendAndReceive);
                // MessageInQueue.MessageReadPropertyFilter.SetAll();
                MessageInQueue.MessageReadPropertyFilter.Id = true;
                MessageInQueue.MessageReadPropertyFilter.Priority = true;
                MessageInQueue.MessageReadPropertyFilter.SentTime = true;
                MessageInQueue.MessageReadPropertyFilter.MessageType = true;
                MessageInQueue.MessageReadPropertyFilter.Label = true;
                MessageInQueue.MessageReadPropertyFilter.Body = true;
                Application.DoEvents();
                messages = MessageInQueue.GetAllMessages();
                Application.DoEvents();
                ArrayList MyMessage = new ArrayList();
                // MyInfo.ID = MessageInQueue.GetAllMessages().Length;
                MyInfo.ID = messages.Length;
                for (int index = 0; index < messages.Length; index++)
                {
                    Application.DoEvents();
                    if (index >= MaxQuery)
                        break;
                    QueueInfos QueueInfo = new QueueInfos();
                    QueueInfo.ID = messages[index].Id;
                    QueueInfo.SentTime = messages[index].SentTime.ToString();
                    QueueInfo.Body = ReadMessageStream(messages[index].BodyStream);
                    QueueInfo.Label = messages[index].Label;
                    QueueInfo.Priority = messages[index].Priority.ToString();
                    QueueInfo.MessageID = index.ToString();
                    QueueInfo.Transact = oQueueTemp.bTransactional;
                    QueueInfo.Queue = oQueueTemp.sQueueName;
                    MyMessage.Add(QueueInfo);

                }
                MyInfo.Message = MyMessage;

            }
            catch
            {

            }

                return MyInfo;
        }
Example #6
0
        public MessageInfo PeekAllMessage(StructuredQueue oQueueTemp, int myID, int MaxQuery)
        {
            //Message messages = null;
            MessageInfo MyInfo = new MessageInfo();

            try
            {
                MessageQueue            MessageInQueue = new System.Messaging.MessageQueue(oQueueTemp.sPath, QueueAccessMode.SendAndReceive);
                System.Messaging.Cursor cursor         = MessageInQueue.CreateCursor();
                Message m = PeekWithoutTimeout(MessageInQueue, cursor, PeekAction.Current);
                Application.DoEvents();
                ArrayList MyMessage = new ArrayList();
                MessageInQueue.MessageReadPropertyFilter.Id          = true;
                MessageInQueue.MessageReadPropertyFilter.Priority    = true;
                MessageInQueue.MessageReadPropertyFilter.SentTime    = true;
                MessageInQueue.MessageReadPropertyFilter.MessageType = true;
                MessageInQueue.MessageReadPropertyFilter.Label       = true;
                MessageInQueue.MessageReadPropertyFilter.Body        = true;
                MessageInQueue.BeginPeek(new TimeSpan(0, 0, 10, 0));
                //MessageEnumerator msgQenum = MessageInQueue.GetMessageEnumerator2();
                int index = 0;
                //  MyInfo.ID = MessageInQueue.GetAllMessages().Length;
                if (m != null)
                {
                    while ((m = PeekWithoutTimeout(MessageInQueue, cursor, PeekAction.Current)) != null)
                    //while (msgQenum.MoveNext())
                    {
                        Application.DoEvents();

                        if (!(index > MaxQuery))
                        {
                            //                       messages = msgQenum.Current;
                            QueueInfos QueueInfo = new QueueInfos();
                            //QueueInfo.ID = messages.Id;
                            //QueueInfo.SentTime = messages.SentTime.ToString();
                            //QueueInfo.Body = ReadMessageStream(messages.BodyStream);
                            //QueueInfo.Label = messages.Label;
                            //QueueInfo.Priority = messages.Priority.ToString();
                            //QueueInfo.MessageID = index.ToString();
                            //QueueInfo.Transact = oQueueTemp.bTransactional;
                            //QueueInfo.Queue = oQueueTemp.sQueueName;
                            QueueInfo.ID        = m.Id;
                            QueueInfo.SentTime  = m.SentTime.ToString();
                            QueueInfo.Body      = ReadMessageStream(m.BodyStream);
                            QueueInfo.Label     = m.Label;
                            QueueInfo.Priority  = m.Priority.ToString();
                            QueueInfo.MessageID = index.ToString();
                            QueueInfo.Transact  = oQueueTemp.bTransactional;

                            QueueInfo.Queue = oQueueTemp.sQueueName;
                            MyMessage.Add(QueueInfo);
                        }
                        index++;
                        PeekWithoutTimeout(MessageInQueue, cursor, PeekAction.Next);
                    }
                }
                MyInfo.ID      = index;
                MyInfo.Message = MyMessage;
            }
            catch  {}

            return(MyInfo);
        }
Example #7
0
        private void UpdateTreeViewbySpecificQueuename()
        {
            MessageInfo MyInfo = new MessageInfo();
            int MaxQuery = oVariables.iMaxMessageToQuery;
            bool bQueryMessage = oVariables.bQueryMessage;

            MSMQTView.ImageList = imageList1;
            oVariables.bbtnRefreshQueue = false;
            oVariables.brefreshQueueToolStripMenuItem = false;
            oVariables.bCancelAllProcess = true;
            TreeNode node2 = MSMQTView.SelectedNode;
            if (node2 != null)
            {
                MSMQTView.Cursor = Cursors.WaitCursor;
                string[] MySelectedMessage = oVariables.SplitByString(MSMQTView.SelectedNode.Tag.ToString(), "|||||");
                StructuredQueue Queues = new StructuredQueue();
                if (node2.FullPath.Contains("Public Queue"))
                {
                    Queues = (StructuredQueue)oVariables.oPublicQueue_ARRAY.GetRange(Convert.ToInt32(MySelectedMessage[1]), 1)[0];
                }
                else if (node2.FullPath.Contains("Private Queue"))
                {
                    Queues = (StructuredQueue)oVariables.oPrivateQueue_ARRAY.GetRange(Convert.ToInt32(MySelectedMessage[1]), 1)[0];
                }

                //StructuredQueue oQueue = new StructuredQueue();
                //oQueue = Queues;
                oVariables.iProgressValue = Queues.iQueueId;
                Application.DoEvents();
                oVariables.sStatusMessage = "Quering " + Queues.sPath + " Please wait...";
                Thread newThread = new Thread(delegate()
                {
                    Application.DoEvents();
                    if (bQueryMessage)
                        MyInfo = oMSMQ.PeekAllMessage(Queues, Queues.iQueueId, MaxQuery);
                    else
                        MyInfo = oMSMQ.GetAllMessage(Queues, Queues.iQueueId, MaxQuery);
                });
                newThread.Start();
                while (newThread.IsAlive)
                {
                    Application.DoEvents();
                    if (oVariables.bCancelAllProcessFlag)
                    {
                        oVariables.bCancelAllProcessFlag = false;
                        newThread.Abort();
                    }
                }
                Queues.CountMessage = MyInfo.ID;

                Queues.Message = MyInfo.Message;

                if (node2.FullPath.Contains("Public Queue"))
                {
                    oVariables.oPublicQueue_ARRAY.RemoveAt(Convert.ToInt32(MySelectedMessage[1]));
                    oVariables.oPublicQueue_ARRAY.Insert(Convert.ToInt32(MySelectedMessage[1]), Queues);
                }
                else if (node2.FullPath.Contains("Private Queue"))
                {
                    oVariables.oPrivateQueue_ARRAY.RemoveAt(Convert.ToInt32(MySelectedMessage[1]));
                    oVariables.oPrivateQueue_ARRAY.Insert(Convert.ToInt32(MySelectedMessage[1]), Queues);
                }

                node2.Text = Queues.sQueueName + "(" + MyInfo.ID + ")";
                node2.Tag = "Queues|||||" + Queues.iQueueId + "|||||" + Queues.bTransactional.ToString() + "|||||" + Queues.CountMessage;
                // MSMQTView.BeginUpdate();
                //TreeNode myNode = new TreeNode();
                node2.Nodes.Clear();
                if (MyInfo.Message != null)
                {
                    progressBar1.Maximum = MyInfo.Message.Count + 1;
                    MSMQTView.BeginUpdate();
                    foreach (QueueInfos Messages in MyInfo.Message)
                    {
                        Application.DoEvents();
                        oVariables.sStatusMessage = "Loading " + Messages.ID + " to " + Queues.sQueueName + " Please wait...";
                        if (progressBar1.Maximum > 0)
                        {
                            if (progressBar1.Maximum > progressBar1.Value)
                                progressBar1.Value += 1;
                            //node2.Text = oQueues.sQueueName + "(" + progressBar1.Value + ")";
                        }
                        if (oVariables.bCancelAllProcessFlag)
                        {
                            progressBar1.Value = Queues.Message.Count;
                            MSMQTView.EndUpdate();
                            MSMQTView.Cursor = Cursors.Default;
                            oVariables.bCancelAllProcessFlag = false;
                            break;
                        }
                        TreeNode mNode = new TreeNode();
                        if (Messages.Transact == 2)
                            mNode.ImageIndex = 1;
                        else if (Messages.Transact == 3)
                            mNode.ImageIndex = 3;
                        else if (Messages.Transact == 1)
                            mNode.ImageIndex = 5;
                        mNode.Tag = "Message|||||" + Messages.MessageID + "|||||" + Queues.iQueueId + "|||||" + Queues.bTransactional.ToString();
                        mNode.Name = Messages.ID;
                        mNode.Text = Messages.Label;

                        //myNode.Nodes.Add(mNode);
                        node2.Nodes.Add(mNode);
                        Application.DoEvents();
                        //MSMQTView.EndUpdate();
                    }
                    oVariables.sStatusMessage = "Queue " + Queues.sQueueName + " has already updated.. There are " + MyInfo.Message.Count + " message queried";
                    MSMQTView.EndUpdate();
                }
                MSMQTView.Cursor = Cursors.Default;

            }
            oVariables.bbtnRefreshQueue = true;
            oVariables.brefreshQueueToolStripMenuItem = true;
            oVariables.bCancelAllProcess = false;
        }