コード例 #1
0
ファイル: WorkHours.cs プロジェクト: alex765022/IBN
        /// <summary>
        /// Calcs the work at time.
        /// </summary>
        /// <param name="time">The time.</param>
        /// <returns></returns>
        public long CalcWorkAtTime(long time)
        {
            long retVal = 0;

            //Before
            if (time < 0)
            {
                return(GetDuration() - CalcWorkAtTime(time * -1));
            }
            if (time > 0)
            {
                //After
                for (int i = 0; i < WorkRanges.Length; i++)
                {
                    WorkRange range = WorkRanges[i];
                    if (range != null)
                    {
                        if (range.End > time)
                        {
                            retVal += (range.End - Math.Max(time, range.Start));
                        }
                    }
                }
            }

            return(retVal);
        }
コード例 #2
0
ファイル: WorkHours.cs プロジェクト: alex765022/IBN
        /// <summary>
        /// Calcs the time remaining work.
        /// </summary>
        /// <param name="duration">The duration.</param>
        /// <returns></returns>
        public long CalcTimeRemainingWork(long duration)
        {
            long retVal = 0;
            long work   = 0;

            duration = duration < 0 ? duration * -1 : duration;

            for (int i = WorkRanges.Length - 1; i >= 0; i--)
            {
                WorkRange range = WorkRanges[i];
                if (range != null)
                {
                    work += range.GetDuration();
                    if (work > duration)
                    {
                        retVal = range.Start + (work - duration);
                        //if (retVal == range.Start && i != 0 && WorkRanges[i - 1] != null)
                        //{

                        // //   retVal = CalcTimeAtWork(duration);
                        //}
                        break;
                    }
                    else if (work == duration)
                    {
                        //retVal = CalcTimeAtWork(range.Start + (work - duration));
                        retVal = range.Start;
                        break;
                    }
                }
            }

            return(retVal);
        }
コード例 #3
0
ファイル: WorkHours.cs プロジェクト: alex765022/IBN
        /// <summary>
        /// Calcs the time at work.
        /// </summary>
        /// <param name="duration">The duration.</param>
        /// <returns></returns>
        public long CalcTimeAtWork(long duration)
        {
            long retVal = 0;
            long work   = 0;

            duration = duration < 0 ? duration * -1 : duration;

            for (int i = 0; i < WorkRanges.Length; i++)
            {
                WorkRange range = WorkRanges[i];
                if (range != null)
                {
                    work += range.GetDuration();
                    if (work > duration)
                    {
                        retVal = range.End - (work - duration);
                        break;
                    }
                    else if (work == duration)
                    {
                        retVal = range.End;
                        break;
                    }
                }
            }

            return(retVal);
        }
コード例 #4
0
ファイル: WorkRange.cs プロジェクト: 0anion0/IBN
        /// <summary>
        /// Overlapses the specified other.
        /// </summary>
        /// <param name="other">The other.</param>
        /// <returns></returns>
        bool Overlaps(WorkRange other)
        {
            if (other == null)
                return false;

            return ((this.Start > other.Start && this.End > other.End)
                    || (other.Start > this.Start && other.End > this.End)) == false;
        }
コード例 #5
0
ファイル: WorkHours.cs プロジェクト: alex765022/IBN
        /// <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);
        }
コード例 #6
0
        /// <summary>
        /// Overlapses the specified other.
        /// </summary>
        /// <param name="other">The other.</param>
        /// <returns></returns>
        bool Overlaps(WorkRange other)
        {
            if (other == null)
            {
                return(false);
            }

            return(((this.Start > other.Start && this.End > other.End) ||
                    (other.Start > this.Start && other.End > this.End)) == false);
        }
コード例 #7
0
ファイル: WorkHours.cs プロジェクト: 0anion0/IBN
        /// <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);
        }
コード例 #8
0
ファイル: WorkHours.cs プロジェクト: alex765022/IBN
        public object Clone()
        {
            WorkHours retVal = new WorkHours();

            for (int i = 0; i < WorkRanges.Length; i++)
            {
                if (WorkRanges[i] != null)
                {
                    WorkRange range = new WorkRange(WorkRanges[i].Start, WorkRanges[i].End, WorkRanges[i].OverTime);

                    retVal.WorkRanges[i] = range;
                }
            }

            return(retVal);
        }
コード例 #9
0
ファイル: WorkHours.cs プロジェクト: 0anion0/IBN
        public object Clone()
        {
            WorkHours retVal = new WorkHours();
            for(int i = 0; i < WorkRanges.Length; i++)
            {
                if(WorkRanges[i] != null)
                {
                    WorkRange range = new WorkRange(WorkRanges[i].Start, WorkRanges[i].End, WorkRanges[i].OverTime);

                    retVal.WorkRanges[i] = range;
                }
            }

            return retVal;
        }