您现在的位置是:首页 > 文章详情

中控考勤机二次开发小记

日期:2017-09-01点击:604

最近公司更换了一批考勤机,但是居然无法上传和下载指纹等数据。我们的系统用的是广东一家人力资源系统,问了一下,说他们的系统不支持最新中控更新了固件的考勤机。我KAO了他NN个熊,不支持居然?特别是还要收好几千大洋的费用,问题我们还交着服务费呢?要不就在他们哪买卡机,免费给我们升级,哪还是一样吗?他们卖的考勤机可不是市场上的价格,是贵 一半的价格。


好吧, 其实要钱也不是要我给,但公司也不愿意给啊,这样的申请过不去啊。人事部也在闹,扯来扯去的。我用中控几年前发布的ZKTIME5.0这款自带的软件操作,发现可以啊?我们的系统怎么不可以,如果几年前的ZKTIME都可以操作,说明固件没什么大的变化,应该不影响才对。但无可奈何,人家就是不支持,要支持,给钱开发插件来,还不是在原来 的人事系统上更新功能。


我看重新开发一小程序,NND,我找来了中控的考勤 机SDK看了一下,提供了很多功能,但并不复杂,我想以我战五渣的写程序能力,应该可以搞定他。(这里赞一个中控二次开发部门的一个工程师,态度很好的帮助我解决了一个问题(请忽略我写程序的能力))。



经过二天的努力(抓头),好吧,小学生作文的程序出炉,功能上满足了,水平大家忽略 啊。


上图


wKiom1mouoaCCaVDAAF00IuCEtQ133.jpg-wh_50

wKioL1moum_hRWFLAAISRxjkH-A766.jpg-wh_50

wKioL1mounCg6VKoAAHnP4HJDOw553.jpg-wh_50



读取考勤数据代码 :

axCZKEM1.EnableDevice(iMachineNumber, false);//disable the device                 if (axCZKEM1.ReadGeneralLogData(iMachineNumber)) //读取所有考勤数据到内存缓存                 {                     while (axCZKEM1.×××_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.×××_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.×××_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;         }


原文链接:https://blog.51cto.com/t4513/1961609
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章