Ejemplo n.º 1
0
        public void NewOrder(int userId, int productId, int cityId)
        {
            IUserSystem      iUserSystem      = new UserSystem("为什么");
            IStorageSystem   iStorageSystem   = new StorageSystem();
            ILogisticsSystem iLogisticsSystem = new LogisticsSystem();
            IOrderSystem     iOrderSystem     = new OrderSystem();

            if (!iUserSystem.CheckUser(userId))
            {
                Console.WriteLine("用户检测失败");
            }
            else if (!iStorageSystem.CheckStorage(productId))
            {
                Console.WriteLine("仓储检测失败");
            }
            else if (!iLogisticsSystem.CheckLogistics(productId, cityId))
            {
                Console.WriteLine("物流检测失败");
                //不能直接去物流增加一个检测失败的数据记录
                //而是通过物流系统的方法去做
            }
            else if (!iOrderSystem.CheckOrder(userId, productId))
            {
                Console.WriteLine("订单检测失败");
            }
            else
            {
                iOrderSystem.NewOrder(userId, productId);
                iLogisticsSystem.NewLogistics(productId, cityId);
            }
        }
        public List <烏龜商品> get存貨清單()
        {
            OrderSystem mOrder    = new OrderSystem();  // 建立對外部供應商系統的參考
            List <烏龜商品> aProdList = new List <烏龜商品>();

            // 從外部系統取得產品清單
            // TODO: 實務應實作如何取得遠端系統的協定, 介面, 參數, 回傳值
            string[][] mOrders = mOrder.get產品清單();

            // A供應商系統的回傳格式為2維字串陣列,因本系統以 List 為回傳值,故需實作轉型的工作
            foreach (string[] product in mOrders)
            {
                烏龜商品 aProd = new 烏龜商品();

                aProd.id       = product[0];
                aProd.name     = product[1];
                aProd.price    = Convert.ToInt32(product[2]);
                aProd.quantity = Convert.ToInt32(product[3]);

                // 將轉型後的烏龜商品資訊新增至 List 集合
                aProdList.Add(aProd);
            }

            return(aProdList);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 门面模式通过是单例的
        /// 门面模式不能直接新增一个物流或者仓储检测方法,只能通过调用物流系统或者仓储系统的检测方法,这是门面模式的严格界定
        /// 用于分层
        /// 门面模式就是为了屏蔽上端知道太多细节
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="productId"></param>
        public void NewOrder(int userId, int productId)
        {
            IUserSystem      iUser      = new UserSystem();
            ILogisticsSystem iLogistics = new LogisticsSystem();
            IStorageSystem   iStorage   = new StorageSystem();
            IOrderSystem     iOrder     = new OrderSystem();

            if (!iUser.CheckUser(userId))
            {
                Console.WriteLine("用户检测失败");
            }
            else if (!iStorage.CheckStorage(productId))
            {
                Console.WriteLine("仓储检测失败");
            }
            else if (!iLogistics.CheckLogistics(userId, productId))
            {
                Console.WriteLine("物流检测失败");
            }
            else if (!iOrder.CheckOrder(userId, productId))
            {
                Console.WriteLine("订单检测失败");
            }
            else
            {
                iOrder.NewOrder(userId, productId);
                iLogistics.NewLogistics(userId, productId);
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            OrderSystem os = new OrderSystem();

            os.StartWorkDay();

            CustomerDTO customer1 = os.GetCustomerDTO("Mordred");
            CustomerDTO customer2 = os.GetCustomerDTO("Arthur");
            CustomerDTO customer3 = os.GetCustomerDTO("Nimue");

            os.SubscribeToPromotion(customer1);
            os.SubscribeToPromotion(customer3);
            while (true)
            {
                List <PizzaDTO> pizzas1 = new List <PizzaDTO>();
                PizzaDTO        pizza1  = os.GetPizzaDTO("Krowi placek");
                pizzas1.Add(pizza1);
                os.OrderPizza(pizzas1, customer1);

                Thread.Sleep(2000);

                List <PizzaDTO> pizzas2 = new List <PizzaDTO>();
                PizzaDTO        pizza2  = os.GetPizzaDTO("Krowi placek");
                pizzas2.Add(pizza2);
                os.OrderPizza(pizzas2, customer2);

                Thread.Sleep(2000);

                List <PizzaDTO> pizzas3 = new List <PizzaDTO>();
                PizzaDTO        pizza3  = os.GetPizzaDTO("Krowi placek");
                pizzas3.Add(pizza3);
                os.OrderPizza(pizzas3, customer3);
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            OrderSystem os = new OrderSystem();

            os.StartWorkDay();

            CustomerDTO customer1 = os.GetCustomerDTO("Tosia");
            CustomerDTO customer2 = os.GetCustomerDTO("Kuba");
            CustomerDTO customer3 = os.GetCustomerDTO("Basia");

            os.SubscribeToPromotion(customer1);
            os.SubscribeToPromotion(customer3);
            while (true)
            {
                List <BurgerDTO> Burgers1 = new List <BurgerDTO>();
                BurgerDTO        Burger1  = os.GetBurgerDTO("Angry Diablo Bacon King");
                Burgers1.Add(Burger1);
                os.OrderBurger(Burgers1, customer1);

                Thread.Sleep(2000);

                List <BurgerDTO> Burgers2 = new List <BurgerDTO>();
                BurgerDTO        Burger2  = os.GetBurgerDTO("Angry Diablo Bacon King");
                Burgers2.Add(Burger2);
                os.OrderBurger(Burgers2, customer2);

                Thread.Sleep(2000);

                List <BurgerDTO> Burgers3 = new List <BurgerDTO>();
                BurgerDTO        Burger3  = os.GetBurgerDTO("Angry Diablo Bacon King");
                Burgers3.Add(Burger3);
                os.OrderBurger(Burgers3, customer3);
            }
        }
Ejemplo n.º 6
0
 private void Start()
 {
     orderSystem   = OrderSystem.instance;
     UIManager     = UIManager.instance;
     playerManager = PlayerManager.instance;
     orderRecipe   = new List <string>();
 }
Ejemplo n.º 7
0
        public ActionResult EnterOrder(string Pizza, DateTime PickupTime, bool Paid)
        {
            ViewBag.Success = OrderSystem.EnterOrder(Models.Menu.Read().Find(p => p.Name == Pizza), PickupTime, Paid);

            ViewData["Menu"] = new SelectList(Models.Menu.Read(true));
            return(View());
        }
Ejemplo n.º 8
0
 private void Calcul(object param)
 {
     if (CanCalcul(param))
     {
         var array = randomEngine.GenerateArray(NbElement);
         MillisecondesEcoulees = OrderSystem.ReorderArray(ref array, OrderByFlag, SortFlag);
         TableauResultat       = array;
     }
 }
Ejemplo n.º 9
0
        public void GetAllOrders()
        {
            Order order = new Order {
                Pizza = Menu.Read()[50], OrderTime = DateTime.Now, PickupTime = DateTime.Now.AddDays(10), Paid = true
            };

            OrderSystem.EnterOrder(order);

            Assert.NotEmpty(OrderSystem.GetAllOrders());
        }
Ejemplo n.º 10
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
Ejemplo n.º 11
0
        public void RemoveOrder()
        {
            Order order = new Order {
                Pizza = Menu.Read()[50], OrderTime = DateTime.Now, PickupTime = DateTime.Now.AddDays(10), Paid = true
            };

            OrderSystem.EnterOrder(order);

            OrderSystem.RemoveOrder(order);

            Assert.DoesNotContain(order, OrderSystem.GetAllOrders());
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OrderController"/> class.
        /// FeatureFlag logic outside the code
        /// </summary>
        public OrderController()
        {
            _orderSystem = new OrderSystem();

            // let the feature flag determine which calculator to use
            if (NewPostageCalculationFeature.FeatureEnabled)
            {
                _postageCalculator = new AdvancedPostageCalculator();
            }
            else
            {
                _postageCalculator = new PostageCalculator();
            }
        }
Ejemplo n.º 13
0
        public void UnitaireNormalOrder()
        {
            Random r      = new Random(DateTime.Now.Millisecond);
            int    taille = 3000000;
            var    array  = new List <double>();

            for (int i = 0; i < taille; i++)
            {
                array.Add(r.NextDouble());
            }

            OrderSystem.ReorderArray(ref array, true, false);

            for (int i = 1; i < array.Count; i++)
            {
                Assert.IsTrue(array[i - 1] <= array[i]);
            }
        }
Ejemplo n.º 14
0
        public void OnPost()
        {
            Request.Form.TryGetValue("Purchaser", out StringValues purchaser);
            Request.Form.TryGetValue("ProductID", out StringValues productIDs);
            Request.Form.TryGetValue("ProductName", out StringValues productNames);
            Request.Form.TryGetValue("Quantity", out StringValues quantities);

            if (purchaser.Count == 0)
            {
                Redirect("~/Index");
            }
            if (purchaser[0] != "" && purchaser[0] != null)
            {
                Redirect("~/Index");
            }


            ProductsList = new List <CartItem>();
            int i = 0;

            foreach (string s in productIDs)
            {
                ProductsList.Add(new CartItem
                {
                    ProductId   = int.Parse(productIDs[i]),
                    ProductName = productNames[i],
                    Count       = int.Parse(quantities[i])
                });
                i++;
            }
            if (ProductsList.Count == 0)
            {
                Redirect("~/Index");
            }
            Purchaser = purchaser;

            Response.Cookies.Delete("CartList");
            Response.Cookies.Delete("CartItemsCount");

            OrderSystem.MakeOrder(purchaser[0], ProductsList);
        }
        public async void Start(string httpListenerPrefix)
        {
            HttpListener httpListener = new HttpListener();

            httpListener.Prefixes.Add(httpListenerPrefix);
            httpListener.Start();
            Console.WriteLine("[{0}] Server nasłuchuje...", DateTime.Now.ToString("HH:mm:ss.fff"));

            os = new OrderSystem();
            os.StartWorkDay();

            while (true)
            {
                HttpListenerContext httpListenerContext = await httpListener.GetContextAsync();

                if (httpListenerContext.Request.IsWebSocketRequest)
                {
                    ProcessRequest(httpListenerContext);
                }
            }
        }
Ejemplo n.º 16
0
    public static bool Activate()
    {
        OrderSystem orderSystem = GameObject.FindObjectOfType <OrderSystem>();

        return(orderSystem.OutsourceTicket());
    }
Ejemplo n.º 17
0
 public void ReceiveOrder(Order order)
 {
     OrderSystem.ReceiveOrder(this, order);
 }
Ejemplo n.º 18
0
        public ActionResult RemoveOrder(long ticks)
        {
            OrderSystem.RemoveOrder(OrderSystem.GetAllOrders().Find(o => o.OrderTime.Ticks == ticks));

            return(RedirectToAction("GetAllOrders", "Pizza"));
        }
Ejemplo n.º 19
0
 public void CancelOrders(HashSet <int> orderIdsToCancel)
 {
     OrderSystem.CancelOrders(this, orderIdsToCancel);
 }
Ejemplo n.º 20
0
    /* COOROUTINES */

    IEnumerator ExecuteImpulseOrder(OrderImpulse order)
    {
        // Get origine position
        Vector3 startPos  = transform.position;
        float   startTime = Time.fixedTime;

        // Create an order transmiter
        GameObject orderTransmiter = Instantiate(_orderTransmiterPrefab);

        // Place the order transmiter in the scenne
        orderTransmiter.transform.position = startPos;
        // Activate it
        orderTransmiter.SetActive(true);

        // Configure order system
        OrderSystem orderSystem = orderTransmiter.GetComponent <OrderSystem>();

        if (_backUnit != null)
        {
            orderSystem.Set(_storredOrder as OrderImpulse, this, _backUnit);
        }
        else
        {
            orderSystem.Set(_storredOrder as OrderImpulse, this, transform.position);
        }

        // Execute order
        _debug_useGravity = true;
        _physic.AddImpulse(order._impulse);

        float delayMin = 0.1f;

        while (delayMin > 0)
        {
            delayMin -= Time.deltaTime;
            yield return(null);
        }
        // Wait for the unit to stop to compleate the process
        _orderCompleated = false;
        while (!_orderCompleated)
        {
            yield return(null);
        }

        // End impulse order
        EndCurrentImpulseOrder();
        _currentOrder._travelTime = Time.fixedTime - startTime;

        /*
         * // Reconfigure order system
         * if (_backUnit != null && !orderSystem._integrateUnitFound) {
         *  orderSystem.Set(_storredOrder as OrderImpulse, this, _backUnit);
         * }
         */

        orderSystem.Initialise();


        // Reset current order
        _storredOrder = _currentOrder;
        _currentOrder = new Order();
        yield return(null);
    }
Ejemplo n.º 21
0
 public ActionResult GetAllOrders()
 {
     return(View(OrderSystem.GetAllOrders()));
 }
Ejemplo n.º 22
0
 void Start()
 {
     inventoryInfo = this.GetComponent <Item2>();
     orders        = FindObjectOfType <OrderSystem>();
     itemName      = inventoryInfo.itemName.Substring(9);
 }
Ejemplo n.º 23
0
 public void RemoveOrderClassic()
 {
     Assert.True(OrderSystem.RemoveOrder(OrderSystem.GetAllOrders()[0]));
 }
Ejemplo n.º 24
0
        public void GetAllOrdersClassic()
        {
            OrderSystem.EnterOrder(_staticMenu[0], DateTime.Now.AddHours(1), true);

            Assert.NotEmpty(OrderSystem.GetAllOrders());
        }
Ejemplo n.º 25
0
 public void EnterOrderClassic()
 {
     Assert.True(OrderSystem.EnterOrder(_staticMenu[0], DateTime.Now.AddHours(1), true));
 }