Example #1
0
        /// <summary>
        /// Create a list of ZephyrAccelerometer 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 zephyr accel data record.</param>
        /// <returns></returns>
        public static List<ZephyrAccelerometer> BuildZephyrAccelDataList(CsvReader csvReader, PatientData patientData)
        {
            List<ZephyrAccelerometer> zephyrAccelData = null;

            if (csvReader != null && patientData != null && patientData.Id != null) {
                zephyrAccelData = new List<ZephyrAccelerometer>();
                while (csvReader.ReadNextRecord()) {
                    if (csvReader != null) {
                        //File should read in the following order.
                        //Time | Vertical | Lateral | Sagittal
                        string dateFormat = "dd/MM/yyyy HH:mm:ss.fff";
                        string date = csvReader[0];
                        DateTime dateTime;
                        if (DateTime.TryParseExact(date, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) {
                            ZephyrAccelerometer zephyrAccel = new ZephyrAccelerometer() {
                                Time = dateTime,
                                Vertical = Convert.ToInt32(csvReader[1]),
                                Lateral = Convert.ToInt32(csvReader[2]),
                                Sagittal = Convert.ToInt32(csvReader[3]),
                                PatientDataId = patientData.Id
                            };
                            zephyrAccelData.Add(zephyrAccel);
                        }
                    }
                }
            }

            return zephyrAccelData;
        }
Example #2
0
 /// <summary>
 /// Add a new Zephyr Accelerometer data record to the database
 /// </summary>
 /// <param name="zephryAccel">ZephyrAccelerometer object to add to the database</param>
 public void CreateZephyrAccel(ZephyrAccelerometer zephyrAccel)
 {
     if(zephyrAccel != null) {
         _repository.Add(zephyrAccel);
     }
 }