Updated samples to work with NodaTime changes (#14)

This commit is contained in:
David Rickard 2017-06-06 09:50:14 -07:00 коммит произвёл GitHub
Родитель 1cdac6fb5e
Коммит 0e7613361d
14 изменённых файлов: 59 добавлений и 24 удалений

Просмотреть файл

@ -67,7 +67,7 @@ namespace HealthVaultMobileSample.UWP.Views.Weights
//Add a custom type mapping for the Weight class so the charting library knows how to draw it
var weightConfiguration = Mappers.Xy<Weight>()
.X(dayModel => (double)dayModel.EffectiveDate.Ticks / TimeSpan.FromHours(1).Ticks)
.X(dayModel => (double)dayModel.EffectiveDate.Value.ToDateTimeUnspecified().Ticks / TimeSpan.FromHours(1).Ticks)
.Y(dayModel => (double)converter.Convert(dayModel.Value.Kilograms, typeof(double), null, null));
//Create the Series and add data

Просмотреть файл

@ -13,6 +13,8 @@ using Windows.ApplicationModel.Resources;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using NodaTime;
using Duration = NodaTime.Duration;
namespace HealthVaultMobileSample.UWP.Views.Weights
{
@ -61,11 +63,13 @@ namespace HealthVaultMobileSample.UWP.Views.Weights
}
else if (QueryTimeframe.SelectedIndex == (int)QueryTimeframeEnum.Last30d)
{
LocalDateTime localNow = SystemClock.Instance.GetCurrentInstant().InZone(DateTimeZoneProviders.Tzdb.GetSystemDefault()).LocalDateTime;
//In this mode, the app specifies a ThingQuery which can be used for functions like
//filtering, or paging through values
ThingQuery query = new ThingQuery()
ThingQuery query = new ThingQuery
{
EffectiveDateMin = DateTime.Now.AddDays(-30)
EffectiveDateMin = localNow.Minus(Period.FromDays(30))
};
Items = await thingClient.GetThingsAsync<Weight>(recordInfo.Id, query);
@ -101,9 +105,11 @@ namespace HealthVaultMobileSample.UWP.Views.Weights
kg = value;
}
LocalDateTime localNow = SystemClock.Instance.GetCurrentInstant().InZone(DateTimeZoneProviders.Tzdb.GetSystemDefault()).LocalDateTime;
List<Weight> list = new List<Weight>();
list.Add(new Weight(
new HealthServiceDateTime(DateTime.Now),
new HealthServiceDateTime(localNow),
new WeightValue(kg, new DisplayValue(value, (Units.SelectedValue as ComboBoxItem).Content.ToString()))));
HealthRecordInfo recordInfo = (await _connection.GetPersonInfoAsync()).SelectedRecord;

Просмотреть файл

@ -1,7 +1,7 @@
{
"dependencies": {
"LiveCharts.Uwp": "0.8.0",
"Microsoft.HealthVault.Client": "1.0.20517.1",
"Microsoft.HealthVault.Client": "1.0.20605.1",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.3.1",
"Microsoft.Xaml.Behaviors.Uwp.Managed": "2.0.0",
"NETStandard.Library": "1.6.1",

Просмотреть файл

@ -67,16 +67,16 @@
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.HealthVault, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.HealthVault.1.0.20517.1\lib\netstandard1.4\Microsoft.HealthVault.dll</HintPath>
<HintPath>..\packages\Microsoft.HealthVault.1.0.20605.1\lib\netstandard1.4\Microsoft.HealthVault.dll</HintPath>
</Reference>
<Reference Include="Microsoft.HealthVault.Client, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.HealthVault.Client.1.0.20517.1\lib\monoandroid\Microsoft.HealthVault.Client.dll</HintPath>
<HintPath>..\packages\Microsoft.HealthVault.Client.1.0.20605.1\lib\monoandroid\Microsoft.HealthVault.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.HealthVault.Client.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.HealthVault.Client.1.0.20517.1\lib\monoandroid\Microsoft.HealthVault.Client.Core.dll</HintPath>
<HintPath>..\packages\Microsoft.HealthVault.Client.1.0.20605.1\lib\monoandroid\Microsoft.HealthVault.Client.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.HealthVault.RestApi, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.HealthVault.1.0.20517.1\lib\netstandard1.4\Microsoft.HealthVault.RestApi.dll</HintPath>
<HintPath>..\packages\Microsoft.HealthVault.1.0.20605.1\lib\netstandard1.4\Microsoft.HealthVault.RestApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Rest.ClientRuntime.2.3.7\lib\netstandard1.4\Microsoft.Rest.ClientRuntime.dll</HintPath>
@ -90,6 +90,12 @@
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\netstandard1.3\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NodaTime, Version=2.0.2.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.2.0.2\lib\netstandard1.3\NodaTime.dll</HintPath>
</Reference>
<Reference Include="NodaTime.Serialization.JsonNet, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.Serialization.JsonNet.2.0.0\lib\netstandard1.3\NodaTime.Serialization.JsonNet.dll</HintPath>
</Reference>
<Reference Include="OkHttp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\modernhttpclient.2.4.2\lib\MonoAndroid\OkHttp.dll</HintPath>
</Reference>

Просмотреть файл

@ -10,6 +10,10 @@
<assemblyIdentity name="XLabs.Serialization" publicKeyToken="d65109b36e5040e4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.5782.15703" newVersion="2.0.5782.15703" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NodaTime" publicKeyToken="4226afe0d9b296d1" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -3,14 +3,16 @@
<package id="ExifLib.PCL" version="1.0.2-pre01" targetFramework="monoandroid71" />
<package id="Grace" version="6.0.1" targetFramework="monoandroid70" />
<package id="Microsoft.CSharp" version="4.3.0" targetFramework="monoandroid70" />
<package id="Microsoft.HealthVault" version="1.0.20517.1" targetFramework="monoandroid71" />
<package id="Microsoft.HealthVault.Client" version="1.0.20517.1" targetFramework="monoandroid71" />
<package id="Microsoft.HealthVault" version="1.0.20605.1" targetFramework="monoandroid71" />
<package id="Microsoft.HealthVault.Client" version="1.0.20605.1" targetFramework="monoandroid71" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="monoandroid70" />
<package id="Microsoft.Rest.ClientRuntime" version="2.3.7" targetFramework="monoandroid71" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="monoandroid70" />
<package id="modernhttpclient" version="2.4.2" targetFramework="monoandroid70" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="monoandroid70" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="monoandroid71" />
<package id="NodaTime" version="2.0.2" targetFramework="monoandroid71" />
<package id="NodaTime.Serialization.JsonNet" version="2.0.0" targetFramework="monoandroid71" />
<package id="System.AppContext" version="4.3.0" targetFramework="monoandroid70" />
<package id="System.Collections" version="4.3.0" targetFramework="monoandroid70" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="monoandroid70" />
@ -47,6 +49,7 @@
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="monoandroid70" />
<package id="System.Runtime.Serialization.Formatters" version="4.3.0" targetFramework="monoandroid70" />
<package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="monoandroid70" />
<package id="System.Runtime.Serialization.Xml" version="4.1.1" targetFramework="monoandroid71" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="monoandroid70" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="monoandroid70" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="monoandroid70" />

Просмотреть файл

@ -10,6 +10,7 @@ using Microsoft.HealthVault.Connection;
using Microsoft.HealthVault.ItemTypes;
using Microsoft.HealthVault.Person;
using Microsoft.HealthVault.Vocabulary;
using NodaTime.Extensions;
using Xamarin.Forms;
namespace HealthVault.Sample.Xamarin.Core.ViewModels
@ -115,7 +116,7 @@ namespace HealthVault.Sample.Xamarin.Core.ViewModels
IThingClient thingClient = _connection.CreateThingClient();
PersonInfo personInfo = await _connection.GetPersonInfoAsync();
await thingClient.UpdateThingsAsync(personInfo.SelectedRecord.Id, new Collection<Medication>() { medication });
await thingClient.UpdateThingsAsync(personInfo.SelectedRecord.Id, new Collection<Medication> { medication });
await NavigationService.NavigateBackAsync();
}
@ -148,7 +149,7 @@ namespace HealthVault.Sample.Xamarin.Core.ViewModels
empty = inputDateEmpty && medication.DateStarted == null;
if (!empty)
{
medication.DateStarted = new ApproximateDateTime(DateStarted);
medication.DateStarted = new ApproximateDateTime(DateStarted.ToLocalDateTime());
}
}
}

