Exemplo n.º 1
0
 private void WaitCashier(Cashier cashier)
 {
     System.Threading.Thread.Sleep(cashier.Time * 1000); //sleep
     OrderProcessing?.Invoke(this, new CashierEventArgs(cashier.Position, cashier.Time));
     //After cashier finish, he get new time
     cashier.Time = rnd.Next(1, 6);
 }
Exemplo n.º 2
0
 public OrderProcessingTest()
 {
     _promotionRepository = new Mock <IPromotionRepository>();
     _productRepository   = new Mock <IProductRepository>();
     _orderRepository     = new Mock <IOrderRepository>();
     orderProcessing      = new OrderProcessing(_promotionRepository.Object, _productRepository.Object, _orderRepository.Object);
 }
Exemplo n.º 3
0
        public async Task <IActionResult> PutOrderProcessing([FromRoute] long id, [FromBody] OrderProcessing orderProcessing)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != orderProcessing.ProcessingId)
            {
                return(BadRequest());
            }

            _context.Entry(orderProcessing).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderProcessingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public void When_Payment_Is_For_PhysicalProduct_Expect_Generate_Packing_Slip_And_Generate_Comission_Payment()
        {
            PhysicalProduct physicalProduct = new PhysicalProduct();

            OrderProcessing orderProcessing = new OrderProcessing(physicalProduct, _user);

            Assert.That(orderProcessing.ProcessOrder(), Is.True);
        }
        public void When_Payment_Is_For_Book_Expect_Generate_Packing_Slip_And_Generate_Comission_Payment_And_Create_Duplicate_Packing_Slip()
        {
            Book book = new Book();

            OrderProcessing orderProcessing = new OrderProcessing(book, _user);

            Assert.That(orderProcessing.ProcessOrder(), Is.True);
        }
        public void When_Payment_Is_For_Membership_Expect_Activate_The_Membership_And_Send_Email_To_Owner()
        {
            MembershipActivation membership = new MembershipActivation();

            OrderProcessing orderProcessing = new OrderProcessing(membership, _user);

            Assert.That(orderProcessing.ProcessOrder(), Is.True);
        }
        public void When_Payment_Is_To_Upgrade_Membership_Expect_Apply_The_Upgrade_And_Send_Email_To_Owner()
        {
            MembershipUpgradation membership = new MembershipUpgradation();

            OrderProcessing orderProcessing = new OrderProcessing(membership, _user);

            Assert.That(orderProcessing.ProcessOrder(), Is.True);
        }
        public void When_Payment_Is_For_Learning_To_Ski_Video_Expect_Add_Free_First_Aid_Video_To_Packing_Slip()
        {
            LearningSkiVideo learningSkiVideo = new LearningSkiVideo();

            OrderProcessing orderProcessing = new OrderProcessing(learningSkiVideo, _user);

            Assert.That(orderProcessing.ProcessOrder(), Is.True);
        }
            //pricecutevent emits an event and calls event handlers in Retailers
            //Implement a method for recieving order from multicellbuffer

            public void GetOrderfromBuffer(String val)
            {
                OrderClass order = new OrderClass();

                order = Retailer.Decoder(val);
                OrderProcessing obj = new OrderProcessing();

                obj.calculate(order);
            }
Exemplo n.º 10
0
        public IActionResult Post(List <Order> orders)
        {
            OrderProcessing process = new OrderProcessing(unitOfWork, _configruation);

            if (process.saveDataToContext(orders) && process.saveDataToFile(orders))
            {
                return(Ok("Success"));
            }
            return(BadRequest("Unexpected error occurred."));
        }
Exemplo n.º 11
0
        private static void ProcessOrder(Order order, Customer sender)
        {
            var orderInfo = new OrderInfo(order, sender);

            var shippingService = new ShippingService("US");
            var orderProcessing = new OrderProcessing(shippingService);

            orderProcessing.ShipOrder(orderInfo, order);

            SendInvoice(orderInfo);
        }
