private void zkFprint_OnCapture(object sender, IZKFPEngXEvents_OnCaptureEvent e) { bool isVerified = false; //fingerprint to verify string template = ZkFprint.EncodeTemplate1(e.aTemplate); foreach (var item in _db.Employees) { if (ZkFprint.VerFingerFromStr(ref template, item.Fingerprint, false, ref Check)) { ShowHintInfo("Verified"); lblName.Text = "Time Out\nName: " + item.Name + "\n" + DateTime.Now.ToString("dddd, dd MMMM yyyy\nhh:mm tt"); ZkFprint.OnCapture -= zkFprint_OnCapture; ZkFprint.OnImageReceived -= zkFprint_OnImageReceived; fpicture.Image = null; //add attendance to database realtime Attendance at = new Attendance(); at.EmpID = item.ID; at.DateTime = DateTime.Now; at.Type = "Out"; _db.Attendances.Add(at); isVerified = true; break; } } if (!isVerified) { //BEEP AND RED ZkFprint.ControlSensor(12, 1); ZkFprint.ControlSensor(13, 1); Thread.Sleep(100); ZkFprint.ControlSensor(12, 0); ZkFprint.ControlSensor(13, 0); //Unregister Events ShowHintInfo("Not Verified"); lblName.Text = ""; ZkFprint.OnCapture -= zkFprint_OnCapture; ZkFprint.OnImageReceived -= zkFprint_OnImageReceived; fpicture.Image = null; } else { //BEEP AND GREEN ZkFprint.ControlSensor(11, 1); ZkFprint.ControlSensor(13, 1); Thread.Sleep(100); ZkFprint.ControlSensor(11, 0); ZkFprint.ControlSensor(13, 0); //Unregister Events ZkFprint.OnCapture -= zkFprint_OnCapture; ZkFprint.OnImageReceived -= zkFprint_OnImageReceived; fpicture.Image = null; _db.SaveChanges(); MessageBox.Show("Saved"); } }
public async Task Sonido(HuelleroSonidos tipo) { if (connected) { await Task.Delay(1); #if (!DEBUG || !DESACTIVAHUELLERO) switch (tipo) { case HuelleroSonidos.Solicitud: ZKFPEng.ControlSensor(11, 1); ZKFPEng.ControlSensor(12, 1); /*ZKFPEng.ControlSensor(13, 1); * await Task.Delay(500); * ZKFPEng.ControlSensor(13, 0);*/ ZKFPEng.ControlSensor(12, 0); ZKFPEng.ControlSensor(11, 0); break; case HuelleroSonidos.Correcto: ZKFPEng.ControlSensor(11, 1); /*ZKFPEng.ControlSensor(13, 1); * ZKFPEng.ControlSensor(13, 0);*/ ZKFPEng.ControlSensor(11, 0); break; case HuelleroSonidos.Incorrecto: default: ZKFPEng.ControlSensor(12, 1); /*ZKFPEng.ControlSensor(13, 1); * ZKFPEng.ControlSensor(13, 0); * ZKFPEng.ControlSensor(13, 1); * ZKFPEng.ControlSensor(13, 0); * ZKFPEng.ControlSensor(13, 1); * ZKFPEng.ControlSensor(13, 0); * ZKFPEng.ControlSensor(13, 1); * ZKFPEng.ControlSensor(13, 0);*/ ZKFPEng.ControlSensor(12, 0); break; } #endif } }
private void zkFprint_OnEnroll(object sender, IZKFPEngXEvents_OnEnrollEvent e) { if (e.actionResult) { Employee emp = new Employee(); emp.Name = txtName.Text; emp.Fingerprint = ZkFprint.EncodeTemplate1(e.aTemplate); _db.Employees.Add(emp); _db.SaveChanges(); ShowHintInfo("Registration successful."); //BEEP AND GREEN ZkFprint.ControlSensor(13, 1); ZkFprint.ControlSensor(11, 1); Thread.Sleep(100); ZkFprint.ControlSensor(13, 0); ZkFprint.ControlSensor(11, 0); MessageBox.Show("Saved"); txtName.Text = ""; ShowHintInfo("Click Register Button to Register"); //Unregister Events ZkFprint.OnImageReceived -= zkFprint_OnImageReceived; ZkFprint.OnFeatureInfo -= zkFprint_OnFeatureInfo; ZkFprint.OnEnroll -= zkFprint_OnEnroll; btnRegister.Enabled = false; } else { //BEEP AND RED ZkFprint.ControlSensor(13, 1); ZkFprint.ControlSensor(12, 1); Thread.Sleep(100); ZkFprint.ControlSensor(13, 0); ZkFprint.ControlSensor(12, 0); ShowHintInfo("Error, please click register again."); //Unregister Events ZkFprint.OnImageReceived -= zkFprint_OnImageReceived; ZkFprint.OnFeatureInfo -= zkFprint_OnFeatureInfo; ZkFprint.OnEnroll -= zkFprint_OnEnroll; } }