public JsonResult ReadCard()
        {
            RFID.NFCReader rf = new RFID.NFCReader();
            rf.Connect();
            var _ıd = rf.GetCardUID();

            rf.Disconnect();
            return(Json(_ıd));
        }
Exemple #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                using (var db = new ProjeEntities())
                {
                    if (label1.Text != null)
                    {
                        label1.Text = null;
                        label2.Text = null;
                        label3.Text = null;
                        label4.Text = null;
                    }
                    r.Connect();

                    var id  = r.GetCardUID();
                    var emp = db.Employees.FirstOrDefault(x => x.CardNumber == id);
                    if (emp != null)
                    {
                        label1.Text = emp.Name;
                        label2.Text = emp.Surname;
                        label3.Text = emp.CardNumber;
                        LoginEmployee l = new LoginEmployee();
                        l.EmployeeId = emp.Id;
                        DateTime localDate = DateTime.Now;
                        l.Date      = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss").ToString());
                        label4.Text = Convert.ToString(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss").ToString()));
                        var s = r.Watch();
                        label4.Text = s;
                        var sname = db.Shifts.Where(x => x.ShiftNumber == s).FirstOrDefault();
                        l.Shiftname = sname.Name;

                        db.LoginEmployees.Add(l);
                        db.SaveChanges();
                    }
                }
            }

            catch (Exception)
            {
                throw;
            }
        }