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 GetActiveMachines(string? machineTypeFilter, out string error); /// Lookup by IP without site-scope filtering (used for sync targets). bool TryGetMachineByIp(string machineIp, out AttendanceMachineRow? row, out string error); /// Lookup by machine_id without site-scope filtering (used for sync targets). 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); } internal interface IAttendanceLogRepository { /// /// Inserts one attendance_log row. Does not use REPLACE until mapping is confirmed. /// must be a non-empty numeric employee string (never ""). /// bool InsertAttendance( string acNo, int acNoInt, DateTime checkTime, int processed, string machineId, int inOutTypeId, string machineIp, DateTime dateOnly, Action? log, out string error); /// /// Inserts one terry_attendance_log row for CONTRACTOR WORKER punches. /// Returns false with error when a same punch already exists (duplicate protection). /// bool InsertTerryAttendance( string acNo, DateTime checkTime, int processed, string machineId, int inOutTypeId, string machineIp, DateTime dateOnly, DateTime forDate, Action? log, out bool wasDuplicate, out string error); } internal interface IEmployeeLookupRepository { /// /// Looks up employee.worker_type by employee.serial_number_int (= Hikvision employeeNo). /// Returns false when no matching employee row exists. /// bool TryGetWorkerTypeBySerialNumberInt(int serialNumberInt, out string? workerType, out string error); } internal interface IAttendanceMachineUserRepository { List GetActiveUsersByMachine(string machineId, out string error); List 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); }