Пример #1
0
        //Upload the 9.0 or 10.0 fingerprint arithmetic templates to the device(in strings) in batches.
        //Only TFT screen devices with firmware version Ver 6.60 version later support function "SetUserTmpExStr" and "SetUserTmpEx".
        //While you are using 9.0 fingerprint arithmetic and your device's firmware version is under ver6.60,you should use the functions "SSR_SetUserTmp" or
        //"SSR_SetUserTmpStr" instead of "SetUserTmpExStr" or "SetUserTmpEx" in order to upload the fingerprint templates.
        private void btnBatchUpdate_Click(object sender, EventArgs e)
        {
            if (bIsConnected == false)
            {
                MessageBox.Show("Please connect the device first!", "Error");
                return;
            }

            if (lvDownload.Items.Count == 0)
            {
                MessageBox.Show("There is no data to upload!", "Error");
                return;
            }
            int idwErrorCode = 0;

            string sdwEnrollNumber = "";
            string sName           = "";
            int    idwFingerIndex  = 0;
            string sTmpData        = "";
            int    iPrivilege      = 0;
            string sPassword       = "";
            string sEnabled        = "";
            bool   bEnabled        = false;
            int    iFlag           = 1;

            int iUpdateFlag = 1;

            Cursor = Cursors.WaitCursor;
            axCZKEM1.EnableDevice(iMachineNumber, false);
            if (axCZKEM1.BeginBatchUpdate(iMachineNumber, iUpdateFlag)) //create memory space for batching data
            {
                string sLastEnrollNumber = "";                          //the former enrollnumber you have upload(define original value as 0)
                for (int i = 0; i < lvDownload.Items.Count; i++)
                {
                    sdwEnrollNumber = lvDownload.Items[i].SubItems[0].Text;
                    sName           = lvDownload.Items[i].SubItems[1].Text;
                    idwFingerIndex  = Convert.ToInt32(lvDownload.Items[i].SubItems[2].Text);
                    sTmpData        = lvDownload.Items[i].SubItems[3].Text;
                    iPrivilege      = Convert.ToInt32(lvDownload.Items[i].SubItems[4].Text);
                    sPassword       = lvDownload.Items[i].SubItems[5].Text;
                    sEnabled        = lvDownload.Items[i].SubItems[6].Text;
                    iFlag           = Convert.ToInt32(lvDownload.Items[i].SubItems[7].Text);

                    if (sEnabled == "true")
                    {
                        bEnabled = true;
                    }
                    else
                    {
                        bEnabled = false;
                    }
                    if (sdwEnrollNumber != sLastEnrollNumber)                                                                  //identify whether the user information(except fingerprint templates) has been uploaded
                    {
                        if (axCZKEM1.SSR_SetUserInfo(iMachineNumber, sdwEnrollNumber, sName, sPassword, iPrivilege, bEnabled)) //upload user information to the memory
                        {
                            axCZKEM1.SetUserTmpExStr(iMachineNumber, sdwEnrollNumber, idwFingerIndex, iFlag, sTmpData);        //upload templates information to the memory
                        }
                        else
                        {
                            axCZKEM1.GetLastError(ref idwErrorCode);
                            MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error");
                            Cursor = Cursors.Default;
                            axCZKEM1.EnableDevice(iMachineNumber, true);
                            return;
                        }
                    }
                    else//the current fingerprint and the former one belongs the same user,that is ,one user has more than one template
                    {
                        axCZKEM1.SetUserTmpExStr(iMachineNumber, sdwEnrollNumber, idwFingerIndex, iFlag, sTmpData);
                    }
                    sLastEnrollNumber = sdwEnrollNumber;//change the value of iLastEnrollNumber dynamicly
                }
            }
            axCZKEM1.BatchUpdate(iMachineNumber); //upload all the information in the memory
            axCZKEM1.RefreshData(iMachineNumber); //the data in the device should be refreshed
            Cursor = Cursors.Default;
            axCZKEM1.EnableDevice(iMachineNumber, true);
            MessageBox.Show("Successfully upload fingerprint templates in batches , " + "total:" + lvDownload.Items.Count.ToString(), "Success");
        }
