protected IEnumerable<RtaaSlicedTerm> SliceIntoPieces(IEnumerable<Term> terms, Func<Term, bool> termsFilter)
        {
            var termsCutter = new TermsCutter<Term, RtaaSlicedTerm>
                (terms, termsFilter, (s, e, t) =>
                {
                    bool ignore = false;
                    if (t != null)
                    {
                        var assignment = t.GetLowestTerm();
                        if (assignment != null)
                            ignore = assignment.IgnoreAdherence();

                    }
                    var slicedTerm = new RtaaSlicedTerm
                    {
                        Ignore = ignore,
                        Start = s,
                        End = e,
                        OnService = t == null ? false : t.OnService,
                        Text = t == null ? "Gap" : t.Level > 0 ? t.Level > 2 ? "Absent" : "SubEvent" : "Assignment"
                    };

                    return slicedTerm;
                });

            return termsCutter.ToList(((begin, current) =>
            {
                bool currentOnService = current != null ? current.OnService : false;
                bool beginOnService = begin != null ? begin.OnService : false;

                bool beginIgnore = false;
                if (begin != null)
                {
                    var assignment = begin.GetLowestTerm();
                    if (assignment != null)
                        beginIgnore = assignment.IgnoreAdherence();

                }

                bool currentIgnore = false;
                if (current != null)
                {
                    var assignment = current.GetLowestTerm();
                    if (assignment != null)
                        currentIgnore = assignment.IgnoreAdherence();

                }


                if (beginOnService != currentOnService || beginIgnore != currentIgnore)
                    return true;
                return false;
            }));

        }
        private string ShiftCheckAdherence(RtaaSlicedTerm leftBlock, RtaaSlicedTerm centerBlock, RtaaSlicedTerm rightBlock,
            DateRangeRef leftDateRange, DateRangeRef centerDateRange, DateRangeRef rightDateRange)
        {
            if (centerBlock.Text == "Assignment")
                return AssignmentCheckAdherence(leftBlock, centerBlock, rightBlock, leftDateRange, centerDateRange, rightDateRange);

            if (centerBlock.Text == "SubEvent")
                return SubEventCheckAdherence(leftBlock, centerBlock, rightBlock, leftDateRange, centerDateRange, rightDateRange);

            if (centerBlock.Text == "Gap")
                return GapCheckAdherence(leftBlock, centerBlock, rightBlock, leftDateRange, centerDateRange, rightDateRange);

            return AbsentCheckAdherence(leftBlock, centerBlock, rightBlock, leftDateRange, centerDateRange, rightDateRange);

        }
        protected IEnumerable<RtaaSlicedTerm> SliceIntoPiecesByType(IEnumerable<Term> terms, Func<Term, bool> termsFilter)
        {
            var termsCutter = new TermsCutter<Term, RtaaSlicedTerm>
                (terms, termsFilter, (s, e, t) =>
                {
                    var slicedTerm = new RtaaSlicedTerm
                    {
                        Start = s,
                        End = e,
                        OnService = t == null ? false : t.OnService,
                        Text = t == null ? "Gap" : t.Level > 0 ? t.Level > 2 ? "Absent" : "SubEvent" : "Assignment"
                    };

                    return slicedTerm;
                });

            return termsCutter.ToList(((begin, current) =>
            {
                return !Equals(begin, current);

            }));

        }
        public string AssignmentCheckAdherence(RtaaSlicedTerm leftBlock, RtaaSlicedTerm centerBlock, RtaaSlicedTerm rightBlock,
            DateRangeRef leftDateRange, DateRangeRef centerDateRange, DateRangeRef rightDateRange)
        {
            DateTime start = centerDateRange.Start;
            DateTime end = centerDateRange.End;

            if (!leftBlock.OnService)
            {
                DateTime temp = leftDateRange.End.AddSeconds(DelayOnLineBuffer);
                if (start < temp)
                    start = temp;
            }

            if (!rightBlock.OnService)
            {
                DateTime temp = rightDateRange.Start.AddSeconds(-PrematureOffLineBuffer);
                if (end > temp)
                    end = temp;
            }

            return start < end ? "LateToWork" : string.Empty;
        }