feat: add configuration for department-based device onboarding

Add initial department-sync and employee-photo source settings, plus department-based user-sync filters. Load, normalize, and apply the new configuration values.
main
SYED MUSTUFA AHMED NAQVI 2026-08-15 15:52:25 +05:00
parent 9d1e361099
commit 8ae1749dac
2 changed files with 34 additions and 18 deletions

View File

@ -19,6 +19,7 @@
"InitialSyncDepartmentIds": [ "InitialSyncDepartmentIds": [
"357" "357"
], ],
"InitialSyncEmployeeIds": [],
"EnableEmployeePhotoSource": true, "EnableEmployeePhotoSource": true,
"EmployeePhotoBaseUrl": "https://portal.utopiaindustries.pk/uind/employee-photo/" "EmployeePhotoBaseUrl": "https://portal.utopiaindustries.pk/uind/employee-photo/"
} }

View File

@ -113,6 +113,13 @@ public sealed class HikvisionAttendanceWindowsService : ServiceBase
[DataMember] [DataMember]
public List<string> InitialSyncDepartmentIds { get; set; } = new List<string>(); public List<string> InitialSyncDepartmentIds { get; set; } = new List<string>();
/// <summary>
/// Optional allow-list of employee serial_numbers. When non-empty, initial sync enrolls only
/// these employees AND only if they belong to <see cref="InitialSyncDepartmentIds"/>. Empty = whole department.
/// </summary>
[DataMember]
public List<string> InitialSyncEmployeeIds { get; set; } = new List<string>();
/// <summary>When true, initial sync downloads JPEG photos from <see cref="EmployeePhotoBaseUrl"/>.</summary> /// <summary>When true, initial sync downloads JPEG photos from <see cref="EmployeePhotoBaseUrl"/>.</summary>
[DataMember] [DataMember]
public bool EnableEmployeePhotoSource { get; set; } public bool EnableEmployeePhotoSource { get; set; }
@ -573,6 +580,8 @@ public sealed class HikvisionAttendanceWindowsService : ServiceBase
cfg.EnableInitialDepartmentSync = overlay.EnableInitialDepartmentSync; cfg.EnableInitialDepartmentSync = overlay.EnableInitialDepartmentSync;
if (overlay.InitialSyncDepartmentIds != null) if (overlay.InitialSyncDepartmentIds != null)
cfg.InitialSyncDepartmentIds = new List<string>(overlay.InitialSyncDepartmentIds); cfg.InitialSyncDepartmentIds = new List<string>(overlay.InitialSyncDepartmentIds);
if (overlay.InitialSyncEmployeeIds != null)
cfg.InitialSyncEmployeeIds = new List<string>(overlay.InitialSyncEmployeeIds);
cfg.EnableEmployeePhotoSource = overlay.EnableEmployeePhotoSource; cfg.EnableEmployeePhotoSource = overlay.EnableEmployeePhotoSource;
if (overlay.EmployeePhotoBaseUrl != null) if (overlay.EmployeePhotoBaseUrl != null)
cfg.EmployeePhotoBaseUrl = overlay.EmployeePhotoBaseUrl; cfg.EmployeePhotoBaseUrl = overlay.EmployeePhotoBaseUrl;
@ -619,6 +628,9 @@ public sealed class HikvisionAttendanceWindowsService : ServiceBase
cfg.InitialSyncDepartmentIds ??= new List<string>(); cfg.InitialSyncDepartmentIds ??= new List<string>();
for (int i = 0; i < cfg.InitialSyncDepartmentIds.Count; i++) for (int i = 0; i < cfg.InitialSyncDepartmentIds.Count; i++)
cfg.InitialSyncDepartmentIds[i] = (cfg.InitialSyncDepartmentIds[i] ?? "").Trim(); cfg.InitialSyncDepartmentIds[i] = (cfg.InitialSyncDepartmentIds[i] ?? "").Trim();
cfg.InitialSyncEmployeeIds ??= new List<string>();
for (int i = 0; i < cfg.InitialSyncEmployeeIds.Count; i++)
cfg.InitialSyncEmployeeIds[i] = (cfg.InitialSyncEmployeeIds[i] ?? "").Trim();
cfg.EmployeePhotoBaseUrl = string.IsNullOrWhiteSpace(cfg.EmployeePhotoBaseUrl) cfg.EmployeePhotoBaseUrl = string.IsNullOrWhiteSpace(cfg.EmployeePhotoBaseUrl)
? "" ? ""
: cfg.EmployeePhotoBaseUrl.Trim(); : cfg.EmployeePhotoBaseUrl.Trim();
@ -669,6 +681,9 @@ public sealed class HikvisionAttendanceWindowsService : ServiceBase
[DataMember] [DataMember]
public List<string> InitialSyncDepartmentIds { get; set; } = new List<string>(); public List<string> InitialSyncDepartmentIds { get; set; } = new List<string>();
[DataMember]
public List<string> InitialSyncEmployeeIds { get; set; } = new List<string>();
[DataMember] [DataMember]
public bool EnableEmployeePhotoSource { get; set; } public bool EnableEmployeePhotoSource { get; set; }