コード例 #1
0
        public static int GrabDataAbsen(string IPAdd, int portNum, int iPass, int machineNumber)
        {
            CZKEM mesinabsen = new CZKEM();
            int   b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, iCount = 0;

            mesinabsen.SetCommPassword(iPass);
            string a = "";

            //Only when connected successfully
            if (mesinabsen.Connect_Net(IPAdd, portNum))
            {
                //read all data and store in database
                using (fingermachDataSetTableAdapters.tdatafingerTableAdapter tbl = new fingermachDataSetTableAdapters.tdatafingerTableAdapter())
                {
                    while (mesinabsen.SSR_GetGeneralLogData(machineNumber, out a, out b, out c, out d, out e, out f, out g, out h, out i, ref j))
                    {
                        tbl.Replace(1, int.Parse(a), b, c, d, e, f, g, h, DateTime.Now);
                        iCount++;
                    }
                }
            }
            else
            {
                //Connection Exception
                throw (new Exception("Fail to connect to fingerprint machine."));
            }
            //clean data
            //mesinabsen.ClearGLog(machineNumber);

            //close connection
            mesinabsen.Disconnect();
            return(iCount);
        }
コード例 #2
0
        public static bool TestConnectMachine(string IPAdd, int portNum, int iPass)
        {
            CZKEM mesinabsen = new CZKEM();

            mesinabsen.SetCommPassword(iPass);
            return(mesinabsen.Connect_Net(IPAdd, portNum));
        }
コード例 #3
0
        private void btnDeleteAttendanceLog_Click(object sender, EventArgs e)
        {
            var answer = MessageBox.Show("Are you sure to delete all attendance log?", "Yes/no sample", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (answer == DialogResult.Yes)
            {
                var thread = new Thread(() =>
                {
                    _czkem      = new CZKEM();
                    var connect = _czkem.Connect_Net(_device.DeviceIp, _device.Port);
                    if (connect)
                    {
                        _device.IsConDevice = true;
                    }
                    if (_device.IsConDevice)
                    {
                        _czkem.ClearGLog(1);
                        _czkem.RefreshData(1);
                        fillListView("Attendance Log Deleted from Device Sucessfully", 0);
                    }
                    //Application.Run();
                });
                thread.IsBackground = true;
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
            }
        }
コード例 #4
0
        private void OnVerifyThumb()
        {
            var thread = new Thread(o => GlobalHandler(() =>
            {
                var _czkem1 = new CZKEM();
                _czkem1.SetCommPassword(Convert.ToInt32(_device.CommPassword));

                if (!_device.IsConDevice)
                {
                    var connect = _czkem1.Connect_Net(_device.DeviceIp, _device.Port);
                    if (connect)
                    {
                        _device.IsConDevice = true;
                    }
                }

                if (_device.IsConDevice)
                {
                    if (_czkem1.RegEvent(1, 65535))
                    {
                        _czkem1.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(zkemClient_OnAttTransactionEx);
                    }
                }
                Application.Run();
            }));

            thread.IsBackground = true;
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }
コード例 #5
0
ファイル: ZKBio.cs プロジェクト: pepealvarezc/Checador-ZKTeco
        public bool ConectarReloj(string ip, int puerto, int intentosDeConexion, bool beep)
        {
            if (intentosDeConexion == 0)
            {
                intentosDeConexion = 1;
            }
            int num = 1;

            this.a = string.Empty;
            this.g = false;
            this.i = new CZKEM();
            while (num <= intentosDeConexion)
            {
                if (this.i.Connect_Net(ip, puerto))
                {
                    this.g = true;
                    if (beep)
                    {
                        this.Beep();
                    }
                    num = intentosDeConexion + 1;

                    return(this.g);
                }
                else
                {
                    ++num;
                    this.i.GetLastError(ref this.h);
                    this.a = "(Método: Conectar) - Error al conectar el dispositivo. Código de error: " + this.h.ToString() + " - " + this.GenerarMensajeDeError(this.h);
                    return(this.g);
                }
            }
            return(this.g);
        }
コード例 #6
0
 static void Main()
 {
     axzkem = new CZKEM();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new Form1());
 }
