//Event handler for order confirmation public void orderConfirmationEvent(OrderClass confirmedOrder) { //only attempt to move order from sent to confirmed after making sure //the order sender id matches the thread sender id //otherwise it is someonelse's order if (confirmedOrder.getID() == senderId.ToString()) { //search for the confirmed order for (int s = 0; s < sentOrders.Count; s++) { if (sentOrders.ElementAt(s).getOrderId() == confirmedOrder.getOrderId()) { Console.WriteLine("Order ({0}) Confirmation Received", confirmedOrder.ToString()); orderFinish[s] = DateTime.Now; //move from sent orders to confirmed orders confirmedOrders.Add(confirmedOrder); // trace events caught //sentOrders.RemoveAt(s); i will not remove the confirmed order from s in order to //maintain the correct order in which the orders were submitted so i can use //that index for the finish time stamp //TimeStamp for end of order s } } } }
//this class is an event listener that creates a new order and //adds it to the list of queued orders to be added to the buffer in the agencyFunc //THIS CALLBACK EVENT HANDLER NEEDS TO CHANGE SO I RECEIVE PREVIOUS PRICE AND CURRENT // Joern on 1/15/13 - previous price added public void priceCutEvent(int newPrice, int prevPrice) { if (orderNumber < 10) { //generate random room demand roomDemand = randDemand.Next(50, 100); //generate scaled demand for first order without previous price //assuming its a price drop of 10% tempDemand = ((double)prevPrice / (double)newPrice) * roomDemand; roomDemand = (int)tempDemand; //create new order; currentOrder.setnoRooms(roomDemand); currentOrder.setID(senderId.ToString()); currentOrder.setCardNo(senderId + 5000); currentOrder.setPrice((double)newPrice); currentOrder.setOrderID(senderId + "-" + orderNumber); orderNumber++; //add new order to pending list queuedOrders.Add(currentOrder); //reset current order currentOrder = new OrderClass(); //Console.WriteLine("Received : {0}", newPrice); //Console.WriteLine("Sender id = {0}", senderId); } }
public OrderProcessing(OrderClass order) { this.order = order; if (checkCardValidity() == true) { calculateTotal(); } else { Console.WriteLine("Card Number {0} invalid ", order.getCardNo()); } }
//Test method to verify encode/decode service with orderclass static Boolean testOrder() { OrderClass order = new OrderClass(); order.setAmt(123); order.setID("test"); order.setCardNo(456418); Encoder enc = new Encoder(order); String encoded = enc.getOrder(); Decoder dec = new Decoder(encoded); return order == dec.getOrder(); }
//Test method to verify encode/decode service with orderclass static Boolean testOrder() { OrderClass order = new OrderClass(); order.setAmt(123); order.setID("test"); order.setCardNo(456418); Encoder enc = new Encoder(order); String encoded = enc.getOrder(); Decoder dec = new Decoder(encoded); return(order == dec.getOrder()); }
public TravelAgency() { //instantiating necessary objects randDemand = new Random(); queuedOrders = new List<OrderClass>(); sentOrders = new List<OrderClass>(); confirmedOrders = new List<OrderClass>(); currentOrder = new OrderClass(); orderEncoder = new Encoder(); orderStart = new DateTime[10]; orderFinish = new DateTime[10]; orderNumber = 0; startNumber = 0; roomDemand = randDemand.Next(50, 100); mcb = new MultiCellBuffer(); }
public TravelAgency() { //instantiating necessary objects randDemand = new Random(); queuedOrders = new List <OrderClass>(); sentOrders = new List <OrderClass>(); confirmedOrders = new List <OrderClass>(); currentOrder = new OrderClass(); orderEncoder = new Encoder(); orderStart = new DateTime[10]; orderFinish = new DateTime[10]; orderNumber = 0; startNumber = 0; roomDemand = randDemand.Next(50, 100); mcb = new MultiCellBuffer(); }
public override bool Equals(object obj) { if (obj == null) { return(false); } OrderClass o = obj as OrderClass; if ((System.Object)o == null) { return(false); } return((amount == o.getAmt()) && (cardNo == o.getCardNo()) && senderId.Equals(o.getID())); }
public void setOrder(OrderClass s) { StringBuilder temp = new StringBuilder(); temp.Append(s.getAmt().ToString()); //Appends amount to string temp.Append(" "); temp.Append(s.getCardNo().ToString()); //Appends card number to string temp.Append(" "); temp.Append(s.getID().ToString()); //Appends ID to string temp.Append(" "); temp.Append(s.getOrderId().ToString()); //Appends orderId to string temp.Append(" "); temp.Append(s.getnoRooms().ToString()); //Appends number of rooms to string temp.Append(" "); temp.Append(s.getPrice().ToString()); //Appends price per room to string temp.Append(" "); order = temp.ToString(); //builds string EncryptionService.ServiceClient serviceClient = new EncryptionService.ServiceClient(); //Instantiates encryption service order = serviceClient.Encrypt(order); //encrypts string }
public Encoder(OrderClass s) { setOrder(s); //constructs an encoder with a class }
//Easy constructor public Decoder(String str) { s = new OrderClass(); setOrder(str); }
public Decoder() { s = new OrderClass(); }