Exemplo n.º 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());
        }