Ejemplo n.º 1
0
        /// <summary>
        /// Create a new miles to HealthVault
        /// </summary>
        public static bool SaveMilesToHV(PersonInfo info, DateTime dateRecorded,
            double distance, ProfileModel profile)
        {
            ApproximateDateTime hvDate = new ApproximateDateTime(
                new ApproximateDate(dateRecorded.Year, dateRecorded.Month, dateRecorded.Day),
                new ApproximateTime(
                    dateRecorded.Hour, dateRecorded.Minute, dateRecorded.Second));

            Exercise newData = new Exercise((ApproximateDateTime)hvDate,
                new CodableValue("walk", new CodedValue("walk", "aerobic-activities")));

            DisplayValue hvDisplay = new DisplayValue(distance, "Miles");

            //convert miles into meters
            if (distance > 0)
            {
                newData.Distance = new Length(DataConversion.ConvertMilesToMeters(distance),
                    hvDisplay);
            }

            if (profile.UserCtx.user_stride > 0)
                newData.Details.Add(ExerciseDetail.Steps_count,
                    new ExerciseDetail(new CodedValue(ExerciseDetail.Steps_count, "exercise-detail-names"),
                        new StructuredMeasurement(
                            DataConversion.GetStepsFromDistanceAndStride(distance, profile.UserCtx.user_stride),
                            new CodableValue("Count", new CodedValue("Count", "exercise-units")))));

            if (profile.UserCtx.user_weight > 0)
                newData.Details.Add(ExerciseDetail.CaloriesBurned_calories,
                    new ExerciseDetail(new CodedValue(ExerciseDetail.CaloriesBurned_calories, "exercise-detail-names"),
                        new StructuredMeasurement(
                            DataConversion.GetEnergyFromDistanceAndWeightNotNullable(distance, profile.UserCtx.user_weight),
                            new CodableValue("Calories", new CodedValue("Calories", "exercise-units")))
                            ));

            info.SelectedRecord.NewItem(newData);
            return true; //Success
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of the <see cref="Height"/> class with the
 /// specified height in meters and display value.
 /// </summary>
 /// 
 /// <param name="meters">
 /// The height in meters.
 /// </param>
 /// 
 /// <param name="displayValue">
 /// The height value as entered by the user. Typically, the display value is 
 /// used when the user-entered height units are not in meters.
 /// </param>
 /// 
 /// <remarks>
 /// The item is not added to the health record until the
 /// <see cref="Microsoft.Health.HealthRecordAccessor.NewItem(HealthRecordItem)"/> method 
 /// is called.
 /// </remarks>
 /// 
 public Height(double meters, DisplayValue displayValue)
     : base(TypeId)
 {
     _value.Value = meters;
     _value.DisplayValue = displayValue;
 }