Exemple #1
0
        private void btnRestore_Click(object sender, EventArgs e)
        {
            ArrayList arQuery = new ArrayList();

            GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection();

            string sqlQuery = "", DeviceIP = "", GetDeviceIP = "";
            Int32  NewId = 0;
            Int32  RowID;

            string DeviceIp = "", pDate = "", pTime = "";

            int Count = 0;

            int idwErrorCode = 0;


            foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.gridDetails.Rows)
            {
                if (row.Cells["Id"].Text.ToString().Length != 0 &&
                    row.Cells["isChecked"].Value.ToString() == "1" && row.Cells["Active"].Value.ToString() == "1")
                {
                    GetDeviceIP = "" + row.Cells["IpAddress"].Text.ToString() + "";

                    bIsConnected = axCZKEM1.Connect_Net(GetDeviceIP, 4370);
                    if (bIsConnected == true)
                    {
                        iMachineNumber = 1;
                        axCZKEM1.RegEvent(iMachineNumber, 65535);
                    }

                    Count = Convert.ToInt32(txtRestore.Text);
                    axCZKEM1.EnableDevice(iMachineNumber, false);       //disable the device
                    if (axCZKEM1.RestoreLogData(iMachineNumber, Count)) //Here we use the function "RestoreLogData" and Restore Number.
                    {
                        MessageBox.Show("There have Restore " + Count.ToString(), " Attendance Data");
                    }
                    else
                    {
                        axCZKEM1.GetLastError(ref idwErrorCode);
                        MessageBox.Show("Operation failed,Attendance Data not Restore,Please input less number.ErrorCode=" + idwErrorCode.ToString(), "Error");
                    }

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

                axCZKEM1.Disconnect();
            }     // for
        }
Exemple #2
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();
        }
Exemple #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();
            }
        }
Exemple #4
0
        public bool Connect_Net(string IPAdd, int Port)
        {
            if (objCZKEM.Connect_Net(IPAdd, Port))
            {
                //65535, 32767
                if (objCZKEM.RegEvent(1, 65535))
                {
                    // [ Register your events here ]
                    // [ Go through the _IZKEMEvents_Event class for a complete list of events

                    objCZKEM.OnConnected    += ObjCZKEM_OnConnected;
                    objCZKEM.OnDisConnected += objCZKEM_OnDisConnected;
                    objCZKEM.OnEnrollFinger += ObjCZKEM_OnEnrollFinger;

                    objCZKEM.OnFinger += ObjCZKEM_OnFinger;

                    //objCZKEM.OnFingerFeature += objCZKEM_OnFingerFeature;

                    objCZKEM.OnHIDNum += objCZKEM_OnHIDNum;

                    objCZKEM.OnFinger           += new _IZKEMEvents_OnFingerEventHandler(ObjCZKEM_OnFinger);
                    objCZKEM.OnFingerFeature    += new _IZKEMEvents_OnFingerFeatureEventHandler(objCZKEM_OnFingerFeature);
                    objCZKEM.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(zkemClient_OnAttTransactionEx);
                }

                return(true);
            }

            return(false);
        }
        public bool Connect_Net(string IPAdd, int Port = 0)
        {
            try
            {
                if (string.IsNullOrEmpty(IPAdd) || Port <= 0)
                {
                    throw new Exception("No se encontrarón la IP/Puerto del Lector");
                }

                if (objCZKEM.Connect_Net(IPAdd, Port))
                {
                    //65535, 32767
                    if (objCZKEM.RegEvent(1, 32767))
                    {
                        // [ Register your events here ]
                        // [ Go through the _IZKEMEvents_Event class for a complete list of events
                        objCZKEM.OnConnected        += ObjCZKEM_OnConnected;
                        objCZKEM.OnDisConnected     += objCZKEM_OnDisConnected;
                        objCZKEM.OnEnrollFinger     += ObjCZKEM_OnEnrollFinger;
                        objCZKEM.OnFinger           += ObjCZKEM_OnFinger;
                        objCZKEM.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(zkemClient_OnAttTransactionEx);
                    }
                    return(true);
                }
                return(false);
            }catch
            {
                throw new Exception("No se ha realizado la conexión con el lector");
            }
        }
Exemple #6
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);
        }
Exemple #7
0
 public bool Connect_Net(string IPAdd, int Port)
 {
     try
     {
         if (objCZKEM.Connect_Net(IPAdd, Port))
         {
             //65535, 32767
             if (objCZKEM.RegEvent(1, 32767))
             {
                 // [ Register your events here ]
                 // [ Go through the _IZKEMEvents_Event class for a complete list of events
                 objCZKEM.OnConnected        += ObjCZKEM_OnConnected;
                 objCZKEM.OnDisConnected     += objCZKEM_OnDisConnected;
                 objCZKEM.OnEnrollFinger     += ObjCZKEM_OnEnrollFinger;
                 objCZKEM.OnFinger           += ObjCZKEM_OnFinger;
                 objCZKEM.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(zkemClient_OnAttTransactionEx);
             }
             return(true);
         }
     }
     catch (Exception ex)
     {
         ex.Message.ToString();
     }
     return(false);
 }
