Esempio n. 1
0
        /// <summary>
        /// Create a list of Microsoft Band Distance objects from the data read from the csv file selected by the user.
        /// </summary>
        /// <param name="csvReader">csv reader object</param>
        /// <param name="patientData">Patient data record that will be referenced by each microsoft band distance data record.</param>
        /// <param name="date">Date the data in the file was collected.</param>
        /// <returns></returns>
        public static List<MSBandDistance> BuildMSBandDistanceDataList(CsvReader csvReader, PatientData patientData, DateTime date)
        {
            List<MSBandDistance> msBandDistanceData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                msBandDistanceData = new List<MSBandDistance>();

                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Time | Motion Type | Pace | Speed | Total
                        string dateFormat = "HH:mm:ss";
                        string dateInfo = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(dateInfo, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {
                            date = new DateTime(date.Year, date.Month, date.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
                            MSBandDistance msBandDistance = new MSBandDistance() {
                                Date = date,
                                MotionType = csvReader[1],
                                Pace = (float)Convert.ToDouble(csvReader[2]),
                                Speed = (float)Convert.ToDouble(csvReader[3]),
                                Total = (float)Convert.ToDouble(csvReader[4]),
                                PatientDataId = patientData.Id
                            };
                            msBandDistanceData.Add(msBandDistance);
                        }
                    }
                }
            }

            return msBandDistanceData;
        }
Esempio n. 2
0
 /// <summary>
 /// Add a new Microsoft Band Distance data record to the database
 /// </summary>
 /// <param name="msBandDistance">MSBandDistance object to add to the database</param>
 public void CreateMSBandDistance(MSBandDistance msBandDistance)
 {
     if(msBandDistance != null) {
         _repository.Add(msBandDistance);
     }
 }