public string GetStatus(ObjectMakeCDResponse response)//bad name: confirm order { string UserID = response.userID.ToString(); var user =UserDB.GetUserByUserID(UserID); var orderID=user.addOrder(); var thread = new Thread(() => { var transportadora = new TransportadoraServiceClient(); var request = new TransportadoraServiceReference.TransportJobRequest(); request.DeliveryAdress = response.DeliveryAdress; request.Distance = response.Distance; request.encomendaID = orderID; request.userID = UserID; request.fabrica = response.fabrica; transportadora.TransportJob(request); }); thread.Start(); return "ack"; }
//bad name: confirm order public string GetStatus(ObjectMakeCDResponse response) { var userId = response.userID.ToString(CultureInfo.InvariantCulture); var user =UserDB.GetUserByUserID(userId); var orderId = user.addOrder(); var thread = new Thread(() => { var transportadora = new TransportadoraServiceClient(); var request = new TransportJobRequest { DeliveryAdress = response.DeliveryAdress, Distance = response.Distance, encomendaID = orderId, userID = userId, fabrica = response.fabrica }; transportadora.TransportJob(request); }); thread.Start(); return "ack"; }
public OrderStatus RequestOrder(OrderInfo order) { var thread = new Thread(() => { BackOfficeCallBackService.orderList.Add(order); //add to cdfactory var inboxMessage = new CDFactory.SongsByOrder { OrderId = BackOfficeCallBackService.orderList.IndexOf(order).ToString(), TrackList = new List<CDFactory.Track>() }; foreach (var track in order.orderedTracks) { var newTrack = new CDFactory.Track { ArtisName = track.ArtisName, Price = track.Price, PriceFormatted = track.PriceFormatted, TrackName = track.TrackName }; inboxMessage.TrackList.Add(newTrack); } MessageQueueHelper.SendMessage(InboxQueuePath, inboxMessage, "Order to Process"); //get quotes from fabricantes IAdapterFabricantes adapterA = new AdapterFabricanteA(new FabricanteAServiceClient()); adapterA.getPrice(order); IAdapterFabricantes adapterB = new AdapterFabricanteB(new FabricanteBServiceClient()); adapterB.getPrice(order); IAdapterFabricantes adapterC = new AdapterFabricanteC(new FabricanteCServiceClient()); adapterC.getPrice(order); //get quotes from transportadora TransportadoraServiceClient transp = new TransportadoraServiceClient(); TransportJobPriceRequest requestA =new TransportJobPriceRequest(); requestA.DeliveryAdress = order.morada; requestA.Distance = GeocodingHelper.GetDistanceBetweenPlaces(order.morada, fabricaA); requestA.fabrica = "fabrica a"; requestA.userID = order.userID; transp.TransportJobPrice(requestA); TransportJobPriceRequest requestB = new TransportJobPriceRequest(); requestB.DeliveryAdress = order.morada; requestB.Distance = GeocodingHelper.GetDistanceBetweenPlaces(order.morada, fabricaB); requestB.fabrica = "fabrica b"; requestB.userID = order.userID; transp.TransportJobPrice(requestB); TransportJobPriceRequest requestC = new TransportJobPriceRequest(); requestC.DeliveryAdress = order.morada; requestC.Distance = GeocodingHelper.GetDistanceBetweenPlaces(order.morada, fabricaC); requestC.fabrica = "fabrica c"; requestC.userID = order.userID; transp.TransportJobPrice(requestC); //select fabricante and tell transportadora qhere to get cd and where to deliver while (order.all3Received()==false) { System.Console.WriteLine("Waiting for CallBacks to Select the best Manufacturer"); Thread.Sleep(1000); } //TransportJobRequest request = new TransportJobRequest(); switch (order.getbestdeal()) { case("fabrica a"): order.distance = GeocodingHelper.GetDistanceBetweenPlaces(order.morada, fabricaA); order.userID = UserDB.GetLoggedInUsers().First().UserId; // "1"; adapterA.setOrder(order); //request.DeliveryAdress = order.morada; //request.Distance= requestA.Distance; //request.encomendaID = order.encomendaid; //request.fabrica="fabrica a"; //request.userID = order.userID; //transp.TransportJob(request); break; case ("fabrica b"): order.distance = GeocodingHelper.GetDistanceBetweenPlaces(order.morada, fabricaC); order.userID = UserDB.GetLoggedInUsers().First().UserId; adapterB.setOrder(order); //request.DeliveryAdress = order.morada; //request.Distance= requestA.Distance; //request.encomendaID = order.encomendaid; //request.fabrica="fabrica b"; //request.userID = order.userID; //transp.TransportJob(request); break; case ("fabrica c"): order.distance = GeocodingHelper.GetDistanceBetweenPlaces(order.morada, fabricaB); order.userID = UserDB.GetLoggedInUsers().First().UserId; adapterC.setOrder(order); //request.DeliveryAdress = order.morada; //request.Distance= requestA.Distance; //request.encomendaID = order.encomendaid; //request.fabrica="fabrica c"; //request.userID = order.userID; //transp.TransportJob(request); break; default: break; } }); thread.Start(); return new OrderStatus { status = "Encomenda Recebida" }; }