Example #1
0
        /// <summary>
        /// 事件代换班
        /// </summary>
        public void InitializeSwapingForSubEvent(Pair <DateRange> dateRange, long subevent)
        {
            var tempassignment = TimeBox.CollideTerms(dateRange.Applier).SpecificTerm <AssignmentBase>().OrderBy(o => o.Start).ToList();

            if (tempassignment.Count == 0)
            {
                return;
            }
            InitializeTerm(subevent);
            CurrentTerms   = TimeBox.CenterTerms(new DateRange(tempassignment[0].Start, tempassignment[tempassignment.Count - 1].End)).ToList();
            AbsentEvents   = CurrentTerms.SpecificTerm <AbsentEvent>().ToList();
            HasAbsentEvent = AbsentEvents.CollideTerms(dateRange.Applier).Any() ||
                             AbsentEvents.CollideTerms(dateRange.Replier).Any();
            //验证是否重叠
            HasExchanged = CurrentTerms.Any(o => o.Level > 0 && o.Id != subevent && o.IsCoverd(dateRange.Replier));
        }
Example #2
0
        /// <summary>
        /// 多日代换班
        /// </summary>
        public void InitializeSwapingForMultiDay()
        {
            var tempassignment = TimeBox.CollideTerms(SwapingDate).SpecificTerm <AssignmentBase>().OrderBy(o => o.Start).ToList();
            var count          = tempassignment.Count;

            if (count == 0)
            {
                return;
            }
            DateRange range;

            if (count == 1)
            {
                range = new DateRange(tempassignment[0].Start, tempassignment[0].End);
            }
            else
            {
                var frist = tempassignment.First();
                var last  = tempassignment.Last();
                range = new DateRange
                {
                    Start = frist.Start < SwapingDate.Start ? tempassignment[1].Start : frist.Start,
                    End   = last.Start < SwapingDate.End ? last.End : tempassignment[count - 1].End
                };
            }
            var collide = TimeBox.CenterTerms(range).ToList();

            //初始化班
            CurrentTerms = collide.SpecificTerm <AssignmentBase>().ToList();
            //初始化第一层事件
            LevelOnes = collide.Where(o => o.Level == 1).ToList();
            //初始化第二层事件
            LevelTwos = collide.Where(o => o.Level == 2).ToList();
            //初始化第三层事件
            LevelThrees = collide.Where(o => o.Level == 3).ToList();

            //是否存在TimeOff
            HasTimeOff = collide.Any(o => o is TimeOff);
            //是否存在AbsentEvent
            HasAbsentEvent = collide.Any(o => o is AbsentEvent);
            //是否存在锁
            Lockeds = collide.Where(o => o.Locked).ToList();
            //DayOff
            DayOffs = collide.Where(o => o is DayOff).ToList();
        }
Example #3
0
        /// <summary>
        /// 时段代换班(scheduleDate用于取TimeBox班表,如果计算工时则需要获取整个排班期班表,如果换班则需要取两人交换范围的班表,dateRange是交换时间段)
        /// </summary>
        public void InitializeSwapingForDateRange(DateRange dateRange)
        {
            var tempassignment = TimeBox.CollideTerms(dateRange).SpecificTerm <AssignmentBase>().OrderBy(o => o.Start).ToList();

            if (tempassignment.Count == 0)
            {
                return;
            }
            CurrentTerms = TimeBox.CenterTerms(new DateRange(tempassignment[0].Start, tempassignment[tempassignment.Count - 1].End)).ToList();
            //初始化班
            TempTerms           = CurrentTerms.SpecificTerm <AssignmentBase>().ToList();
            HasAbsentEvent      = CurrentTerms.CollideTerms(dateRange).SpecificTerm <AbsentEvent>().Any();
            AbsentEvents        = CurrentTerms.SpecificTerm <AbsentEvent>().ToList();
            HasLockedSubEvent   = CurrentTerms.Any(o => o.Level > 0 && o.Locked);
            HasTimeOff          = CurrentTerms.CollideTerms(dateRange).SpecificTerm <TimeOff>().Any();
            HasShrink           = CurrentTerms.CollideTerms(dateRange).SpecificTerm <Shrink>().Any();
            HasLockedAssignment = TempTerms.Any(o => o.Locked);
        }