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); // Search the health record for basic demographic // information. // Most user records contain an item of this type. HealthRecordSearcher search = access.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter( HvShellUtilities.NameToTypeId(Type)); search.Filters.Add(filter); foreach (Object o in search.GetMatchingItems()[0]) { WriteObject(o); } }
public void DeProvision() { Guid tempPersonId = _personId; Guid tempRecordId = _recordId; // first reset local state so // that even if things fail after this // the next app launch will have fresh state _isProvisioned = false; _personId = Guid.Empty; _recordId = Guid.Empty; _applicationId = Guid.Empty; SaveUserSettings(); // attempt to remove authorization of application from server HealthClientAuthorizedConnection connection = HealthClientApplication.CreateAuthorizedConnection(tempPersonId); HealthRecordAccessor accessor = new HealthRecordAccessor(connection, tempRecordId); accessor.RemoveApplicationAuthorization(); // delete the local certificate _healthClientApplication.DeleteCertificate(); _healthClientApplication = null; }
public void SetTemperatureOnHealthVault(double tempValue) { try { if (!_isProvisioned) { MessageBox.Show("Please provision application first"); return; } HealthClientAuthorizedConnection connection = HealthClientApplication.CreateAuthorizedConnection(PersonId); HealthRecordAccessor accessor = new HealthRecordAccessor(connection, RecordId); TemperatureMeasurement temperature = new TemperatureMeasurement(tempValue); VitalSigns vitalSign = new VitalSigns(); //generate random date DateTime startDate = new DateTime(2018, 1, 1); DateTime endDate = new DateTime(2018, 12, 30); TimeSpan timeSpan = endDate - startDate; var randomTest = new Random(); TimeSpan newSpan = new TimeSpan(0, randomTest.Next(0, (int)timeSpan.TotalMinutes), 0); DateTime newDate = startDate + newSpan; //set time now //vitalSign.When = new HealthServiceDateTime(DateTime.UtcNow); vitalSign.When = new HealthServiceDateTime(newDate); CodableValue codableValue = new CodableValue(); codableValue.Text = "celsius"; VitalSignsResultType vitalSignsResultType = new VitalSignsResultType(); vitalSignsResultType.Unit = codableValue; vitalSignsResultType.TextValue = "Temperature"; vitalSignsResultType.Title.Text = "Temperature"; vitalSignsResultType.Value = tempValue; vitalSign.VitalSignsResults.Add(vitalSignsResultType); accessor.NewItem(vitalSign); } catch (Exception ex) { throw; } }
/// <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); }
/// <summary> /// Creates a connection to HealthVault and obtains weight data /// </summary> /// <returns></returns> public HealthRecordItemCollection GetWeightFromHealthVault() { if (!_isProvisioned) { MessageBox.Show("Please provision application first"); return(null); } HealthClientAuthorizedConnection connection = HealthClientApplication.CreateAuthorizedConnection(PersonId); HealthRecordAccessor accessor = new HealthRecordAccessor(connection, RecordId); HealthRecordSearcher searcher = accessor.CreateSearcher(); HealthRecordFilter filter = new HealthRecordFilter(ItemTypes.Weight.TypeId); searcher.Filters.Add(filter); HealthRecordItemCollection items = searcher.GetMatchingItems()[0]; return(items); }
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); }
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 accessor = new HealthRecordAccessor( authConnection, authConnection.GetPersonInfo().GetSelfRecord().Id); HealthServiceRequest request = new HealthServiceRequest(accessor.Connection, "PutThings", 2, accessor); // Read the input file request.Parameters = System.IO.File.ReadAllText(Path.GetFullPath(FileName)); request.Execute(); }