Exemplo n.º 12
0
        public async Task <IActionResult> PostOrderProcessing([FromBody] OrderProcessing orderProcessing)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Processings.Add(orderProcessing);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOrderProcessing", new { id = orderProcessing.ProcessingId }, orderProcessing));
        }
            public override void Finally()
            {
                OrderProcessing     __svc__  = (OrderProcessing)_service;
                __OrderProcessing_1 __ctx1__ = (__OrderProcessing_1)(__svc__._stateMgrs[1]);

                if (__ctx1__ != null && __ctx1__.__CustomerMessage != null)
                {
                    __ctx1__.UnrefMessage(__ctx1__.__CustomerMessage);
                    __ctx1__.__CustomerMessage = null;
                }
                if (__ctx1__ != null && __ctx1__.__OrderMessage != null)
                {
                    __ctx1__.UnrefMessage(__ctx1__.__OrderMessage);
                    __ctx1__.__OrderMessage = null;
                }
                base.Finally();
            }
            public override void Finally()
            {
                OrderProcessing          __svc__  = (OrderProcessing)_service;
                __OrderProcessing_root_0 __ctx0__ = (__OrderProcessing_root_0)(__svc__._stateMgrs[0]);

                if (__svc__.OrderPort != null)
                {
                    __svc__.OrderPort.Close(this, null);
                    __svc__.OrderPort = null;
                }
                if (__svc__.CustomerPort != null)
                {
                    __svc__.CustomerPort.Close(this, null);
                    __svc__.CustomerPort = null;
                }
                base.Finally();
            }
Exemplo n.º 15
0
        public void testRuleForVideoLearningtoSki()
        {
            Order ordUpgradeMembership = new Order
            {
                OrderID   = 001,
                OrderDate = DateTime.Now,
                PType     = PaymentType.Video
            };
            OrderProcessing orderProcessingService = new OrderProcessing();

            orderProcessingService.ProcessOrder(ordUpgradeMembership);
            List <string> checkList = new List <string>()
            {
                "Add Free Aid Video To Packing Slip"
            };

            Assert.AreEqual(checkList[0], Constants.OrderStatuses[0]);
        }
        // Airline thread calls the function
        public void UpdatePrice()
        {
            // No of Price cuts
            while (NumOfPriceCut < 6)
            {
                if (PriceCounter == 5)
                {
                    Int32 p = rng.Next(100, 900);
                    Console.WriteLine("* * * * * * New Price Is : " + p + " * * * * * * * *");
                    PriceCounter = 0;

                    if (p < FlightTicket)
                    {
                        NumOfPriceCut++;
                    }
                    TravelAgents.oldTicket = FlightTicket;
                    TravelAgents.newTicket = p;
                    Airlines.changePrice(p);
                }


                rwObj1.AcquireWriterLock(1000);
                try
                {
                    String en_order = MCB.getOneCell();//gets the order string from the  buffer
                    PriceCounter++;

                    OrderClass orderObject = Decoder(en_order); //Convert the string order to order object

                    OrderProcessing opObj = new OrderProcessing();
                    //Console.WriteLine(orderObject.SenderId);
                    Thread orderProcessing = new Thread(() => opObj.orderP(orderObject));
                    orderProcessing.Start();
                    // orderProcessing.Join();
                }

                finally { rwObj1.ReleaseWriterLock(); }

                if (NumOfPriceCut > 5)
                {
                    Console.WriteLine("The Airlines thread will terminate - No of price cuts completed"); //Print before termination of  thread
                }
            }
        } //End of method
Exemplo n.º 17
0
        public void testRuleForUpgradeToMembership()
        {
            Order ord = new Order
            {
                OrderID   = 001,
                OrderDate = DateTime.Now,
                PType     = PaymentType.UpgradeMembership
            };
            OrderProcessing orderProcessingService = new OrderProcessing();

            orderProcessingService.ProcessOrder(ord);
            List <string> checkList = new List <string>()
            {
                "Membership Upgrade",
                "Send Activation Email to User"
            };

            Assert.AreEqual(checkList[0], Constants.OrderStatuses[0]);
            Assert.AreEqual(checkList[1], Constants.OrderStatuses[1]);
        }
