Exemplo n.º 1
0
        private void EnsureCheckInOrCheckOut(AttendanceLog log, string workerId)
        {
            var attendance          = _db.GetLastAttendanceLogByEnrollNumber(log.UserId);
            AttendanceStatus status = AttendanceStatus.Unknown;

            try
            {
                status = log.CalculateStatus(attendance);
            }
            catch (NotSupportedException ex)
            {
                _logger.ErrorFormat("EnsureCheckInOrCheckOut error:{exception}, attendance:{@log}, worker:{id}",
                                    ex.Message, attendance, workerId);
                return;
            }

            if (status == AttendanceStatus.CheckIn)
            {
                EnsureCheckIn(log, workerId);
                return;
            }

            if (status == AttendanceStatus.CheckOut)
            {
                EnsureCheckOut(log, workerId);
                return;
            }

            _logger.ErrorFormat("EnsureCheckInOrCheckOut: Unknown status, attendance:{@log}, worker:{id}", attendance, workerId);
        }