/*validate credit card*/
        public static Boolean validateCard(String card)
        {
            encryptionService.ServiceClient decrypt = new encryptionService.ServiceClient();
            Boolean found = false;

            for (int i = 0; i < 5; i++)
            {
                if (decrypt.Decrypt(card) == creditCardNumbers[i])
                {
                    found = true;
                }
            }
            return(found);
        }
Пример #2
0
        //processes the order by checking the available rooms and validating credit card with BankService
        void processOrder(Object x)
        {
            try
            {
                float price1 = roomPrice;
                Order o      = (Order)x;
                encryptionService.ServiceClient encrypt = new encryptionService.ServiceClient();
                int    orderID      = o.getOrderId();
                int    agencyID     = o.getAgencyId();
                int    hotelID      = o.getHotelId();
                int    roomsOrdered = o.getRooms();
                float  quotedPrice  = o.getQuotePrice();
                float  totalPrice   = quotedPrice * roomsOrdered;
                String cardNo       = o.getCardNo();

                String success = "Order " + orderID + " booked with " + hotelID + " for " + roomsOrdered + " rooms was processed successfully with a total of $" + totalPrice;
                //String failure = "Order " + orderID + " for Agency " + agencyID + " failed to proccess";


                lock (this)
                {
                    //Console.WriteLine("Thread{2} : Orderporcess ..{0}..,{1}", quotedPrice, roomPrice,Thread.CurrentThread.ManagedThreadId);
                    //Console.WriteLine("OrderProcess***********" + this);
                    if (BankService.validateCard(encrypt.Encrypt(cardNo)) == false)
                    {
                        ReceiptBuffer.setBuffer(agencyID, "The card number for Order " + orderID + " booked with Hotel " + hotelID + " is invalid");
                    }
                    else if (roomsOrdered > roomsAvailable)
                    {
                        ReceiptBuffer.setBuffer(agencyID, "The number of rooms ordered in Order " + orderID + " booked with " + hotelID + " is greater than the available rooms");
                    }
                    else if ((int)quotedPrice != (int)price1)
                    {
                        //Console.WriteLine("Thread:"+Thread.CurrentThread.ManagedThreadId+" Orderporcess ..The quoted price for Order " + orderID + " for Agency " + agencyID + " of $" + quotedPrice + " does not match the current price of $" + roomPrice);
                        ReceiptBuffer.setBuffer(agencyID, "The quoted price for Order " + orderID + " booked with Hotel " + hotelID + " of $" + quotedPrice + " does not match the current price of $" + price1);
                    }
                    else
                    {
                        roomsAvailable = roomsAvailable - roomsOrdered;
                        ReceiptBuffer.setBuffer(agencyID, success);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }