コード例 #1
0
 /// <summary>
 /// Converts a DMeasurement to string format "Measurement (Dept)"
 /// </summary>
 /// <param name="meas">Measurement to convert</param>
 /// <returns>String in format "Measurement (Dept)"</returns>
 private static string measurementToString(DMeasurement meas)
 {
     return meas.ViewModel.NameMeasurement
             + " (" + meas.Parent.ViewModel.DepartmentName + ")";
 }
コード例 #2
0
        /// <summary>
        /// Calculates measurement's score weight based on all its weighted goals
        /// </summary>
        /// <param name="meas">Measurement to retrieve score weight</param>
        /// <returns>Number between 0 and 100, or null if no valid goals</returns>
        private Decimal? GetMeasScoreWeight(DMeasurement meas)
        {
            bool validWeight = false;
            decimal? sumWeights = 0;

            if (meas.Goal != null)
            {
                var goalScoreWeight = getGoalScoreWeight(meas.Goal);
                if (goalScoreWeight != null)
                {
                    validWeight = true;
                    sumWeights += goalScoreWeight;
                }
            }

            if (!validWeight)
                return null;
            return sumWeights;
        }
コード例 #3
0
 /// <summary>
 /// Creates a new instance of the DGoal class
 /// </summary>
 /// <param name="parent">DMeasurement hosting this DGoal</param>
 /// <param name="model">Model providing data for this DGoal</param>
 public DGoal(DMeasurement parent, Goal model)
 {
     this.Parent = parent;
     this.db = parent.db;
     this.Model = model;
     ViewModel = new GoalDataViewModel();
     ViewModel.AppliesAfter = model.Applies_After_Tmstp;
     ViewModel.ExceedsVal = model.Exceeds_Val;
     ViewModel.GoalID = model.Goal_ID;
     ViewModel.MeetsPlusVal = model.Meets_Plus_Val;
     ViewModel.MeetsVal = model.Meets_Val;
     ViewModel.Operation = model.Typ;
 }
コード例 #4
0
        /// <summary>
        /// Calculates measurements's score based on all its weighted goals
        /// </summary>
        /// <param name="meas">Measurement 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>
        public Decimal? GetMeasScore(DMeasurement meas, DateTime? optionalStart = null, DateTime? optionalEnd = null)
        {
            DateTime end = optionalEnd.GetValueOrDefault(DateTime.Today);
            DateTime start = optionalStart.GetValueOrDefault(end.AddYears(-1));

            if (meas.Goal != null)
            {
                return GetGoalScore(meas.Goal, start, end);
            }
            return null;
        }
コード例 #5
0
 /// <summary>
 /// Creates a new instance of the DDatapoint class
 /// </summary>
 /// <param name="parent">DMeasurement hosting this DDatapoint</param>
 /// <param name="model">Model providng data for this DDatapoint</param>
 public DDatapoint(DMeasurement parent, Datapoint model)
 {
     this.Parent = parent;
     this.db = parent.db;
     this.Model = model;
     ViewModel = new DataPointViewModel();
     ViewModel.MeasurementID = Parent.Model.Measurement_ID;
     ViewModel.NameMeasurement = Parent.Model.NM;
     ViewModel.YTDCalc = Parent.Model.YTD_Calc;
     ViewModel.DataPointID = model.Datapoint_ID;
     ViewModel.Applicable = model.Applicable_DT;
     ViewModel.Value = model.Value_AMT;
     ViewModel.NumType = Parent.Model.Type_ID;
     ViewModel.IsCalculated = Parent.Model.Is_Calculated;
     ViewModel.HasSubmitted = model.HasSubmitted_IN;
     string roundingString = "";
     var decimalPlaces = (from m in db.Measurements
                          where Parent.Model.Measurement_ID == m.Measurement_ID
                          select m.Decimal_Points_SZ).ToList();
     var roundingInt = (int)(decimalPlaces.Count > 0 ? decimalPlaces.First() : 0);
     if (roundingInt != 0)
     {
         roundingString = ".";
         for (var i = 0; i < roundingInt; i++)
             roundingString += "0";
     }
     ViewModel.RoudingString = roundingString;
 }