Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }