Exemplo n.º 1
0
        //To get All Template set UserID To "" Empty
        public void GetTemplates(string UserID, out UserData UserData)
        {
            int    ret        = 0;
            string str        = "Size\tUID\tPin\tFingerID\tValid\tTemplate\tResverd\tEndTag"; //this.txtdevdata.Text;
            int    BUFFERSIZE = 1 * 1024 * 1024 * 2;                                          // increas it if data is larg to handle -112

            byte[] buffer = new byte[BUFFERSIZE];
            string options = "", filter = "";

            if (UserID == "")
            {
                filter = "";
            }
            else
            {
                filter = "Pin=" + UserID;
            }
            UserData        = new UserData();
            UserData.UserID = UserID;
            List <UserTemplate> Templates = new List <UserTemplate>();

            if (IntPtr.Zero != h)
            {
                ret = GetDeviceData(h, ref buffer[0], BUFFERSIZE, "templatev10", str, filter, options);
            }
            else
            {
                Library.WriteErrorLog("Connect device failed!");
            }
            string[][] dataArray          = Library.LoadCsv(Encoding.Default.GetString(buffer).TrimEnd('\0'), ',');
            if (ret >= 0)
            {
                for (int i = 1; i < dataArray.Length; i++)
                {
                    UserTemplate temp = new UserTemplate();
                    temp.TemplateSize = int.Parse(dataArray[i][0]);
                    //temp.Password = dataArray[i][1];
                    //temp.UserID = dataArray[i][2];
                    temp.FingerID = int.Parse(dataArray[i][3]);
                    //temp.Valid = dataArray[i][4];
                    temp.Template = dataArray [i][5];
                    UserData.Templates.Add(temp);
                }
                Library.WriteErrorLog("templatev10 : Get " + ret + " records");
            }
            else
            {
                Library.WriteErrorLog("Get data failed.The error is " + ret);
            }
        }
Exemplo n.º 2
0
        public void GetUserData(string UserID, out UserData UserData)
        {
            string Name, Password;
            int    Privilege, FaceIndex = 0, TmpLength = 128 * 1024, idwErrorCode = 0; // FaceIndex = 50 for alll fingers
            //byte[] byTmpData = new byte[TmpLength];
            string byTmpData = "";
            bool   Enable;

            axCZKEM1.EnableDevice(iMachineNumber, false);
            axCZKEM1.RefreshData(iMachineNumber);
            //Templates = new List<UserTemplate>();
            //Faces = new List<UserFace>();
            //UserData data = new UserData();
            UserData        = new UserData();
            UserData.UserID = UserID;
            axCZKEM1.SSR_GetUserInfo(iMachineNumber, UserID, out UserData.Name, out UserData.Password, out UserData.Privilege, out UserData.Enable);
            axCZKEM1.GetStrCardNumber(out UserData.CardNo);


            for (FaceIndex = 0; FaceIndex <= 15; FaceIndex++)
            {
                if (axCZKEM1.GetUserFaceStr(iMachineNumber, UserID, FaceIndex, ref byTmpData, ref TmpLength))
                {
                    UserFace face = new UserFace();
                    face.FaceID   = FaceIndex;
                    face.FaceSize = TmpLength;
                    face.Face     = byTmpData;
                    UserData.Faces.Add(face);

                    //Here you can manage the information of the face templates according to your request.(for example,you can sava them to the database)
                    //MessageBox.Show("GetUserFace,the  length of the bytes array byTmpData is " + iLength.ToString(), "Success");
                }
                else
                {
                    axCZKEM1.GetLastError(ref idwErrorCode);
                    //MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error");
                }
            }


            int    idwFingerIndex;
            string sTmpData   = "";
            int    iTmpLength = 0;
            int    iFlag      = 0;

            //for (idwFingerIndex = 0; idwFingerIndex < 10; idwFingerIndex++)
            //{
            //    bool test = axCZKEM1.GetUserTmpExStr(iMachineNumber, UserID, idwFingerIndex, out iFlag, out  sTmpData, out iTmpLength);
            //    if (axCZKEM1.GetUserTmpStr(iMachineNumber, int.Parse(UserID), idwFingerIndex, ref sTmpData, ref iTmpLength))//get the corresponding templates string and length from the memory
            //    {
            //        UserTemplate template = new UserTemplate();
            //        template.FingerID = idwFingerIndex;
            //        template.TemplateSize = TmpLength;
            //        template.Template = sTmpData;
            //        //template.TempBin = TempBin;
            //        UserData.Templates.Add(template);
            //    }
            //    else
            //    {
            //        axCZKEM1.GetLastError(ref idwErrorCode);
            //        //MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error");
            //    }
            //}
            axCZKEM1.ReadAllUserID(iMachineNumber);                                                                  //read all the user information to the memory
            axCZKEM1.ReadAllTemplate(iMachineNumber);                                                                //read all the users' fingerprint templates to the memory
            if (axCZKEM1.SSR_GetUserInfo(iMachineNumber, UserID, out Name, out Password, out Privilege, out Enable)) //get all the users' information from the memory
            //{
            {
                for (idwFingerIndex = 0; idwFingerIndex < 10; idwFingerIndex++)
                {
                    if (axCZKEM1.GetUserTmpExStr(iMachineNumber, UserID, idwFingerIndex, out iFlag, out sTmpData, out iTmpLength))//get the corresponding templates string and length from the memory
                    {
                        UserTemplate template = new UserTemplate();
                        template.FingerID     = idwFingerIndex;
                        template.TemplateSize = TmpLength;
                        template.Template     = sTmpData;
                        //template.TempBin = TempBin;
                        UserData.Templates.Add(template);
                    }
                }
            }
            // }

            axCZKEM1.EnableDevice(iMachineNumber, true);
        }