コード例 #1
0
        private static void TestGetUpdatedRecords(string token)
        {
            try
            {
                HVDataAccess.HVDataAccessClient       client  = new HVDataAccess.HVDataAccessClient();
                HVDataAccess.GetUpdatedRecordsRequest request = new HVDataAccess.GetUpdatedRecordsRequest();

                request.Token     = token;
                request.SinceDate = DateTime.Parse("4/1/2012");

                HVDataAccess.GetUpdatedRecordsResponse response = client.GetUpdatedRecords(request);

                if (response.Success)
                {
                    Console.WriteLine("\nGetUpdatedRecords Response:\n");
                    foreach (HVDataAccess.RecordUpdateInfo rui in response.UpdatedRecords)
                    {
                        Console.WriteLine("{0}\t{1}\t{2}\n", rui.LastUpdateDate.ToShortDateString(), rui.PersonId.ToString(), rui.RecordId.ToString());
                    }
                }
                else
                {
                    Console.WriteLine("Error = {0}\n", response.Message);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception : GetUpdatedRecords : {0}", ex.Message);
                return;
            }
        }
コード例 #2
0
        private static void TestPutThing(string token, string personId, string recordId)
        {
            try
            {
                HVDataAccess.HVDataAccessClient client  = new HVDataAccess.HVDataAccessClient();
                HVDataAccess.PutThingRequest    request = new HVDataAccess.PutThingRequest();

                request.Token    = token;
                request.PersonId = new Guid(personId);
                request.RecordId = new Guid(recordId);
                request.TypeName = "care-plan";
                request.TypeId   = new Guid("415c95e0-0533-4d9c-ac73-91dc5031186c");
                request.XmlItem  = myCarePlan;

                HVDataAccess.PutThingResponse response = client.PutThing(request);

                if (response.Success == false)
                {
                    Console.WriteLine("Error = {0}\n", response.Message);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception : TestPutThing : {0}\n{1}", ex.Message, ex.StackTrace);
                return;
            }
        }
コード例 #3
0
        private static void TestPutThings(string token, string personId, string recordId)
        {
            try
            {
                HVDataAccess.HVDataAccessClient client  = new HVDataAccess.HVDataAccessClient();
                HVDataAccess.PutThingsRequest   request = new HVDataAccess.PutThingsRequest();

                request.Token    = token;
                request.PersonId = new Guid(personId);
                request.RecordId = new Guid(recordId);

                List <string> items = new List <string>();

                // Add a weight item entry just for testing.
                // See the Health types schema browser at http://developer.healthvault.com for more types.
                //
                items.Add(@"<thing>
                            <type-id>3d34d87e-7fc1-4153-800f-f56592cb0d17</type-id>
                            <data-xml>
                            <weight>
                                <when>
                                    <date>
                                        <y>2012</y>
                                        <m>4</m>
                                        <d>14</d>
                                    </date>
                                    <time>
                                        <h>1</h>
                                        <m>0</m>
                                        <s>0</s>
                                        <f>0</f>
                                    </time>
                                </when>
                                <value>
                                    <kg>60</kg>
                                    <display units='lb'>132</display>
                                </value>
                            </weight>
                            </data-xml>
                        </thing>");

                request.XmlInputs = items.ToArray <string>();

                HVDataAccess.PutThingsResponse response = client.PutThings(request);

                if (response.Success)
                {
                    Console.WriteLine("PutThings : Received={0}\tSucceeded={1}", response.CountReceived, response.CountSucceeded);
                }
                else
                {
                    Console.WriteLine("PutThings : Recevied={0}\tSucceeded={1}\tIndexOnError={2}\t\nError = {0}\n", response.CountReceived, response.CountSucceeded, response.IndexOnError, response.Message);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception : TestPutThings : {0}\n{1}", ex.Message, ex.StackTrace);
                return;
            }
        }
コード例 #4
0
        private static void TestGetThings(string token, string personId, string recordId, ref Guid[] typeIds)
        {
            try
            {
                HVDataAccess.HVDataAccessClient client  = new HVDataAccess.HVDataAccessClient();
                HVDataAccess.GetThingsRequest   request = new HVDataAccess.GetThingsRequest();

                request.Token     = token;
                request.PersonId  = new Guid(personId);
                request.RecordId  = new Guid(recordId);
                request.TypeIds   = typeIds;
                request.SinceDate = DateTime.Parse("1/1/2008");

                HVDataAccess.GetThingsResponse response = client.GetThings(request);
                if (response.Success)
                {
                    Console.WriteLine("\nGetThings Response:\n");
                    foreach (string item in response.Things)
                    {
                        // Example : use LINQ to parse the xml record
                        XElement thing = XElement.Parse(item);
                        Console.WriteLine(thing);

                        // Example : use SimpleThings classes to parse the xml into specific object types, Weight in this example.
                        Guid typeId = new Guid(thing.Element("type-id").Value);
                        if (typeId.Equals(typeIds[0]))                                // Weight type-id is expected at myTypeIds[0] in this test-app
                        {
                            SimpleWeight sw = new SimpleWeight();
                            sw.Initialize(item);
                            Console.WriteLine("SimpleWeight : {0}", sw.Display);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Error = {0}\n", response.Message);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception : TestGetThings : {0}", ex.Message);
                return;
            }
        }