コード例 #7
0
 public DeviceSetting(UserSession userSession)
 {
     if (_czkem == null)
     {
         _czkem = new CZKEM();
     }
     _timeReport = new TimeReport(userSession);
 }
コード例 #8
0
 public CzkemHelper(int machineid, string title, bool back, bool auto)
 {
     _czkem    = new CZKEM();
     MachineId = machineid;
     Title     = title;
     Back      = back;
     Auto      = auto;
 }
コード例 #9
0
        public ZktecoDevice(CZKEM device, DeviceInfo info, EventHub hub) : this(device)
        {
            Hub = hub;

            IP         = info.IP;
            Port       = info.Port;
            DeviceName = info.DeviceName;
            DeviceType = info.Type;
            Password   = info.Password;
        }
コード例 #10
0
        private ZktecoDevice(CZKEM device)
        {
            Device = device;

            Timer          = new System.Timers.Timer(30000);
            Timer.Elapsed += OnReadAttendances;

            Signal = new ManualResetEvent(false);

            Logger = HostLogger.Get <ZktecoDevice>();
        }
コード例 #11
0
        public bool IsFaceMachine(CZKEM czkem)
        {
            var faceMaxCount = 0;            //1904507651

            czkem.GetDeviceStatus(czkem.MachineNumber, 22, ref faceMaxCount);
            if (faceMaxCount == 1904507651 || faceMaxCount == 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #12
0
        public Session(string ip, int port, int commKey, int machineNumber)
        {
            this.ip = ip != null?IPAddress.Parse(ip).ToString() : throw new ArgumentNullException(nameof(ip));

            this.port            = (port > 0 && port <= 65535) ? port : throw new ArgumentOutOfRangeException(nameof(port), port, "port must be between 1 and 65535");
            this.commKey         = (commKey >= 0 && commKey <= 999999) ? commKey : throw new ArgumentOutOfRangeException(nameof(commKey), commKey, "commKey must be between 0 and 999999");
            this.dwMachineNumber = machineNumber;

            axCZKEM1                 = new zkemkeeper.CZKEM();
            axCZKEM1.OnConnected    += Sdk_OnConnected;
            axCZKEM1.OnDisConnected += Sdk_OnDisconnected;
            configureConnectionStateMachine();
        }
コード例 #13
0
 public Result Connect(string ip, int machineNo, int portNo)
 {
     objCZKEM = new CZKEM();
     try
     {
         result.isSucess = objCZKEM.Connect_Net(ip, 4370);
     }
     catch (Exception ex)
     {
         result.message = ex.Message;
     }
     return(result);
 }
コード例 #14
0
        protected override void OnStart(string[] args)
        {
            //if (args.GetLength(0) > 0 && args[0].Equals("DEBUG"))
            //    System.Diagnostics.Debugger.Launch();


            ip            = ConfigurationManager.AppSettings["device_ip"];
            port          = ConfigurationManager.AppSettings["device_port"];
            device_number = ConfigurationManager.AppSettings["device_number"];



            using (StreamWriter writer = new StreamWriter(filePath, true))
            {
                writer.WriteLine(Environment.NewLine + "--BioZ SERVICIO INICIADO------------------------------------------------------" + Environment.NewLine);
                writer.WriteLine("Fecha: " + DateTime.Now + "");
            }
            EventLog.WriteEntry("BioZ SERVICIO INICIADO");
            //if (Conexion_BaseDatos())
            //{
            //    using (StreamWriter writer = new StreamWriter(filePath, true))
            //    {
            //        writer.WriteLine(Environment.NewLine + "--Conexión Exitosa de la Base de Datos------------------------------------------------------" + Environment.NewLine);
            //    }
            //}


            Thread createComAndMessagePumpThread = new Thread(() =>
            {
                if (Conexion_BaseDatos())
                {
                    objCZKEM = new CZKEM();
                    //connSatus = Connect_Net(ip, int.Parse(port));
                    //Mensaje_Conexion_Dispositivo(connSatus);

                    _timer          = new System.Timers.Timer(5 * 60 * 1000); // every 1 hour
                    _timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
                    _timer.Start();
                    Application.Run();
                }
            });

            createComAndMessagePumpThread.SetApartmentState(ApartmentState.STA);

            createComAndMessagePumpThread.Start();



            EventLog.WriteEntry("Service BioZ started.");
        }
コード例 #15
0
        private void GetLogData(CZKEM axCZKEM)
        {
            try
            {
                int    dwTMachineNumber = 0;
                string dwEnrollNumber   = "";
                int    dwEMachineNumber = 0;
                int    dwVerifyMode     = 0;
                int    dwInOutMode      = 0;
                int    dwYear           = 0;
                int    dwMonth          = 0;
                int    dwDay            = 0;
                int    dwHour           = 0;
                int    dwMinute         = 0;
                int    dwSecond         = 0;
                int    dwWorkCode       = 0;

                object BaudRate = GetBaudRate(axCZKEM.MachineNumber);
                string sTime    = BaudRate == DBNull.Value ? "2019-01-01 00:00:00" : BaudRate.ToString().Replace('/', '-');
                string eTime    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second).
                                  ToString("yyyy-MM-dd HH:mm:ss");

                axCZKEM.EnableDevice(axCZKEM.MachineNumber, false);
                if (axCZKEM.ReadTimeGLogData(axCZKEM.MachineNumber, sTime, eTime))
                {
                    while (axCZKEM.SSR_GetGeneralLogData(axCZKEM.MachineNumber, out dwEnrollNumber, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode))
                    {
                        LogTransaction(axCZKEM.MachineNumber, dwTMachineNumber, int.Parse(dwEnrollNumber), dwEMachineNumber, dwVerifyMode, dwInOutMode, dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
                    }
                    UpdateBaudRate(axCZKEM.MachineNumber, eTime);
                }
                else
                {
                    if (axCZKEM.ReadNewGLogData(axCZKEM.MachineNumber))
                    {
                        while (axCZKEM.SSR_GetGeneralLogData(axCZKEM.MachineNumber, out dwEnrollNumber, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkCode))
                        {
                            LogTransaction(axCZKEM.MachineNumber, dwTMachineNumber, int.Parse(dwEnrollNumber), dwEMachineNumber, dwVerifyMode, dwInOutMode, dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
                        }
                        UpdateBaudRate(axCZKEM.MachineNumber, eTime);
                    }
                }
                axCZKEM.EnableDevice(axCZKEM.MachineNumber, true);//enable the device
            }
            catch (Exception ex)
            {
                Loger(ex.Message);
            }
        }
コード例 #16
0
 /// <summary>
 /// Connect To Device
 /// </summary>
 /// <param name="ipAddress"></param>
 /// <param name="portNum"></param>
 /// <returns></returns>
 public static ConnectStatus ConnectDevice(string ipAddress, int portNum)
 {
     if (DeviceCzkem == null)
     {
         DeviceCzkem = new CZKEM();
     }
     if (!ValidateIP(ipAddress))
     {
         return(ConnectStatus.IPNotValid);
     }
     else
     {
         bool?isConnect = DeviceCzkem.Connect_Net(ipAddress, portNum);
         return(isConnect.Value ? ConnectStatus.Connected : ConnectStatus.NotConnected);
     }
 }
コード例 #17
0
        public static bool RegisterUserName(string IPAdd, int portNum, int iPass, int machineNumber, string enrollNum, string userName)
        {
            CZKEM mesinabsen = new CZKEM();

            mesinabsen.SetCommPassword(iPass);
            if (mesinabsen.Connect_Net(IPAdd, portNum))
            {
                mesinabsen.SSR_SetUserInfo(machineNumber, enrollNum, userName, null, 0, true);
            }
            {
                //Connection Exception
                throw (new Exception("Fail to connect to fingerprint machine."));
            }
            //close connection
            mesinabsen.Disconnect();
            return(true);
        }
コード例 #18
0
        private void pullData()
        {
            zk = new CZKEM();
            bool isConnected = zk.Connect_Net(ipAddress, port);

            if (!isConnected)
            {
                log("Unable to Connect " + DateTime.Now);
                return;
            }
            string enrollNO;
            int    verifyMode;
            int    inoutMode;
            int    year;
            int    month;
            int    DayOfWeek;
            int    hour;
            int    minute;
            int    second;
            int    workerCode = 1;

            if (zk.ReadGeneralLogData(1))
            {
                bool canDelete = true;
                while (zk.SSR_GetGeneralLogData(branch, out enrollNO, out verifyMode, out inoutMode, out year, out month, out DayOfWeek, out hour, out minute, out second, ref workerCode))
                {
                    string date = year + "-" + month + "-" + DayOfWeek + " " + hour + ":" + minute + ":" + second;

                    if (!saveRecord(enrollNO, date, inoutMode))
                    {
                        log("Unable to SaveData   " + DateTime.Now);
                        canDelete = false;
                    }
                }
                bool deleteAllowed = Properties.Settings.Default.delete;
                if (canDelete && deleteAllowed)
                {
                    zk.ClearGLog(branch);
                }
            }
            zk.Disconnect();
        }
コード例 #19
0
ファイル: FingerPrint.cs プロジェクト: MManoj915/Autotime
        public void DoEvent()
        {
            // ISSUE: variable of a compiler-generated type
            CZKEM instance = (CZKEM)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("00853A19-BD51-419B-9269-2DABE57EB61F")));

            // ISSUE: reference to a compiler-generated method
            instance.Connect_Net("192.168.2.99", 4370);
            // ISSUE: reference to a compiler-generated method
            if (!instance.RegEvent(1, (int)ushort.MaxValue))
            {
                return;
            }
            // ISSUE: method pointer
            // ISSUE: object of a compiler-generated type is created
            new ComAwareEventInfo(typeof(_IZKEMEvents_Event), "OnVerify").AddEventHandler((object)instance, (Delegate) new _IZKEMEvents_OnVerifyEventHandler((object)this, (UIntPtr)__methodptr(axCZKEM1_OnVerify)));
            // ISSUE: method pointer
            // ISSUE: object of a compiler-generated type is created
            new ComAwareEventInfo(typeof(_IZKEMEvents_Event), "OnAttTransactionEx").AddEventHandler((object)instance, (Delegate) new _IZKEMEvents_OnAttTransactionExEventHandler((object)this, (UIntPtr)__methodptr(axCZKEM1_OnAttTransactionEx)));
            Application.DoEvents();
        }
コード例 #20
0
ファイル: Service1.cs プロジェクト: dperezs/ServicioBioZ
        protected override void OnStart(string[] args)
        {
            ip   = ConfigurationManager.AppSettings["device_ip"];
            port = ConfigurationManager.AppSettings["device_port"];

            Thread createComAndMessagePumpThread = new Thread(() =>
            {
                objCZKEM = new CZKEM();

                connSatus = Connect_Net(ip, int.Parse(port));
                if (connSatus)
                {
                    using (StreamWriter writer = new StreamWriter(filePath, true))
                    {
                        writer.WriteLine("Machine is connected on" + "Número de Equipo :" + objCZKEM.MachineNumber.ToString());
                        writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
                        EventLog.WriteEntry("Machine is connected on" + "Date :" + DateTime.Now.ToString() + "Status: " + connSatus);
                    }
                }
                // Ping a Dispositivo

                bool isValidIpA = ValidateIP(ip);
                if (!isValidIpA)
                {
                    EventLog.WriteEntry("The Device IP is invalid !!");
                }
                else
                {
                    EventLog.WriteEntry("The Device IP is valid !!");
                }


                Application.Run();
            });

            createComAndMessagePumpThread.SetApartmentState(ApartmentState.STA);

            createComAndMessagePumpThread.Start();

            EventLog.WriteEntry("Service BioZ started.");
        }
コード例 #21
0
        public bool FshiUser()
        {
            objCZKEM = new CZKEM();
            string _Name = "", _Password = "";
            int    _Privilefe = 0;
            bool   _Enabled   = false;

            try
            {
                //var t = objCZKEMClass.SSR_GetUserInfo(1, "13", out _Name, out _Password, out _Privilefe, out _Enabled);
                //t = objCZKEM.SSR_SetUserInfo(1, "13", _Name, _Password, _Privilefe, false);
                Debug.Write("True Fshi");
                objCZKEMClass.DeleteUserInfoEx(1, 13);
                objCZKEM.DeleteUserInfoEx(1, 13);
                return(true);
            }
            catch (Exception ex)
            {
                Debug.Write("False Fshi: " + ex.Message);
                return(false);
            }
        }
コード例 #22
0
        public void GetGeneratLog(CZKEM objZkeeper, int machineNumber, string enrollNo)
        {
            string name      = null;
            string password  = null;
            int    previlage = 0;
            bool   enabled   = false;

            byte[] byTmpData  = new byte[2000];
            int    tempLength = 0;

            int idwFingerIndex = 0; // [ <--- Enter your fingerprint index here ]
            int iFlag          = 0;

            objZkeeper.ReadAllTemplate(machineNumber);

            while (objZkeeper.SSR_GetUserInfo(machineNumber, enrollNo, out name, out password, out previlage, out enabled))
            {
                if (objZkeeper.GetUserTmpEx(machineNumber, enrollNo, idwFingerIndex, out iFlag, out byTmpData[0], out tempLength))
                {
                    break;
                }
            }
        }
コード例 #23
0
        public MainWindow()
        {
            InitializeComponent();

            // INITIALZE FINGERPRINT SCANNER & CONFIG
            zk         = new CZKEM();
            ip_address = "192.168.1.201";
            port       = 4370;

            // INITIALIZE CONNECT ON CREATE
            if (zk.Connect_Net(ip_address, port))
            {
                Logs.Items.Add("Connected to Device!");
                ConnectionStatus.Text       = "Connected";
                ConnectionStatus.Foreground = Brushes.LawnGreen;

                // REGISTER FINGERPRINT SCANNER EVENTS
                if (zk.RegEvent(zk.MachineNumber, 1))
                {
                    zk.OnAttTransactionEx += AttendanceTransactionHandler;
                }
            }
        }
コード例 #24
0
        private void GetAllLogs()
        {
            foreach (KeyValuePair <int, string> machine in lstMachines)
            {
                CZKEM axCZKEM = new CZKEM();
                axCZKEM.Disconnect();

                if (axCZKEM.Connect_Net(machine.Value, 4370))
                {
                    axCZKEM.MachineNumber = machine.Key;

                    GetLogData(axCZKEM);
                    if (lstDevices.ContainsKey(machine.Key))
                    {
                        lstDevices.Remove(machine.Key);
                    }
                }
            }
            MethodInvoker lbl = delegate { lblText.Text = "Last Update " + DateTime.Now.ToString(); };

            Invoke(lbl);

            PingMachines();
        }
コード例 #25
0
        public MainWindow()
        {
            InitializeComponent();

            // INITIALZE FINGERPRINT SCANNER & CONFIG
            zk      = new CZKEM();
            ZK_IP   = ConfigurationManager.AppSettings["ZK_IP"];
            ZK_PORT = Convert.ToInt32(ConfigurationManager.AppSettings["ZK_PORT"]);
            API_URL = ConfigurationManager.AppSettings["API_URL"];

            // INITIALIZE CONNECT ON CREATE
            if (zk.Connect_Net(ZK_IP, ZK_PORT))
            {
                Logs.Items.Add("Connected to Device!");
                ConnectionStatus.Text       = "Connected";
                ConnectionStatus.Foreground = Brushes.LawnGreen;

                // REGISTER FINGERPRINT SCANNER EVENTS
                if (zk.RegEvent(zk.MachineNumber, 65355))
                {
                    zk.OnAttTransactionEx += AttendanceTransactionHandler;
                }
            }
        }
コード例 #26
0
 public CzkemHelper()
 {
     _czkem = new CZKEM();
 }
コード例 #27
0
ファイル: FingerPrintUpdater.cs プロジェクト: meroag/ZkTeko
 public FingerPrintDevice(bool isZkBW)
 {
     device      = new CZKEM();
     this.isZkBW = isZkBW;
 }
コード例 #28
0
        public JsonResult DownloadFromDevice()
        {
            // test
            dt.Clear();
            dt.Columns.Add("attendanceDate");
            dt.Columns.Add("dwEnrollNumber");
            dt.Columns.Add("dwVerifyMode");
            dt.Columns.Add("dwInOutMode");

            //message = SaveLog(DumyData());
            message = string.Empty;

            objCZKEM = new CZKEM();
            bool IsRead = false, isConnected = false;

            string        dwEnrollNumber = "";
            int           dwVerifyMode, dwInOutMode, dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond, dwWorkcode = 0;
            int           empNumber = 0, totalCount = 0;
            DateTime      attendanceDate = new DateTime();
            StringBuilder sb;
            string        minute = string.Empty, second = string.Empty;

            try
            {
                if (!isConnected)
                {
                    isConnected = objCZKEM.Connect_Net(ip, 4370);
                }

                string message2 = string.Empty;

                if (isConnected)
                {
                    IsRead = objCZKEM.ReadGeneralLogData(dwMachineNumber);
                    if (IsRead == true)
                    {
                        LogCollection logTemplates = new LogCollection();
                        while (objCZKEM.SSR_GetGeneralLogData(dwMachineNumber, out dwEnrollNumber, out dwVerifyMode, out dwInOutMode, out dwYear, out dwMonth, out dwDay, out dwHour, out dwMinute, out dwSecond, ref dwWorkcode))
                        {
                            if (dwYear > 2020)
                            {
                                empNumber = Convert.ToInt32(dwEnrollNumber);
                                totalCount++;
                                sb = new StringBuilder();
                                sb.Append(empNumber);
                                sb.Append(dwYear);
                                sb.Append(dwMonth);
                                sb.Append(dwDay);
                                sb.Append(dwHour);
                                sb.Append(dwMinute);
                                sb.Append(dwSecond);
                                attendanceDate = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
                                UserLog log = new UserLog();
                                log.ADate        = attendanceDate;
                                log.EmpNumber    = empNumber;
                                log.MachineNO    = dwMachineNumber;
                                log.VerifyMethod = dwVerifyMode;
                                log.UniqueID     = sb.ToString();
                                log.PunchTime    = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
                                logTemplates.Add(log);
                            }

                            //showInOut(attendanceDate, dwEnrollNumber, dwVerifyMode, dwInOutMode);

                            //GetGeneratLog(objCZKEM, dwMachineNumber, dwEnrollNumber);

                            //message2 = dwEnrollNumber + " " + dwVerifyMode + dwInOutMode;
                        }
                        message = SaveLog(logTemplates);


                        DataTable newDt = dt;
                        message = message2;
                    }
                    else
                    {
                        message = "No Log Found....";
                    }
                }
                else
                {
                    message = "Device Not Connected";
                }
            }
            catch (Exception ex)
            {
                message = ex.Message.ToString();
            }

            return(Json(message, JsonRequestBehavior.AllowGet));
        }
コード例 #29
0
ファイル: Service1.cs プロジェクト: dperezs/ServicioBioZ
 public bool ClearGLog(CZKEM objZkeeper, int machineNumber)
 {
     return(objCZKEM.ClearGLog(machineNumber));
 }
コード例 #30
0
 public CzkemHelper(int machineid)
 {
     _czkem    = new CZKEM();
     MachineId = machineid;
 }