/// <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(); }
/// <summary> /// The Function that actually processes an order, Validates Order with the BankService and returns a confirmation. /// </summary> /// <param name="encoded_order_object">The encoded OrderObject string to process as an OrderObject, once it is decoded of course.</param> public static void orderProcessor(string encoded_order_object) { //Decode string into an object: OrderObject new_order_object = EnDecoder.Decode(encoded_order_object); //Update total amount to account for Sales tax: decimal total = BankService.formatCurrency((new_order_object.getAmount() + (new_order_object.getAmount() * SALES_TAX))); new_order_object.setAmount(total); //Create an encryption service via ASU's Repo: Service encryption = new Service(); //Encrypt the credit card number: string encrypted_cc_number = encryption.Encrypt(Convert.ToString(new_order_object.getCardNo())); //encrypt the total amount to charge the account: string encrypted_amount = encryption.Encrypt(Convert.ToString(new_order_object.getAmount())); //Have Bank validate the Account charge given the encrypted credit card number and amount to charge: new_order_object.setIsValid(BankService.confirmCreditCard(encrypted_cc_number, encrypted_amount)); //Get the Travel_agencies ID: string travel_agency_id = new_order_object.getSenderID(); //Encode the Processed Order Object: string encoded_processed_order = EnDecoder.Encode(new_order_object); //Create a new thread to handle the processed order: OrderProcessing.submitProcessedOrderObject(encoded_processed_order, travel_agency_id); Thread processed_order_thread = new Thread(() => OrderProcessing.submitProcessedOrderObject(encoded_processed_order, travel_agency_id)); //Start the thread: processed_order_thread.Start(); }
/// <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); }