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); }
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); } }
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); } }
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); }
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; }
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); } }
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; }
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; }
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); }
private void dgSearchresult_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { try { // txtBodyWeb.Visible = true; //txtBody.Visible = true; // rdoBytext.Checked = true; QueueInfos MyMessage = new QueueInfos(); MyMessage.Queue = dgSearchresult.Rows[e.RowIndex].Cells["QueueName"].Value.ToString(); MyMessage.Label = dgSearchresult.Rows[e.RowIndex].Cells["sLabel"].Value.ToString(); MyMessage.Body = dgSearchresult.Rows[e.RowIndex].Cells["sBody"].Value.ToString(); MyMessage.Priority = dgSearchresult.Rows[e.RowIndex].Cells["sPriority"].Value.ToString(); MyMessage.ID = dgSearchresult.Rows[e.RowIndex].Cells["sMessageID"].Value.ToString(); if (dgSearchresult.Rows[e.RowIndex].Cells["FormatName"].Value.ToString().Contains("private$")) oVariables.sQueueType = "\\private$"; else oVariables.sQueueType = null; if (dgSearchresult.Rows[e.RowIndex].Cells["Transactional"].Value.ToString().Contains("True")) oVariables.IsTransactional = true; else if (dgSearchresult.Rows[e.RowIndex].Cells["Transactional"].Value.ToString().Contains("False")) oVariables.IsTransactional = false; oVariables.sComputerName = ComBoxComputer.Text.ToString(); ResendtoolStripMenuItem.Enabled = true; msmqgroupbox.Visible = true; msmqgroupbox.BringToFront(); groupboxSearch_Text.Visible = false; SetQueueInfos(MyMessage); } catch { } }
private void SetQueueInfos(QueueInfos Messages) { if (oVariables.bLastRdo) { txtBodyWeb.SendToBack(); txtBody.BringToFront(); rdoBytext.Checked = true; } else { txtBody.SendToBack(); txtBodyWeb.BringToFront(); rdoByXML.Checked = true; } //txtQueueName.Text = ""; //txtBody.Text = ""; //txtLabel.Text = ""; //cboPriority.Text = ""; //txtMessageID.Text = ""; //txtSentTime.Text = ""; //txtPathName.Text = ""; txtQueueName.Text = Messages.Queue; txtQueueName.Tag = Messages.ID; // txtBody.Text = Messages.Body; //objVar.TempMessageBody = Messages.Body; txtQueuelabel.Text = Messages.Label; comboPriority.Text = Messages.Priority; // .Text = Messages.Priority; //txtMessageID.Text = Messages.ID; //txtSentTime.Text = Messages.SentTime; //txtPathName.Text = Messages.Path; oVariables.sCurrentMessageBody = Messages.Body; if (rdoBytext.Checked) { txtBody.BringToFront(); txtBody.Text = Messages.Body; } else if (rdoByXML.Checked) { txtBodyWeb.BringToFront(); using (StreamWriter myStream = new StreamWriter(oVariables.sTempFolder + "\\messagebody.tmp")) { if (!(String.IsNullOrEmpty(Messages.Body))) myStream.Write(Messages.Body); else if (!(String.IsNullOrEmpty(txtBody.Text.ToString()))) myStream.Write(txtBody.Text.ToString()); else myStream.Write("Message Body is Empty"); myStream.Close(); } oVariables.sWebUrl = oVariables.sTempFolder + "\\messagebody.tmp"; txtBodyWeb.Navigate(oVariables.sWebUrl); } else { } //if (MSMQTView.SelectedNode.ImageIndex == 2) // oVariables.IsTransactional = true; //else if (MSMQTView.SelectedNode.ImageIndex == 3) // oVariables.IsTransactional = false; }
private void DgViewMessage_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { try { DgViewMessage.SendToBack(); // txtBodyWeb.Visible = true; //txtBody.Visible = true; // rdoBytext.Checked = true; QueueInfos MyMessage = new QueueInfos(); MyMessage.Label = DgViewMessage.Rows[e.RowIndex].Cells["Label"].Value.ToString(); MyMessage.Body = DgViewMessage.Rows[e.RowIndex].Cells["Body"].Value.ToString(); MyMessage.Priority = DgViewMessage.Rows[e.RowIndex].Cells["Priority"].Value.ToString(); MyMessage.Queue = txtQueueName.Text; SetQueueInfos(MyMessage); } catch { } }