public async Task <GetHRBoundsMsg> GetHRBounds(UsernameData data) { GetHRBoundsMsg msg = new GetHRBoundsMsg(); Biometric bio = null; try { bio = await _bio.GetMostRecentRecord(data); } catch (Exception e) { throw new CustomException("Error getting HR data in service" + e); } int age = CalculateAge(bio.dob); int resting = await GetRestingHeartRate(data); msg.maxHR = 220 - age; msg.heartRateReserve = msg.maxHR - resting; double seventy = msg.heartRateReserve * 0.7 + resting; double eightFive = msg.heartRateReserve * 0.85 + resting; msg.targetHR = Math.Round((seventy + eightFive) / 2, 0); return(msg); }
public async Task <GetRangesMsg> GetRanges(UsernameData data) { GetRangesMsg msg = new GetRangesMsg(); Biometric bio = null; try { bio = await _bio.GetMostRecentRecord(data); } catch (Exception e) { throw new CustomException("Error getting HR data in service" + e); } int resting = await GetRestingHeartRate(data); int age = CalculateAge(bio.dob); int maxHR = 220 - age; int heartRateReserve = maxHR - resting; msg.fiftyPerc = Math.Round(heartRateReserve * 0.5 + resting, 0); msg.sixtyPerc = Math.Round(heartRateReserve * 0.6 + resting, 0); msg.seventyPerc = Math.Round(heartRateReserve * 0.7 + resting, 0); msg.eightyPerc = Math.Round(heartRateReserve * 0.8 + resting, 0); msg.ninetyPerc = Math.Round(heartRateReserve * 0.9 + resting, 0); msg.hundPerc = Math.Round(heartRateReserve * 1.0 + resting, 0); return(msg); }
public void EqualsTest() { var biometric = new Biometric { Data = new string('A', 10), Position = BiometricPosition.LeftIndex, Type = BiometricType.Fingerprint }; var differByType = new Biometric { Data = new string('A', 10), Position = BiometricPosition.LeftIndex, Type = BiometricType.Minutiae }; var differByPosition = new Biometric { Data = new string('A', 10), Position = BiometricPosition.RightIndex, Type = BiometricType.Fingerprint }; var differByData = new Biometric { Data = new string('B', 10), Position = BiometricPosition.LeftIndex, Type = BiometricType.Fingerprint }; var differByClass = new Identity(); Assert.False(biometric.Equals(differByType)); Assert.NotEqual(biometric.GetHashCode(), differByType.GetHashCode()); Assert.False(biometric.Equals(differByPosition)); Assert.NotEqual(biometric.GetHashCode(), differByPosition.GetHashCode()); Assert.True(biometric.Equals(differByData)); Assert.Equal(biometric.GetHashCode(), differByData.GetHashCode()); Assert.False(biometric.Equals(differByClass)); Assert.NotEqual(biometric.GetHashCode(), differByClass.GetHashCode()); }
private void Initialize(bool isToReloadBiometrics) { _student = new Data.Student(); _biometric = new Biometric(); _relBiometric = new RelBiometric(); _attendance = new Attendance(); _IsFingerEnrolled = false; _Verificator = new DPFP.Verification.Verification(); // Create a fingerprint template verificator if (isToReloadBiometrics) { _Biometrics = _biometricsRepository.GetBiometrics(); //Load all FingerPrintTemplate (fpt); Remarks = (_Biometrics.Count == 0) ? "No fingerprint template available in our records." : ""; } Student.ImageData = null; if (smsTimer == null) { smsTimer = new Timer(1000 * 60 * 60); smsTimer.Elapsed += new ElapsedEventHandler(OnSMSTimerEvent); smsTimer.Start(); } }
private async void OnDeleteBiometric(Biometric biometric) { var result = await DialogHelper.ShowDialog(DialogType.Validation, "Are you sure you want to unenroll this finger?"); if (result) { Student.Biometrics.Remove(Student.Biometrics.SingleOrDefault(i => i.FingerID == biometric.FingerID)); DeletedBiometrics.Add(biometric); } }
public Biometric AddBiometric(Biometric Biometric) { using (_context = ConnectionHelper.CreateConnection()) { _context.Biometrics.Add(Biometric); _context.SaveChanges(); return(Biometric); } }
public Biometric UpdateBiometric(Biometric Biometric) { using (_context = ConnectionHelper.CreateConnection()) { if (!_context.Biometrics.Local.Any(r => r.FingerID == Biometric.FingerID)) { _context.Biometrics.Attach(Biometric); } _context.Entry(Biometric).State = EntityState.Modified; _context.SaveChanges(); return(Biometric); } }
private void ButtonAdd_Click(object sender, EventArgs e) { if (comboBoxPort.SelectedIndex == 0) { MessageBox.Show("Please select port", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { Biometric.Init((string)comboBoxPort.SelectedItem); Close(); } }
private void LoadTesting() { IBiometricsRepository repo = new BiometricsRepository(); Biometric bio = repo.GetBiometric(Guid.Parse("9A9258E6-89DB-4AB3-B468-A4C7FF0D740B")); for (int c = 0; c < 2000; c++) { Biometric newBio = new Biometric(); newBio.FingerID = Guid.NewGuid(); newBio.FingerName = "F"; newBio.FingerPrintTemplate = bio.FingerPrintTemplate; repo.AddBiometric(newBio); } }
private void ButtonScanBioRight_Click(object sender, EventArgs e) { if (leftId == -1) { labelFingerLeft.Text = "Left fingerprint not scanned"; labelFingerLeft.ForeColor = Color.DarkGray; } rightId = -1; int id = PartialDB.GetNextRightFingerprintId(); labelFingerRight.Text = "Right fingerprint waiting to scan"; labelFingerRight.ForeColor = Color.DarkGray; Biometric.Set(id, delegate { Invoke(new MethodInvoker(delegate { labelFingerRight.Text = "Remove right finger"; labelFingerRight.ForeColor = Color.DarkGray; })); }, delegate { Invoke(new MethodInvoker(delegate { labelFingerRight.Text = "Place right finger again to confirm"; labelFingerRight.ForeColor = Color.DarkGray; })); }, delegate { rightId = id; Invoke(new MethodInvoker(delegate { labelFingerRight.Text = "Right fingerprint scanned"; labelFingerRight.ForeColor = Color.Green; })); }, delegate { Invoke(new MethodInvoker(delegate { labelFingerRight.Text = "Right fingerprint scan failed"; labelFingerRight.ForeColor = Color.DarkGray; })); }); }
private void Initialize() { IsFingerEnrolled = false; IsInitial = true; IsDone = false; //Biometrics = new ObservableCollection<Biometric>(_biometricsRepository.GetBiometrics()); Biometric = new Biometric(); Status = "Let\'s start"; Notification = "Put your finger on the sensor and lift after you see next instruction."; Instruction = ""; Completion = 0; Enroller = new DPFP.Processing.Enrollment(); // Create an enrollment. }
public void OnEnrollBiometric(Biometric biometric) { Biometric = biometric; RelBiometric relBiometric = new RelBiometric { RelBiometricID = Guid.NewGuid() }; relBiometric.FingerID = Biometric.FingerID; relBiometric.StudentID = Student.StudentGuid; if (Student.RelBiometrics == null) { Student.RelBiometrics = new ObservableCollection <RelBiometric>(); } if (Student.RelBiometrics.FirstOrDefault() == null) { Biometric.FingerName = "Finger 1"; } else { Biometric temp = Student.Biometrics.FirstOrDefault(); if (temp == null) { Biometric.FingerName = "Finger 1"; } else if (temp.FingerName == "Finger 1") { Biometric.FingerName = "Finger 2"; } else { Biometric.FingerName = "Finger 1"; } } Student.RelBiometrics.Add(relBiometric); Student.Biometrics.Add(Biometric); _biometricsRepository.AddBiometric(Biometric); AddedBiometrics.Add(Biometric); AddedRelBiometrics.Add(relBiometric); }
public async Task <GetBiometricDataMsg> GetBiometricData(UsernameData data) { GetBiometricDataMsg msg = new GetBiometricDataMsg(); Biometric b = null; try { b = await _bio.GetBiometricData(data); } catch (Exception e) { throw new CustomException("Error getting biometrics in service" + e); } msg.height = b.height.ToString(); msg.weight = b.weight.ToString(); msg.sex = b.sex.ToString(); msg.dob = b.dob.ToShortDateString(); return(msg); }
public async Task CreateBiometric(BiometricData cbd) { var biometric = new Biometric() { height = double.Parse(cbd.height), weight = double.Parse(cbd.weight), Date = DateTime.Now, sex = char.Parse(cbd.sex), dob = DateTime.Parse(cbd.dob), }; try { await _bio.CreateBiometricData(biometric, cbd.username); } catch (Exception e) { throw new CustomException("Error at creating biometric service" + e); } }
public async Task <GetExerciseIntensityMsg> GetIntensities(UsernameData data) { List <GetExerciseHeartRateMsg> records = null; Biometric bio = null; try { records = await _heart.GetExerciseHeartRateHistory(data); bio = await _bio.GetMostRecentRecord(data); } catch (Exception e) { throw new CustomException("Error getting HR data in service" + e); } int age = CalculateAge(bio.dob); int resting = await GetRestingHeartRate(data); return(CalculateIntensities(records, age, resting)); }
public void ToXmlTest() { var personalInfo = Data.PersonalInfo; var xml = XElement.Parse(File.ReadAllText(Data.PersonalInfoXml)).Elements().ToArray(); // Set: All Assert.True(XNode.DeepEquals(xml[0], personalInfo.ToXml("Pid"))); // Set: Biometrics[Fingerprint] var fingerprint = new Biometric { Type = BiometricType.Fingerprint }; personalInfo.Biometrics.Add(fingerprint); Assert.Throws <ArgumentException>(nameof(PersonalInfo.Biometrics), () => personalInfo.ToXml("Pid")); personalInfo.Biometrics.Remove(fingerprint); // Remove: All personalInfo.Demographic = null; personalInfo.PinValue = null; personalInfo.Biometrics.Clear(); Assert.Throws <ArgumentException>(() => personalInfo.ToXml("Pid")); }
private void StartBiometric() { Biometric.Get(id => { User user = users.FirstOrDefault(item => item.HasFingerId(Convert.ToInt32(id))); if (user != null) { if (userName.Equals(user.Name) || string.IsNullOrEmpty(userName)) { labelGreetings.Text = "Welcome," + Environment.NewLine + user.Name + "!"; userName = user.Name; panelOverride.Visible = false; } else { labelOverride.Text = "New user detected: " + user.Name; userNameOverride = user.Name; panelOverride.Visible = true; } } StartBiometric(); }); }
public async Task CreateBiometricData(Biometric b, string username) { try { Account acc = await _context.accounts.Where(x => x.username == username).FirstOrDefaultAsync(); if (acc == null) { throw new InvalidOperationException("There is no account matching the username"); } b.accountId = acc.Id; b.account = acc; //Add the record to the DB and save _context.biometrics.Add(b); _context.SaveChanges(); } catch (Exception e) { throw new CustomException("Database error while trying to create biometric data " + e); } }
protected override void OnClosing(CancelEventArgs e) { ML.FaceRecognition.Stop(); Biometric.Standby(); base.OnClosing(e); }
public void CreateBiometric([FromForm] Biometric model) { _db.Biometric.CreateBiometric(model); _db.Save(); }
public IActionResult UpdateBiometric(int id, [FromBody] Biometric model) { _db.Biometric.UpdateBiometric(id, model); _db.Save(); return(Ok()); }