84 lines
3.5 KiB
C#
84 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace HikvisionAttendanceService.Data;
|
|
|
|
internal interface IHrmsDbConnectionFactory
|
|
{
|
|
string BuildConnectionStringMasked();
|
|
bool TryBuildConnectionString(out string connectionString, out string error);
|
|
}
|
|
|
|
internal interface IAttendanceMachineRepository
|
|
{
|
|
List<AttendanceMachineRow> GetActiveMachines(string? machineTypeFilter, out string error);
|
|
/// <summary>Lookup by IP without site-scope filtering (used for sync targets).</summary>
|
|
bool TryGetMachineByIp(string machineIp, out AttendanceMachineRow? row, out string error);
|
|
/// <summary>Lookup by machine_id without site-scope filtering (used for sync targets).</summary>
|
|
bool TryGetMachineByMachineId(string machineId, out AttendanceMachineRow? row, out string error);
|
|
void UpdateMachineSyncState(string machineIp, string status, DateTime? lastSyncDate, int? totalUsers, out string error);
|
|
bool TryGetMachineLastSyncDate(string machineIp, out DateTime? lastSyncDate, out string error);
|
|
bool UpdateMachineLastSyncDate(string machineIp, DateTime lastSyncDate, out string error);
|
|
/// <summary>Fallback when machine_ip lookup/update fails (deviceId is attendance_machine.machine_id).</summary>
|
|
bool UpdateMachineLastSyncDateByMachineId(string machineId, DateTime lastSyncDate, out string error);
|
|
}
|
|
|
|
internal interface IAttendanceLogRepository
|
|
{
|
|
/// <summary>
|
|
/// Inserts one attendance_log row. Does not use REPLACE until mapping is confirmed.
|
|
/// <paramref name="acNo"/> must be a non-empty numeric employee string (never "").
|
|
/// </summary>
|
|
bool InsertAttendance(
|
|
string acNo,
|
|
int acNoInt,
|
|
DateTime checkTime,
|
|
int processed,
|
|
string machineId,
|
|
int inOutTypeId,
|
|
string machineIp,
|
|
DateTime dateOnly,
|
|
Action<string>? log,
|
|
out string error);
|
|
|
|
/// <summary>
|
|
/// Inserts one terry_attendance_log row for CONTRACTOR WORKER punches.
|
|
/// Returns false with error when a same punch already exists (duplicate protection).
|
|
/// </summary>
|
|
bool InsertTerryAttendance(
|
|
string acNo,
|
|
DateTime checkTime,
|
|
int processed,
|
|
string machineId,
|
|
int inOutTypeId,
|
|
string machineIp,
|
|
DateTime dateOnly,
|
|
DateTime forDate,
|
|
Action<string>? log,
|
|
out bool wasDuplicate,
|
|
out string error);
|
|
}
|
|
|
|
internal interface IEmployeeLookupRepository
|
|
{
|
|
/// <summary>
|
|
/// Looks up employee.worker_type by employee.serial_number_int (= Hikvision employeeNo).
|
|
/// Returns false when no matching employee row exists.
|
|
/// </summary>
|
|
bool TryGetWorkerTypeBySerialNumberInt(int serialNumberInt, out string? workerType, out string error);
|
|
}
|
|
|
|
internal interface IAttendanceMachineUserRepository
|
|
{
|
|
List<AttendanceMachineUserRow> GetActiveUsersByMachine(string machineId, out string error);
|
|
List<AttendanceMachineUserRow> GetPendingDeletionUsersByMachine(string machineId, out string error);
|
|
bool UpsertMachineUser(string machineId, string serialNumber, string employeeName, string updatedBy, out string error);
|
|
bool MarkDeleted(string machineId, string serialNumber, string updatedBy, out string error);
|
|
}
|
|
|
|
internal interface IAttendanceMachineFaceTemplateRepository
|
|
{
|
|
bool UpsertFaceTemplate(string serialNo, byte[] template, DateTime createdDate, bool isActive, string? sourceMachineId, string? sourceMachineIp, out bool createdNew, out string error);
|
|
bool TryGetActiveFaceTemplateBySerial(string serialNo, out AttendanceMachineFaceTemplateRow? row, out string error);
|
|
}
|