Exemplo n.º 18
0
        public void testRulePaymentForBook()
        {
            Order ord = new Order
            {
                OrderID   = 001,
                OrderDate = DateTime.Now,
                PType     = PaymentType.Book
            };
            OrderProcessing orderProcessingService = new OrderProcessing();

            orderProcessingService.ProcessOrder(ord);
            List <string> checkList = new List <string>()
            {
                "Generate Dulicate Packing Slip",
                "Generate Comission Payment To Agent"
            };

            Assert.AreEqual(checkList[0], Constants.OrderStatuses[0]);
            Assert.AreEqual(checkList[1], Constants.OrderStatuses[1]);
        }
Exemplo n.º 19
0
        protected void btnCheckout_Click(object sender, EventArgs e)
        {
            var    shoppinginstance = ShoppingCart.GetShoppingCart();
            string message          = string.Empty;

            CalculateTax.AbstractTaxFactory abstractTaxFactory = new ShoppingCartApplication.Business.CalculateTax.TaxFactory();
            if (!string.IsNullOrWhiteSpace(lblTotalAmount.Text))
            {
                //Calculate Total Amount After Tax based on the State code Selected
                TotalAmountAfterTax =
                    abstractTaxFactory.CalculateTax(drpStateCode.SelectedValue, Convert.ToDouble(lblTotalAmount.Text)).TotalTax;

                lblTaxLabel.Visible            = true;
                lblTotalAmountAfterTax.Visible = true;
                lblTotalAmountAfterTax.Text    = TotalAmountAfterTax.ToString();
                btnCheckout.Visible            = true;

                OrderProcessing orderProcessing = new OrderProcessing();
                orderProcessing.OrderProcessWorkFlow(shoppinginstance.SelectedItems, TotalAmountAfterTax);
                //string  message = orderProcessing.GetInvoice();
                message = "Invoice Successfully Generate for a bill amount: " + TotalAmountAfterTax.ToString();
            }
            else
            {
                message = "Your cart is empty!";
            }
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<script type = 'text/javascript'>");
            sb.Append("window.onload=function(){");
            sb.Append("alert('");
            sb.Append(message);
            sb.Append("')};");
            sb.Append("</script>");
            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
            //Server.Transfer("~\\ShoppingDetails\\Invoice.aspx");
        }
