public void DeleteMessage(ref GlobalVariables oVar, string FormatType, string MSMQServer, string QueueName, string MessageId,string MessageLabel) { string MQPath = FormatType + MSMQServer + "\\" + QueueName; try { MessageQueue oMQueue = new MessageQueue(MQPath); try { oMQueue.ReceiveById(MessageId); oVar.sStatusMessage = " Message succesfully deleted"; //MessageBox.Show(MessageLabel + " Message succesfully deleted", // "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information); //MessageBox.Show(ex + "Queue Name is not valid or exist"); oVar.sStatusMessage = ex.Message; } oMQueue.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information); oVar.sStatusMessage = ex.Message; } }
static void Main() { GlobalVariables oVariables = new GlobalVariables(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmQXplorer(oVariables)); }
public void DeleteQueue(ref GlobalVariables oVar, string MSMQServer, string QueueName, bool AllQueue) { string MQPath = MSMQServer + "\\" + QueueName; try { if (MessageQueue.Exists(MQPath)) { DialogResult result; if (AllQueue) result = DialogResult.Yes; else result = MessageBox.Show("Are you sure you want to delete " + MQPath + " ?", "Message Queuing", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { MessageQueue.Delete(MQPath); if (!(AllQueue)) MessageBox.Show(QueueName + " was succesfully deleted", "Message Queuing", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show(QueueName + " Queue is not exist", "Message Queuing", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void CreateQueue(ref GlobalVariables oVar, string MSMQServer, string QueueName, bool IsTransaction) { try { string MQPath = MSMQServer + "\\" + QueueName; if (MessageQueue.Exists(MQPath)) { MessageBox.Show(QueueName + " Queue is already exist", "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if(IsTransaction) MessageQueue.Create(MQPath, true); else MessageQueue.Create(MQPath, false); // MessageBox.Show(QueueName + " Queue succesfully created", // "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public frmAboutBox(ref GlobalVariables objArg) { InitializeComponent(); oVar = objArg; // Initialize the AboutBox to display the product information from the assembly information. // Change assembly information settings for your application through either: // - Project->Properties->Application->Assembly Information // - AssemblyInfo.cs this.Text = String.Format("About {0}", AssemblyTitle); this.labelProductName.Text = AssemblyProduct; this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion); this.labelCopyright.Text = AssemblyCopyright; this.labelCompanyName.Text = AssemblyCompany; this.textBoxDescription.Text = AssemblyDescription; this.labelOwner.Text = ("Owner : Julius L. Ramos, ECE, QA , MCSA\r\n" + " [email protected]\r\n" + " [email protected]\r\n"); }
public frmCreateQueue(ref GlobalVariables objArg) { oVar = objArg; InitializeComponent(); }
private void SendMessage() { oVariables.sComputerName = ComBoxComputer.Text.ToString().Trim(); oVariables.IsRemote = oVariables.CheckIsRemote(oVariables.sComputerName); oVariables.GetQueueFormatType(oVariables.sComputerName); oVariables.bsendmessageStripMenuItem = false; oVariables.bSendMessagetoolStripButton = false; oVariables.bbtnSendMessage = false; oVariables.bCancelAllProcess = true; try { if (String.IsNullOrEmpty(txtQueueName.Text.Trim())) { MessageBox.Show("Information is missing"); if (String.IsNullOrEmpty(txtQueuelabel.Text.Trim())) txtQueuelabel.BorderStyle = BorderStyle.FixedSingle; else txtQueuelabel.BorderStyle = BorderStyle.Fixed3D; if (String.IsNullOrEmpty(txtQueueName.Text.Trim())) txtQueueName.BorderStyle = BorderStyle.FixedSingle; else txtQueueName.BorderStyle = BorderStyle.Fixed3D; if (String.IsNullOrEmpty(txtBody.Text.Trim())) txtBody.BorderStyle = BorderStyle.FixedSingle; else txtBody.BorderStyle = BorderStyle.Fixed3D; oVariables.bsendmessageStripMenuItem = true; oVariables.bSendMessagetoolStripButton = true; oVariables.bbtnSendMessage = true; oVariables.sStatusMessage = "Error sending message to " + txtQueueName.Text.Trim(); return; } txtQueueName.BorderStyle = BorderStyle.Fixed3D; txtQueuelabel.BorderStyle = BorderStyle.Fixed3D; txtBody.BorderStyle = BorderStyle.Fixed3D; if ((oVariables.IsRemote) && (oVariables.sQueueType.Equals("\\private$"))) { DialogResult result = MessageBox.Show("These tool cannot be determined if the queue is transactional or Non-transactional" + "\r\nPlease provide additional information of these queue\r\n\r\n" + "Select Yes if Transactional and No if Non-trasactional", "Message Queuing Admin", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (result == DialogResult.Yes) oVariables.IsTransactional = true; else if (result == DialogResult.No) oVariables.IsTransactional = false; else if (result == DialogResult.Cancel) { oVariables.bsendmessageStripMenuItem = true; oVariables.bSendMessagetoolStripButton = true; oVariables.bbtnSendMessage = true; return; } } if (numericUpDownCopy.Value > 1) { GlobalVariables MultiMessage = new GlobalVariables(); ; MultiMessage.IsJournal = oVariables.IsJournal; MultiMessage.IsRemote = oVariables.IsRemote; MultiMessage.IsTransactional = oVariables.IsTransactional; MultiMessage.sComputerName = oVariables.sComputerName; MultiMessage.sQueueFormatType = oVariables.sQueueFormatType; MultiMessage.sQueueType = oVariables.sQueueType; MultiMessage.sMessageBody = txtBody.Text.Trim(); MultiMessage.sMessageLabel = txtQueuelabel.Text.Trim().ToString(); MultiMessage.sMessagePriority = comboPriority.Text.ToString(); MultiMessage.sMessageQueuename = txtQueueName.Text.Trim().ToString(); MultiMessage.iNumberofCopy = Convert.ToInt32(numericUpDownCopy.Value); MultiMessage.iMessageDelay = Convert.ToInt32(numericUpDownDelay.Value); Thread newThread = new Thread(delegate() { Application.DoEvents(); SendMultiMessage(MultiMessage.sQueueFormatType, MultiMessage.sComputerName, MultiMessage.sQueueType, MultiMessage.sMessageQueuename, MultiMessage.sMessageLabel, MultiMessage.sMessageBody, MultiMessage.IsTransactional, MultiMessage.sMessagePriority, MultiMessage.IsJournal, MultiMessage.IsRemote, MultiMessage.iNumberofCopy, MultiMessage.iMessageDelay); }); newThread.Start(); while (newThread.IsAlive) { Application.DoEvents(); if (oVariables.bCancelAllProcessFlag) { oVariables.bCancelAllProcess = false; oVariables.sStatusMessage = "Sending message cancelled"; newThread.Abort(); } } oVariables.sStatusMessage = "Sending message done"; } else { oVariables.sStatusMessage = "Start Sending message to " + txtQueueName.Text.Trim(); oMSMQ.SendMessage(oVariables.sQueueType, oVariables.sQueueFormatType, oVariables.sComputerName + oVariables.sQueueType, txtQueueName.Text.Trim(), txtQueuelabel.Text.Trim(), txtBody.Text.Trim(), oVariables.IsTransactional, comboPriority.Text, oVariables.IsJournal, oVariables.IsRemote); //MSMQ.SendMessageQ(MQ_String, // cboNetworkComputers.Text.ToString().Trim() + GetQueueType(), txtQueueName.Text, // TransactionType(), txtLabel.Text, txtBody.Text, cboPriority.Text, 0, IsJournal(), false); oVariables.sStatusMessage = "Sending message done"; } } catch (Exception Ex) { oVariables.sStatusMessage = "Encountered an Error " + Ex.Message.ToString(); } oVariables.bsendmessageStripMenuItem = true; oVariables.bSendMessagetoolStripButton = true; oVariables.bbtnSendMessage = true; if (oVariables.bAutoRefreshQueue) Refresh_MSMQ(); }
public frmSettings(ref GlobalVariables objArg) { oVar = objArg; InitializeComponent(); }
//public void GetSystemQueues(ref GlobalVariables oVar, string MSMQServer) //{ // MessageQueue[] SystemQueues = null; // StructuredQueue oQueue = new StructuredQueue(); // QueueInfos QueueInfo = new QueueInfos(); // MessageInfo MyInfo = new MessageInfo(); // string sQueueOath = ""; // try // { // oVar.bFlagProgressBar = true; // //SystemQueues = MessageQueue(MSMQServer); // oVar.iProgressMax = PublicQueues.Length; // for (int i = 0; i < PublicQueues.Length; i++) // { // sQueueOath = PublicQueues[i].Path; // 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.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; // } // catch (Exception ex) // { // MessageBox.Show(ex.Message + "\r\n" + sQueueOath, // "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Error); // } //} public void GetOutgoingQueues(ref GlobalVariables oVar, string MSMQServer) { ArrayList OutgoingQueuename = new ArrayList(); try { MSMQ.MSMQApplication q = new MSMQ.MSMQApplication(); object obj = q.ActiveQueues; Object[] oArray = (Object[])obj; for (int i = 0; i < oArray.Length; i++) { if (oArray[i] == null) { continue; } if (oArray[i].ToString().IndexOf("DIRECT=") >= 0) { OutgoingQueuename.Add(oArray[i].ToString()); } } } catch (Exception ee) { MessageBox.Show(ee.ToString()); } // return OutgoingQueuename; // MessageQueue[] SystemQueues = null; // StructuredQueue oQueue = new StructuredQueue(); // QueueInfos QueueInfo = new QueueInfos(); // MessageInfo MyInfo = new MessageInfo(); // string sQueueOath = ""; // try // { // oVar.bFlagProgressBar = true; // //SystemQueues = MessageQueue(MSMQServer); // oVar.iProgressMax = PublicQueues.Length; // for (int i = 0; i < PublicQueues.Length; i++) // { // sQueueOath = PublicQueues[i].Path; // 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.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; // } // catch (Exception ex) // { // MessageBox.Show(ex.Message + "\r\n" + sQueueOath, // "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Error); // } }
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 void PurgeQueue(ref GlobalVariables oVar, string FormatType, string MSMQServer, string QueueName,bool AllQueue) { string MQPath = FormatType + MSMQServer + "\\" + QueueName; ; DialogResult result ; if (AllQueue) result = DialogResult.Yes; else result = MessageBox.Show("Are you sure you want to delete all messages in the queue?", "Message Queuing Admin", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (result == DialogResult.Yes) { try { MessageQueue oMQueue = new MessageQueue(MQPath); try { oMQueue.Receive(new TimeSpan(0, 0, 1)); oMQueue.Purge(); if (!(AllQueue)) MessageBox.Show("All message succesfully purge", "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { if (!(AllQueue)) MessageBox.Show(ex.Message, "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information); } oMQueue.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
//public void GetSystemQueues(ref GlobalVariables oVar, string MSMQServer) //{ // MessageQueue[] SystemQueues = null; // StructuredQueue oQueue = new StructuredQueue(); // QueueInfos QueueInfo = new QueueInfos(); // MessageInfo MyInfo = new MessageInfo(); // string sQueueOath = ""; // try // { // oVar.bFlagProgressBar = true; // //SystemQueues = MessageQueue(MSMQServer); // oVar.iProgressMax = PublicQueues.Length; // for (int i = 0; i < PublicQueues.Length; i++) // { // sQueueOath = PublicQueues[i].Path; // 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.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; // } // catch (Exception ex) // { // MessageBox.Show(ex.Message + "\r\n" + sQueueOath, // "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Error); // } //} public void GetOutgoingQueues(ref GlobalVariables oVar, string MSMQServer) { ArrayList OutgoingQueuename = new ArrayList(); try { MSMQ.MSMQApplication q = new MSMQ.MSMQApplication(); object obj = q.ActiveQueues; Object[] oArray = (Object[])obj; for (int i = 0; i < oArray.Length; i++) { if (oArray[i] == null) continue; if (oArray[i].ToString().IndexOf("DIRECT=") >= 0) { OutgoingQueuename.Add(oArray[i].ToString()); } } } catch (Exception ee) { MessageBox.Show(ee.ToString()); } // return OutgoingQueuename; // MessageQueue[] SystemQueues = null; // StructuredQueue oQueue = new StructuredQueue(); // QueueInfos QueueInfo = new QueueInfos(); // MessageInfo MyInfo = new MessageInfo(); // string sQueueOath = ""; // try // { // oVar.bFlagProgressBar = true; // //SystemQueues = MessageQueue(MSMQServer); // oVar.iProgressMax = PublicQueues.Length; // for (int i = 0; i < PublicQueues.Length; i++) // { // sQueueOath = PublicQueues[i].Path; // 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.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; // } // catch (Exception ex) // { // MessageBox.Show(ex.Message + "\r\n" + sQueueOath, // "Message Queuing Admin", MessageBoxButtons.OK, MessageBoxIcon.Error); // } }
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 frmQXplorer(GlobalVariables oVariable) { oVariables = oVariable; InitializeComponent(); }
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 frmConnectComputer(ref GlobalVariables objArg) { oVar = objArg; InitializeComponent(); }