目前,我已成功连接到设备并获取日志,将其保存在数据库中,因为我还在数据库中保存更新的记录以避免任何复制的数据。但我正试图"禁用/锁定"在数据被提取并存储在数据库中之间的设备(提示消息说,请等待将是最顶层)。因此,如果有人使用它,他/她的记录就不会丢失。
我尝试了什么? 我已经完成了这个Biometric_Device_SDK-_Programmers_Guide并遇到了这个事件,
BOOL EnableDevice(
long dwMachineNumber ,
BOOL bFlag );
我曾尝试在阅读日志/调用设备之前使用此事件但没有效果。等;
控制器:
public class UserInfoController : Controller
{
DeviceManipulator manipulator = new DeviceManipulator();
ZkemClient objZkeeper1 = new ZkemClient();
public ActionResult GetDevice1Logs()
{
isDevice1Connected = objZkeeper1.Connect_Net("xx.xxx.xxx.xxx", 4370);
if (isDevice1Connected)
{
var machineNum = 1;
//here
objZkeeper1.EnableDevice(machineNum, false);
ICollection<Device1Log> lstMachineInfo = manipulator.GetLogData1(objZkeeper1, machineNum);
if (lstMachineInfo != null && lstMachineInfo.Count > 0)
{
var lastRecord = db.Device1Log.OrderByDescending(x => x.DateTime).FirstOrDefault();
if (lastRecord != null)
{
lstMachineInfo = lstMachineInfo.Where(x => x.DateTime > lastRecord.DateTime).ToList();
}
foreach (var p in lstMachineInfo)
{
db.Device1Log.Add(p);
}
db.SaveChanges();
}
objZkeeper1.EnableDevice(machineNum, true);
}
return View();
这没有触发,所以我进入了GetLogData1
的定义并试图在那里实现它;
Dmanipulator:
public ICollection<Device1Log> GetLogData1(ZkemClient objZkeeper, int machineNumber)
{
string dwEnrollNumber1 = "";
int dwVerifyMode = 0;
int dwInOutMode = 0;
int dwYear = 0;
int dwMonth = 0;
int dwDay = 0;
int dwHour = 0;
int dwMinute = 0;
int dwSecond = 0;
int dwWorkCode = 0;
ICollection<Device1Log> lstEnrollData = new List<Device1Log>();
//disabling here
objZkeeper.EnableDevice(machineNumber, false);
objZkeeper.ReadAllGLogData(machineNumber);
while (objZkeeper.SSR_GetGeneralLogData(machineNumber, out dwEnrollNumber1, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode))
{
DateTime inputDate = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
Device1Log objInfo = new Device1Log();
objInfo.MachineNum = machineNumber;
objInfo.RegisterationId = int.Parse(dwEnrollNumber1);
objInfo.DateTime = inputDate;
objInfo.Date = DateTime.Parse(DateTime.Parse((objInfo.DateTime).ToString()).ToString("yyyy-MM-dd"));
objInfo.Time = DateTime.Parse(DateTime.Parse((objInfo.DateTime).ToString()).ToString("hh:mm:ss tt"));
lstEnrollData.Add(objInfo);
}
objZkeeper.EnableDevice(machineNumber, true);
return lstEnrollData;
}
不幸的是,这些都没有奏效。我究竟做错了什么?该设备是zkteco F18。 的更新: 我试图将machineNum转换为int,因为它之前是一个字符串;
if (isDevice1Connected)
{
var machineNum = 1;
objZkeeper1.Beep(5000);
objZkeeper1.EnableDevice(Convert.ToInt32(machineNum), false);
ICollection<Device1Log> lstMachineInfo = manipulator.GetLogData1(objZkeeper1, machineNum);
if (lstMachineInfo != null && lstMachineInfo.Count > 0){
即使Beep()
事件未触发,为什么!! :(