Exemplo n.º 20
0
    public void CreateObj(GameObject obj, int id, OrderProcessing linkOnFood)
    {
        if (GetComponent <SavedItem>().objOnTable == null)
        {
            test = Instantiate(obj, GetComponent <SavedItem>().placeObj.transform.position, transform.rotation);
            test.transform.SetParent(GetComponent <SavedItem>().placeObj.transform);
            GetComponent <SavedItem>().objOnTable = test;
            GetComponent <SavedItem>().canTake    = true;

            orderId      = GetComponent <SavedItem>().objOnTable.AddComponent <IdTable>();
            orderId.id   = id;
            orderId.link = linkOnFood;

            if (GetComponent <OrderProcessing>() != null)
            {
                transform.GetComponent <OrderProcessing>().readyFood = test;         // сохраняем сылку на заказ
            }

            else
            {
                linkOnFood.readyFood = test;
            }
        }
    }
        public static async Task <MachineRunResults> ProcessResults([ActivityTrigger] List <MachineRun> machines,
                                                                    [ServiceBus("orders", Connection = "ServiceBusConnection")] ICollector <string> orderOutput,
                                                                    [ServiceBus("logs", Connection = "ServiceBusConnection")] ICollector <string> logOutput,
                                                                    ILogger log)
        {
            log.LogDebug("starting run log");


            try
            {
                using (IDbConnection conn = new SqlConnection(Environment.GetEnvironmentVariable("SqlConnection")))
                {
                    var orderRepo  = new OrderRepository(conn);
                    var openOrders = orderRepo.GetOpenOrders().Result;

                    //store initial results
                    var results = new MachineRunResults(machines, openOrders.ToList());
                    results.OrderEnd = new List <Order>();

                    foreach (var order in openOrders.OrderBy(o => o.CreateDate))
                    {
                        var result = OrderProcessing.RunMachines(order, machines);

                        results.OrderEnd.Add(result.Order);
                        results.SmashedCount     += result.SmashedCount;
                        results.SlashedCount     += result.SlashedCount;
                        results.TrashedCount     += result.TrashedCount;
                        results.WidgetsDestroyed += result.WidgetsDestroyed;

                        machines = results.MachineRuns;

                        bool fixOffByOne = false;

                        if (order.PendingCount < 0)
                        {
                            fixOffByOne = true;

                            if (order.SmashedCount > -(order.PendingCount))
                            {
                                order.SmashedCount += order.PendingCount;
                                order.PendingCount  = 0;
                            }
                            else if (order.SlashedCount > -(order.PendingCount))
                            {
                                order.SlashedCount += order.PendingCount;
                                order.PendingCount  = 0;
                            }
                            else
                            {
                                order.CompletedCount += order.PendingCount;
                                order.PendingCount    = 0;
                            }
                        }

                        if (order.SmashedCount < 0)
                        {
                            fixOffByOne         = true;
                            order.PendingCount += order.SmashedCount;
                            order.SmashedCount  = 0;
                        }

                        if (order.SlashedCount < 0)
                        {
                            fixOffByOne         = true;
                            order.PendingCount += order.SlashedCount;
                            order.SlashedCount  = 0;
                        }

                        if (result.SlashedCount > 0 || results.SmashedCount > 0 || results.TrashedCount > 0 || results.WidgetsDestroyed > 0 || fixOffByOne)
                        {
                            var orderUpdate = orderRepo.UpdateOrder(result.Order).Result;


                            orderOutput.Add(JsonConvert.SerializeObject(result.Order,
                                                                        new JsonSerializerSettings
                            {
                                ContractResolver = new CamelCasePropertyNamesContractResolver()
                            }));
                            logOutput.Add($"{TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("US Eastern Standard Time")).ToLongTimeString()} Order updated. Id: {result.Order.Id}, (SM: {result.SmashedCount}, SL: {result.SlashedCount}, TR: {result.TrashedCount}, Failed: {result.WidgetsDestroyed})");
                        }
                    }

                    log.LogWarning($"Processing Complete {results.SmashedCount}, {results.SlashedCount}, {results.TrashedCount}, {results.WidgetsDestroyed}");

                    return(results);
                }
            }
            catch (Exception e)
            {
                log.LogError(e.Message);
            }

            return(null);
        }
