Exemple #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="day"></param>
        /// <returns></returns>
        private TimeStandardCollection CreateTimeStandard(DateTime day)
        {
            TimeStandardCollection timeStandards = new TimeStandardCollection();
            //TimeStandard r = null;
            foreach (TimeDefine td in this.TimeDefines)
            {
                WeekTimeDefine weekTD = (WeekTimeDefine)td;
                if (weekTD.BeginWeek == day.DayOfWeek)
                {
                    DateTime b = day + weekTD.Begin;
                    DateTime e = day + weekTD.End + (weekTD.IsCrossDay ? TimeSpan.FromDays(1d) : TimeSpan.Zero);
                    TimeStandard r = TimeStandard.CreateWorkTimeStandard(b, e, weekTD.NormalBeginTimeSpan,
                        weekTD.NormalEndTimeSpan);
                    timeStandards.Add(r);
                }
                else
                {

                }
            }
            //if (r == null)
            if( timeStandards.Count == 0)
            {
                TimeStandard r = TimeStandard.CreateRestTimeStandard(day);
                timeStandards.Add(r);
            }
            return timeStandards;
        }
Exemple #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="month"></param>
        /// <returns></returns>
        internal override TimeStandardCollection CreateTimeStandards(DateTime month)
        {
            Debug.Assert(month.Day == 1);

            TimeStandardCollection r = new TimeStandardCollection();

            DateTime dt = new DateTime(month.Year, month.Month, month.Day);

            do
            {
                TimeStandardCollection s = CreateTimeStandard(dt);
                r.Add(s);
                dt += TimeSpan.FromDays(1d);
            } while (dt.Month == month.Month);

            return r;
        }
Exemple #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="month"></param>
        /// <returns></returns>
        internal override TimeStandardCollection CreateTimeStandards(DateTime month)
        {
            TimeStandardCollection r = new TimeStandardCollection();

            DateTime monthStart = new DateTime(month.Year, month.Month, month.Day);
            DateTime startDT = monthStart - TimeSpan.FromTicks(
                    (monthStart - this.StartDateTime).Ticks % TimeSpan.FromDays(this.DayOfCycle).Ticks);

            DateTime dt = startDT;
            int exitMonth = month.Month + 1;
            if (exitMonth > 12)
            {
                exitMonth -= 12;
            }

            int n = 0;
            DateTime b1 = DateTime.MinValue;
            DateTime e1 = DateTime.MinValue;
            do
            {
                foreach (TimeDefine td in this.TimeDefines)
                {
                    UserTimeDefine userTD = (UserTimeDefine)td;
                    b1 = dt + TimeSpan.FromDays(n * this.DayOfCycle) + TimeSpan.FromDays(userTD.BeginDayOffset) + userTD.Begin;
                    e1 = dt + TimeSpan.FromDays(n * this.DayOfCycle) + TimeSpan.FromDays(userTD.EndDayOffset) + userTD.End;

                    if (b1.Month == month.Month)
                    {
                        TimeStandard s = TimeStandard.CreateWorkTimeStandard(b1, e1,
                            userTD.NormalBeginTimeSpan, userTD.NormalEndTimeSpan);
                        r.Add(s);
                    }
                }
                n++;
            }
            while (b1.Month != exitMonth);
            TimeStandardCollection rests = CreateMonthTimeStandarsWithRest(month);
            r = Merge(rests, r);
            return r;
        }
Exemple #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="month"></param>
        /// <returns></returns>
        private TimeStandardCollection CreateMonthTimeStandarsWithRest(DateTime month)
        {
            TimeStandardCollection r = new TimeStandardCollection();
            DateTime b = new DateTime(month.Year, month.Month, 1);
            DateTime e = CreateNextMonth(month);

            while (b < e)
            {
                TimeStandard s = TimeStandard.CreateRestTimeStandard(b);
                r.Add(s);
                b += TimeSpan.FromDays(1d);
            }
            return r;
        }
Exemple #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="rests"></param>
 /// <param name="works"></param>
 /// <returns></returns>
 private TimeStandardCollection Merge(TimeStandardCollection rests, TimeStandardCollection works)
 {
     TimeStandardCollection r = new TimeStandardCollection();
     foreach (TimeStandard iRest in rests)
     {
         bool added = false;
         //if (item.begin
         foreach (TimeStandard iWork in works)
         {
             if (iRest.IsInTime(iWork.Begin))
             {
                 r.Add(iWork);
                 added = true;
             }
         }
         if (!added)
         {
             r.Add(iRest);
         }
     }
     return r;
 }