Ejemplo n.º 1
0
        private async Task InitActiveOrder()
        {
            var seller = await _sellerAuthService.GetProfile();

            var token = await _sellerAuthService.GetToken();

            var recivedActiveOrdrers = await Policy.Handle <Exception>(_ => true)
                                       .WaitAndRetryForeverAsync
                                       (
                sleepDurationProvider: retry => TimeSpan.FromSeconds(10)
                                       )
                                       .ExecuteAsync(async() => await _orderController.GetActiveOrders(seller.ID, token));

            foreach (var item in recivedActiveOrdrers)
            {
                var activeOrder = new PayedOrder("", item, item.Timer,
                                                 (orderInProcess) =>
                {
                    orderInProcess.CloseOrderTimer = new Timer(orderInProcess.OrderTime,
                                                               (_) =>
                    {
                        orderInProcess.CloseOrderTimer.WaitTime.Value -= new TimeSpan(0, 0, 1);

                        if (orderInProcess.CloseOrderTimer.WaitTime.Value > TimeSpan.Zero)
                        {
                            return;
                        }

                        try
                        {
                            _dialogService.Notification(
                                new NotificaiosModel($"Время приготовления заказа №{orderInProcess.Order.RowNumber} закончилось"
                                                     , "")
                                );
                            orderInProcess.CloseOrderTimer.WaitTime.Value = TimeSpan.Zero;
                            orderInProcess.StopTimer();

                            orderInProcess.IsOrderFinished.Value = true;
                        }
                        catch (Exception exp)
                        {
                            var a = exp.Message;
                        }
                    });
                });
                activeOrder.StartTimer();
                activeOrder.Order.OrderedFood.OrderBy(f => f.ProductInfo.Name).ToList();

                this.AddActiveOrder(activeOrder);
            }
        }
Ejemplo n.º 2
0
        private void Init()
        {
            CurentStatus = "";

            _orderController.OnGettingPurchasedOrders((customer, order) =>
            {
                var deserializeOrder = JsonConvert.DeserializeObject <OrderItem>(order);

                var payedOrder = new PayedOrder(deserializeOrder.WhoSold, deserializeOrder, deserializeOrder.Timer,
                                                (orderInProcess) =>
                {
                    orderInProcess.CloseOrderTimer = new Timer(orderInProcess.OrderTime,
                                                               (_) =>
                    {
                        orderInProcess.CloseOrderTimer.WaitTime.Value -= new TimeSpan(0, 0, 1);
                        if (orderInProcess.CloseOrderTimer.WaitTime.Value > TimeSpan.Zero)
                        {
                            return;
                        }
                        try
                        {
                            _dialogService.Notification(new NotificaiosModel($"Время приготовления заказа №{orderInProcess.Order.RowNumber} закончилось"
                                                                             , "")
                                                        );
                            orderInProcess.CloseOrderTimer.WaitTime.Value = TimeSpan.Zero;
                            orderInProcess.StopTimer();
                            orderInProcess.IsOrderFinished.Value = true;
                        }
                        catch (Exception exp)
                        {
                            var a = exp.Message;
                        }
                    });
                });
                payedOrder.StartTimer();

                payedOrder.Order.OrderedFood = payedOrder.Order.OrderedFood.OrderBy(f => f.ProductInfo.Name).ToList();

                this.AddActiveOrder(payedOrder);

                onNewPayedOrder?.Invoke(null, payedOrder);
            });

            this._orderController.OnChangeStatusSeller((_, status) =>
            {
                CurentStatus = status;
            });
        }