Esempio n. 1
0
 private void btn_LoadLog_Click(object sender, EventArgs e)
 {
     logs.AddRange(DeviceManipulator.GetAllLogInfo(1, 1, dtp_from.Value.Date, dtp_to.Value.Date).ToList());
     //dataGridView1.DataSource = null;
     logs = logs.OrderBy(c => c.LogDate).ToList();
     DGVLogs.DataSource = logs;
     label3.Text        = logs.Count.ToString();
 }
Esempio n. 2
0
        static ICollection <MachineInfo> GetMachineLog(DeviceManipulator manipulator, ZkemClient objZkeeper)
        {
            var machineLogs = new List <MachineInfo>();

            try
            {
                machineLogs = manipulator.GetLogData(objZkeeper, 1).ToList();
                machineLogs = machineLogs.Where(i => i.DateOnlyRecord.Date >= DateTime.Now.Date && i.DateOnlyRecord.Date <= DateTime.Now.Date).ToList();
            }
            catch (Exception ex)
            {
                WriteToErrorLog("Something wrong with GetMachineLog()", ex.ToString());
            }
            return(machineLogs);
        }
Esempio n. 3
0
        private void btn_LoadUser_Click(object sender, EventArgs e)
        {
            ApplicationDbContext db    = new ApplicationDbContext();
            List <UserInfo>      Users = new List <UserInfo>();
            //  Users = db.UserInfos.ToList();
            List <UserInfo> UserFromDevice = DeviceManipulator.GetAllUserInfo(1).ToList();

            foreach (var usr in UserFromDevice)
            {
                UserInfo user = db.UserInfos.Where(c => c.EnrollNumber == usr.EnrollNumber).FirstOrDefault();
                if (user == null)
                {
                    user = new UserInfo();
                    user.EnrollNumber = usr.EnrollNumber;
                    user.FullName     = usr.FullName;
                    user.FingerIndex  = usr.FingerIndex;
                    user.Enabled      = usr.Enabled;
                    user.Password     = usr.Password;
                    user.CreatedBy    = "admin";
                    user.CreationDate = DateTime.Now;
                    user.BirthDate    = DateTime.Now;
                    user.StartDate    = DateTime.Now;
                    user.DepartmentId = 3;
                    //المارتيني
                    user.CommunityCenterId = 1;
                    db.UserInfos.Add(user);
                    db.SaveChanges();
                }
                else
                {
                    user.EnrollNumber    = usr.EnrollNumber;
                    user.FullName        = usr.FullName;
                    user.FingerIndex     = usr.FingerIndex;
                    user.Enabled         = usr.Enabled;
                    user.Password        = usr.Password;
                    db.Entry(user).State = EntityState.Modified;
                    user.UpdatedDate     = DateTime.Now;
                    user.UpdatedBy       = "admin";
                    db.SaveChanges();
                }
            }
            MessageBox.Show("All Users Loaded Successfully...");
        }
Esempio n. 4
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());
            }
        }