Пример #1
0
        /// <summary>
        /// Create a list of Microsoft Band Gyroscope 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 gyroscope data record.</param>
        /// <param name="date">Date the data in the file was collected.</param>
        /// <returns></returns>
        public static List<MSBandGyroscope> BuildMSBandGyroscopeDataList(CsvReader csvReader, PatientData patientData, DateTime date)
        {
            List<MSBandGyroscope> msBandGyroscopeData = null;

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

                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Timestamp | X | Y | Z
                        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);
                            MSBandGyroscope msBandGyroscope = new MSBandGyroscope() {
                                Timestamp = date,
                                X = (float)Convert.ToDouble(csvReader[1]),
                                Y = (float)Convert.ToDouble(csvReader[2]),
                                Z = (float)Convert.ToDouble(csvReader[3]),
                                PatientDataId = patientData.Id
                            };
                            msBandGyroscopeData.Add(msBandGyroscope);
                        }
                    }
                }
            }

            return msBandGyroscopeData;
        }
Пример #2
0
 /// <summary>
 /// Add a new Microsoft Band Gyroscope data record to the database
 /// </summary>
 /// <param name="msBandGyroscope">MSBandGyroscope object to add to the database</param>
 public void CreateMSBandGyroscope(MSBandGyroscope msBandGyroscope)
 {
     if(msBandGyroscope != null) {
         _repository.Add(msBandGyroscope);
     }
 }