private void btnConnect_Click(object sender, RoutedEventArgs e) { MQMessageStatus connectStatus = _manager.ConnectMQ(this.txtQueueManager.Text.Trim(), _channelName, _hostName, _port, _userName, _password); if (connectStatus.Status) { MessageBox.Show(connectStatus.Message, "Information"); this.btnSendMessage.IsEnabled = true; this.btnRetrieveMessage.IsEnabled = true; this._isMQConnected = true; } else { this._isMQConnected = false; this.btnSendMessage.IsEnabled = false; this.btnRetrieveMessage.IsEnabled = false; if (!string.IsNullOrWhiteSpace(connectStatus.Message)) { MessageBox.Show(connectStatus.Message, "Error"); } else { MessageBox.Show("Some error occured while establishing the connection", "Error"); } } }
private void btnRetrieveMessage_Click(object sender, RoutedEventArgs e) { MQMessageStatus messageStatus = _manager.ReadLocalQMsg(this.txtGetQueue.Text.Trim()); if (messageStatus.Status) { this.QueueDataList.Add(new QueueData { Data = messageStatus.Message }); } else { if (!string.IsNullOrWhiteSpace(messageStatus.Message)) { MessageBox.Show(messageStatus.Message, "Error"); } else { MessageBox.Show("Some error occured while getting the message from the queue", "Error"); } } }
private void btnSendMessage_Click(object sender, RoutedEventArgs e) { string messageToSend = string.Empty; if (this.radioPartDelievered.IsChecked.HasValue && this.radioPartDelievered.IsChecked.Value) { PartDeliveredMessage partDeliveredMessage = new PartDeliveredMessage(); partDeliveredMessage.MessageType = (MessageType)Enum.Parse(typeof(MessageType), Convert.ToString(this.comboMessageTypePartDelivered.Text), true); partDeliveredMessage.RouteColor = (RouteColor)Enum.Parse(typeof(RouteColor), Convert.ToString(this.comboColorPartDelivered.Text), true); partDeliveredMessage.PartNumber = this.txtPartNumberPartDelivered.Text.Trim(); partDeliveredMessage.Timestamp = DateTime.Parse(this.txtTimestampPartDelivered.Text.Trim()); partDeliveredMessage.UID = int.Parse(this.txtUniqueIdPartDelivered.Text.Trim()); messageToSend = this.SerializeObject <PartDeliveredMessage>(partDeliveredMessage); //Increment unique id on each message send this._uniqueIdPartDelivered = this._uniqueIdPartDelivered + 1; } else if (this.radioPartReorder.IsChecked.HasValue && this.radioPartReorder.IsChecked.Value) { PartReorderMessage partReorderMessage = new PartReorderMessage(); partReorderMessage.MessageType = (MessageType)Enum.Parse(typeof(MessageType), Convert.ToString(this.comboMessageTypePartReorder.Text), true); partReorderMessage.RouteColor = (RouteColor)Enum.Parse(typeof(RouteColor), Convert.ToString(this.comboColorPartReorder.Text), true); partReorderMessage.PartNumber = this.txtPartNumberPartReorder.Text.Trim(); partReorderMessage.Timestamp = DateTime.Parse(this.txtTimestampPartReorder.Text.Trim()); partReorderMessage.UID = int.Parse(this.txtUniqueIdPartReorder.Text.Trim()); messageToSend = this.SerializeObject <PartReorderMessage>(partReorderMessage); //Increment unique id on each message send this._uniqueIdPartOrdered = this._uniqueIdPartOrdered + 1; } else if (this.radioEntryLoad.IsChecked.HasValue && this.radioEntryLoad.IsChecked.Value) { EntryLoadArea entryLoadAreaMessage = new EntryLoadArea(); entryLoadAreaMessage.RFIDDeviceAddress = this.txtRFIDDeviceAddressEntryLoad.Text.Trim(); entryLoadAreaMessage.RFIDDeviceAntennaID = this.txtRFIDDeviceAntennaIDEntryLoad.Text.Trim(); entryLoadAreaMessage.RFIDDeviceID = this.txtRFIDDeviceIDEntryLoad.Text.Trim(); entryLoadAreaMessage.RFIDTagEPC = this.txtRFIDTagEPCEntryLoad.Text.Trim(); entryLoadAreaMessage.PartNumber = this.txtPartNumberEntryLoad.Text.Trim(); entryLoadAreaMessage.TimeStamp = DateTime.Parse(this.txtTimestampEntryLoad.Text.Trim()); entryLoadAreaMessage.UID = int.Parse(this.txtUniqueIdEntryLoad.Text.Trim()); messageToSend = this.SerializeObject <EntryLoadArea>(entryLoadAreaMessage); //Increment unique id on each message send this._uniqueIdEntryLoad = this._uniqueIdEntryLoad + 1; } else if (this.radioExitLoad.IsChecked.HasValue && this.radioExitLoad.IsChecked.Value) { ExitLoadArea exitLoadAreaMessage = new ExitLoadArea(); exitLoadAreaMessage.RFIDDeviceAddress = this.txtRFIDDeviceAddressExitLoad.Text.Trim(); exitLoadAreaMessage.RFIDDeviceAntennaID = this.txtRFIDDeviceAntennaIDExitLoad.Text.Trim(); exitLoadAreaMessage.RFIDDeviceID = this.txtRFIDDeviceIDExitLoad.Text.Trim(); exitLoadAreaMessage.RFIDTagEPC = this.txtRFIDTagEPCExitLoad.Text.Trim(); exitLoadAreaMessage.PartNumber = this.txtPartNumberExitLoad.Text.Trim(); exitLoadAreaMessage.TimeStamp = DateTime.Parse(this.txtTimestampExitLoad.Text.Trim()); exitLoadAreaMessage.UID = int.Parse(this.txtUniqueIdExitLoad.Text.Trim()); messageToSend = this.SerializeObject <ExitLoadArea>(exitLoadAreaMessage); //Increment unique id on each message send this._uniqueIdExitLoad = this._uniqueIdExitLoad + 1; } if (!string.IsNullOrWhiteSpace(messageToSend)) { MQMessageStatus messageStatus = _manager.WriteLocalQMsg(messageToSend, this.txtPutQueue.Text.Trim()); if (messageStatus.Status) { MessageBox.Show(messageStatus.Message, "Information"); //Clear the existing data from the fields this.ClearFields(); this.txtUniqueIdPartDelivered.Text = this._uniqueIdPartDelivered.ToString(); this.txtUniqueIdPartReorder.Text = this._uniqueIdPartOrdered.ToString(); this.txtUniqueIdEntryLoad.Text = this._uniqueIdEntryLoad.ToString(); this.txtUniqueIdExitLoad.Text = this._uniqueIdExitLoad.ToString(); //this.btnRetrieveMessage.IsEnabled = true; } else { if (!string.IsNullOrWhiteSpace(messageStatus.Message)) { MessageBox.Show(messageStatus.Message, "Error"); } else { MessageBox.Show("Some error occured while queuing the message", "Error"); } } } else { MessageBox.Show("No message available to queue", "Info"); } }