Exemple #8
0
        public static bool TestConnectMachine(string IPAdd, int portNum, int iPass)
        {
            CZKEM mesinabsen = new CZKEM();

            mesinabsen.SetCommPassword(iPass);
            return(mesinabsen.Connect_Net(IPAdd, portNum));
        }
 public bool Connect(string ip, int port, int?password)
 {
     if (password.HasValue)
     {
         _czkem.SetCommPassword(password.Value);
     }
     return(_czkem.Connect_Net(ip, port));
 }
Exemple #10
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);
 }
Exemple #11
0
        private bool Connect_Net(string IPAdd, int Port)
        {
            if (objCZKEM.Connect_Net(IPAdd, Port))
            {
                //65535, 32767
                if (objCZKEM.RegEvent(1, 32767))
                {
                    // [ Register your events here ]
                    // [ Go through the _IZKEMEvents_Event class for a complete list of events
                    // objCZKEM.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(zkemClient_OnAttTransactionEx);
                }

                return(true);
            }
            return(false);
        }
Exemple #12
0
 private void Connect(object sender, RoutedEventArgs e)
 {
     // IF DISCONNECTED, INITIATE CONNECTION TO FINGERPRINT SCANNER
     if (ConnectionStatus.Text == "Disconnected")
     {
         if (zk != null)
         {
             if (zk.Connect_Net(ZK_IP, ZK_PORT))
             {
                 Logs.Items.Add("Connected to Device!");
                 ConnectionStatus.Text       = "Connected";
                 ConnectionStatus.Foreground = Brushes.LawnGreen;
             }
         }
     }
 }
Exemple #13
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);
        }
Exemple #14
0
        private bool ConnectBiometric(string ip)
        {
            bool connection = _reader.Connect_Net(ip, Convert.ToInt32(4370));

            if (connection)
            {
                bool events = _reader.RegEvent(1, 65535);

                if (events)
                {
                    _reader.OnVerify           += new _IZKEMEvents_OnVerifyEventHandler(GetUser);
                    _reader.OnHIDNum           += new _IZKEMEvents_OnHIDNumEventHandler(GetCard);
                    _reader.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(GetType);
                }
            }

            return(connection);
        }
Exemple #15
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();
        }
Exemple #16
0
        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();
        }
Exemple #17
0
 private bool Connect_Net(string IPAdd, int Port)
 {
     if (objCZKEM.Connect_Net(IPAdd, Port))
     {
         //65535, 32767
         if (objCZKEM.RegEvent(1, 32767))
         {
             // [ Register your events here ]
             // [ Go through the _IZKEMEvents_Event class for a complete list of events
             objCZKEM.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(zkemClient_OnAttTransactionEx);
             using (StreamWriter writer = new StreamWriter(filePath, true))
             {
                 writer.WriteLine("finger print Event is registered... ");
                 writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
             }
         }
         return(true);
     }
     return(false);
 }
Exemple #18
0
        public void ConnectViaNet(List <string> messages)
        {
            if (ValidateIpAddress())
            {
                Settings.Default._machineNo = 1;
                var port = Settings.Default._devicePort;

                if (port <= 0 || port > 65535)
                {
                    messages.Add(Resources.LABEL_ILLEGAL_PORT);
                }

                var iCommkey = Convert.ToInt32(Settings.Default._commKey);
                _czkem.SetCommPassword(iCommkey);
                if (Settings.Default._connected)
                {
                    _czkem.Disconnect();
                    UnRegisterEvents();
                    SetConnected(false);
                    messages.Add(WriteLog(Resources.LABEL_DISCONNECT_WITH_DEVICE));
                }

                if (_czkem.Connect_Net(Settings.Default._deviceIpAddress,
                                       Settings.Default._devicePort))
                {
                    RegisterEvents(messages);
                    SetConnected(true);
                    messages.Add(WriteLog(Resources.LABEL_DEVICE_CONNECTED));
                }
                else
                {
                    var idwErrorCode = 0;
                    _czkem.GetLastError(ref idwErrorCode);
                    messages.Add(WriteLog(Resources.LABEL_UNABLE_TO_CONNECT_VIA_NET + idwErrorCode));
                }
            }
            else
            {
                messages.Add(WriteLog(Resources.LABEL_INVALID_DEVICE_IP_ADDRESS));
            }
        }
