From 7b2b9b353e4ce6df95156fac3a1cb8ad44e2305e Mon Sep 17 00:00:00 2001 From: Syed Mustafa Ahmed Naqvi Date: Mon, 1 Jun 2026 15:22:24 +0500 Subject: [PATCH] Include shared logging sources in projects & Log admin login and scanner outcomes Links logging/shared sync result files into the client and adds backend logging abstraction dependency. Adds client-side logs for admin login success/failure and scan processing results. --- UtopiaCanteen.Backend/UtopiaCanteen.Backend.csproj | 1 + UtopiaCanteen.Client/UtopiaCanteen.Client.csproj | 2 ++ ViewModels/AdminLoginViewModel.cs | 6 ++++++ ViewModels/ScannerDashboardViewModel.cs | 3 +++ 4 files changed, 12 insertions(+) diff --git a/UtopiaCanteen.Backend/UtopiaCanteen.Backend.csproj b/UtopiaCanteen.Backend/UtopiaCanteen.Backend.csproj index 28601a6..1eee47d 100644 --- a/UtopiaCanteen.Backend/UtopiaCanteen.Backend.csproj +++ b/UtopiaCanteen.Backend/UtopiaCanteen.Backend.csproj @@ -12,6 +12,7 @@ + diff --git a/UtopiaCanteen.Client/UtopiaCanteen.Client.csproj b/UtopiaCanteen.Client/UtopiaCanteen.Client.csproj index 7b7b848..a387958 100644 --- a/UtopiaCanteen.Client/UtopiaCanteen.Client.csproj +++ b/UtopiaCanteen.Client/UtopiaCanteen.Client.csproj @@ -59,6 +59,8 @@ + + diff --git a/ViewModels/AdminLoginViewModel.cs b/ViewModels/AdminLoginViewModel.cs index a97bb24..cd78c69 100644 --- a/ViewModels/AdminLoginViewModel.cs +++ b/ViewModels/AdminLoginViewModel.cs @@ -1,6 +1,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using UtopiaCanteenSystem.Services; +using UtopiaCanteenSystem.Services.Logging; namespace UtopiaCanteenSystem.ViewModels; @@ -84,6 +85,7 @@ public partial class AdminLoginViewModel : ObservableObject if (!result.Success) { ErrorMessage = "Invalid username or password."; + FileLogger.Warn("ClientLogin", $"Admin login failed for user '{user}'."); return; } @@ -95,6 +97,10 @@ public partial class AdminLoginViewModel : ObservableObject _employeeLookup, _backendApi).ConfigureAwait(true); + FileLogger.Info( + "ClientLogin", + $"Admin login succeeded. EmployeeId={result.EmployeeId}, AdminCardId saved, SiteId={_config.GetSiteId()}"); + // Persist who logged in (for audit / reporting). await _adminAudit.RecordLoginAsync(user, result.EmployeeId).ConfigureAwait(false); diff --git a/ViewModels/ScannerDashboardViewModel.cs b/ViewModels/ScannerDashboardViewModel.cs index 464bbc1..014aa63 100644 --- a/ViewModels/ScannerDashboardViewModel.cs +++ b/ViewModels/ScannerDashboardViewModel.cs @@ -12,6 +12,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using UtopiaCanteenSystem.Models; using UtopiaCanteenSystem.Services; +using UtopiaCanteenSystem.Services.Logging; namespace UtopiaCanteenSystem.ViewModels; @@ -570,9 +571,11 @@ public partial class ScannerDashboardViewModel : ObservableObject if (string.IsNullOrWhiteSpace(cardId)) return; + FileLogger.Info("ClientScan", $"Scan started. CardId={LogMasking.MaskCardId(cardId)}"); var result = _rfidService.ProcessScanDetailed(cardId); IsSuccess = result.Success; Message = result.Message; + FileLogger.Info("ClientScan", $"Scan UI message. Success={result.Success}, Message={result.Message}"); // Check if this is a site mismatch error if (!result.Success && result.Message.Contains("not allowed to scan here"))