示例#1
0
        private static JArray CreateJsonResponse(HealthRecordItemCollection items)
        {
            JObject result    = new JObject();
            JObject resultObj = new JObject();
            JArray  itemArr   = new JArray();

            if (items != null)
            {
                foreach (HealthRecordItem item in items)
                {
                    ItemTypes.Weight weight = (ItemTypes.Weight)item;
                    JObject          itemW  = new JObject();
                    itemW["time"]   = weight.EffectiveDate.ToUniversalTime();
                    itemW["weight"] = weight.Value.Kilograms.ToString();
                    itemW["unit"]   = "kilograms";
                    itemArr.Add(itemW);
                }
            }
            result["count"]  = items.Count();
            result["result"] = itemArr;
            if (itemArr.Count > 0)
            {
                resultObj["status"]            = "ok";
                resultObj["getWeightResponse"] = result;
                return(itemArr);
            }
            else
            {
                resultObj["status"]            = "no content";
                resultObj["getWeightResponse"] = result;
                return(itemArr);
            }
        }
示例#2
0
        /// <summary>
        /// Creates a connection to HealthVault and sets weight data
        /// </summary>
        /// <param name="weightValue"></param>
        public void SetWeightOnHealthVault(double weightValue)
        {
            if (!_isProvisioned)
            {
                MessageBox.Show("Please provision application first");
                return;
            }

            HealthClientAuthorizedConnection connection =
                HealthClientApplication.CreateAuthorizedConnection(PersonId);

            HealthRecordAccessor accessor = new HealthRecordAccessor(connection, RecordId);

            ItemTypes.Weight weight = new ItemTypes.Weight();
            weight.Value = new WeightValue(weightValue);
            accessor.NewItem(weight);
        }
示例#3
0
        private void buttonGetWeight_Click(object sender, EventArgs e)
        {
            listViewWeight.Items.Clear();

            HealthRecordItemCollection items = _hvclient.GetWeightFromHealthVault();

            if (items != null)
            {
                foreach (HealthRecordItem item in items)
                {
                    ItemTypes.Weight weight = (ItemTypes.Weight)item;
                    ListViewItem     lvi    = new ListViewItem(weight.Value.Kilograms.ToString());
                    lvi.SubItems.Add(weight.When.ToString());

                    listViewWeight.Items.Add(lvi);
                }
            }
        }
        protected void saveButton_clicked(object sender, EventArgs e)
        {
            if (cmc == null) { cmc = new CommomMethodsClass(PersonInfo); }

            Double weightInPounds = Double.Parse(weight);

            Weight weightHV = new Weight();
            weightHV.Value.Kilograms = weightInPounds / 2.204;
            weightHV.Value.DisplayValue = new DisplayValue(weightInPounds, "pounds");
            weightHV.When = new HealthServiceDateTime(DateTime.Today);
            PersonInfo.SelectedRecord.NewItem(weightHV);

            Double heightInInches = Double.Parse(height);

            Height heightHV = new Height(heightInInches/39.3701);
            heightHV.Value.DisplayValue = new DisplayValue(heightInInches, "inches");
            heightHV.When = new HealthServiceDateTime(DateTime.Today);
            PersonInfo.SelectedRecord.NewItem(heightHV);

            System.Diagnostics.Debug.Write(age + height + weight);
        }
示例#5
0
        protected override void ProcessRecord()
        {
            HealthClientApplication clientApp = HvShellUtilities.GetClient();
            List<PersonInfo> authorizedPeople = new List<PersonInfo>
                (clientApp.ApplicationConnection.GetAuthorizedPeople());
            // Create an authorized connection for each person on the
            //   list.
            HealthClientAuthorizedConnection authConnection = clientApp.CreateAuthorizedConnection(
                authorizedPeople[0].PersonId);

            // Use the authorized connection to read the user's default
            //   health record.
            HealthRecordAccessor access = new HealthRecordAccessor(
                authConnection, authConnection.GetPersonInfo().GetSelfRecord().Id);

            Weight weight = new Weight();
            weight.Value = new WeightValue(Value / 2.2,
                new DisplayValue(Value, "pounds"));

            access.NewItem(weight);
        }