中控考勤機二次開發小記

最近公司更換了一批考勤機,可是竟然沒法上傳和下載指紋等數據。咱們的系統用的是廣東一家人力資源系統,問了一下,說他們的系統不支持最新中控更新了固件的考勤機。我KAO了他NN個熊,不支持竟然?特別是還要收好幾千大洋的費用,問題咱們還交着服務費呢?要不就在他們哪買卡機,免費給咱們升級,哪仍是同樣嗎?他們賣的考勤機可不是市場上的價格,是貴 一半的價格。sql


好吧, 其實要錢也不是要我給,但公司也不肯意給啊,這樣的申請過不去啊。人事部也在鬧,扯來扯去的。我用中控幾年前發佈的ZKTIME5.0這款自帶的軟件操做,發現能夠啊?咱們的系統怎麼不能夠,若是幾年前的ZKTIME均可以操做,說明固件沒什麼大的變化,應該不影響纔對。但迫不得已,人家就是不支持,要支持,給錢開發插件來,還不是在原來 的人事系統上更新功能。小程序


我看從新開發一小程序,NND,我找來了中控的考勤 機SDK看了一下,提供了不少功能,但並不複雜,我想以我戰五渣的寫程序能力,應該能夠搞定他。(這裏贊一箇中控二次開發部門的一個工程師,態度很好的幫助我解決了一個問題(請忽略我寫程序的能力))。緩存



通過二天的努力(抓頭),好吧,小學生做文的程序出爐,功能上知足了,水平你們忽略 啊。tcp


上圖ide


wKiom1mouoaCCaVDAAF00IuCEtQ133.jpg-wh_50

wKioL1moum_hRWFLAAISRxjkH-A766.jpg-wh_50

wKioL1mounCg6VKoAAHnP4HJDOw553.jpg-wh_50



讀取考勤數據代碼 :this

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;
        }
相關文章
相關標籤/搜索