Mobile Punch System
The mobile punch system bridges field staff GPS check-ins with the core attendance system. When a staff member starts duty, a punch timing record is created and processed by the background service into the daily attendance table.
Punch Creation Flow
Two-Path Attendance Posting
The system has two distinct paths for converting a mobile punch into a daily attendance record:
Path 1: Immediate Post — When there are zero pending tasks at check-in time, PostAttendanceWhileOnDuty() is called immediately, creating the attendance record in real-time.
Path 2: Deferred Post — When pending tasks exist, the punch record is created with a reason string listing all pending items. The AttendancePostService background job picks this up later once tasks are cleared or the grace period expires.
Punch Timing Record
The punch timing record created by InsertMobilePunchTiming captures:
| Field | Value | Source |
|---|---|---|
| EmployeeId | From UM_Users lookup | SELECT EmployeeId FROM UM_Users WHERE UserId = @UserId |
| PunchDateTime | DateTime.Now | Server timestamp at check-in |
| Latitude | StartingLatitude | From mobile app GPS |
| Longitude | StartingLongitude | From mobile app GPS |
| Reason | Pending items string | Conditionally set if tasks pending |
User-to-Employee Mapping
The mobile app works with UserId (login identity), but the attendance system uses EmployeeId (HR identity). The mapping is done via:
SELECT EmployeeId FROM UM_Users WHERE UserId = @UserIdThis mapping happens at every check-in to ensure the correct employee record is updated.
Mobile Attendance Record
The MobileAttendance table tracks the full punch-in/punch-out cycle:
The OutDateAndTime being null indicates an active session. The continuous location tracking system uses this check to determine whether to record waypoints.
Source Files
| File | Purpose |
|---|---|
SiteVisitGPSAPIController.cs | SaveReportOnDuty - punch creation |
PunchTimingsBO.cs | InsertMobilePunchTiming, UpdateReason |
MobileAttendanceBO.cs | GetMyTodayMobileAttendanceId |
MyAttendanceBO.cs | PostAttendanceWhileOnDuty |