/* * TAG FOUND EVENT: * This event occurs when the user passes a NFC card near the reader. * It checks if the UID is valid and unlock the door if so. */ private void TagFound(string uid) { if (!scanWindow.IsShowing()) { // Check authorization var authorized = DataHelper.CheckCardId(uid); // Show access window accessWindow.Show(authorized); // Log the event string logText; Log log; if (authorized) { // Access granted UnlockDoor(); logText = "Card \"" + uid + "\" inserted. Authorized access."; log = new Log(Log.TypeAccess, null, uid, logText); } else { // Access denied logText = "Card \"" + uid + "\" inserted. Access denied!"; log = new Log(Log.TypeInfo, logText); } DebugOnly.Print(logText); // Add log to loglist DataHelper.AddLog(log); } else { // Log new cardID var newCardIdLog = new Log( Log.TypeAccess, pendingPin, uid, "Card \"" + uid + "\" has been added for pin \"" + pendingPin + "\"."); // Update CardID in userList DataHelper.AddCardId(pendingPin, uid); // Send urgent log DataHelper.AddLog(newCardIdLog, true); var cardAddedAlert = new AlertWindow(WindowAlertPeriod); cardAddedAlert.SetText("NFC card added!"); cardAddedAlert.SetPositiveButton("Ok", delegate { cardAddedAlert.Dismiss(); }); cardAddedAlert.Show(); DebugOnly.Print("Card added to user with pin \"" + pendingPin + "\""); } }