Esempio n. 1
0
        /// <summary>
        /// This takes an OrderObject to be confirmed, and creates a timestamp of when this is called as well as writing to Console
        /// </summary>
        /// <param name="order_confirm">The OrderObject retreived from the ProcessedOrder MultiCellBuffer.</param>
        private void confirmOrder(OrderObject order_confirm)
        {
            string timeStamp = DateTime.Now.ToString(); //Create a time stamp for when order is confirmed

            //Print Order Confirmation received message:
            Console.WriteLine("Travel Agency {0} received a new order confirmation:", this.agency_id);

            //Print header and Body of Order Confirmation Receipt:
            Console.WriteLine("---------------------------------");
            Console.WriteLine("Order Confirmation:");
            Console.WriteLine("Agency ID: {0}", order_confirm.getSenderID());
            Console.WriteLine("Hotel ID: {0}", order_confirm.getReceiverID());
            Console.WriteLine("Rooms Ordered: {0}", order_confirm.getNumberOfRoomsOrdered());
            Console.WriteLine("Room Price: {0}", order_confirm.getUnitPrice());
            Console.WriteLine("Total(+tax): {0}", order_confirm.getAmount());
            if (order_confirm.isValid())
            {
                Console.WriteLine("Order Confirmation: VALID");
            }
            else
            {
                Console.WriteLine("Order Confirmation: NOT VALID");
            }

            //Footer of the Order Confirmation Receipt:
            Console.WriteLine("TimeStamp: {0}", timeStamp);
            Console.WriteLine("---------------------------------");
            Console.WriteLine();
        }
Esempio n. 2
0
        /// <summary>
        /// This function takes in an OrderObject and "encodes" it into a string format.
        /// </summary>
        /// <param name="orderObj">The OrderObject to encode into a string.</param>
        /// <returns>The "encoded" string representation of the OrderObject passed in.</returns>
        public static String Encode(OrderObject orderObj)
        {
            //Generate the new string to be the "encoded" orderObject:
            string orderObj_toString = orderObj.getSenderID();

            orderObj_toString += (" " + orderObj.getReceiverID());
            orderObj_toString += (" " + orderObj.getCardNo());
            orderObj_toString += (" " + orderObj.getAmount());
            orderObj_toString += (" " + orderObj.getUnitPrice());

            //Return the encoded String of the orderObject passed in:
            return(orderObj_toString);
        }
Esempio n. 3
0
        /// <summary>
        /// This takes an OrderObject and encrypts it into a string.
        /// </summary>
        /// <param name="order">The OrderObject to place an order with.</param>
        private void placeOrder(OrderObject order)
        {
            //Get the ID of the hotel who will receive this order for processing:
            string hotel_id = order.getReceiverID();

            //encrypt the orderobject into a string:
            string encrypted_order = EnDecoder.Encode(order);


            //Create a new OrderProcessing thread to handle the unprocessed order:
            Thread place_order_thread = new Thread(() => OrderProcessing.submitOrderToProcess(encrypted_order, hotel_id));

            //Start the thread:
            place_order_thread.Start();
        }