コード例 #1
0
ファイル: Program.cs プロジェクト: simonpfeifhofer/YASS
        private static void SubmitTrackPoint(Activity_t activity, ActivityLap_t lap, Trackpoint_t tp, string url)
        {
            string requestString = JsonConvert.SerializeObject(
                new Measure()
                {
                    ActivityIdentifier = activity.Id.ToString(),
                    GroupIdentifier = "Team Dowe Sportswear",
                    Timestamp = tp.Time,
                    EntityIdentifier = "Simon Pfeifhofer",
                    SensorName = "HeartRate",
                    SensorType = SensorType.Numeric,
                    Value = Convert.ToDouble(tp.HeartRateBpm.Value).ToString()
                }
            );

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentType = "application/json";
            request.ContentLength = requestString.Length;
            using (StreamWriter requestWriter = new StreamWriter(request.GetRequestStream()))
            {
                requestWriter.Write(requestString);
            }
        }