Live Location Tracking
Beyond check-in and check-out, the system continuously tracks field staff location throughout their duty period. The mobile app sends periodic GPS waypoints that are stored as detail records linked to the active site visit.
Continuous Tracking Flow
Safety Check: Only Track Active Sessions
The system performs a critical check before storing any location data. It first looks up the current day's mobile attendance record for the user. Location is only recorded if:
- A mobile attendance record exists for today
- The
OutDateAndTimefield is still null (meaning the user hasn't clocked out yet)
This prevents stale location data from being recorded after a user has already ended their duty.
DataTable dt = objBO.GetMyTodayMobileAttendanceId(UserId);
bool lProoceedToAdd = false;
if (dt.Rows.Count > 0)
lProoceedToAdd = SHGeneral.GetDate(dt.Rows[0]["OutDateAndTime"])
.ToString("dd-MM-yyyy") == "01-01-0001" ? true : false;The check compares the OutDateAndTime against the default date 01-01-0001 — if it matches, the session is still active.
Device Metadata Captured
Each location update includes device health information:
| Field | Type | Description |
|---|---|---|
| BatteryPercentage | int | Current battery level (0-100) |
| IsGPSOn | bool | Whether GPS is enabled on device |
| IsWifiOn | bool | Whether WiFi is connected |
| SignalStrength | int | Mobile network signal strength |
| AppVersion | string | Current app version installed |
This metadata helps managers identify if a staff member's tracking gaps are due to technical issues (low battery, GPS disabled, poor signal) rather than intentional avoidance.
Site Visit Location Updates
Separate from the continuous background tracking, the app can also send explicit location updates tied to a specific site visit record:
This endpoint (SaveReportOnDutyLocation) inserts a waypoint linked to a specific SiteVisitGPSID, unlike SaveLocationOfUser which operates independently.
Location Service Status
The mobile app also reports its location service status to the server:
GET /webapi/SiteVisitGPS/UpdateLocationServiceStatus?UserId=1234&IsLocationEnabled=trueThis allows the admin portal to flag users who have disabled their GPS.
API Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
SaveLocationOfUser | POST | Background continuous tracking with device metadata |
SaveReportOnDutyLocation | POST | Explicit location update tied to a site visit |
UpdateLocationServiceStatus | GET | Report GPS enable/disable status |
Source Files
| File | Purpose |
|---|---|
SiteVisitGPSAPIController.cs | Location API endpoints |
clsMobileAppService | InsertUserLocationForRegularTrack, InsertUserCurrentLocation |
MyAttendanceBO | GetMyTodayMobileAttendanceId check |