Code: Select all
#include <fiveweb.ch>
#define ZK_ProgID 'zkemkeeper.ZKEM' // CreateObject
#define ZK_OnAttTransaction 1 // const EnrollNumber: LongInt; const IsInValid: LongInt; const AttState: LongInt; const VerifyMethod: LongInt; const Year: LongInt; const Month: LongInt; const Day: LongInt; const Hour: LongInt; const Minute: LongInt; const Second: LongInt
#define ZK_OnKeyPress 2 // const Key: LongInt
#define ZK_OnEnrollFinger 3 // const EnrollNumber: LongInt; const FingerIndex: LongInt; const ActionResult: LongInt; const TemplateLength: LongInt
#define ZK_OnNewUser 4 // const EnrollNumber: LongInt
#define ZK_OnEMData 5 // (const DataType: LongInt; const DataLen: LongInt; const DataBuffer: ShortInt); dispid 5;
#define ZK_OnConnected 6 //
#define ZK_OnDisConnected 7 //
#define ZK_OnFinger 8 //
#define ZK_OnVerify 9 // (const UserID: LongInt): HRESULT; dispid 9;
#define ZK_OnFingerFeature 10 // (const Score: LongInt): HRESULT; dispid 10;
#define ZK_OnHIDNum 11 // (const CardNumber: LongInt): HRESULT; dispid 11;
#define ZK_OnDoor 12 // (const EventType: LongInt); dispid 12;
#define ZK_OnAlarm 13 // (const AlarmType: LongInt; const EnrollNumber: LongInt; const Verified: LongInt); dispid 13;
#define ZK_OnWriteCard 14 // (const EnrollNumber: LongInt; const ActionResult: LongInt; const Length: LongInt): HRESULT; dispid 14;
#define ZK_OnEmptyCard 15 // (const ActionResult: LongInt): HRESULT; dispid 15;
#define ZK_OnDeleteTemplate 16 // (const EnrollNumber: LongInt; const FingerIndex: LongInt): HRESULT; dispid 16;
#define ZK_OnAttTransactionEx 17 // (const EnrollNumber: WideString; const IsInValid: LongInt; const AttState: LongInt; const VerifyMethod: LongInt; const Year: LongInt; const Month: LongInt; const Day: LongInt; const Hour: LongInt; const Minute: LongInt; const Second: LongInt; const WorkCode: LongInt); dispid 17;
#define ZK_OnEnrollFingerEx 18 // (const EnrollNumber: WideString; const FingerIndex: LongInt; const ActionResult: LongInt; const TemplateLength: LongInt); dispid 18;
static g_uid:=1 // ID used for each machine connected
static g_err:={;
{-100,'Operation failed or data not exist'},;
{ -10,'Transmitted data length is incorrect'},;
{ -7,'Can not connect to device'},; // non-Official define...
{ -5,'Data already exists'},;
{ -4,'Space is not enough'},;
{ -3,'Error size'},;
{ -2,'Error in file read/write'},;
{ -1,'SDK is not initialized and needs to be reconnected'},;
{ 0,'Data not found or data repeated'},;
{ 1,'Operation is correct'},;
{ 4,'Parameter is incorrect'},;
{ 101,'Error in allocating buffer'};
}
function getZKTeco()
return zkteco():init()
class zkteco
data m_obj, m_uid
data m_err init .f.
method init() constructor
method connect(address,port,password)
method serialNumber()
method enableDevice(p_bool)
method readGeneralLogData()
/*
SSR_GetGeneralLogData
Read attendance records one by one from the internal buffer. Before using this function,
you can use ReadAllGLogData or ReadGeneralLogData to read attendance records from
the device and write them into the internal buffer of the PC. Each time this function is
executed, the pointer points to the next attendance record.
*/
method getGeralLogData()
method getLastError()
/*
clearGLog
Clear all attendance records from the device.
*/
method clearGLog()
/*
refreshData
Refresh the data in the device. This function is usually called after user information or
fingerprints are uploaded. In this way, the modifications take effect immediately.
*/
method refreshData()
/*
getDeviceStatus
Obtain the data storage status of the device, for example, number of administrators and
number of current users.
Data to be obtained. The value ranges from 1 to 22. Values:
1 Number of administrators
2 Number of registered users
3 Number of fingerprint templates in the device
4 Number of passwords
5 Number of operation records
6 Number of attendance records
7 Fingerprint template capacity
8 User capacity
9 Attendance record capacity
10 Residual fingerprint template capacity
11 Residual user capacity
12 Residual attendance record capacity
21 Number of faces
22 Face capacity
Returned 0 in other cases.
*/
method getDeviceStatus()
method disconnect()
/*
clearAdministrators
Clear all administrator privileges from the device.
*/
method clearAdministrators()
method version()
method getAllUserInfo()
method readAllUserID()
method setCardNumber()
method setUserInfo()
method exit()
endclass
method init() class zkteco
local m_err:=.f.
try
::m_obj:=createobject(ZK_ProgID)
::m_uid:=(g_uid++)
catch
msgstop('Problem with register SDK !!!',::className()+' SDK')
m_err:=.t.
::m_obj:=nil
end
::m_err:=m_err
return self
method connect(address,port,password) class zkteco
local m_ret:=.f.
hb_default(@address,'127.0.0.1')
hb_default(@port,4370)
hb_default(@password,0)
if!::m_err
if password<>0
if!::m_obj:setCommPassword(password)
return m_ret
end
end
m_ret:=::m_obj:connect_net(address,port)
end
return m_ret
method disconnect() class zkteco
if!::m_err
::m_obj:disconnect()
end
return nil
method version() class zkteco
local m_str:=''
if!::m_err
::m_obj:getSDKVersion(@m_str)
end
return m_str
method serialNumber() class zkteco
local m_num:=0,m_ret:=''
if!::m_err
::m_obj:getSerialNumber(m_num,@m_ret)
end
return m_ret
method enableDevice(p_bool) class zkteco
local m_ret:=.f.
hb_default(@p_bool,.t.)
if!::m_err
m_ret:=::m_obj:enableDevice(::m_uid,p_bool)
end
return m_ret
method readGeneralLogData() class zkteco
local m_ret:=.f.
if!::m_err
m_ret:=::m_obj:readGeneralLogData(::m_uid)
end
return m_ret
method getGeralLogData() class zkteco
local m_enrollNumber:=''
local m_verifyMode:=0
local m_inOutMode:=0
local m_year:=0
local m_month:=0
local m_day:=0
local m_hour:=0
local m_minute:=0
local m_second:=0
local m_workCode:=0
local m_data:={}
if!::m_err
while ::m_obj:SSR_GetGeneralLogData(::m_uid,@m_enrollNumber,@m_verifyMode,@m_inOutMode,@m_year,@m_month,@m_day,@m_hour,@m_minute,@m_second,@m_workCode)
aadd(m_data,{;
m_enrollNumber ,; // employee number
m_verifyMode ,; // verifyMode ??
m_inOutMode ,; // inOutmode ??
strzero(m_year,4)+'-'+strzero(m_month,2)+'-'+strzero(m_day,2)+' ' +; // DATE
strzero(m_hour,2)+':'+strzero(m_minute,2)+':'+strzero(m_second,2) ,; // TIME
m_workCode ; // workCode
})
end
end
return m_data
method readAllUserID() class zkteco
local m_ret:=.f.
if!::m_err
m_ret:=::m_obj:readAllUserID(::m_uid)
end
return m_ret
method getAllUserInfo() class zkteco
local m_enum:=''
local m_name:=''
local m_pass:=''
local m_priv:=0
local m_bool:=.f.
local m_card:=''
local m_data:={}
if!::m_err
while ::m_obj:SSR_GetAllUserInfo(::m_uid,@m_enum,@m_name,@m_pass,@m_priv,@m_bool)==true
::m_obj:GetStrCardNumber(@m_card)
aadd(m_data,{m_enum,m_name,m_card,m_priv,m_pass,m_bool})
end
end
return m_data
method getDeviceStatus(m_num) class zkteco
local m_ret:=.f.
if!::m_err
m_ret:=::m_obj:getdevicestatus(::m_uid,6,@m_num)
end
return m_ret
method clearGLog() class zkteco
local m_ret:=.f.
if!::m_err
m_ret:=::m_obj:clearGLog(::m_uid)
end
return m_ret
method clearAdministrators() class zkteco
local m_ret:=.f.
if!::m_err
m_ret:=::m_obj:clearAdministrators(::m_uid)
end
return m_ret
method refreshData() class zkteco
local m_ret:=.f.
if!::m_err
m_ret:=::m_obj:refreshData(::m_uid)
end
return m_ret
method getLastError() class zkteco
local m_err:=0,m_num,m_ret
::m_obj:getLastError(@m_err)
if(m_num:=ascan(g_err,{|a,b|a[1]==m_err}))>0
m_ret:=g_err[m_num][2]
else
if m_err<>0
m_ret:='Reading data from terminal failed, ErrorCode: '+alltrim(str(m_err))+' !'
else
m_ret:='No data from terminal returns!'
end
end
return m_ret
method setCardNumber(p_card) class zkteco
local m_ret:=.f.
hb_default(@p_card,0)
if!::m_err .and. p_card>0
m_ret:=::m_obj:SetStrCardNumber(p_card)
end
return m_ret
method setUserInfo(p_enum,p_name,p_pass,p_priv,p_bool,p_card) class zkteco
local m_ret:=.f.
hb_default(@p_enum,'')
hb_default(@p_name,'')
hb_default(@p_pass,'')
hb_default(@p_priv,0)
hb_default(@p_bool,.f.)
hb_default(@p_card,0)
if!::m_err
::setCardNumber(p_card)
m_ret:=::m_obj:SSR_SetUserInfo(::m_uid,p_enum,p_name,p_pass,p_priv,p_bool)
end
return m_ret
method exit() class zkteco
::m_obj:=nil
::m_err:=.f.
return nil
Saludos.