Пример #2
0
        //Upload the 9.0 or 10.0 fingerprint arithmetic templates to the device(in strings) in batches.
        //Only TFT screen devices with firmware version Ver 6.60 version later support function "SetUserTmpExStr" and "SetUserTmpEx".
        //While you are using 9.0 fingerprint arithmetic and your device's firmware version is under ver6.60,you should use the functions "SSR_SetUserTmp" or
        //"SSR_SetUserTmpStr" instead of "SetUserTmpExStr" or "SetUserTmpEx" in order to upload the fingerprint templates.
        public void BtnBatchUpdate_Click(string filename)
        {
            if (bIsConnected == false)
            {
                ILog logerr = log4net.LogManager.GetLogger("loguserinfoerr");
                //System.Console.Write("Please connect the device first!", "Error");
                logerr.Error("Please connect the device first!");
                return;
            }
            int    idwErrorCode    = 0;
            string sdwEnrollNumber = "";
            string sName           = "";
            int    idwFingerIndex  = 0;
            string sTmpData        = "";
            int    iPrivilege      = 0;
            string sPassword       = "";
            string sEnabled        = "";
            bool   bEnabled        = true;
            int    iFlag           = 1;
            bool   bHasFace        = false;
            int    iFaceIndex      = 0;
            string sTmpFaceData    = "";
            int    iTmpLength      = 0;

            string[]     sArray;
            StreamReader objReader;

            if (filename == "")
            {
                objReader = new StreamReader(logPath + "userInfo.csv");
            }
            else
            {
                objReader = new StreamReader(logPath + filename);
            }
            string sLine = "";

            sLine = objReader.ReadLine();
            sLine = objReader.ReadLine();
            int iUpdateFlag = 1;

            axCZKEM1.EnableDevice(iMachineNumber, false);
            if (axCZKEM1.BeginBatchUpdate(iMachineNumber, iUpdateFlag)) //create memory space for batching data
            {
                string sLastEnrollNumber = "";                          //the former enrollnumber you have upload(define original value as 0)
                while (sLine != null)
                {
                    sArray = sLine.Split(',');
                    if (sArray.Length != 12)
                    {
                        System.Diagnostics.Debug.WriteLine("csv file not right");
                        return;
                    }
                    sdwEnrollNumber = sArray[0];
                    sName           = sArray[1];
                    idwFingerIndex  = int.Parse(sArray[2] == "" ? "0" : sArray[2]);
                    sTmpData        = sArray[3];
                    iPrivilege      = int.Parse(sArray[4]);
                    sPassword       = sArray[5];
                    sEnabled        = sArray[6];
                    iFlag           = int.Parse(sArray[7]);
                    if (sArray[8] == "50")
                    {
                        bHasFace     = true;
                        iFaceIndex   = int.Parse(sArray[8]);
                        sTmpFaceData = sArray[9];
                        iTmpLength   = int.Parse(sArray[10]);
                    }
                    //sCardnumber = long.Parse(sArray[11]);
                    if (sdwEnrollNumber != sLastEnrollNumber)
                    {
                        string hexString = sArray[11];
                        int    num       = Int32.Parse(hexString, System.Globalization.NumberStyles.HexNumber);
                        axCZKEM1.SetStrCardNumber(num.ToString());                                                      //Before you using function SetUserInfo,set the card number to make sure you can upload it to the device
                        if (axCZKEM1.SSR_SetUserInfo(iMachineNumber, sdwEnrollNumber, sName, sPassword, iPrivilege, bEnabled))
                        {                                                                                               //upload user information to the device
                            axCZKEM1.SetUserTmpExStr(iMachineNumber, sdwEnrollNumber, idwFingerIndex, iFlag, sTmpData); // upload templates information to the device
                            if (bHasFace == true)
                            {
                                byte[] decBytes = Convert.FromBase64String(sTmpFaceData);
                                axCZKEM1.SetUserFace(iMachineNumber, sdwEnrollNumber, iFaceIndex, ref decBytes[0], iTmpLength);//upload face templates information to the device
                                bHasFace = false;
                            }
                        }
                        else
                        {
                            axCZKEM1.GetLastError(ref idwErrorCode);
                            System.Diagnostics.Debug.WriteLine("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error");
                            axCZKEM1.EnableDevice(iMachineNumber, true);
                            return;
                        }
                    }
                    else//the current fingerprint and the former one belongs the same user,that is ,one user has more than one template
                    {
                        axCZKEM1.SetUserTmpExStr(iMachineNumber, sdwEnrollNumber, idwFingerIndex, iFlag, sTmpData);
                    }
                    sLastEnrollNumber = sdwEnrollNumber;//change the value of iLastEnrollNumber dynamicly
                    sLine             = objReader.ReadLine();
                }
            }
            objReader.Close();
            axCZKEM1.BatchUpdate(iMachineNumber); //upload all the information in the memory
            axCZKEM1.RefreshData(iMachineNumber); //the data in the device should be refreshed
            axCZKEM1.EnableDevice(iMachineNumber, true);
            System.Diagnostics.Debug.WriteLine("Successfully upload fingerprint templates in batches , " + "total:" + "Success");
        }