/************************************ * count all record/log/attendance method ************************************/ public int GetLogCountAll() { if (!_bConnected) { return(-1); } var iCount = 0; axCZKEM1.EnableDevice(_con.MachineNo, false); if (axCZKEM1.GetDeviceStatus(_con.MachineNo, 6, ref iCount)) { Console.WriteLine(String.Format("Record Counted {0}", iCount)); } else { axCZKEM1.GetLastError(ref _idwErrorCode); } //enable device axCZKEM1.EnableDevice(_con.MachineNo, true); return(iCount); }
/// <summary> /// 更新设备状态 /// </summary> /// <param name="device_ip"></param> /// <param name="device_port"></param> /// <returns></returns> public ResultSet GetDeviceStatus(string device_ip, int device_port) { try { log.Info(string.Format("Function : GetDeviceStatus Start ,{0}:{1}", device_ip, device_port)); if (Connect(device_ip)) { int idwValue = 0; string NumberOfRegisteredUser = "******"; string NumberOfAttendanceRecords = "NA"; string UserCapacity = "NA"; string ResidualAttendanceRecordCapacity = "NA"; //Number of registered users log.Info(string.Format("ZKSoftware API : axCZKEM1.GetDeviceStatus, type=2")); if (axCZKEM1.GetDeviceStatus(iMachineNumber, 2, ref idwValue)) { NumberOfRegisteredUser = idwValue.ToString(); } //Number of attendance records log.Info(string.Format("ZKSoftware API : axCZKEM1.GetDeviceStatus, type=6")); if (axCZKEM1.GetDeviceStatus(iMachineNumber, 6, ref idwValue)) { NumberOfAttendanceRecords = idwValue.ToString(); } //User capacity log.Info(string.Format("ZKSoftware API : axCZKEM1.GetDeviceStatus, type=8")); if (axCZKEM1.GetDeviceStatus(iMachineNumber, 8, ref idwValue)) { UserCapacity = idwValue.ToString(); } //User capacity log.Info(string.Format("ZKSoftware API : axCZKEM1.GetDeviceStatus, type=12")); if (axCZKEM1.GetDeviceStatus(iMachineNumber, 12, ref idwValue)) { ResidualAttendanceRecordCapacity = idwValue.ToString(); } string device_status = string.Format("USER:{0}/{1}, EVENT LOG:{2}/{3}" , NumberOfRegisteredUser , UserCapacity , NumberOfAttendanceRecords , ResidualAttendanceRecordCapacity); Common.UpdateDeviceConfig(device_ip, device_status); } else { _resultset = new ResultSet { SeccessFlag = false, Result = device_ip, Description = string.Format("Can not connect to the device. please check it.") }; } } catch (Exception ex) { log.Fatal(ex); _resultset = new ResultSet { SeccessFlag = false, Result = ErrorCode.ToString(), Description = string.Format("Try Catched Error {0}", ex.Message) }; } finally { Close(); log.Info(string.Format("Function : GetDeviceStatus finish")); } return(_resultset); }