Exemplo n.º 22
0
 // Function called when the MultiCellBuffer class emits an OrderSubmit() event.
 // Airline gets the encoded order, decodes it, then sends it to OrderProcessing to be completed.
 public void OnOrderSubmitted(object sender, EventArgs e)
 {
     try
     {
         string encodedOrderString;
         OrderObject decodedOrder;
         encodedOrderString = buffer.getOneCell();
         decodedOrder = Decoder.decodeOrder(encodedOrderString);
         OrderProcessing orderProcessor = new OrderProcessing(decodedOrder);
         // Process the order in a thread.
         Thread t1 = new Thread(orderProcessor.processOrder);
         t1.Start();
     }
     catch(Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Exemplo n.º 23
0
        /// <summary>
        /// runPublisher -- This method is the method that will be executed in the thread.
        /// The publisher does:
        /// 1) Check the multicell buffer for orders
        /// 2) if order, then read, and processed by executing a OrderProcess Thread
        /// 3) Check warehouse for book quality
        /// 4) calcuate the new price
        /// 5) Schedule an event on price if the reduction is greater thatn 25%
        /// 6) Sleep thread for 50ms
        /// 7) repeat.
        /// </summary>
        public void runPublisher()
        {
            String bufferedString = String.Empty;
            Int32  count          = 0;

            while (p < 20)
            {
                bufferedString = Program.mcb.getOneCell(name);
                if (!String.IsNullOrEmpty(bufferedString))
                {
                    //Take string from multicell buffer and convert to OrderObject
                    OrderObject obj = decoder.decode(bufferedString);

                    //Make sure there are enough books in the publisher to complete order
                    decrementBooks(obj.getAmount());

                    //Generate thread to process order
                    Thread oProc = new Thread(() => OrderProcessing.OrderProcessingThread(obj));
                    oProc.Start();

                    //Used if publisher had to restock books and a price drop resulted
                    if (books == RESTOCK_AMT)
                    {
                        count = 0;
                        if (name == 1)
                        {
                            currentPrice = modeler.calcPrice(obj);   //Calculate new price and store in local variable
                            Program.GV.set_Pub1_Price(currentPrice); //Push new price up to the global variable
                            priceCutEvent(currentPrice, name);       //Issue price cut event
                        }
                        else
                        {
                            currentPrice = modeler.calcPrice(obj);   //Calculate new price and store in local variable
                            Program.GV.set_Pub2_Price(currentPrice); //Push new price up to the global variable
                            priceCutEvent(currentPrice, name);       //Issue price cut event
                        }
                    }

                    //Used if no restock was performed
                    else
                    {
                        count = 0;
                        if (name == 1)
                        {
                            double temp = currentPrice;
                            currentPrice = modeler.calcPrice(obj); //Calculate new price and store in local variable


                            Program.GV.set_Pub1_Price(currentPrice); //Push local price to global variable

                            //Issue a price cut event if the price dropped by 25%
                            if ((1 - currentPrice / temp) >= .25)
                            {
                                priceCutEvent(currentPrice, name);
                            }
                        }
                        else
                        {
                            double temp = currentPrice;
                            currentPrice = modeler.calcPrice(obj); //Calculate new price and store in local variable
                            Program.GV.set_Pub2_Price(currentPrice);


                            if (1 - (currentPrice / temp) >= .25)
                            {
                                currentPrice = Program.GV.get_Pub2_Price();
                                priceCutEvent(currentPrice, name);
                            }
                        }
                    }
                }

                count++;
                if (count == 3)
                {
                    if (name == 1)
                    {
                        setNumBooks(RESTOCK_AMT);
                        currentPrice = modeler.getUnitPrice();
                        Program.GV.set_Pub1_Price(currentPrice);
                    }
                    else
                    {
                        setNumBooks(RESTOCK_AMT);
                        currentPrice = modeler.getUnitPrice();
                        Program.GV.set_Pub2_Price(currentPrice);
                    }
                }
                Thread.Sleep(SLEEP_TIME);
            }
        }
Exemplo n.º 24
0
 public void AddZakaz(int id, OrderProcessing link)
 {
     listCooked.Add(new Cooked(id, link));
     listCooked[listCooked.Count - 1].IdReadyOrderEv += ReadyOrder;
 }
Exemplo n.º 25
0
 void ReadyOrder(int id, Cooked link, OrderProcessing linkOnFood)
 {
     readyOrder.Enqueue(new IdTable(id, linkOnFood));
     listCooked.Remove(link);
 }
Exemplo n.º 26
0
 public Cooked(int id, OrderProcessing link)
 {
     this.id   = id;
     this.link = link;
 }
Exemplo n.º 27
0
    public OrderProcessing link;        //ссылка на заказ 

    public IdTable(int id, OrderProcessing link)
    {
        this.id = id;
        this.link = link;
    }