locked
Webservice to connect to HV RRS feed

  • Question

  • Hi!

    I am converting my web application to webservice and I simply start with small task: saving BloodGlucose level. I also use offline connection.
    I added references to all HV dll, added application info to Webconfig file, but I get the error

    Error     An object reference is required for the nonstatic field, method, or property 'Microsoft.Health.PersonInfo.SelectedRecord.get'

    Here is my simple code :

    using System;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Web.Services.Configuration;
    using System.Web.Services.Discovery;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.Health;
    using Microsoft.Health.Web;
    using Microsoft.Health.ItemTypes;

    ...

        [WebMethod]
        public string BloodGlucoseInput(int BG)
        {
            //Predefined PersonId and RecordId for my application, we can get them by running offline SDK sample for the first time
            Guid personId = new Guid("43fe67fb-e551-48e3-9dad-2bbbcbf41b96");
            Guid recordId = new Guid("b4379b7c-a228-4e15-b457-4785cf16099c");

            // Do the offline connection
            OfflineWebApplicationConnection offlineConn = new OfflineWebApplicationConnection(personId);
            offlineConn.Authenticate();
            HealthRecordAccessor accessor = new HealthRecordAccessor(offlineConn, recordId);

            //Store Blood Glucose level
            BloodGlucoseMeasurement value = new BloodGlucoseMeasurement(BG);
            BloodGlucose bloodGlucose = new BloodGlucose(new HealthServiceDateTime(DateTime.Now), value, new CodableValue("whole-blood"));
            PersonInfo.SelectedRecord.NewItem(bloodGlucose);

            return "Blood Glucose Level was saved!";
        }



    Do you know where is the problem?

     
    Monday, August 3, 2009 8:47 AM

Answers

  • Instead of PersonInfo.SelectedRecord (which is available only in online scenario when you derive a page from HealthServicePage)

    Use the following code:

    accessor.NewItem(bloodGlucose);


    Raj


    Raj HealthVault Developer Tool http://xray.getrealconsulting.com
    Monday, August 3, 2009 9:18 AM

All replies

  • Instead of PersonInfo.SelectedRecord (which is available only in online scenario when you derive a page from HealthServicePage)

    Use the following code:

    accessor.NewItem(bloodGlucose);


    Raj


    Raj HealthVault Developer Tool http://xray.getrealconsulting.com
    Monday, August 3, 2009 9:18 AM
  • oh! sure ) thanks a lot for help and have a good day!
    Monday, August 3, 2009 9:54 AM