Exemple #19
0
        public StatusReport Connect()
        {
            lock (syncRoot)
            {
                connectionState.Fire(Trigger.ConnectRequested);

                axCZKEM1.SetCommPassword(commKey);

                if (axCZKEM1.Connect_Net(ip, port))
                {
                    return(StatusReport.Success());
                }
                else
                {
                    connectionState.Fire(Trigger.ConnectFailed);

                    int errorCode = 0;
                    axCZKEM1.GetLastError(ref errorCode);
                    return(StatusReport.Fail(errorCode));
                }
            }
        }
        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;
                }
            }
        }
Exemple #21
0
        public bool Connect_Net(string IPAdd, int Port)
        {
            if (objCZKEM.Connect_Net(IPAdd, Port))
            {
                //65535, 32767
                if (objCZKEM.RegEvent(1, 32767))
                {
                    objCZKEM.OnConnected        += ObjCZKEM_OnConnected;
                    objCZKEM.OnDisConnected     += objCZKEM_OnDisConnected;
                    objCZKEM.OnEnrollFinger     += ObjCZKEM_OnEnrollFinger;
                    objCZKEM.OnFinger           += ObjCZKEM_OnFinger;
                    objCZKEM.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(zkemClient_OnAttTransactionEx);

                    // Re-attach OnTransactionEx every X seconds
                    //System.Timers.Timer timer = new System.Timers.Timer();
                    //timer.Interval = 30000;
                    //timer.Elapsed += ReAttachOnTrasactionEx;
                    //timer.Start();
                }
                return(true);
            }
            return(false);
        }
Exemple #22
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();
        }
Exemple #23
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;
                }
            }
        }
Exemple #24
0
 public bool Connect(string ip, int port)
 {
     isConnected = device.Connect_Net(ip, port);
     return(isConnected);
 }
        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));
        }
