public void AddOrUpdateHealthKitDataToStorage(HealthKitData record)
        {
            string sql;

            //if (GetSpesificHealthKitData (record.PersonId).Any (x => x.RecordId.Equals (record.PersonId)))
            //{
            //	sql = @"INSERT INTO HealthKitData(RecordingTimeStamp,BloodType,DateOfBirth,Sex,Height) VALUES (@RecordingTimeStamp,@BloodType,@DateOfBirth,@Sex,@Height) WHERE PersonId = @PersonId ;";
            //}

            sql = @"INSERT INTO HealthKitData(PersonId,RecordingTimeStamp,BloodType,DateOfBirth,Sex,Height)
						VALUES (@PersonId, @RecordingTimeStamp,@BloodType,@DateOfBirth,@Sex,@Height);"                        ;

            using (var connection = new MySqlConnection())
            {
                try
                {
                    connection.ConnectionString = m_connectionString;
                    connection.Open();
                    connection.Execute(sql, record);
                }
                catch (MySql.Data.MySqlClient.MySqlException e)
                {
                    Console.WriteLine(e.ToString());
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Exemple #2
0
        public void AddOrUpdateHealthKitDataToStorage(HealthKitData person)
        {
            var stopWatch = Stopwatch.StartNew();

            m_dataStorage.AddOrUpdateHealthKitDataToStorage(person);
            stopWatch.Stop();
            m_logger.Info(string.Format("{0} AddOrUpdateHealthKitDataToStorage: Call took {1} Ms", m_dataStorage.GetType(), stopWatch.ElapsedMilliseconds));
        }
 public void Init()
 {
     m_healthKitAccess                     = new TestableHealthKitDataAccess();
     m_decoratableObject                   = new HealthKitData();
     m_decoratableDistanceReading          = new DistanceReading();
     m_decoratableHeartRateReading         = new HeartRateReading();
     m_decoratableObject.DistanceReadings  = m_decoratableDistanceReading;
     m_decoratableObject.HeartRateReadings = m_decoratableHeartRateReading;
     m_decorator = new HealthKitDataDecorator(m_healthKitAccess, m_decoratableObject);
 }
Exemple #4
0
 public DistanceSummaryViewModel(IHealthKitDataWebService healthKitDataWebService)
 {
     m_healthKitdataObject = new HealthKitData {
         PersonId = 3, DistanceReadings = new DistanceReading {
         }, HeartRateReadings = new HeartRateReading {
         }, Device = Container.Resolve <IDevice>().Device
     };
     m_healthKitDataDecorator = new HealthKitDataDecorator(Container.Singleton <IHealthKitAccess> (), m_healthKitdataObject);
     StartDecoration();
     m_healthKitDataWebService = healthKitDataWebService;
     m_healthKitDataFromServer = new ObservableCollection <HealthKitData> ();
     m_uploadCommand           = new RelayCommand(() => UploadDataToHealthKitServer(), () => true);    // => CanUploadHealthKitDataToServer());
     m_GetDataCommand          = new DelegateCommand(GetDataFromHealthKitServer, () => true);
     m_reloadCommand           = new DelegateCommand(StartDecoration, () => true);
 }
Exemple #5
0
        public void AddOrUpdateHealthKitDataToStorage(HealthKitData record)
        {
            List <HealthKitData> healthKitDataRecords = new List <HealthKitData> ();

            if (record.PersonId == 0)
            {
                record.PersonId = m_storedHealthInfo.Count + 1;
                healthKitDataRecords.Add(record);
            }
            if (GetSpesificHealthKitData(record.PersonId) != null)
            {
                healthKitDataRecords = GetSpesificHealthKitData(record.PersonId).ToList();
                record.RecordId      = healthKitDataRecords.Count + 1;
                healthKitDataRecords.Add(record);
            }

            m_storedHealthInfo.AddOrUpdate(record.PersonId, healthKitDataRecords, (id, oldPersonHealthInfo) => healthKitDataRecords);
        }
        public void AddOrUpdateHealthKitDataToStorage(HealthKitData person)
        {
            var sql = @"INSERT INTO HealthKitData(PersonId,RecordingTimeStamp,BloodType,DateOfBirth,Sex,Height)
						VALUES (@PersonId, @RecordingTimeStamp,@BloodType,@DateOfBirth,@Sex,@Height);"                        ;

            using (var connection = new NpgsqlConnection())
            {
                try
                {
                    connection.ConnectionString = m_connectionString;
                    connection.Open();
                    connection.Execute(sql, person);
                }
                catch (MySql.Data.MySqlClient.MySqlException e)
                {
                    Console.WriteLine(e.ToString());
                }
                finally
                {
                    connection.Close();
                }
            }
        }
 public void AddOrUpdateHealthKitDataToStorage(HealthKitData person)
 {
     //	m_redisDatabase.SetAdd (person.Id, person);
 }
 public void AddOrUpdateHealthKitDataToStorage(HealthKitData person)
 {
     m_solrServer.Add(person);
 }
 public string UploadHealthKitDataToHealthKitServer(string healthKitServerAPIAddress, HealthKitData dataObject)
 {
     try
     {
         using (var client = new WebClient())
         {
             client.Headers[HttpRequestHeader.ContentType] = "application/json";
             var response = client.UploadString(new Uri(healthKitServerAPIAddress), JsonConvert.SerializeObject(dataObject));
             return(response);
         }
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }