Exclude new sdk connection and features and save template into Db feature.
parent
f64e75970c
commit
a8837c4a10
|
@ -51,6 +51,8 @@ namespace ZktecoAttendenceService
|
|||
{
|
||||
if (attendanceLogs == null || attendanceLogs.Count == 0) return;
|
||||
|
||||
|
||||
|
||||
// Start building the INSERT statement
|
||||
StringBuilder queryBuilder = new StringBuilder("INSERT INTO attendance_log (ac_no, checktime, processed, machine_id, in_out_type_id, machine_ip, date) VALUES ");
|
||||
|
||||
|
@ -69,6 +71,7 @@ namespace ZktecoAttendenceService
|
|||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace ZktecoAttendenceService
|
|||
|
||||
public void update(AttendanceMachine attendanceMachine, MySqlConnection connection)
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
string query = "UPDATE `hrms`.`attendance_machine` SET `machine_ip` = @machine_ip, `port_number` = @port_number, `machine_name` = @machine_name, `site_id` = @site_id, `status` = @status, `last_sync_date` = @last_sync_date WHERE `machine_id` = @machine_id";
|
||||
MySqlCommand cmd = new MySqlCommand(query, connection);
|
||||
cmd.Parameters.AddWithValue("@machine_ip", attendanceMachine.MachineIp);
|
||||
|
@ -24,7 +24,7 @@ namespace ZktecoAttendenceService
|
|||
cmd.Parameters.AddWithValue("@machine_id", attendanceMachine.MachineId);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
connection.Close();
|
||||
|
||||
}
|
||||
public void updateColony(AttendanceMachine attendanceMachine, MySqlConnection connection)
|
||||
{
|
||||
|
|
|
@ -133,7 +133,9 @@ namespace ZktecoAttendenceService
|
|||
axCZKEM1.Disconnect();
|
||||
}
|
||||
else
|
||||
{ }
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -216,20 +218,19 @@ namespace ZktecoAttendenceService
|
|||
|
||||
public void UpdateTotalEmpInMachines(string machine_id, int total_users, MySqlConnection connection)
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
string query = "UPDATE `hrms`.`attendance_machine` SET `total_users` =" + total_users + " WHERE `machine_id` = '" + machine_id + "'";
|
||||
MySqlCommand cmd = new MySqlCommand(query, connection);
|
||||
cmd.ExecuteNonQuery();
|
||||
connection.Close();
|
||||
|
||||
}
|
||||
|
||||
public void UpdateFlag_InMachineUsers(string machine_id, string serial_no, MySqlConnection connection)
|
||||
{
|
||||
connection.Open();
|
||||
string query = "UPDATE `hrms`.`attendance_machine_user` SET `is_deleted` = 1 WHERE `machine_id` = '" + machine_id + "' and serial_number = " + serial_no + "";
|
||||
MySqlCommand cmd = new MySqlCommand(query, connection);
|
||||
cmd.ExecuteNonQuery();
|
||||
connection.Close();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,11 @@ namespace ZktecoAttendenceService
|
|||
WriteToTxtFile WriteFile_obj = new WriteToTxtFile();
|
||||
|
||||
|
||||
|
||||
public zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
|
||||
|
||||
|
||||
|
||||
private bool bIsConnected = false;//the boolean value identifies whether the device is connected
|
||||
private int iMachineNumber = 0;//the serial number of the device.After connecting the device ,this value will be changed.
|
||||
DataTable dtMachines = new DataTable();
|
||||
|
@ -58,6 +62,8 @@ namespace ZktecoAttendenceService
|
|||
}
|
||||
|
||||
public List<string> StartPooling()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<string> responses = new List<string>();
|
||||
AttendanceMachineDAO attendanceMachineDAO = new AttendanceMachineDAO();
|
||||
|
@ -72,7 +78,7 @@ namespace ZktecoAttendenceService
|
|||
foreach (var machine in machines)
|
||||
{
|
||||
|
||||
// if (machine.MachineIp == "192.168.85.202")
|
||||
//if (machine.MachineIp == "192.168.52.16")
|
||||
{
|
||||
bool isConnected = axCZKEM1.Connect_Net(machine.MachineIp, Convert.ToInt32(machine.PortNumber));
|
||||
if (isConnected)
|
||||
|
@ -82,17 +88,10 @@ namespace ZktecoAttendenceService
|
|||
if (machine.MachineId != "100")
|
||||
{
|
||||
|
||||
|
||||
//Saving the templates to the database
|
||||
SaveTemplateDb saveTemplateDb = new SaveTemplateDb();
|
||||
saveTemplateDb.InsertFaceIntoDb(machine, connection,axCZKEM1);
|
||||
|
||||
|
||||
|
||||
machine.Status = "SYNCING";
|
||||
attendanceMachineDAO.update(machine, connection);
|
||||
|
||||
responses.AddRange(poolMachineData(machine.MachineIp, machine.PortNumber, Convert.ToInt16(machine.MachineId)));
|
||||
responses.AddRange(poolMachineData(machine.MachineIp, machine.PortNumber, Convert.ToInt16(machine.MachineId), connection));
|
||||
machine.Status = "IDLE";
|
||||
|
||||
DateTime now = DateTime.Now.AddMinutes(-5);
|
||||
|
@ -111,8 +110,9 @@ namespace ZktecoAttendenceService
|
|||
responses.AddRange(newResponses);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Saving the templates to the database
|
||||
//SaveTemplateDb saveTemplateDb = new SaveTemplateDb();
|
||||
//saveTemplateDb.InsertFaceIntoDb(machine, connection,axCZKEM1);
|
||||
|
||||
empList = new List<string>();
|
||||
axCZKEM1.EnableDevice(Convert.ToInt32(machine.MachineId), true);
|
||||
|
@ -148,6 +148,12 @@ namespace ZktecoAttendenceService
|
|||
|
||||
return responses;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Exception ex = new Exception();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> poolMachineDataColony(string ip, int port, int machineId)
|
||||
{
|
||||
|
@ -222,7 +228,8 @@ namespace ZktecoAttendenceService
|
|||
|
||||
}
|
||||
}
|
||||
public List<string> poolMachineData(string ip, int port, int machineId)
|
||||
int errorCode = 0;
|
||||
public List<string> poolMachineData(string ip, int port, int machineId, MySqlConnection connection)
|
||||
{
|
||||
List<string> responses = new List<string>();
|
||||
List<Attendance> attendanceLogs = new List<Attendance>();
|
||||
|
@ -239,8 +246,22 @@ namespace ZktecoAttendenceService
|
|||
|
||||
try
|
||||
{
|
||||
|
||||
DateTime today = DateTime.Today;
|
||||
DateTime startTime = new DateTime(today.Year, today.Month, today.Day, 4, 0, 0); // 4:00 AM
|
||||
DateTime endTime = new DateTime(today.Year, today.Month, today.Day, 16, 0, 0); // 4:00 PM
|
||||
|
||||
string startTimeFormatted = startTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
string endTimeFormatted = endTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
|
||||
|
||||
//if(axCZKEM1.ReadGeneralLogData(machineId))
|
||||
|
||||
if(axCZKEM1.ReadAllGLogData(machineId))
|
||||
|
||||
// Connect and read attendance records
|
||||
if (axCZKEM1.ReadAllGLogData(machineId)) // read all the attendance records into memory
|
||||
//if (axCZKEM1.ReadTimeGLogData(machineId, startTimeFormatted, endTimeFormatted)) // read all the attendance records into memory
|
||||
{
|
||||
while (axCZKEM1.SSR_GetGeneralLogData(machineId, out sdwEnrollNumber, out idwVerifyMode,
|
||||
out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode)) // get records from memory
|
||||
|
@ -253,31 +274,38 @@ namespace ZktecoAttendenceService
|
|||
responses.Add($"MACHINE: {ip}, EMP NO: {sdwEnrollNumber}, TIME: {date}");
|
||||
}
|
||||
|
||||
// Perform bulk insert for all records
|
||||
// Perform bulk insert for all records2
|
||||
try
|
||||
{
|
||||
if (attendanceLogs.Count > 0)
|
||||
{
|
||||
attendanceDAO.BulkInsert(attendanceLogs, connection); // Bulk insert method
|
||||
responses.Add($"Successfully inserted {attendanceLogs.Count} records for MACHINE: {ip}");
|
||||
// Clear logs from the machine
|
||||
axCZKEM1.ClearGLog(machineId);
|
||||
}
|
||||
else
|
||||
{
|
||||
responses.Add($"MACHINE: {ip} - No attendance logs found.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responses.Add($"Error during bulk insert: {ex.Message}");
|
||||
}
|
||||
|
||||
// Clear logs from the machine
|
||||
axCZKEM1.ClearGLog(machineId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
axCZKEM1.GetLastError(ref errorCode); // Get the last error code
|
||||
responses.Add($"MACHINE: {ip} - No data available.");
|
||||
}
|
||||
//MessageBox.Show(errorCode.ToString());
|
||||
; }
|
||||
|
||||
return responses;
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ namespace ZktecoAttendenceService
|
|||
}
|
||||
|
||||
|
||||
axCZKEM1.EnableDevice(machineNo, true);
|
||||
axCZKEM1.Disconnect();
|
||||
//axCZKEM1.EnableDevice(machineNo, true);
|
||||
//axCZKEM1.Disconnect();
|
||||
|
||||
|
||||
SaveInDb(empTemplateList, connection);
|
||||
|
@ -99,7 +99,7 @@ namespace ZktecoAttendenceService
|
|||
Console.WriteLine("Employee already exist");
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
|
||||
}
|
||||
|
||||
public (long EmpExist, long TemplateExist) CheckEmpInDb(string empId, MySqlConnection connection)
|
||||
|
|
|
@ -62,7 +62,8 @@
|
|||
</Reference>
|
||||
<Reference Include="Interop.zkemkeeper, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>D:\UtilityForFingerIdentity\bin\Debug\Interop.zkemkeeper.dll</HintPath>
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
<HintPath>bin\Debug\Interop.zkemkeeper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Compression.LZ4, Version=1.3.5.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Compression.LZ4.1.3.5\lib\net462\K4os.Compression.LZ4.dll</HintPath>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue