中控考勤机二次开发小记
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
上图
读取考勤数据代码 : axCZKEM1.EnableDevice(iMachineNumber, false);//disable the device
if (axCZKEM1.ReadGeneralLogData(iMachineNumber))
//读取所有考勤数据到内存缓存
{
while (axCZKEM1.SSR_GetGeneralLogData(iMachineNumber, out sdwEnrollNumber, out idwVerifyMode,
out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode))
//从内存缓存取得所有的考勤记录数据
{
iGLCount++;
lv_kq.Items.Add(iGLCount.ToString());
lv_kq.Items[iIndex].SubItems.Add(sdwEnrollNumber);//modify by Darcy on Nov.26 2009
lv_kq.Items[iIndex].SubItems.Add(idwVerifyMode.ToString());
lv_kq.Items[iIndex].SubItems.Add(idwInOutMode.ToString());
//这里有点悲剧,中控SDK提供的API读取时间是int类型的,如果时间01,05等以0开头的时间或分钟,会变成单个0,或单个1.如:2017-08-31 12:01:09 会变成:2017-08-31 12:1:9 很难看,所以需要在此转换。
if (idwMinute < 10)
{
strMinute = "0" + idwMinute.ToString();
}
else { strMinute = idwMinute.ToString(); }
if (idwSecond < 10)
{
strSecond = "0" + idwSecond.ToString();
}
else { strSecond = idwSecond.ToString(); }
if(idwHour<10){
strHour="0"+idwHour.ToString();
}else{
strHour=idwHour.ToString();
}
lv_kq.Items[iIndex].SubItems.Add(idwYear.ToString() + "-" + idwMonth.ToString() + "-" + idwDay.ToString() + " " + strHour + ":" + strMinute + ":" + strSecond);
lv_kq.Items[iIndex].SubItems.Add(idwWorkcode.ToString());
iIndex++;
}
}
else
{
Cursor = Cursors.Default;
axCZKEM1.GetLastError(ref idwErrorCode);
if (idwErrorCode != 0)
{
MessageBox.Show("Reading data from terminal failed,ErrorCode: " + idwErrorCode.ToString(), "Error");
}
else
{
MessageBox.Show("No data from terminal returns!", "Error");
}
}
axCZKEM1.EnableDevice(iMachineNumber, true);//enable the device
Cursor = Cursors.Default;
//读取用户数据
axCZKEM1.EnableDevice(iMachineNumber, false);
Cursor = Cursors.WaitCursor;
axCZKEM1.ReadAllUserID(iMachineNumber);
//读取所有卡机上的用户信息到内存缓存
axCZKEM1.ReadAllTemplate(iMachineNumber);
//读取所有的指纹模板到内存缓存
while (axCZKEM1.SSR_GetAllUserInfo(iMachineNumber, out sdwEnrollNumber, out sName, out sPassword, out iPrivilege, out bEnabled))//get all the users'' information from the memory
{
for (idwFingerIndex = 0; idwFingerIndex < 10; idwFingerIndex++)
{
if (axCZKEM1.SSR_GetUserTmpStr(iMachineNumber, sdwEnrollNumber, idwFingerIndex, out sTmpData, out iTmpLength))
{
ListViewItem list = new ListViewItem();
list.Text = iSn.ToString();
list.SubItems.Add(sdwEnrollNumber);
list.SubItems.Add(sName);
list.SubItems.Add(idwFingerIndex.ToString());
list.SubItems.Add(sTmpData);
list.SubItems.Add(iPrivilege.ToString());
list.SubItems.Add(sPassword);
if (bEnabled == true)
{
list.SubItems.Add("true");
}
else
{
list.SubItems.Add("false");
}
list.SubItems.Add(iFlag.ToString());
lv_finger.Items.Add(list);
}
}
iSn++;
}
lv_finger.EndUpdate();
axCZKEM1.EnableDevice(iMachineNumber, true);
Cursor = Cursors.Default;
}
CardConn.DisConn();
//连接中控考勤机,通过IP
private void conn_card(string ip, string port)
{
//string ip = "", port = "";
if (ip == "" || port == "")
{
MessageBox.Show("IP地址或端口不能为空", "错误");
return;
}
int idwErrorCode = 0;
Cursor = Cursors.WaitCursor;
bIsConnected = axCZKEM1.Connect_Net(ip.Trim(), Convert.ToInt32(port.Trim()));
if (bIsConnected == true)
{
//status_lbl.Text = "当前状态:连接成功。";
iMachineNumber = 1;
//In fact,when you are using the tcp/ip communication,this parameter will be ignored,that is any integer will all right.Here we use 1.
axCZKEM1.RegEvent(iMachineNumber, 65535);
//在这里注册卡机的实时事件使用65535参数注册的是全部)
}
else
{
axCZKEM1.GetLastError(ref idwErrorCode);
MessageBox.Show("不能连接到此设置,错误码=" + idwErrorCode.ToString(), "Error");
}
Cursor = Cursors.Default;
}
该文章在 2017/11/10 9:00:52 编辑过 |
关键字查询
相关文章
正在查询... |