Harden sync, cache, dashboard, and schedule flows
Updates cache sync, production order sync, meal schedule view logic, and scanner dashboard behavior to support the new backend/client architecture.feature/centralized-offline-canteen
parent
e85d465bf1
commit
e3effcb416
|
|
@ -28,7 +28,7 @@ public class EmployeeRfidTagSyncService : IEmployeeRfidTagSyncService
|
||||||
return new EmployeeRfidTagSyncResult
|
return new EmployeeRfidTagSyncResult
|
||||||
{
|
{
|
||||||
Success = false,
|
Success = false,
|
||||||
ErrorMessage = "HRMS lookup connection string is not configured."
|
ErrorMessage = "MySQL connection string is not configured."
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public class MealMenuCacheSyncService : IMealMenuCacheSyncService
|
||||||
return new MealMenuCacheSyncResult
|
return new MealMenuCacheSyncResult
|
||||||
{
|
{
|
||||||
Success = false,
|
Success = false,
|
||||||
ErrorMessage = "HRMS lookup connection string is not configured."
|
ErrorMessage = "MySQL connection string is not configured."
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,6 @@ public class SyncService : ISyncService
|
||||||
}
|
}
|
||||||
|
|
||||||
var hrmsConnStr = _configService.GetHrmsLookupConnectionString();
|
var hrmsConnStr = _configService.GetHrmsLookupConnectionString();
|
||||||
if (string.IsNullOrWhiteSpace(hrmsConnStr))
|
|
||||||
{
|
|
||||||
System.Diagnostics.Debug.WriteLine("HRMS lookup connection string not configured; skipping sync (need both for lunch_order).");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ScanRecord> toSync;
|
List<ScanRecord> toSync;
|
||||||
using (var db = _dbFactory.CreateDbContext())
|
using (var db = _dbFactory.CreateDbContext())
|
||||||
|
|
@ -59,7 +54,7 @@ public class SyncService : ISyncService
|
||||||
VALUES
|
VALUES
|
||||||
(@ScanTimeUtc, @SiteId, @DeviceId, @CardId, @IpAddress, UTC_TIMESTAMP(3))";
|
(@ScanTimeUtc, @SiteId, @DeviceId, @CardId, @IpAddress, UTC_TIMESTAMP(3))";
|
||||||
|
|
||||||
// HRMS/local: lunch_order (GetHrmsLookupConnectionString)
|
// HRMS/UIND: lunch_order (HrmsLookup when set, else MySqlConnectionString)
|
||||||
const string existsOrderSql = @"
|
const string existsOrderSql = @"
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM lunch_order
|
FROM lunch_order
|
||||||
|
|
|
||||||
|
|
@ -357,7 +357,7 @@ public partial class MealSchedulesViewModel : ObservableObject
|
||||||
? $"{mysql.Message}{Environment.NewLine}{Environment.NewLine}{mysql.StackTrace}"
|
? $"{mysql.Message}{Environment.NewLine}{Environment.NewLine}{mysql.StackTrace}"
|
||||||
: $"{ex.Message}{Environment.NewLine}{Environment.NewLine}{ex.StackTrace}";
|
: $"{ex.Message}{Environment.NewLine}{Environment.NewLine}{ex.StackTrace}";
|
||||||
|
|
||||||
Message = "Could not load schedules.";
|
Message = "Could not load schedules from backend.";
|
||||||
MessageBox.Show(msg, "Meal Schedules – Load Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(msg, "Meal Schedules – Load Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
||||||
|
|
@ -215,22 +215,7 @@ public partial class ScannerDashboardViewModel : ObservableObject
|
||||||
_clockTimer.Tick += (_, _) => CurrentTime = DateTime.Now.ToString("MM/dd/yyyy, hh:mm:ss tt");
|
_clockTimer.Tick += (_, _) => CurrentTime = DateTime.Now.ToString("MM/dd/yyyy, hh:mm:ss tt");
|
||||||
_clockTimer.Start();
|
_clockTimer.Start();
|
||||||
|
|
||||||
// Load initial site from config.
|
RefreshSiteFromConfig();
|
||||||
var siteId = _configService.GetSiteId();
|
|
||||||
if (!string.IsNullOrWhiteSpace(siteId))
|
|
||||||
{
|
|
||||||
// Extract digits from legacy format "SITE : X"or use value directly if already numeric
|
|
||||||
if (siteId.StartsWith("SITE : ", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
var num = siteId.Substring("SITE : ".Length).Trim();
|
|
||||||
if (num.Length > 0 && num.All(char.IsDigit))
|
|
||||||
SiteNumber = num;
|
|
||||||
}
|
|
||||||
else if (siteId.All(char.IsDigit))
|
|
||||||
{
|
|
||||||
SiteNumber = siteId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RefreshScannerStatus();
|
RefreshScannerStatus();
|
||||||
_ = RefreshDashboardAsync();
|
_ = RefreshDashboardAsync();
|
||||||
|
|
@ -361,6 +346,13 @@ public partial class ScannerDashboardViewModel : ObservableObject
|
||||||
return localDate.ToString("MMM d");
|
return localDate.ToString("MMM d");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Loads SITE header from config (set on admin login).</summary>
|
||||||
|
public void RefreshSiteFromConfig()
|
||||||
|
{
|
||||||
|
SiteNumber = AdminLoginHelper.ExtractSiteDigits(_configService.GetSiteId());
|
||||||
|
OnPropertyChanged(nameof(CurrentSiteDisplay));
|
||||||
|
}
|
||||||
|
|
||||||
partial void OnSiteNumberChanged(string value)
|
partial void OnSiteNumberChanged(string value)
|
||||||
{
|
{
|
||||||
// Numeric only: filter to digits so display stays valid.
|
// Numeric only: filter to digits so display stays valid.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue