Ejemplo n.º 1
0
        public bool UploadFTPTemplate(ZkemClient objZkeeper, int machineNumber, List <UserInfo> lstUserInfo)
        {
            string sdwEnrollNumber = string.Empty, sName = string.Empty, sTmpData = string.Empty;
            int    idwFingerIndex = 0, iPrivilege = 0, iFlag = 1, iUpdateFlag = 1;
            string sPassword = "";
            string sEnabled  = "";
            bool   bEnabled  = false;

            if (objZkeeper.BeginBatchUpdate(machineNumber, iUpdateFlag))
            {
                string sLastEnrollNumber = "";

                for (int i = 0; i < lstUserInfo.Count; i++)
                {
                    sdwEnrollNumber = lstUserInfo[i].EnrollNumber;
                    sName           = lstUserInfo[i].Name;
                    idwFingerIndex  = lstUserInfo[i].FingerIndex;
                    sTmpData        = lstUserInfo[i].TmpData;
                    iPrivilege      = lstUserInfo[i].Privelage;
                    sPassword       = lstUserInfo[i].Password;
                    sEnabled        = lstUserInfo[i].Enabled.ToString();
                    iFlag           = Convert.ToInt32(lstUserInfo[i].iFlag);
                    bEnabled        = true;

                    /* [ Identify whether the user
                     *   information(except fingerprint templates) has been uploaded */

                    if (sdwEnrollNumber != sLastEnrollNumber)
                    {
                        if (objZkeeper.SSR_SetUserInfo(machineNumber, sdwEnrollNumber, sName, sPassword, iPrivilege, bEnabled)) //upload user information to the memory
                        {
                            objZkeeper.SetUserTmpExStr(machineNumber, sdwEnrollNumber, idwFingerIndex, iFlag, sTmpData);        //upload templates information to the memory
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        /* [ The current fingerprint and the former one belongs the same user,
                         * i.e one user has more than one template ] */
                        objZkeeper.SetUserTmpExStr(machineNumber, sdwEnrollNumber, idwFingerIndex, iFlag, sTmpData);
                    }

                    sLastEnrollNumber = sdwEnrollNumber;
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }