Пример #1
0
        /// <summary>
        /// Create/ Send messages to MSMQ
        /// </summary>
        public void SendPendingMessage(PendingBooking pb, UpdatedBooking ub, BlockBooking bb)
        {
            //int start = 0;
            int     maxNumberofqueues = queueLists.Count - 1;
            Message message           = new Message();

            message.Recoverable = true;
            if (pb != null)
            {
                message.Body  = pb;
                message.Label = "pending";
            }
            else if (ub != null)
            {
                message.Body  = ub;
                message.Label = "update";
            }
            else if (bb != null)
            {
                message.Body  = bb;
                message.Label = "blockbooking";
            }
            mq = queueLists[bookingCounter];
            logger.Debug("message sending to " + mq.Path);
            logger.Debug("message: " + message.ToString());
            mq.Send(message);
            if (bookingCounter == maxNumberofqueues)
            {
                bookingCounter = 0;
            }
            else
            {
                bookingCounter++;
            }
        }
Пример #2
0
 public void EnqueueUpdatedMSSBooking(UpdatedBooking updatedBooking)
 {
     if (!updatedBookingsQueue.Any(x => x != null && x.MeetingKey == updatedBooking.MeetingKey))
     {
         updatedBookingsQueue.Enqueue(updatedBooking);
         logger.Info("Updated booking added to its concurrent queue successfully");
     }
 }
Пример #3
0
        private void MyReceiveCompleted(Object source, ReceiveCompletedEventArgs asyncResult)
        {
            // Connect to the queue.
            mq = (MessageQueue)source;
            try
            {
                Message              msg = mq.EndReceive(asyncResult.AsyncResult);
                PendingBooking       pb  = null;
                UpdatedBooking       ub  = null;
                BlockBooking         bb  = null;
                ChangedAppointment   ca  = null;
                CancelledAppointment cancelledAppointment = null;
                string label = (string)msg.Label;
                logger.Info("label created fine"); //temp changes should be removed
                if (label == "pending")
                {
                    msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(PendingBooking) });
                    logger.Info("pending formatter  created fine");//temp changes should be removed
                    pb = (PendingBooking)msg.Body;
                    logger.Info("#STPendingSAR# " + pb.MeetingKey + " " + DateTime.UtcNow.Ticks);
                    logger.Info("pendingbookin conversion  created fine");          //temp changes should be removed
                                                                                    // Display the message information on the screen.
                    logger.Info("pendingbooking meeting key" + pb.MeetingKey);      //temp changes should be removed
                    logger.Info("PendingBookingList Status " + PendingBookingList); //temp changes should be removed
                    logger.Info("#STPendingSAEN# " + pb.MeetingKey + " " + DateTime.UtcNow.Ticks);
                    EnqueuePendingBooking(pb);
                }
                else if (label == "update")
                {
                    msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(UpdatedBooking) });
                    logger.Info("update formatter  created fine");  //temp changes should be removed
                    ub = (UpdatedBooking)msg.Body;
                    logger.Info("update conversion  created fine"); //temp changes should be removed
                                                                    // Display the message information on the screen.
                    EnqueueUpdatedMSSBooking(ub);
                }
                else if (label == "Create Appointment" || label == "Update Appointment")
                {
                    msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(ChangedAppointment) });
                    logger.Info("Appointment formatter  created fine");  //temp changes should be removed
                    ca = (ChangedAppointment)msg.Body;
                    logger.Info("Appointment conversion  created fine"); //temp changes should be removed

                    EnqueueChangedAppointment(ca);
                }
                else if (label == "Delete Appointment")
                {
                    logger.Info("start reading deleted appointment");
                    msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(CancelledAppointment) });
                    logger.Info("Appointment formatter  created fine");
                    cancelledAppointment = (CancelledAppointment)msg.Body;
                    logger.Info("Appointment conversion  created fine");

                    EnqueueCancelledAppointment(cancelledAppointment);
                }
                else if (label == "blockbooking")
                {
                    msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(BlockBooking) });
                    logger.Info("Block booking formatter created successfully");
                    bb = (BlockBooking)msg.Body;
                    logger.Info("Block booking conversion was successful"); //temp log
                    EnqueueBlockBooking(bb);
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error in ReceiveComplete Event : Block Booking - Exception = " + ex.StackTrace + " " + ex.Message);
            }
            mq.BeginReceive();
        }