public void Handle(EventMessage msg) { AttendanceLog attendance = null; try { attendance = msg.ConvertFromJSON <AttendanceLog>(); } catch (Exception ex) { Logger.ErrorFormat("DeserializeObject error: {@ex}, EventMessage[{@msg}] is not supported.", ex, msg); return; } if (IsPendingAttendance(attendance.Id)) { Logger.DebugFormat("The attendance({id}) is handled.", attendance.Id); return; } string workerId = null; try { workerId = Bundle.GetCurrentWorkerId(attendance.UserId, attendance.ProjectId); } catch (Exception ex) { throw new FailedHandleException(ex, FailedEventType.NotFoundWorker, HandlerKey, msg); } if (workerId == string.Empty) { throw new FailedHandleException(string.Format("Not found the worker id({0})", attendance.UserId), FailedEventType.NotFoundWorker, HandlerKey, msg); } switch (attendance.DeviceType) { case DeviceType.OnlyIn: CheckIn(attendance, workerId); break; case DeviceType.OnlyOut: CheckOut(attendance, workerId); break; case DeviceType.InOut: CheckInOrCheckOut(attendance, workerId); break; default: Logger.ErrorFormat("Not support device type:{@attendance}", attendance); break; } }