Exemple #1
0
        private void AddOrder(NewOrderEventArgs e)
        {
            PointInCode("OrdersViewModel: AddOrder");
            Interval currentInterval = _beursfuifData.CurrentInterval;
            ClientDrinkOrder[] items = e.Order;
            foreach (var drinkItem in items)
            {
                drinkItem.IntervalId = currentInterval.Id;
            }

            Client client = _beursfuifData.Clients.FirstOrDefault(x => x.Id == e.ClientId);

            if (client != null)
            {
                ShowOrder newOrder = new ShowOrder()
                {
                    ClientName = client.Name,
                    IntervalId = currentInterval.Id,
                    OrderContent = e.Order.ToContentString(_beursfuifData.Drinks),
                    Time = _beursfuifData.BeursfuifCurrentTime,
                    TotalPrice = e.Order.TotalPrice(currentInterval),
                    Orders = items
                };

                if (AllOrders == null)
                {
                    AllOrders = new ObservableCollection<ShowOrder>();
                }

                if (ReducedIntervals == null)
                {
                    InitData();
                }

                AllOrders.Add(newOrder);
                RaisePropertyChanged(AllOrdersPropertyName);
                if (SelectedInterval == null) SelectedInterval = ReducedIntervals[0];

                if (SelectedInterval.Id == currentInterval.Id || SelectedInterval.Id == int.MaxValue)
                {
                    if (ShowOrderList == null)
                    {
                        ShowOrderList = new ObservableCollection<ShowOrder>();
                    }

                    ShowOrderList.Add(newOrder);
                }

                if (_beursfuifData.AllOrderItems == null)
                {
                    _beursfuifData.AllOrderItems = new List<ClientDrinkOrder>();
                }

                _beursfuifData.AllOrderItems.AddRange(e.Order);

                UpdateDrinkStats();
            }
        }
Exemple #2
0
        void Server_NewOrderEvent(object sender, NewOrderEventArgs e)
        {
            PointInCode("OrdersViewModel: Server_NewOrderEvent");

            if (_beursfuifData.AuthenticationString() == e.AuthenticationCode)
            {
                App.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    AddOrder(e);
                }));
                return;
            }
            //else
            //client doesn't have a valid code

            SendLogMessage($"Invalid authcode from client {_beursfuifData.GetClientName(e.ClientId)}",
                LogType.ORDER_VM | LogType.CLIENT_SERVER_ERROR);
            MessengerInstance.Send<KickClientMessage>(new KickClientMessage()
            {
                ClientId = e.ClientId,
                Reason = KickWasKickedReason.TIME_OUT_ERROR
            });
        }
Exemple #3
0
 protected void OnNewOrderEvent(object sender, NewOrderEventArgs e)
 {
     NewOrderEvent?.Invoke(this, e);
 }