예제 #1
0
        /// <summary>
        /// 时段代换班验证
        /// </summary>
        public Dictionary <Guid, Dictionary <string, bool> > SwapingForDateRangeValidate(Pair <Guid> agentPair, Pair <DateRange> dateRange)
        {
            ReSet();
            _attendanceRepository.Clear();
            Applier.SwapingDate = Replier.SwapingDate = dateRange.Applier.GetSwapingDate(dateRange.Applier, dateRange.Replier);
            Initialize(agentPair, false);
            Applier.InitializeSwapingForDateRange(Applier.SwapingDate);
            Replier.InitializeSwapingForDateRange(Replier.SwapingDate);

            if (dateRange.Applier == dateRange.Replier)
            {
                if (Replier.NotSubEventAndGap(dateRange.Applier))
                {
                    Applier.HasExchanged = true;
                }
                if (Applier.NotSubEventAndGap(dateRange.Replier))
                {
                    Replier.HasExchanged = true;
                }
            }
            else
            {
                //获取切割时间
                var cutDateRange  = DateRange.Cut(dateRange.Applier, dateRange.Replier);
                var applierRegion = cutDateRange.Where(t => t.Item2 == RegionType.Applier).Select(o => o.Item1);
                var replierRegion = cutDateRange.Where(t => t.Item2 == RegionType.Replier).Select(o => o.Item1);
                foreach (var range in applierRegion)
                {
                    if (Replier.NotSubEventAndGap(range))
                    {
                        Applier.HasExchanged = true;
                        break;
                    }
                }
                foreach (var range in replierRegion)
                {
                    if (Applier.NotSubEventAndGap(range))
                    {
                        Replier.HasExchanged = true;
                        break;
                    }
                }
            }
            return(SetValidates());
        }
예제 #2
0
        public void DealWithDateRange(BoxSwapModel opp, Pair <DateRange> dateRange)
        {
            List <Term> frontTerms, insideTerms, backTerms;

            Term.SliceTerm(CurrentTerms, dateRange.Applier.Start, dateRange.Applier.End, out insideTerms, out frontTerms,
                           out backTerms);
            var day = TempTerms.HasDayTerms();

            DealWithTerms(insideTerms, day);
            insideTerms.ForEach(opp.TimeBoxCreateTerm);
            //获取切割时间
            var         cutDateRange  = DateRange.Cut(dateRange.Applier, dateRange.Replier);
            var         replierRegion = cutDateRange.Where(t => t.Item2 == RegionType.Replier).Select(o => o.Item1);
            List <Term> outside       = null;
            List <Term> outside2      = null;

            if (replierRegion.Count() == 1)
            {
                var         range = replierRegion.FirstOrDefault();
                List <Term> inside;
                //右边
                if (range.Start >= dateRange.Applier.End)
                {
                    Term.SliceTerm(backTerms, range.Start, range.End, out outside, out inside);
                    DealWithTerms(frontTerms, day);
                    frontTerms.ForEach(TimeBoxCreateTerm);
                }
                //左边
                if (range.End <= dateRange.Applier.Start)
                {
                    Term.SliceTerm(frontTerms, range.Start, range.End, out outside, out inside);
                    DealWithTerms(backTerms, day);
                    backTerms.ForEach(TimeBoxCreateTerm);
                }
            }
            if (replierRegion.Count() > 1)
            {
                foreach (var range in replierRegion)
                {
                    List <Term> inside;
                    //右边
                    if (range.Start >= dateRange.Applier.End)
                    {
                        Term.SliceTerm(backTerms, range.Start, range.End, out outside, out inside);
                    }
                    //左边
                    if (range.End <= dateRange.Applier.Start)
                    {
                        Term.SliceTerm(frontTerms, range.Start, range.End, out outside2, out inside);
                    }
                }
            }
            if (outside2 != null)
            {
                DealWithTerms(outside2, day);
                outside2.ForEach(TimeBoxCreateTerm);
            }
            if (outside != null)
            {
                DealWithTerms(outside, day);
                outside.ForEach(TimeBoxCreateTerm);
            }
            else
            {
                DealWithTerms(frontTerms, day);
                DealWithTerms(backTerms, day);
                frontTerms.ForEach(TimeBoxCreateTerm);
                backTerms.ForEach(TimeBoxCreateTerm);
            }
        }