コード例 #1
0
        /// <summary>
        /// Calculates goal's score
        /// </summary>
        /// <param name="goal">Goal to retrieve score</param>
        /// <param name="optionalStart">Inclusive start date to consider datapoints, if blank will be one year before end</param>
        /// <param name="optionalEnd">Inclusive end date to consider datapoints, if blank will be today</param>
        /// <returns>Number between 0 and 5, or null if no valid goals</returns>
        private Decimal? GetGoalScore(DGoal goal, DateTime? optionalStart = null, DateTime? optionalEnd = null)
        {
            DateTime end = optionalEnd.GetValueOrDefault(DateTime.Today);
            DateTime start = optionalStart.GetValueOrDefault(end.AddYears(-1));

            var currentValue = goal.Parent.CalculateSingleMeasurementValue(start, end);

            if (currentValue == null)
                return null;

            switch (goal.Model.Typ)
            {
                case "<=":
                    if (currentValue <= goal.Model.Exceeds_Val)
                        return 5;
                    if (currentValue <= goal.Model.Meets_Plus_Val)
                        return 4;
                    if (currentValue <= goal.Model.Meets_Val)
                        return 3;
                    /*
                    if (currentValue <= Model.Meets_Val + (Model.Meets_Val * (decimal).10))
                        return 0; // meetsMinus?
                    if (Model.Meets_Plus_Val != null &&
                            currentValue <= Model.Meets_Plus_Val + (Model.Meets_Plus_Val * (decimal).10))
                        return 0; // meetsMinusMinus?
                    if (Model.Exceeds_Val != null &&
                            currentValue <= Model.Exceeds_Val + (Model.Exceeds_Val * (decimal).10))
                        return 0; // meetsMinusMinusMinus?
                    */
                    return 0;

                case ">=":
                    if (currentValue >= goal.Model.Exceeds_Val)
                        return 5;
                    if (currentValue >= goal.Model.Meets_Plus_Val)
                        return 4;
                    if (currentValue >= goal.Model.Meets_Val)
                        return 3;
                    /*
                    if (currentValue >= Model.Meets_Val - (Model.Meets_Val * (decimal).10))
                        return 0;
                    if (Model.Meets_Plus_Val != null &&
                            currentValue >= Model.Meets_Plus_Val + (Model.Meets_Plus_Val * (decimal).10))
                        return 0;
                    if (Model.Exceeds_Val != null &&
                            currentValue >= Model.Exceeds_Val + (Model.Exceeds_Val * (decimal).10))
                        return 0;
                    */
                    return 0;
                default:
                    return null;
            }
        }
コード例 #2
0
 /// <summary>
 /// Calculates goal's score weight
 /// </summary>
 /// <param name="goal">Goal to retrieve score weight</param>
 /// <returns>Number between 0 and 100, or null if no valid goals</returns>
 private Decimal? getGoalScoreWeight(DGoal goal)
 {
     return goal.Model.Wgt;
 }
コード例 #3
0
 /// <summary>
 /// Refreshes list of goals in measurement
 /// </summary>
 public void RefreshGoals()
 {
     savedGoal = null;
 }