Beispiel #1
0
 public void Copy(Pedometer from)
 {
     steps           = from.steps;
     sleep           = from.sleep;
     trandate        = from.trandate;
     weight          = from.weight;
     bodyfat         = from.bodyfat;
     createddate     = createddate ?? DateTime.UtcNow;
     lastupdateddate = DateTime.UtcNow;
     calconsumed     = from.calconsumed;
 }
Beispiel #2
0
 public void Copy(Pedometer from)
 {
     steps = from.steps;
     sleep = from.sleep;
     trandate = from.trandate;
     weight = from.weight;
     bodyfat = from.bodyfat;
     createddate = createddate ?? DateTime.UtcNow;
     lastupdateddate = DateTime.UtcNow;
     calconsumed = from.calconsumed;
 }
 private async Task FillBlanks()
 {
     try
     {
         for (var tDate = FitbitAPIKey.start_date; tDate <= DateTime.Now.Date; tDate = tDate.AddDays(1))
         {
             if (PedometerRecords.All(x => x.trandate != tDate))
             {
                 var newrec = new Pedometer
                     {
                         bodyfat = 0,
                         createddate = DateTime.UtcNow,
                         weight = 0,
                         sleep = 0,
                         steps = 0,
                         calconsumed = null,
                         id = 0,
                         lastupdateddate = null,
                         trandate = tDate
                     };
                 PedometerRecords.Add(newrec);
                 await WebAPIClient.Post(APIKeyName, newrec);
             }
         }
     }
     catch (Exception ex)
     {
         log.Error(string.Format("Error during FillBlanks: {0}", ex.Message));
     }
 }
        private IEnumerable<Pedometer> GetFitbitRecords(DateTime startDate, DateTime endDate)
        {
            var list = new List<Pedometer>();

            using (var fbClient = GetFitbitClient())
            {                             
                var weightlog = fbClient.GetWeight(startDate, endDate);
                for (var d = startDate; d <= endDate; d = d.AddDays(1))
                {
                    var activity = fbClient.GetDayActivitySummary(d);
                    var sleep = fbClient.GetSleep(d);
                    var calLog = fbClient.GetFood(d);
                    var newrec = new Pedometer
                    {
                        trandate = d,
                        steps = activity.Steps,
                        sleep = sleep.Summary.TotalMinutesAsleep,
                        createddate = DateTime.UtcNow,
                        calconsumed = (int?)calLog.Summary.Calories
                    };
                    var dayWeight = weightlog.Weights.FirstOrDefault(x => x.Date == d);
                    newrec.weight = dayWeight != null ? dayWeight.Weight * 2.2046226 : 0;

                    list.Add(newrec);
                }
            }

            return list;
        }