Exemple #1
0
 private void CheckForDequeue()
 {
     if (NeedRearrangeLocation.Count > 0)
     {
         FrameModel f = frames.Where(x => x.Location == NeedRearrangeLocation.Peek()).ElementAt(0);
         if (f.Times.Count > 0)
         {
             if (!string.IsNullOrEmpty(CurrentFlight))
             {
                 if (f.Times.Peek() == CurrentFlight)
                 {
                     NeedRearrangeLocation.Dequeue();
                     return;
                 }
             }
             for (int i = 1; i < f.Times.Count; i++)
             {
                 if (FlightTime[f.Times.ElementAt(i - 1)] > FlightTime[f.Times.ElementAt(i)])
                 {
                     return;
                 }
             }
         }
         NeedRearrangeLocation.Dequeue();
     }
 }
Exemple #2
0
        public LogicLocation Pop(string flight, int shelf)
        {
            CurrentFlight = flight;
            if (string.IsNullOrEmpty(flight))
            {
                MessageBox.Show("航班号不存在!");
                return(null);
            }
            var frameNotEmpty = frames.Where(x => x.Times.Count > 0 && x.Location.Shelf == shelf);

            foreach (var frame in frameNotEmpty)
            {
                if (frame.Times.Peek() == flight)
                {
                    frame.Times.Dequeue();
                    return(frame.Location);
                }
            }
            FrameModel f = CheckForRest(frameNotEmpty.ToList(), flight);

            if (f != null)
            {
                NeedRearrangeLocation.Enqueue(f.Location);
                return(f.Location);
            }
            return(null);
        }
Exemple #3
0
 private void CheckForRearrange()
 {
     foreach (var f in frames.Where(x => x.Times.Count != 0))
     {
         for (int i = 1; i < f.Times.Count; i++)
         {
             if (FlightTime[f.Times.ElementAt(i - 1)] > FlightTime[f.Times.ElementAt(i)])
             {
                 NeedRearrangeLocation.Enqueue(f.Location);
                 break;
             }
         }
     }
 }
Exemple #4
0
        public void Next()
        {
            CheckForDepartureTime();

            CheckForDequeue();

            if (NeedRearrangeLocation.Count > 0)
            {
                if (Rearrange != null)
                {
                    Rearrange(this, new LogicLocationEventArgs(NeedRearrangeLocation.Peek()));
                }
            }
        }
Exemple #5
0
        public LogicLocation Push(string flight, int shelf)
        {
            if (string.IsNullOrEmpty(flight))
            {
                MessageBox.Show("航班号不存在!");
                return(null);
            }
            if (!CurrCount.Keys.Contains(flight))
            {
                MessageBox.Show("此航班不是早交行李!");
                return(null);
            }
            if (CurrCount[flight] >= FlightBaggageCount[flight])
            {
                MessageBox.Show("此行李不是早交行李!");
                return(null);
            }
            var frameNotFull = frames.Where(f => f.Times.Count < FrameCount && f.Location.Shelf == shelf);

            foreach (var frame in frameNotFull)
            {
                if (frame.Times.Count == 0)
                {
                    frame.Times.Enqueue(flight);
                    if (!flightAtShelf.Keys.Contains(flight))
                    {
                        flightAtShelf.Add(flight, frame.Location.Shelf);
                    }
                    return(frame.Location);
                }
                else if (frame.Times.Peek() == flight)
                {
                    frame.Times.Enqueue(flight);
                    if (!flightAtShelf.Keys.Contains(flight))
                    {
                        flightAtShelf.Add(flight, frame.Location.Shelf);
                    }
                    return(frame.Location);
                }
            }
            if (IsAllFull())
            {
                MessageBox.Show("所有仓库都已满!");
                return(null);
            }
            else
            {
                string str   = "";
                int    index = 0;
                for (int i = 1; i < FlightTime.Count; i++)
                {
                    foreach (var frame in frameNotFull)
                    {
                        str   = frame.Times.ElementAt(frame.Times.Count - 1);
                        index = FlightTime.Keys.ToList().IndexOf(str);
                        if (index + i >= FlightTime.Count)
                        {
                            break;
                        }
                        if (flight == FlightTime.Keys.ToList()[index + i])
                        {
                            frame.Times.Enqueue(flight);
                            return(frame.Location);
                        }
                    }
                }

                var f = frameNotFull.OrderBy(x => x.Times.Count).ToList()[0];
                f.Times.Enqueue(flight);
                NeedRearrangeLocation.Enqueue(f.Location);
                CurrCount[flight] += 1;
                return(f.Location);
            }
        }