Exemple #26
0
        private void InActiveUser()
        {
            btnDeActive.Enabled = false;
            var thread = new Thread(async() =>
            {
                var obj = new Dictionary <string, string>();
                obj.Add("gymid", Settings.Default.BranchId.ToString());
                var data        = JsonConvert.SerializeObject(obj);
                var url         = ConfigurationManager.AppSettings["ApiUrl"].ToString() + "webappservices/GetInactiveMembers";
                var queryString = new StringContent(data, Encoding.UTF8, "text/plain");
                using (var client = new HttpClient())
                {
                    var result           = await client.PostAsync(new Uri(url), queryString);
                    string resultContent = await result.Content.ReadAsStringAsync();
                    var res = JsonConvert.DeserializeObject <LoginResponse[]>(resultContent);
                    if (res != null && res.Any())
                    {
                        _czkem      = new CZKEM();
                        var connect = _czkem.Connect_Net(_device.DeviceIp, _device.Port);
                        if (connect)
                        {
                            _device.IsConDevice = true;
                        }
                        if (_device.IsConDevice)
                        {
                            _czkem.ReadAllTemplate(_device.DeviceId);

                            string sTmpData = string.Empty;
                            int iTmpLength  = 0, iFlag = 0;

                            //foreach (var item in res)
                            //{
                            //    for (int i = 0; i <= 9; i++)
                            //    {
                            //        if (_czkem.GetUserTmpExStr(_device.DeviceId, item.id, i, out iFlag, out sTmpData, out iTmpLength))
                            //        {
                            //            var sendData = new SaveApiTemplate
                            //            {
                            //                gymid = Settings.Default.BranchId,
                            //                BackUpTemplate = new List<BackUpTemplate>
                            //                {
                            //                    new BackUpTemplate
                            //                    {
                            //                        name = "",
                            //                        member_id = item.id,
                            //                        Password = "",
                            //                        prvlg = 1,
                            //                        enabled = 1,
                            //                        fingerIndex = i,
                            //                        flag = iFlag,
                            //                        templateData = sTmpData

                            //                    }
                            //                }
                            //            };
                            //            SendTemplateBackUpToAPI(sendData);
                            //            _czkem.SSR_DelUserTmp(_device.DeviceId, item.id, i);
                            //        }
                            //    }
                            //}
                        }

                        await fillListView("In-Active Users Done Successfully", 0);
                    }
                    else
                    {
                        await fillListView("No record found to In-Active users", 0);
                    }
                }
                btnDeActive.Enabled = true;
            });

            thread.IsBackground = true;
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }
Exemple #27
0
        private void SyncAttendance()
        {
            btnSyncAttendance.Enabled = false;
            var thread = new Thread(async() =>
            {
                tblS.Clear();
                var dates        = new List <DateTime>();
                var strResetTime = string.Empty;
                var iGLCount     = 0;
                _czkem           = new CZKEM();
                var connect      = _czkem.Connect_Net(_device.DeviceIp, _device.Port);
                if (connect)
                {
                    _device.IsConDevice = true;
                }
                if (_device.IsConDevice)
                {
                    var readLog = _czkem.ReadAllGLogData(1);
                    if (readLog)
                    {
                        //int idwErrorCode = 0;
                        string sdwEnrollNumber = "";
                        var idwVerifyMode      = 0;
                        var idwInOutMode       = 0;
                        var idwYear            = 0;
                        var idwMonth           = 0;
                        var idwDay             = 0;
                        var idwHour            = 0;
                        var idwMinute          = 0;
                        var idwSecond          = 0;
                        var idwWorkcode        = 0;
                        while (_czkem.SSR_GetGeneralLogData(_device.DeviceId, out sdwEnrollNumber, out idwVerifyMode,
                                                            out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour,
                                                            out idwMinute, out idwSecond, ref idwWorkcode))
                        {
                            double memberId;
                            if (Double.TryParse(sdwEnrollNumber, out memberId))
                            {
                                iGLCount++;
                                var date            = new DateTime(idwYear, idwMonth, idwDay, idwHour, idwMinute, idwSecond);
                                var dr              = tblS.NewRow();
                                dr["intEmployeeId"] = sdwEnrollNumber;
                                dr["dtDate"]        = date.ToString();
                                dr["intInOut"]      = idwVerifyMode;
                                dr["intBranchId"]   = _device.BranchId;
                                if (date >= Settings.Default.Date)
                                {
                                    if (string.IsNullOrEmpty(strResetTime))
                                    {
                                        strResetTime = date.ToString();
                                    }
                                    tblS.Rows.Add(dr);
                                    dates.Add(date);
                                }
                            }
                        }
                        if (string.IsNullOrEmpty(strResetTime))
                        {
                            strResetTime = Settings.Default.Date.ToString();
                        }
                        if (dates.Any())
                        {
                            Settings.Default.Date = dates.OrderByDescending(x => x).First();
                        }
                        //await fillListView("Starting from " + strResetTime + " Compare To " + Settings.Default.Date, 0);
                        //fillListView("fetched In", iGLCount);
                        SaveSyncData(tblS);
                    }
                    else
                    {
                        //await fillListView("No data found from device to sync.", 0);
                        btnSyncAttendance.Enabled = true;
                    }
                }
            });

            thread.IsBackground = true;
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }
        private bool clkZKSoft(int pRid, int pNro, string pDes, string pDir, int pPor, long pPsw)
        {
            bool clkZKSoft = false;

            try
            {
                string sdwEnrollNumber = "";
                int    idwVerifyMode;
                int    idwInOutMode;
                int    idwYear;
                int    idwMonth;
                int    idwDay;
                int    idwHour;
                int    idwMinute;
                int    idwSecond;
                int    idwWorkcode = 0;
                string vFic;
                bool   vClean = false;
                CZKEM  Reloj  = new CZKEM();
                DevOps devolucionOperacion = new DevOps();

                RelojesIngresos      objFichada    = new RelojesIngresos();
                List <RelojResponse> relojResponse = new List <RelojResponse>();
                //DevOps devolucionOperacion = new DevOps();

                //if (pDir == "192.168.0.241")
                //    pDir = "192.168.5.111"; // Reloj Pilar
                // If pDir = "192.168.0.241" Then pDir = "200.49.156.125"
                // If pDir = "200.85.127.22" Then pDir = "192.168.5.125"
                // If pDir = "192.168.4.240" Then
                // pDir = "661705e2a569.sn.mynetname.net"
                // pPor = 64370
                // End If
                //FuncionPrueba(pRid);
                Logger.GetInstance().AddLog(true, "clkZKSoft()", "Conectandose " + pDir + ":" + pPor);
                if (Reloj.Connect_Net(pDir, pPor))/* && false)*/
                {
                    Logger.GetInstance().AddLog(true, "clkZKSoft()", "Conectado a " + pDir + ":" + pPor);
                    Reloj.EnableDevice(pNro, false);

                    // ----> Leo Datos
                    if (Reloj.ReadGeneralLogData(pNro))
                    {
                        // SSR_GetGeneralLogData
                        // ----> Leo Datos
                        while (Reloj.SSR_GetGeneralLogData(pNro, out sdwEnrollNumber, out idwVerifyMode, out idwInOutMode, out idwYear, out idwMonth, out idwDay, out idwHour, out idwMinute, out idwSecond, ref idwWorkcode))
                        {
                            if (!vClean)
                            {
                                Logger.GetInstance().AddLog(true, "clkZKSoft()", "Procesando registros de " + pDir + ":" + pPor);
                            }

                            vClean = true;
                            //Logger.GetInstance().AddLog(true, "clkZKSoft()", "Revisando Legajo: " + sdwEnrollNumber);

                            if (idwYear == DateTime.Now.Year)
                            {
                                RelojResponse relojResponseItem = new RelojResponse();
                                vFic = string.Format(idwYear.ToString("0000")) + "-" + string.Format(idwMonth.ToString("00")) + "-" + string.Format(idwDay.ToString("00")) + " " + String.Format(idwHour.ToString("00")) + ":" + String.Format(idwMinute.ToString("00")) + ":" + String.Format(idwSecond.ToString("00"));
                                //Logger.GetInstance().AddLog(true, "clkZKSoft()", "Fecha del Registro: " + vFic);
                                relojResponseItem.Fich            = vFic;
                                relojResponseItem.Nro             = pNro;
                                relojResponseItem.SdwEnrollNumber = sdwEnrollNumber;
                                relojResponseItem.IdwVerifyMode   = idwVerifyMode;
                                relojResponseItem.IdwInOutMode    = idwInOutMode;
                                relojResponseItem.IdwWorkcode     = idwWorkcode;

                                relojResponse.Add(relojResponseItem);
                            }
                        }

                        if (relojResponse.Count > 0)
                        {
                            if (ConnectServer(dBServer1))
                            {
                                Logger.GetInstance().AddLog(true, "clkZKSoft()", "Envios a Server1: " + dBServer1);
                                Logger.GetInstance().AddLog(true, "clkZKSoft()", "Cantidad de Registros: " + relojResponse.Count);

                                foreach (RelojResponse item in relojResponse)
                                {
                                    Logger.GetInstance().AddLog(true, "clkZKSoft()", "Revisando Legajo: " + item.SdwEnrollNumber);
                                    Logger.GetInstance().AddLog(true, "clkZKSoft()", "Fecha del Registro: " + item.Fich);
                                    try
                                    {
                                        devolucionOperacion = objFichada.SetFichada(pRid, item.SdwEnrollNumber, item.Fich, "CLOCK");

                                        Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada CacheDebug: " + devolucionOperacion.CacheDebug);

                                        if (devolucionOperacion.Resultado)
                                        {
                                            Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada OK");
                                        }
                                        else
                                        {
                                            Logger.GetInstance().AddLog(false, "clkZKSoft()", "SetFichada Error: " + devolucionOperacion.DescripcionError);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Logger.GetInstance().AddLog(false, "clkZKSoft()", "Excepción en SetFichada: " + ex.Message);
                                    }
                                }
                                modDeclares.ShamanSession.Cerrar(modDeclares.ShamanSession.PID);
                            }

                            if (ConnectServer(dBServer2))
                            {
                                Logger.GetInstance().AddLog(true, "clkZKSoft()", "Envios a Server2: " + dBServer2);
                                Logger.GetInstance().AddLog(true, "clkZKSoft()", "Cantidad de Registros: " + relojResponse.Count);
                                foreach (RelojResponse item in relojResponse)
                                {
                                    Logger.GetInstance().AddLog(true, "clkZKSoft()", "Revisando Legajo: " + item.SdwEnrollNumber);
                                    Logger.GetInstance().AddLog(true, "clkZKSoft()", "Fecha del Registro: " + item.Fich);
                                    try
                                    {
                                        devolucionOperacion = objFichada.SetFichada(pRid, item.SdwEnrollNumber, item.Fich, "CLOCK");
                                        Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada CacheDebug: " + devolucionOperacion.CacheDebug);

                                        if (devolucionOperacion.Resultado)
                                        {
                                            Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada OK");
                                        }
                                        else
                                        {
                                            Logger.GetInstance().AddLog(false, "clkZKSoft()", "SetFichada Error: " + devolucionOperacion.DescripcionError);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Logger.GetInstance().AddLog(false, "clkZKSoft()", "Excepción en SetFichada: " + ex.Message);
                                    }
                                }
                                modDeclares.ShamanSession.Cerrar(modDeclares.ShamanSession.PID);
                            }

                            if (ConnectServer(dBServer3))
                            {
                                Logger.GetInstance().AddLog(true, "clkZKSoft()", "Envios a Server3: " + dBServer3);
                                Logger.GetInstance().AddLog(true, "clkZKSoft()", "Cantidad de Registros: " + relojResponse.Count);
                                foreach (RelojResponse item in relojResponse)
                                {
                                    Logger.GetInstance().AddLog(true, "clkZKSoft()", "Revisando Legajo: " + item.SdwEnrollNumber);
                                    Logger.GetInstance().AddLog(true, "clkZKSoft()", "Fecha del Registro: " + item.Fich);
                                    try
                                    {
                                        devolucionOperacion = objFichada.SetFichada(pRid, item.SdwEnrollNumber, item.Fich, "CLOCK");
                                        Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada CacheDebug: " + devolucionOperacion.CacheDebug);

                                        if (devolucionOperacion.Resultado)
                                        {
                                            Logger.GetInstance().AddLog(true, "clkZKSoft()", "SetFichada OK");
                                        }
                                        else
                                        {
                                            Logger.GetInstance().AddLog(false, "clkZKSoft()", "SetFichada Error: " + devolucionOperacion.DescripcionError);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Logger.GetInstance().AddLog(false, "clkZKSoft()", "Excepción en SetFichada: " + ex.Message);
                                    }
                                }
                                modDeclares.ShamanSession.Cerrar(modDeclares.ShamanSession.PID);
                            }
                        }

                        if (vClean)
                        {
                            Logger.GetInstance().AddLog(true, "clkZKSoft()", "Vaciar Reloj " + pNro + " Ip: " + pDir + ":" + pPor);
                            if (Reloj.ClearGLog(pNro))
                            {
                                Reloj.RefreshData(pNro);
                                Logger.GetInstance().AddLog(true, "clkZKSoft()", "Se vació RelojId " + pNro + " Ip: " + pDir + ":" + pPor);
                            }
                            else
                            {
                                int idwErrorCode = 0;
                                Reloj.GetLastError(idwErrorCode);
                                Logger.GetInstance().AddLog(false, "clkZKSoft()", "Error al vaciar " + pDir + ":" + pPor + " " + idwErrorCode);
                            }

                            vClean = false;
                        }
                        else
                        {
                            Logger.GetInstance().AddLog(true, "clkZKSoft()", "No hay fichadas en " + pDir + ":" + pPor);
                        }
                    }
                    else
                    {
                        Logger.GetInstance().AddLog(true, "clkZKSoft()", "No hay fichadas en " + pDir + ":" + pPor);
                    }

                    Logger.GetInstance().AddLog(true, "clkZKSoft()", "Desconectar Reloj " + pDir + ":" + pPor);
                    Reloj.Disconnect();

                    clkZKSoft = true;
                }
                else
                {
                    Logger.GetInstance().AddLog(true, "clkZKSoft()", "Sin conexión a " + pDir + ":" + pPor);
                }
            }
            catch (Exception ex)
            {
                Logger.GetInstance().AddLog(false, "clkZKSoft()", ex.Message);
            }
            return(clkZKSoft);
        }
        /// <summary>
        ///    Permite conectar con una terminal:
        ///      1. Lector Biometrico
        ///      2. Lector RFID
        ///      3. Camara
        /// </summary>
        /// <param name="ip">
        ///     La ip de la terminal a conectar
        /// </param>
        /// <param name="puerto">
        ///     Puerto por donde transmite la información
        /// </param>
        /// <param name="tipo">
        ///     tipo de terminal ya sea:
        ///      1. (Biometrico)
        ///      2. (RFID)
        ///      3. (Camara)
        /// </param>
        public bool ConectarConTerminal(string ip, string puerto, string tipo)
        {
            if (tipo == "Biometrico")
            {
                #region
                /// <summary>
                ///     Connect_Net: Permite conectar con el dispositivo a través de la dirección IP y configurar una conexión de red con el dispositivo.
                /// </summary>
                /// <param name="IPAdd">
                ///      Ip del dispositivo
                /// </param>
                /// <param name="Port">
                ///      Puerto usado para conectar con el dispositivo. El puerto por defecto es el 4370.
                /// </param>
                /// <returns>
                ///      Deevuelve True o False. Verificando si el dispositivo pudo conectarse o no.
                /// </returns>
                #endregion
                bool existeConexionBiometrico = lectorObject.Connect_Net(ip, Convert.ToInt32(puerto));

                if (existeConexionBiometrico == true)
                {
                    conexion = true;

                    /// <summary>
                    ///     RegEvent: Permite registrar los eventos en tiempo real.
                    /// </summary>
                    /// <param name="dwMachineNumber">Número de dispositivos</param>
                    /// <param name="EventMask">Código de un evento. Los valores son los siguientes:
                    ///     1. (1):     OnAttTransaction, OnAttTransactionEx  (Este evento se desencadena después de la verificación tiene éxito.)
                    ///     2. (2):     OnFinger (Este evento se activa cuando una huella dactilar se coloca sobre el sensor de huellas digitales del dispositivo. No se devuelve ningún valor.)
                    ///     3. (4):     OnNewUser (Este evento se activa cuando un nuevo usuario se inscribió con éxito.)
                    ///     4. (8):     OnEnrollFinger (Este evento se activa Cuando Se ha Registrado Una Huella digital.)
                    ///     5. (16):    OnKeyPress (No existe documentación para la función)
                    ///     6. (256):   OnVerify (Este evento se activa cuando se verifica un usuario)
                    ///     7. (512):   OnFingerFeature (Este evento se activa cuando un usuario coloca un dedo y el dispositivo registra la huella dactilar.)
                    ///     8. (1024):  OnDoor (Este evento se activa cuando el dispositivo se abre la puerta.),
                    ///                 OnAlarm (Este evento se activa cuando el dispositivo informa de una alarma.)
                    ///     9. (2048):  OnHIDNum (Este evento se activa cuando se pasa una tarjeta.)
                    ///     10.(4096):  OnWriteCard (Este evento se activa cuando el dispositivo registra una carta.)
                    ///     11.(8192):  OnEmptyCard (Este evento se activa cuando una tarjera esta vacia o sin codigo asignado.)
                    ///     12.(16384): OnDeleteTemplate (No existe documentación para la función.)
                    ///     13.(65535): Para registrar todos los eventos.
                    /// </param>
                    /// <returns>
                    ///    Devuelve True o False: Dependiendo si tiene exito en registrar los eventos u ocurre errores.
                    /// </returns>
                    bool existenEventos = lectorObject.RegEvent(Dispositivo, 65535);

                    if (existenEventos == true)
                    {
                        lectorObject.OnVerify           += new _IZKEMEvents_OnVerifyEventHandler(ObtenerUsuarioEvent);
                        lectorObject.OnHIDNum           += new _IZKEMEvents_OnHIDNumEventHandler(ObtenerTarjetaEvent);
                        lectorObject.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(ObtenerAtributosPostValidacion);
                    }
                    else
                    {
                        //Muestre un mensaje que no se puede registrar los eventos.
                    }
                }
                else
                {
                    //Muestre un Mensaje de que no se puede conectar con el dispositivo.
                }
                return(existeConexionBiometrico);
            }
            return(false);
        }
Exemple #30
0
        private void prcExecuteDownload()
        {
            gridInfo.DataSource = null;

            ArrayList arQuery = new ArrayList();

            GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection();

            try
            {
                string sqlQuery = "", DeviceIP = "", GetDeviceIP = "";
                Int32  NewId = 0;
                Int32  RowID;

                string sdwEnrollNumber = "", DeviceIp = "", pDate = "", pTime = "", CardNo = "", EnrollID = "";
                int    idwTMachineNumber = 0, idwEMachineNumber = 0;
                int    idwVerifyMode = 0, idwInOutMode = 0, idwEnrollNumber = 0, EnrollData = 0;

                int idwYear = 0, idwMonth = 0, idwDay = 0;
                int idwHour = 0, idwMinute = 0, idwSecond = 0;

                int idwWorkcode = 0, idwErrorCode = 0;

                int iGLCount = 0, iIndex = 0;

                //Raw Data Clear
                sqlQuery = "Truncate Table tblRawdataMIGTR_Temp";
                arQuery.Add(sqlQuery);


                sqlQuery = "Update tblMachineNo_GTR set  Status = 'Disconnect'";
                arQuery.Add(sqlQuery);
                clsCon.GTRSaveDataWithSQLCommand(arQuery);

                foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.gridDetails.Rows)
                {
                    if (row.Cells["Id"].Text.ToString().Length != 0 &&
                        row.Cells["isChecked"].Value.ToString() == "1" && row.Cells["Active"].Value.ToString() == "1")
                    {
                        GetDeviceIP = "" + row.Cells["IpAddress"].Text.ToString() + "";

                        bIsConnected = axCZKEM1.Connect_Net(GetDeviceIP, 4370);
                        if (bIsConnected == true)
                        {
                            iMachineNumber = 1;
                            axCZKEM1.RegEvent(iMachineNumber, 65535);
                        }
                        else
                        {
                            axCZKEM1.GetLastError(ref idwErrorCode);
                            MessageBox.Show("Device not connected. Please check your device or network connection.Problem IP Address = " + GetDeviceIP.ToString(), "Error");
                        }

                        //ZK Black & White Device Download Code

                        if (row.Cells["BlackWhite"].Value.ToString() == "1")
                        {
                            sqlQuery = "Update tblMachineNo_GTR set  Status = 'Connect' where IpAddress ='" + row.Cells["IpAddress"].Text.ToString() + "'";
                            arQuery.Add(sqlQuery);
                            clsCon.GTRSaveDataWithSQLCommand(arQuery);


                            Cursor = Cursors.WaitCursor;
                            //lvLogs.Items.Clear();
                            axCZKEM1.EnableDevice(iMachineNumber, false);    //disable the device
                            if (axCZKEM1.ReadGeneralLogData(iMachineNumber)) //read all the attendance records to the memory
                            {
                                while (axCZKEM1.GetGeneralLogData(iMachineNumber, ref idwTMachineNumber, ref idwEnrollNumber,
                                                                  ref idwEMachineNumber, ref idwVerifyMode, ref idwInOutMode, ref idwYear, ref idwMonth, ref idwDay, ref idwHour, ref idwMinute))//get records from the memory
                                {
                                    //iGLCount++;

                                    DeviceIp = GetDeviceIP.Substring(7);

                                    //CardNo = idwEnrollNumber.ToString();
                                    //CardNo = GTRDecToHexCon(CardNo);

                                    EnrollData = int.Parse(sdwEnrollNumber);
                                    //EnrollID = EnrollData.ToString("0000000000");

                                    //pDate = idwDay + "-" + idwMonth + "-" + idwYear;
                                    pDate = idwYear + "-" + idwMonth + "-" + idwDay;
                                    pTime = idwHour + ":" + idwMinute + ":" + idwSecond;


                                    sqlQuery = "Insert into tblRawdataMIGTR_Temp(ComId,DeviceNo,CardNo,dtPunchDate,dtPunchTime) values(" + Common.Classes.clsMain.intComId + ",'" +
                                               DeviceIp + "','" + sdwEnrollNumber + "','" + pDate + "','" + pTime + "')";
                                    arQuery.Add(sqlQuery);


                                    sqlQuery = "Insert into tblRawdata(ComId,DeviceNo,CardNo,dtPunchDate,dtPunchTime,LUserID,PCName) values(" + Common.Classes.clsMain.intComId + ",'" +
                                               DeviceIp + "','" + sdwEnrollNumber + "','" + pDate + "','" + pTime + "'," + GTRHRIS.Common.Classes.clsMain.intUserId + ",'" + Common.Classes.clsMain.strComputerName + "')";
                                    arQuery.Add(sqlQuery);


                                    //iIndex++;
                                } //while
                            }     //if

                            if (chkClear.Checked == true)
                            {
                                axCZKEM1.EnableDevice(iMachineNumber, false);//disable the device
                                if (axCZKEM1.ClearGLog(iMachineNumber))
                                {
                                    axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed
                                    //MessageBox.Show("All att Logs have been cleared from teiminal!", "Success");
                                }
                            }

                            axCZKEM1.EnableDevice(iMachineNumber, true);//enable the device
                            Cursor = Cursors.Default;

                            axCZKEM1.Disconnect();
                        }  //if

                        //ZK Color Device Download Code
                        else
                        {
                            sqlQuery = "Update tblMachineNo_GTR set  Status = 'Connect' where IpAddress ='" + row.Cells["IpAddress"].Text.ToString() + "'";
                            arQuery.Add(sqlQuery);
                            clsCon.GTRSaveDataWithSQLCommand(arQuery);

                            Cursor = Cursors.WaitCursor;
                            //lvLogs.Items.Clear();
                            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
                                {
                                    //iGLCount++;

                                    DeviceIp = GetDeviceIP.Substring(7);

                                    //CardNo = sdwEnrollNumber;
                                    //CardNo = GTRDecToHexCon(CardNo);

                                    EnrollData = int.Parse(sdwEnrollNumber);
                                    EnrollID   = EnrollData.ToString("0000000000");

                                    //pDate = idwDay + "-" + idwMonth + "-" + idwYear;
                                    pDate = idwYear + "-" + idwMonth + "-" + idwDay;
                                    pTime = idwHour + ":" + idwMinute + ":" + idwSecond;


                                    sqlQuery = "Insert into tblRawdataMIGTR_Temp(ComId,DeviceNo,CardNo,dtPunchDate,dtPunchTime) values(" + Common.Classes.clsMain.intComId + ",'" +
                                               DeviceIp + "','" + EnrollID + "','" + pDate + "','" + pTime + "')";
                                    arQuery.Add(sqlQuery);


                                    sqlQuery = "Insert into tblRawdata(ComId,DeviceNo,CardNo,dtPunchDate,dtPunchTime,LUserID,PCName) values(" + Common.Classes.clsMain.intComId + ",'" +
                                               DeviceIp + "','" + EnrollID + "','" + pDate + "','" + pTime + "'," + GTRHRIS.Common.Classes.clsMain.intUserId + ",'" + Common.Classes.clsMain.strComputerName + "')";
                                    arQuery.Add(sqlQuery);


                                    //iIndex++;
                                } //while
                            }     //if

                            if (chkClear.Checked == true)
                            {
                                axCZKEM1.EnableDevice(iMachineNumber, false);//disable the device
                                if (axCZKEM1.ClearGLog(iMachineNumber))
                                {
                                    axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed
                                    //MessageBox.Show("All att Logs have been cleared from teiminal!", "Success");
                                }
                            }

                            axCZKEM1.EnableDevice(iMachineNumber, true);//enable the device
                            Cursor = Cursors.Default;

                            axCZKEM1.Disconnect();
                        } //else
                    }     //if
                }         //foreach

                // Insert Information To Log File
                sqlQuery = "Insert Into tblUser_Trans_Log (LUserId, formName, tranStatement, PCName, tranType)"
                           + " Values (" + GTRHRIS.Common.Classes.clsMain.intUserId + ", '" + this.Name.ToString() +
                           "','" + sqlQuery.Replace("'", "|") + "','" + Common.Classes.clsMain.strComputerName + "','Download')";
                arQuery.Add(sqlQuery);

                clsCon.GTRSaveDataWithSQLCommand(arQuery);

                prcLoadList();
                prcRawData();
            }  //try
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                clsCon = null;
            }
        }