Ejemplo n.º 1
0
        /// <summary>
        /// Sets the curent.
        /// </summary>
        /// <param name="date">The date.</param>
        private void SetCurent(long date)
        {
            long     intervalStart = CalendarHelper.DayOf(date);
            Interval interval      = new Interval(intervalStart, intervalStart + GetStepAmount());

            if (GetIfExistException(interval, out _current) == false)
            {
                //First get workDay working resource calendar
                _current = _calendar.WorkingWeek.WeekDays[CalendarHelper.DayOfWeek(intervalStart)];
                //If resource calendar not set and calendar have base calendar get work day from him
                if (_current == null)
                {
                    if (_calendar.BaseCalendar != null)
                    {
                        _current = (WorkDay)_calendar.BaseCalendar.WorkingWeek.WeekDays[CalendarHelper.DayOfWeek(intervalStart)].Clone();
                    }
                    else
                    {
                        throw new Exception("Invalid work day");
                    }
                }

                _current.Start = interval.Start;
                _current.End   = interval.End;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the interval.
        /// </summary>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        public void AddInterval(int number, long start, long end)
        {
            //If end time is 0, it is treated as midnight the next day
            if (CalendarHelper.HourFromMilis(end) == 0 && CalendarHelper.MinuteFromMilis(end) == 0)
            {
                end = CalendarHelper.MilisPerHour() * 24 + end;
            }

            WorkRanges[number] = new WorkRange(start, end, false);
        }
Ejemplo n.º 3
0
        DefaultCalendar IFactoryMethod <DefaultCalendar> .Create(object obj)
        {
            DefaultCalendar retVal       = new DefaultCalendar();
            WorkDay         workingDay   = new WorkDay();
            WorkDay         noWorkingDay = new WorkDay();

            workingDay.WorkingHours.AddInterval(0, CalendarHelper.MilisPerHour() * 9, CalendarHelper.MilisPerHour() * 13);
            workingDay.WorkingHours.AddInterval(1, CalendarHelper.MilisPerHour() * 14, CalendarHelper.MilisPerHour() * 18);
            retVal.WorkingWeek.SetWeekDays(workingDay);
            retVal.WorkingWeek.SetWeekEndDays(noWorkingDay);
            return(retVal);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adjusts the in calendar.
        /// </summary>
        /// <param name="date">The date.</param>
        /// <param name="useSooner">if set to <c>true</c> [use sooner].</param>
        /// <returns></returns>
        public override long AdjustInCalendar(long date, bool useSooner)
        {
            long retVal = 0;

            if (useSooner)
            {
                long backOne = AddDuration(date, CalendarHelper.MilisPerMinute() * -1, useSooner);
                retVal = AddDuration(backOne, CalendarHelper.MilisPerMinute(), useSooner);
            }
            else
            {
                long aheadOne = AddDuration(date, CalendarHelper.MilisPerMinute(), useSooner);
                retVal = AddDuration(date, CalendarHelper.MilisPerMinute() * -1, useSooner);
            }

            return(retVal);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Gets the step amount.
 /// </summary>
 /// <returns></returns>
 private long GetStepAmount()
 {
     return(_step * CalendarHelper.MilisPerDay());
 }