Example #1
0
 public override void Push(Bag bagtoqueue)
 {
     if (bagtoqueue.IsNull())
     {
         return;
     }
     lock (BagsQueue)
     {
         if (BagsQueue.Count >= _setsize)
         {
             return;
         }
         BagsQueue.Enqueue(bagtoqueue);
         IsEmpty = false;
         var count = BagsQueue.Count;
         if (count < _setsize - 1)
         {
             BagsQueue.Enqueue(null);
         }
         if (count == _setsize)
         {
             IsFull = true;
         }
     }
     OnQueueChangedEventHandler?.Invoke(this, EventArgs.Empty);
 }
Example #2
0
        public Bag ScanBagSecurity()
        {
            if (nbrOfSuspiciousBagPerDestination == null)
            {
                nbrOfSuspiciousBagPerDestination = new Dictionary <Destination?, Dictionary <SuspiciousBagtype, int> >();
                Airport.Destinations.Values.ToList().ForEach(destination =>
                {
                    // need to be fixed the items are being added twice
                    nbrOfSuspiciousBagPerDestination.Add(destination, new Dictionary <SuspiciousBagtype, int>
                    {
                        { SuspiciousBagtype.Flammables, 0 },
                        { SuspiciousBagtype.Drug, 0 },
                        { SuspiciousBagtype.Other, 0 },
                        { SuspiciousBagtype.Weapons, 0 },
                    });
                    destinationDistribution.Add(destination, 0);
                });
            }
            Bag b = null;

            try
            {
                lock (BagsQueue)
                {
                    b = base.Remove();
                }
            }
            catch (Exception)
            {
                // ignored
            }

            if (!b.IsNull())
            {
                foreach (var destination in Airport.Destinations.Where(destination =>
                                                                       destination.Key == b.TerminalAndGate))
                {
                    destinationDistribution[destination.Value]++;
                }
            }

            {
            }

            if (b?.GetSecurityStatus() == null)
            {
                return(b);
            }

            SuspiciousBagCategoryPerDestination(b);
            Airport.Storage.StoreSuspiciousBag(b);


            return(b);
        }