Просмотреть файл

@ -10,6 +10,7 @@ using Microsoft.HealthVault.Connection;
using Microsoft.HealthVault.ItemTypes;
using Microsoft.HealthVault.Record;
using Microsoft.HealthVault.Thing;
using NodaTime.Extensions;
using Xamarin.Forms;
namespace HealthVault.Sample.Xamarin.Core.ViewModels
@ -124,7 +125,7 @@ namespace HealthVault.Sample.Xamarin.Core.ViewModels
if (_personalInformation.BirthDate != null)
{
BirthDate = _personalInformation.BirthDate.ToDateTime();
BirthDate = _personalInformation.BirthDate.ToLocalDateTime().ToDateTimeUnspecified();
}
else
{
@ -187,7 +188,7 @@ namespace HealthVault.Sample.Xamarin.Core.ViewModels
_basicInformation.BirthYear = BirthDate.Year;
_basicInformation.Gender = GenderIndex == 0 ? Gender.Male : Gender.Female;
_personalInformation.BirthDate = new HealthServiceDateTime(BirthDate);
_personalInformation.BirthDate = new HealthServiceDateTime(BirthDate.ToLocalDateTime());
await _thingClient.UpdateThingsAsync(_recordId, new List<IThing> { _basicInformation, _personalInformation });

Просмотреть файл

@ -6,6 +6,7 @@ using HealthVault.Sample.Xamarin.Core.Services;
using Microsoft.HealthVault.Clients;
using Microsoft.HealthVault.Connection;
using Microsoft.HealthVault.ItemTypes;
using NodaTime;
using Xamarin.Forms;
namespace HealthVault.Sample.Xamarin.Core.ViewModels
@ -73,7 +74,7 @@ namespace HealthVault.Sample.Xamarin.Core.ViewModels
List<Weight> weightList = new List<Weight>();
weightList.Add(new Weight(
new HealthServiceDateTime(DateTime.Now),
new HealthServiceDateTime(SystemClock.Instance.GetCurrentInstant().InZone(DateTimeZoneProviders.Tzdb.GetSystemDefault()).LocalDateTime),
new WeightValue(kilograms, new DisplayValue(weightNumber, isMetric ? "kg" : "lbs"))));
IThingClient thingClient = _connection.CreateThingClient();

Просмотреть файл

@ -1,7 +1,7 @@
{
"supports": {},
"dependencies": {
"Microsoft.HealthVault.Client": "1.0.20517.1",
"Microsoft.HealthVault.Client": "1.0.20605.1",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.1",
"Newtonsoft.Json": "10.0.2",

Просмотреть файл

@ -1,6 +1,6 @@
{
"dependencies": {
"Microsoft.HealthVault.Client": "1.0.20517.1",
"Microsoft.HealthVault.Client": "1.0.20605.1",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.3.3",
"Newtonsoft.Json": "10.0.2",
"Xamarin.Forms": "2.3.4.224",

Просмотреть файл

@ -130,16 +130,16 @@
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.HealthVault, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.HealthVault.1.0.20517.1\lib\netstandard1.4\Microsoft.HealthVault.dll</HintPath>
<HintPath>..\packages\Microsoft.HealthVault.1.0.20605.1\lib\netstandard1.4\Microsoft.HealthVault.dll</HintPath>
</Reference>
<Reference Include="Microsoft.HealthVault.Client, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.HealthVault.Client.1.0.20517.1\lib\xamarinios\Microsoft.HealthVault.Client.dll</HintPath>
<HintPath>..\packages\Microsoft.HealthVault.Client.1.0.20605.1\lib\xamarinios\Microsoft.HealthVault.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.HealthVault.Client.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.HealthVault.Client.1.0.20517.1\lib\xamarinios\Microsoft.HealthVault.Client.Core.dll</HintPath>
<HintPath>..\packages\Microsoft.HealthVault.Client.1.0.20605.1\lib\xamarinios\Microsoft.HealthVault.Client.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.HealthVault.RestApi, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.HealthVault.1.0.20517.1\lib\netstandard1.4\Microsoft.HealthVault.RestApi.dll</HintPath>
<HintPath>..\packages\Microsoft.HealthVault.1.0.20605.1\lib\netstandard1.4\Microsoft.HealthVault.RestApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Rest.ClientRuntime.2.3.7\lib\netstandard1.4\Microsoft.Rest.ClientRuntime.dll</HintPath>
@ -150,6 +150,12 @@
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\netstandard1.3\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NodaTime, Version=2.0.2.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.2.0.2\lib\netstandard1.3\NodaTime.dll</HintPath>
</Reference>
<Reference Include="NodaTime.Serialization.JsonNet, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.Serialization.JsonNet.2.0.0\lib\netstandard1.3\NodaTime.Serialization.JsonNet.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />

Просмотреть файл

@ -10,6 +10,10 @@
<assemblyIdentity name="XLabs.Serialization" publicKeyToken="d65109b36e5040e4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.5782.15703" newVersion="2.0.5782.15703" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NodaTime" publicKeyToken="4226afe0d9b296d1" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -3,14 +3,16 @@
<package id="ExifLib.PCL" version="1.0.2-pre01" targetFramework="xamarinios10" />
<package id="Grace" version="6.0.1" targetFramework="xamarinios10" />
<package id="Microsoft.CSharp" version="4.3.0" targetFramework="xamarinios10" />
<package id="Microsoft.HealthVault" version="1.0.20517.1" targetFramework="xamarinios10" />
<package id="Microsoft.HealthVault.Client" version="1.0.20517.1" targetFramework="xamarinios10" />
<package id="Microsoft.HealthVault" version="1.0.20605.1" targetFramework="xamarinios10" />
<package id="Microsoft.HealthVault.Client" version="1.0.20605.1" targetFramework="xamarinios10" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="xamarinios10" />
<package id="Microsoft.Rest.ClientRuntime" version="2.3.7" targetFramework="xamarinios10" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="xamarinios10" />
<package id="modernhttpclient" version="2.4.2" targetFramework="xamarinios10" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="xamarinios10" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="xamarinios10" />
<package id="NodaTime" version="2.0.2" targetFramework="xamarinios10" />
<package id="NodaTime.Serialization.JsonNet" version="2.0.0" targetFramework="xamarinios10" />
<package id="System.AppContext" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Collections" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="xamarinios10" />
@ -47,6 +49,7 @@
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Runtime.Serialization.Formatters" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Runtime.Serialization.Xml" version="4.1.1" targetFramework="xamarinios10" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="xamarinios10" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="xamarinios10" />