/// <summary> /// GoogleFitに体重を送信する /// </summary> /// <returns></returns> public async Task <bool> SetGoogleFit(List <HealthRecord> healthRecordList) { var isSuccess = true; var token = await GetToken(); if (string.IsNullOrEmpty(token)) { return(false); } var dataSource = new DataSource(); var dataSourceId = $"{dataSource.Type}:{dataSource.DataType.Name}:{_googleConfiguration.ClientId.Split('-')[0]}:{dataSource.Device.Manufacturer}:{dataSource.Device.Model}:{dataSource.Device.Uid}:{dataSource.DataStreamName}"; try { if (!(await CheckDataSourceAsync(token, dataSourceId))) { //データソース作成 if (!(await CreateDataSourceAsync(token, dataSource))) { return(false); } } foreach (var healthRecord in healthRecordList) { var date = (DateTime)healthRecord.AssayDate; var postNanosecond = ParseExtensions.GetUnixEpochNanoseconds(date.ToUniversalTime()); var widthDataSet = new Dataset() { DataSourceId = dataSourceId, MaxEndTimeNs = postNanosecond, MinStartTimeNs = postNanosecond, Point = new List <Point>() { new Point() { DataTypeName = DataTypeName, StartTimeNanos = postNanosecond, EndTimeNanos = postNanosecond, Value = new List <Value>() { new Value() { FpVal = (double)healthRecord.Weight } } } } }; if (!(await PostWeightDataAsync(token, widthDataSet))) { isSuccess = false; } } } catch (Exception e) { Console.WriteLine(e); return(false); } return(isSuccess); }