//Processing the order placed in the buffer public void processOrderQueue() { string orderString = null; int hotelId; while (true) { //retrieving the order from the buffer orderString = Program.orderBuffer.deQueueOrder(); //Split to seperate encoded value from the date. string[] orderStringSplit = Regex.Split(orderString, "\t"); //Decode order from multi-buffer orderString = EncodeDecode.decodeOrder(orderStringSplit[0], "ABCDEFGHIJKLMNOP"); orderString = orderString + "::" + orderStringSplit[1]; // Create new string with decoded value and date. Console.WriteLine("Order Dispatcher: Processing Order: " + orderString); //Code to figure out which hotel's order.... and dispatch event hotelId = getHotelIdFromOrderString(orderString); if (orderReceivedEvent != null) { orderReceivedEvent(hotelId, orderString); } } }
//placing the order for rooms private void placeOrder(int hotelId) { // new order object Order order = new Order(this.agencyId, hotelId, this.agencyCardNo, this.noOfRooms); string orderString = order.toString(); string encodedOrderString = EncodeDecode.encodeOrder(orderString, "ABCDEFGHIJKLMNOP"); //Encoding order string encodedOrderStringWithDate = attachTimeStamp(encodedOrderString); //Attach timestamp when order placed. Program.orderBuffer.enQueueOrder(encodedOrderStringWithDate); //Adding order to the buffer Console.WriteLine("OrderFormat-> AgencyId:HotelId:creditcardNo:RoomsOrdered"); Console.WriteLine("Agency[" + agencyId.ToString() + "]: " + "Placed Order " + orderString + " for Hotel[" + hotelId.ToString() + "]"); }