Пример #1
0
        /// <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();
        }
Пример #2
0
        /// <summary>
        /// This takes the ID of the TravelAgency it will be processing for and checks for correct destination. It then processes the order and confirms it.
        /// </summary>
        /// <param name="travel_agency_id">The travelAgency id that was emitted </param>
        public void processedOrder(string travel_agency_id)                                      //Method to check if order was meant for specific travel agency and confirm it
        {
            if (travel_agency_id == this.agency_id)                                              //Basic check for correct agency ID
            {
                string encryptedOrder = OrderProcessing.getProcessedOrderObject(this.agency_id); //Encrypted order is retrieved from OrderProcessing

                OrderObject newOrder = EnDecoder.Decode(encryptedOrder);                         //decrypt order via decode method in EnDecoder

                confirmOrder(newOrder);                                                          //confirm the order of the neworder that was created (and also holds timestamp!)
            }
        }
Пример #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();
        }