Example #1
0
        public float GetDesiredPercentage(DayInfo today)
        {
            float result = 0;

            if (GetTotalDays() != 0)
            {
                if (Nature == NatureEnum.Standart)
                {
                    result = 100 * GetPassedDays(today) / GetTotalDays();
                }
                else if (Nature == NatureEnum.BetweenLimits)
                {
                    result = 100 * GetRemainingDays(today) / GetTotalDays();
                }
            }
            else
            {
                result = 0;
            }

            if (result < 0)
            {
                result = 0;
            }
            else if (result > 100)
            {
                result = 100;
            }

            return(result);
        }
Example #2
0
        /// <summary>
        /// Gets the relative performence of goal completion.
        /// 100 * (PresentPercentage - DesiredPercentage) / PresentPercentage)
        /// </summary>
        /// <returns>The percentage</returns>
        public float GetRelativePerformance(DayInfo today)
        {
            float result = 0;
            float factor1, factor2 = 0;
            float presentPercentage = GetPresentPercentage();
            float desiredPercentage = GetDesiredPercentage(today);

            if (presentPercentage > 0 && presentPercentage > desiredPercentage)
            {
                factor1 = (100 * (presentPercentage - desiredPercentage) / presentPercentage) / 2;
            }
            else
            {
                factor1 = 0;
            }

            factor2 = presentPercentage / 2;

            result = factor1 + factor2;

            if (result > 100)
            {
                result = 100;
            }
            if (result < 0)
            {
                result = 0;
            }

            return(result);
        }
Example #3
0
        /// <summary>
        /// This method gives the daily suggested value to meet the goals.
        /// </summary>
        /// <returns>The daily suggested value.</returns>
        public float GetDailySuggestedValue(DayInfo today)
        {
            float result = 0;

            if (DateTime.Today > DueDate)
            {
                return(0);
            }

            if (this.Nature == NatureEnum.Standart)
            {
                if (GetRemainingDays(today) > 1)
                {
                    result = Math.Sign(GoalValue - StartingValue) * (GoalValue - PresentValue) / GetRemainingDays(today);
                }
                else
                {
                    result = Math.Sign(GoalValue - StartingValue) * GoalValue - PresentValue;
                }
            }
            if (this.Nature == NatureEnum.BetweenLimits)
            {
                if (PresentValue < GoalValue)
                {
                    if (GetRemainingDays(today) > 1)
                    {
                        result = (GoalValue - PresentValue) / GetRemainingDays(today);
                    }
                    else
                    {
                        result = GoalValue - PresentValue;
                    }
                }
                else
                {
                    result = 0;
                }
            }

            if (result < 0)
            {
                result = 0;
            }
            return(result);
        }
Example #4
0
        /// <summary>
        /// Number of days remaining to "due date".
        /// </summary>
        /// <returns>Number of days</returns>
        public float GetRemainingDays(DayInfo today)
        {
            float result = 0;

            TimeSpan leftDays = DueDate.Subtract(DateTime.Today);

            result = (float)leftDays.Days;

            result += (today.GetTodaysTotalHours() - today.GetTodaysPassedHours()) / today.GetTodaysTotalHours();

            if (result < 0)
            {
                result = 0;
            }
            if (result > GetTotalDays())
            {
                result = GetTotalDays();
            }

            return(result);
        }
Example #5
0
        private float GetPassedDays(DayInfo today)
        {
            float result = 0;

            TimeSpan upToNow = DateTime.Today.Subtract(StartDate);

            result = (float)upToNow.Days;

            result += today.GetTodaysPassedHours() / today.GetTodaysTotalHours();

            if (result < 0)
            {
                result = 0;
            }
            if (result > GetTotalDays())
            {
                result = GetTotalDays();
            }

            return(result);
        }
Example #6
0
        /// <summary>
        /// When tracking goals, present value should be compared to "desired value".
        /// This method calculates the desired value.
        /// </summary>
        /// <returns>The desired value.</returns>
        public float GetDesiredValue(DayInfo today)
        {
            float result = 0;

            if (GoalValue > 0)
            {
                if (Nature == NatureEnum.Standart)
                {
                    result = StartingValue - GetDesiredPercentage(today) * (StartingValue - GoalValue) / 100;
                }
                else if (Nature == NatureEnum.BetweenLimits)
                {
                    result = StartingValue - (100 - GetDesiredPercentage(today)) * (StartingValue - GoalValue) / 100;
                }
                //result = startingValue - (desiredPercentage) * (startingValue - goalValue) / 100;
            }
            else
            {
                result = 0;
            }

            return(result);
        }
Example #7
0
        /// <summary>
        /// Gets the present performence of goal completion.
        /// 100 * PresentPercentage / DesiredPresentPercentage
        /// </summary>
        /// <returns>The percentage</returns>
        public float GetPerformance(bool isFull, DayInfo today)
        {
            float result            = 0;
            float presentPercentage = GetPresentPercentage();
            float desiredPercentage = GetDesiredPercentage(today);

            if (desiredPercentage > 0)
            {
                result = 100 * presentPercentage / desiredPercentage;
            }
            else
            {
                if (presentPercentage > 0)
                {
                    result = 100;
                }
                else
                {
                    result = 0;
                }
            }

            if (!isFull)
            {
                if (result > 100)
                {
                    result = 100;
                }
            }
            if (result < 0)
            {
                result = 0;
            }

            return(result);
        }