コード例 #1
0
ファイル: UserInfoLib.cs プロジェクト: dienbien001/AAM
        public List <UserInfo> GetUserInfos()
        {
            List <UserInfo> lUserInfo = new List <UserInfo>(); //Store result
            //string logPath = AppDomain.CurrentDomain.BaseDirectory; //Path to root directory of the app
            string       data    = "";
            LogUtilities logUtil = new LogUtilities();

            bIsConnected = axCZKEM1.Connect_Net(sDevIPAddress, iDevPort);
            if (bIsConnected)
            {
                data = string.Format("Connected to device <{0}:{1}>", sDevIPAddress, iDevPort);
                logUtil.WriteLog(data);
                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); //Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all)
            }
            else
            {
                data = string.Format("Failed to connect to device <{0}:{1}>", sDevIPAddress, iDevPort);
                logUtil.WriteLog(data);
                return(null);
            }

            string sdwEnrollNumber = "";
            string sName           = "";
            string sPassword       = "";
            int    iPrivilege      = 0;
            bool   bEnabled        = false;

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

            lUserInfo.Clear();
            axCZKEM1.EnableDevice(iMachineNumber, false);

            axCZKEM1.ReadAllUserID(iMachineNumber);                                                                                          //read all the user information to the memory
            axCZKEM1.ReadAllTemplate(iMachineNumber);                                                                                        //read all the users' fingerprint templates to the memory
            while (axCZKEM1.SSR_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.GetUserTmpExStr(iMachineNumber, sdwEnrollNumber, idwFingerIndex, out iFlag, out sTmpData, out iTmpLength))//get the corresponding templates string and length from the memory
                    {
                        UserInfo userInfo = new UserInfo {
                            EnrollNumber = sdwEnrollNumber, Name = sName, FingerIndex = idwFingerIndex,
                            TmpData      = sTmpData, Privilege = iPrivilege, Password = sPassword, Enable = bEnabled == true ? true : false,
                            Flag         = iFlag
                        };
                        lUserInfo.Add(userInfo);
                    }
                }
            }
            axCZKEM1.EnableDevice(iMachineNumber, true);
            axCZKEM1.Disconnect();
            logUtil.WriteLog("User count: " + lUserInfo.Count());
            return(lUserInfo);
        }
コード例 #2
0
ファイル: UserAttLib.cs プロジェクト: dienbien001/AAM
        private List <AttendanceInfo> GetAttInfos()
        {
            List <AttendanceInfo> lAttInfo = new List <AttendanceInfo>();           //Store result
            string       logPath           = AppDomain.CurrentDomain.BaseDirectory; //Path to root directory of the app
            string       data    = "";
            LogUtilities logUtil = new LogUtilities();

            logUtil.WriteLog(""); //Print break line

            bIsConnected = axCZKEM1.Connect_Net(sDevIPAddress, iDevPort);
            if (bIsConnected)
            {
                data = string.Format("Connected to device <{2} - {3}> at address <{0}:{1}>. Last update time: <{4}>", sDevIPAddress, iDevPort, iDeviceID, sDevName, dateToGet.ToString());
                logUtil.WriteLog(data);
                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); //Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all)
            }
            else
            {
                int errorCode = 0;
                axCZKEM1.GetLastError(errorCode);
                data = string.Format("Failed to connect to device <{3} - {4}> at address <{0}:{1}>. Error code: {2}", sDevIPAddress, iDevPort, errorCode.ToString(), iDeviceID, sDevName);
                logUtil.WriteLog(data);
                return(null);
            }

            string sdwEnrollNumber   = "";
            int    idwTMachineNumber = 0;
            int    idwEMachineNumber = 0;
            int    idwVerifyMode     = 0;
            int    idwInOutMode      = 0;
            int    idwYear           = 0;
            int    idwMonth          = 0;
            int    idwDay            = 0;
            int    idwHour           = 0;
            int    idwMinute         = 0;
            int    idwSecond         = 0;
            int    idwWorkcode       = 0;

            int idwErrorCode = 0;
            int iGLCount     = 0;
            int iIndex       = 0;

            System.Globalization.CultureInfo provider = System.Globalization.CultureInfo.InvariantCulture;

            axCZKEM1.EnableDevice(iMachineNumber, false);    //disable the device
            if (axCZKEM1.ReadGeneralLogData(iMachineNumber)) //read all the attendance records to the memory
            {
                while (axCZKEM1.SSR_GetGeneralLogData(iMachineNumber, out sdwEnrollNumber, out idwVerifyMode,
                                                      out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode))//get records from the memory
                {
                    AttendanceInfo attInfo = new AttendanceInfo
                    {
                        DeviceID       = iDeviceID,
                        EnrollNumber   = sdwEnrollNumber,
                        VerifyMode     = idwVerifyMode,
                        InOutMode      = idwInOutMode,
                        Year           = idwYear,
                        Month          = idwMonth,
                        Day            = idwDay,
                        Hour           = idwHour,
                        Minute         = idwMinute,
                        Second         = idwSecond,
                        WorkCode       = idwWorkcode,
                        EnrollDateTime = DateTime.ParseExact(idwDay.ToString() + "/" + idwMonth.ToString() + "/" + idwYear.ToString() + " " + idwHour.ToString() + ":" + idwMinute.ToString() + ":" + idwSecond.ToString(), "d/M/yyyy H:m:s", provider),
                    };
                    lAttInfo.Add(attInfo);
                }
            }
            else
            {
                axCZKEM1.GetLastError(ref idwErrorCode);

                if (idwErrorCode != 0)
                {
                    logUtil.WriteLog("Reading data from terminal failed,ErrorCode: " + idwErrorCode.ToString());
                }
                else
                {
                    logUtil.WriteLog("No data from terminal returns!");
                }
            }

            axCZKEM1.EnableDevice(iMachineNumber, true);//enable the device

            axCZKEM1.EnableDevice(iMachineNumber, true);
            axCZKEM1.Disconnect();
            logUtil.WriteLog("Attendance logs count: " + lAttInfo.Count());
            return(lAttInfo);
        }