Exemplo n.º 1
0
        // GET: Asistencia
        private bool Connect()
        {
            bool respuesta = true;

            objZkeeper = new ZkemClient();
            if (!objZkeeper.Connect_Net("172.16.5.163", 4370))
            {
                respuesta = false;
            }
            return(respuesta);
        }
Exemplo n.º 2
0
        // GET: Empleados
        private bool Connect(string ip, int puerto)
        {
            bool respuesta = true;

            objZkeeper = new ZkemClient();

            if (!objZkeeper.Connect_Net(ip, puerto))
            {
                respuesta = false;
            }
            return(respuesta);
        }
Exemplo n.º 3
0
        public string CheckingConnectionStatus(string ipAddress, string port)
        {
            string status = string.Empty;

            try
            {
                #region Validating
                if (ipAddress == string.Empty || port == string.Empty)
                {
                    status = "The Device IP Address and Port is mandotory !!";
                }


                int portNumber = 0;
                if (!int.TryParse(port, out portNumber))

                {
                    status = "Not a valid port number";
                }
                bool isValidIpA = UniversalStatic.ValidateIP(ipAddress);
                if (!isValidIpA)
                {
                    status = "The Device IP is invalid !!";
                }
                isValidIpA = UniversalStatic.PingTheDevice(ipAddress);
                if (!isValidIpA)
                {
                    status = "The device at " + ipAddress + ":" + port + " did not respond!!";
                }
                #endregion
                ZkemClient objZkeeper        = new ZkemClient();
                bool       IsDeviceConnected = objZkeeper.Connect_Net(ipAddress, portNumber);

                if (IsDeviceConnected)
                {
                    status = "Device Is Online";
                }
            }
            catch (Exception ex)
            {
                status = ex.Message.ToString();
                //ShowStatusBar(ex.Message, false);
            }
            return(status);
        }
Exemplo n.º 4
0
        private static void conectar(int index)
        {
            try
            {
                string ipAddress = marcadores[index].IP; //cmbUbicacion.SelectedValue.ToString(); //tbxDeviceIP.Text.Trim();
                string port      = marcadores[index].PUERTO.ToString();
                if (ipAddress == string.Empty || port == string.Empty)
                {
                    throw new Exception("La dirección IP y el número de puerto son requeridos.");
                }

                int portNumber = 4370;
                if (!int.TryParse(port, out portNumber))
                {
                    throw new Exception("No es un número IP válido");
                }

                bool isValidIpA = UniversalStatic.ValidateIP(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("La dirección IP no es una dirección IVP4 válida.");
                }

                isValidIpA = UniversalStatic.PingTheDevice(ipAddress);
                if (!isValidIpA)
                {
                    throw new Exception("La terminal con IP " + ipAddress + ":" + port + " no pudo ser alcanzada.");
                }

                objZkeeper = new ZkemClient(RaiseDeviceEvent);
                objZkeeper.Connect_Net(ipAddress, portNumber);

                string deviceInfo = manipulator.FetchDeviceInfo(objZkeeper, 1);
                Console.WriteLine("Se ha conectado a la terminal: " + deviceInfo + " - en ubicación: " + marcadores[index].UBICACION);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error! " + ex.Message);
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            DeviceManipulator manipulator = new DeviceManipulator();
            ZkemClient        objZkeeper  = new ZkemClient();

            setting = ReadSetting();

            SendEmail("hey tayo hey tayo bus kecil ramah lingkungan");

            try
            {
                objZkeeper.Connect_Net(setting.IpAddress, Int32.Parse(setting.Port));
            }
            catch (Exception ex)
            {
                WriteToErrorLog("Something wrong with Connect_net()", ex.ToString());
            }

            var machineLogs = GetMachineLog(manipulator, objZkeeper);

            var attendanceTempLog = ReadAttendanceTempLog();

            attendanceTempLog = AddNewMachineLogToTemp(machineLogs, attendanceTempLog);

            attendanceTempLog = GenerateAttendanceLogToHit(attendanceTempLog);

            WriteAttendanceTempLog(attendanceTempLog);

            try
            {
                objZkeeper.Disconnect();
            }
            catch (Exception ex)
            {
                WriteToErrorLog("Something wrong with Disconnect()", ex.ToString());
                //WriteToErrorLog(ex.ToString());
            }
        }
Exemplo n.º 6
0
        public ICollection <MachineInfo> ReadMachineData(string machineId, string status, string ipAddress, int port, DateTime fromDate, DateTime toDate)
        {
            IList <MachineInfo> listAttandance = new List <MachineInfo>();

            {
                try
                {
                    List <TimeConfigSettings> timeConfigSettings  = new List <TimeConfigSettings>();
                    TimeConfigSettings        _timeConfigSettings = new TimeConfigSettings();
                    timeConfigSettings  = GetDynamic(" where IP = " + "'" + ipAddress + "'");
                    _timeConfigSettings = timeConfigSettings[0];
                    DateTime fromDate2 = _timeConfigSettings.LastUpdateTime;
                    if (status.Trim() == "Device Is Online")
                    {
                        objZkeeper = new ZkemClient();
                        bool IsDeviceConnected = objZkeeper.Connect_Net(ipAddress, port);

                        if (IsDeviceConnected)
                        {
                            ICollection <MachineInfo> lstMachineInfo = manipulator.GetLogData(objZkeeper, int.Parse(machineId.Trim()));

                            if (lstMachineInfo != null && lstMachineInfo.Count > 0)
                            {
                                DateTime fromDate1 = DateTime.Parse(fromDate.ToString("yyyy-MM-dd"));
                                DateTime fromDate3 = DateTime.Parse(fromDate2.ToString("yyyy-MM-dd"));
                                DateTime toDate1   = Convert.ToDateTime(toDate.ToString("yyyy-MM-dd"));

                                var myQuery = from p in lstMachineInfo
                                              where

                                              p.PunchDate > fromDate2
                                              //&& p.PunchDate <= toDate1
                                              orderby p.EmployeeID
                                              select p;

                                if (myQuery.ToList <MachineInfo>().Count > 0)
                                {
                                    listAttandance = myQuery.ToList <MachineInfo>();
                                }
                                else
                                {
                                    listAttandance = null;
                                }
                            }
                            else
                            {
                                listAttandance = null;
                            }
                        }
                        else
                        {
                            listAttandance = null;
                        }
                    }
                }
                catch (Exception ex)
                {
                    // MessageBox.Show(ex.Message);
                }
            }
            return(listAttandance);
        }