Reputation: 103
I attempted to integrate my Winform application with real-time attendance. I have used the zkemkeeper class. devices connected. can read other data. but cannot get real-time log.
private void EnableRealTimeTracking()
{
if (isConnected)
{
zkem.OnAttTransactionEx += RealTimeLogHandler;
MessageBox.Show("Real-time tracking enabled.");
}
else
{
MessageBox.Show("Please connect to the device first.");
}
}
private void RealTimeLogHandler(
string EnrollNumber,
int IsInValid,
int AttState,
int VerifyMethod,
int Year,
int Month,
int Day,
int Hour,
int Minute,
int Second,
int WorkCode)
{
// Construct the date-time string for the transaction
string dateTime = $"{Year}-{Month:D2}-{Day:D2} {Hour:D2}:{Minute:D2}:{Second:D2}";
// Determine the verification method (e.g., Fingerprint or other)
string verifyMethodStr = VerifyMethod == 1 ? "Fingerprint" : "Other";
// Determine the attendance state (In or Out)
string attStateStr = AttState == 1 ? "In" : "Out";
// If the transaction is valid, process it
if (IsInValid == 1)
{
// Update the DataTable with the attendance information
// We are using Invoke to ensure thread-safety when updating the UI from the event handler
Invoke(new Action(() =>
{
// Add a new row to the DataTable for the attendance log
attendanceTable.Rows.Add(EnrollNumber, verifyMethodStr, dateTime, WorkCode);
}));
}
else
{
// Optionally, handle invalid transactions, if needed
// For example, you can log it or alert the user
Console.WriteLine("Invalid attendance transaction for user: " + EnrollNumber);
}
}
I need that real-time log data, so please let me know how to invoke it or if you have any suggestions.
Upvotes: 0
Views: 75