Exemple #1
0
 public static String encoder(OrderClass order)
 {
     if (order != null)
     {
         String orderId      = order.getOrderId().ToString() + "&";
         String senderId     = order.getSenderId().ToString() + "#";
         String cardNo       = order.getCardNo().ToString() + "$";
         String unitPrice    = order.getUnitPrice().ToString() + "?";
         String amountOfRoom = order.getAmt().ToString() + "%";
         String senderTime   = order.getSenderTime().ToString() + "@";
         String str          = orderId + senderId + cardNo + unitPrice + amountOfRoom + senderTime;
         HotelBookingSystem.CryptService.ServiceClient encrypt = new HotelBookingSystem.CryptService.ServiceClient();
         //               Console.WriteLine("string: {0}, encoded: {1}", order, encrypt.Encrypt(str));
         return(encrypt.Encrypt(str));
     }
     else
     {
         return("Null order!");
     }
 }
Exemple #2
0
        public void orderProcessing()
        {
            String orderString;

            while (true)
            {
                orderString = Program.mcb.getOneCell();
                OrderClass orderObj = Coder.decoder(orderString);
                Monitor.Enter(roomPrice);
                if (HotelSupplier.checkCreditCardNumber(orderObj.getCardNo()))
                {
                    double amountOfCharge = orderObj.getUnitPrice() * orderObj.getAmt() + taxRate * orderObj.getUnitPrice() * orderObj.getAmt() + locationCharge;
                    orderObj.setReceiveTime(DateTime.Now);
                    if (orderCompleted != null)
                    {
                        orderCompleted(orderObj, amountOfCharge);
                    }
                }
                Monitor.Exit(roomPrice);
            }
        }
Exemple #3
0
 public void receiveTime(OrderClass orderObj, Double amountOfCharge)
 {
     orderObj.setReceiveTime(DateTime.Now);
     Console.WriteLine();
     Console.WriteLine("Order ID: {0}, Agency ID: {1}, UnitPrice of Room: {2}, Amount of Room: {3}, Amount of Charge: {4}, Start Time: {5}, Completed Time: {6}, Time to process the order: {7}", orderObj.getOrderId(), orderObj.getSenderId() + 1, orderObj.getUnitPrice().ToString("f0"), orderObj.getAmt(), amountOfCharge.ToString("f0"), orderObj.getSenderTime(), orderObj.getReceiveTime(), (orderObj.getReceiveTime() - orderObj.getSenderTime()));
     pricecutLockCounter++;
     if (pricecutLockCounter == 10)
     {
         pricecutLock.Event.Set();
         pricecutLockCounter = 0;
         //            Console.WriteLine("Order ID: {0}, Agency ID: {1}, Unit Price: {3}, Amount of Room: {2}, Amount of Charge: {4}, Start Time: {5}, Completed Time: {6}, Time to process the order: {7}", orderObj.getOrderId(), orderObj.getSenderId() + 1, orderObj.getAmt(), roomPrice.price, amountOfCharge, orderObj.getSenderTime(), orderObj.getReceiveTime(), (orderObj.getReceiveTime() - orderObj.getSenderTime()));
         //            if (orderObj.getPriceCutId()<10)
         //                Console.WriteLine("No.{8} Price-cut, Order ID: {0}, Agency ID: {1}, Unit Price: {3}, Amount of Room: {2}, Amount of Charge: {4}, Start Time: {5}, Completed Time: {6}, Time to process the order: {7}", orderObj.getOrderId(), orderObj.getSenderId() + 1, orderObj.getAmt(), roomPrice.price, amountOfCharge, orderObj.getSenderTime(), orderObj.getReceiveTime(), (orderObj.getReceiveTime() - orderObj.getSenderTime()), orderObj.getPriceCutId() + 1);
     }
 }