Ejemplo n.º 1
0
        public static bool VerifyAnyOverlap(this Term source, TimeBox timeBox)
        {
            var lowestTerm   = source.GetLowestTerm() as Term;
            var convertTerms = timeBox.GetCoveredTermsWithAbsent(lowestTerm).ToArray();

            if (lowestTerm == source)
            {
                return(timeBox.TermSet.Where(o => o != source && o.Level == source.Level).Any(o =>
                {
                    var overlap = source.AnyOverlap(o);
                    return overlap;
                }));
            }

            var closestBottomTerm = timeBox.GetClosestBottom(source);

            if (closestBottomTerm != source.Bottom)
            {
                return(true);
            }

            return(convertTerms.Where(o => o != source || o.Id != source.Id).OrderBy(o => o.Start).Any(o => o.Id != source.Id && o.Level > source.Level ? source.OverlapNotEnclosed(o) : o.OverlapNotEnclosed(source)));
        }
Ejemplo n.º 2
0
        public static void X(Term prv, Term term, ref Term result)
        {
            var source    = term;
            var prvIsNull = prv == null;

            if (!prvIsNull && prv.GetLowestTerm().If(o => o.Equals(term.GetLowestTerm())) != true)
            {
                prvIsNull = true;
            }

            if (!prvIsNull && term.Level <= 1)
            {
                if (prv.Bottom != null)
                {
                    if (prv.IsNeedSeat == false && prv.Level > 0 || (prv.Level - term.Level == 1))
                    {
                        if (!prv.CanBeSeatSource() && prv.Bottom.If(b => !b.SeatIsEmpty()) == true) // 第三层不能做为下一段位置的依据
                        {
                            source = prv.Bottom;                                                    // 改变参考的来源
                        }
                        else
                        {
                            source = prv;
                        }
                    }
                    else
                    {
                        prv.DiveInto(o =>
                        {
                            if (!o.IsNeedSeat) //不占席事件所产生的座位表
                            {
                                //if (!o.SeatIsEmpty())
                                source = o;
                                return(true);
                            }


                            //var prvIsCutPoint = prv.IsNeedSeat == false && prv.Level > 0;

                            //if (prvIsCutPoint)
                            //{
                            //    source = prv;

                            //}

                            if (!o.SeatIsEmpty())
                            {
                                source = o;
                                return(true);
                            }
                            return(false);
                        });
                    }
                }
                else
                {
                    if (prv.Level == 0 && term.Level == 0 && prv.AnyOverlap(term) && !prv.IsInTheRange(term.Start, term.End))
                    {
                    }
                    else if (term.Level == 1 && prv.Level == 0 && !term.IsInTheRange(prv.Start, prv.End) && term.Bottom != null && term.Bottom.IsNeedSeat)
                    {
                        source = term.Bottom;
                    }
                    else
                    {
                        source = prv;
                    }
                }
            }
            else if (prvIsNull && term.Level == 1)
            {
                if (!term.Bottom.SeatIsEmpty())
                {
                    source = term.Bottom;
                }
            }

            //用于判断当assignment为不占席
            source.GetLowestTerm().SaftyInvoke <IAssignment>(a =>
            {
                if (!a.IsNeedSeat && term.OcuppiedAndHasSeat())
                {
                    source = term;
                }
            });

            result = source;
        }