static void Main(string[] args)
        {
            WebSphereLibTest obj = new WebSphereLibTest();

            PartDeliveredMessage partDeliveredMessage = new PartDeliveredMessage();

            partDeliveredMessage.MessageType = MessageType.PartDelivered;
            partDeliveredMessage.RouteColor  = RouteColor.Red;
            partDeliveredMessage.PartNumber  = "100";
            partDeliveredMessage.Timestamp   = DateTime.Now;
            partDeliveredMessage.UID         = 1;

            string xmlPartDeliveredMessage = obj.SerializeObject <PartDeliveredMessage>(partDeliveredMessage);

            PartReorderMessage partReorderMessage = new PartReorderMessage();

            partReorderMessage.MessageType = MessageType.PartReorder;
            partReorderMessage.RouteColor  = RouteColor.Blue;
            partReorderMessage.PartNumber  = "101";
            partReorderMessage.Timestamp   = DateTime.Now;
            partReorderMessage.UID         = 1;

            string xmlPartReorderMessage = obj.SerializeObject <PartReorderMessage>(partReorderMessage);

            MQManager myMQ = new MQManager();

            string strQueueManagerName = string.Empty;
            string strQueueName        = string.Empty;
            string strChannelInfo      = string.Empty;
            string getQueueName        = string.Empty;
            string putQueueName        = string.Empty;
            string putText             = string.Empty;


            //strQueueManagerName = "queuemanager";
            //strQueueName = "omniIdQueue";
            //strChannelInfo = "SYSTEM.ADMIN.SVRCONN/TCP/192.168.10.221(1414)";
            //getQueueName = "omniIdQueue";
            //putQueueName = "omniIdQueue";
            //putText = xmlPartDeliveredMessage;

            //var connectStatus = myMQ.ConnectMQ(strQueueManagerName, strChannelInfo);


            //var writeStatus = myMQ.WriteLocalQMsg(putText, putQueueName);
            //var getStatus = myMQ.ReadLocalQMsg(getQueueName);
        }
示例#2
0
        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");
            }
        }