// Transfer clients from one cash to another (not sure what parameters are needed yet)
        public void MoveClients(List<Client> clients, StoreQueue backup)
        {
            List<ServicePoint> sp = store.getServicePoints();

            // Since there could possibly be more clients int he queue removed than total number of service points
            while (clients.Count != 0)
            {

                // If the cashes are all full, then insert the remaining clients into the front of the wait queue
                if (store.AllCashesFull())
                {
                    clients.ElementAt(0).setWaitQueueStatus();
                    List<Client> toMove = new List<Client>();
                    foreach (Client c in clients)
                    {
                        toMove.Add(c);
                    }

                    foreach (Client c in toMove)
                    {
                        c.setWaitQueueStatus();
                        backup.AddClientInFront(c);
                    }
                    backup.PeekNext().setFrontOfWaitQueueStatus();
                    break;
                }

                foreach (ServicePoint s in sp)
                {
                    if (clients.Count == 0)
                        break;

                    if (!s.isFull())
                    {
                        Client c = clients.ElementAt(0);
                        if (s.CanService(c))
                        {
                            clients.RemoveAt(0);
                            s.AddClient(c);
                        }
                    }
                }

            }
        }
Exemple #2
0
        public int AddClientToWaitQueue(Client c, StoreQueue queue)
        {
            if (queue != null)
            {
                //waitQueue.Add(c);
                queue.AddClient(c);

                OnClientAddedToQueue(new ClientEventArgs(c, Timer.getTick(), c.currentQueue));

                //index = waitQueue.IndexOf(c);

                if (queue.PeekNext() == c)
                {
                    this.OnClientInFrontOfQueue(new ClientEventArgs(c, Timer.getTick(), c.currentQueue));
                }
                return queue.IndexOf(c);
                //Logger.Info("Added client " + c.getId().ToString() + " to the wait queue at " + DateTime.Now.ToString());
            }
            return -1;
        }