中控考勤機二次開發(fā)小記
當(dāng)前位置:點晴教程→知識管理交流
→『 技術(shù)文檔交流 』
上圖
讀取考勤數(shù)據(jù)代碼 : axCZKEM1.EnableDevice(iMachineNumber, false);//disable the device
if (axCZKEM1.ReadGeneralLogData(iMachineNumber))
//讀取所有考勤數(shù)據(jù)到內(nèi)存緩存
{
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))
//從內(nèi)存緩存取得所有的考勤記錄數(shù)據(jù)
{
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 很難看,所以需要在此轉(zhuǎn)換。
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;
//讀取用戶數(shù)據(jù)
axCZKEM1.EnableDevice(iMachineNumber, false);
Cursor = Cursors.WaitCursor;
axCZKEM1.ReadAllUserID(iMachineNumber);
//讀取所有卡機上的用戶信息到內(nèi)存緩存
axCZKEM1.ReadAllTemplate(iMachineNumber);
//讀取所有的指紋模板到內(nèi)存緩存
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 = "當(dāng)前狀態(tài):連接成功。";
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參數(shù)注冊的是全部)
}
else
{
axCZKEM1.GetLastError(ref idwErrorCode);
MessageBox.Show("不能連接到此設(shè)置,錯誤碼=" + idwErrorCode.ToString(), "Error");
}
Cursor = Cursors.Default;
}
該文章在 2017/11/10 9:00:52 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |