private static BiometricReadings Transform(IDataReader rdr) { var readings = new BiometricReadings(); while (rdr.Read()) { var reading = new BiometricReading { deviceid = rdr[0].ToString(), participantid = rdr[1].ToString(), longitude = (double)rdr[2], latitude = (double)rdr[3], reading = (DateTime)rdr[4], value = (double)rdr[6] }; var sensorType = Convert.ToInt32(rdr[5]); switch (sensorType) { case 1: reading.type = BiometricType.Glucose; break; case 2: reading.type = BiometricType.Heartrate; break; case 3: reading.type = BiometricType.Bloodoxygen; break; case 4: reading.type = BiometricType.Temperature; break; } readings.Add(reading); } rdr.Close(); return(readings); }
public void Insert(BiometricReading alarm) { var type = 0; var sql = string.Empty; try { switch (alarm.type) { case BiometricType.Glucose: type = 1; break; case BiometricType.Heartrate: type = 2; break; case BiometricType.Bloodoxygen: type = 3; break; case BiometricType.Temperature: type = 4; break; case BiometricType.NotSet: break; default: throw new ArgumentOutOfRangeException(); } sql = $"INSERT INTO [dbo].[alarms]([deviceid],[participantid],[longitude],[latitude],[reading],[type],[value]) VALUES('{alarm.deviceid}','{alarm.participantid}',{alarm.longitude},{alarm.latitude},'{alarm.reading}',{type},{alarm.value})"; var cmd = new SqlCommand(sql, _conn); cmd.ExecuteReader(); } catch (Exception err) { Trace.TraceError(sql); Trace.TraceError(err.Message); } }
private static BiometricReadings Transform(IDataReader rdr) { var readings = new BiometricReadings(); while (rdr.Read()) { var reading = new BiometricReading { deviceid = rdr[0].ToString(), participantid = rdr[1].ToString(), longitude = (double) rdr[2], latitude = (double) rdr[3], reading = (DateTime) rdr[4], value = (double) rdr[6] }; var sensorType = Convert.ToInt32(rdr[5]); switch (sensorType) { case 1: reading.type = BiometricType.Glucose; break; case 2: reading.type = BiometricType.Heartrate; break; case 3: reading.type = BiometricType.Bloodoxygen; break; case 4: reading.type = BiometricType.Temperature; break; } readings.Add(reading); } rdr.Close(); return readings; }
public void CreateAlarm([FromBody] BiometricReading alarm) { _biometrics.CreateAlarm(alarm); }
public void Insert(BiometricReading alarm) { var type = 0; var sql = string.Empty; try { switch (alarm.type) { case BiometricType.Glucose: type = 1; break; case BiometricType.Heartrate: type = 2; break; case BiometricType.Bloodoxygen: type = 3; break; case BiometricType.Temperature: type = 4; break; case BiometricType.NotSet: break; default: throw new ArgumentOutOfRangeException(); } sql = $"INSERT INTO [dbo].[alarms]([deviceid],[participantid],[longitude],[latitude],[reading],[type],[value]) VALUES('{alarm.deviceid}','{alarm.participantid}',{alarm.longitude},{alarm.latitude},'{alarm.reading}',{type},{alarm.value})"; var cmd = new SqlCommand(sql, _conn); cmd.ExecuteReader(); } catch (Exception err) { Trace.TraceError(sql); Trace.TraceError(err.Message); } }
public async Task ProcessEventsAsync(PartitionContext context, IEnumerable <EventData> messages) { foreach (var eventData in messages) { // get the alarm from event hub var stream = eventData.GetBodyStream(); var bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); var json = bytes.Aggregate(string.Empty, (current, t) => current + ((char)t).ToString()); BiometricReading alarm = null; try { alarm = ModelManager.JsonToModel <BiometricReading>(json); } catch (Exception) { continue; } // log the alarm to biometrics database using the API //Rest.Post(new Uri(_biometricsApi), json); // lookup the user that rasied the alarm var user = _profile.GetById(alarm.participantid); //format the toast message var biometric = string.Empty; switch (alarm.type) { case BiometricType.Glucose: biometric = "Glucose"; break; case BiometricType.Heartrate: biometric = "Heartrate"; break; case BiometricType.Temperature: biometric = "Tempurature"; break; case BiometricType.Bloodoxygen: biometric = "Blood Oxygen"; break; case BiometricType.NotSet: break; default: biometric = "Not Set"; break; } var toast = "<toast><visual><binding template = 'ToastText04'> " + $"<text id = '1'>{"BioMax Alert"}</text>" + $"<text id = '2'>{"The " + biometric + " reading for " + user.firstname + " " + user.lastname + " is out of range."}</text>" + $"<text id = '3' >{"Contact: " + user.social.phone}</text>" + "</binding ></visual></toast>"; _hub.SendWindowsNativeNotificationAsync(toast).Wait(); } await context.CheckpointAsync(); }
public void CreateAlarm(BiometricReading alarm) { _dac.Insert(alarm); }
public void CreateAlarm(BiometricReading alarm) { _dac.Insert(alarm); }