63 lines
2.4 KiB
C#
63 lines
2.4 KiB
C#
using System.Text.Json.Serialization;
|
||
|
||
namespace KronaStaffTerminal.Models;
|
||
|
||
public sealed class EmployeeRecord
|
||
{
|
||
public string Id { get; set; } = UlidGenerator.New();
|
||
public string PersonnelNumber { get; set; } = "";
|
||
public string DisplayName { get; set; } = "";
|
||
public string Position { get; set; } = "";
|
||
public bool IsAdministrator { get; set; }
|
||
public int FingerprintId { get; set; }
|
||
public string? FingerprintTemplate { get; set; }
|
||
|
||
[JsonIgnore]
|
||
public bool HasFingerprint => FingerprintId > 0 && !string.IsNullOrWhiteSpace(FingerprintTemplate);
|
||
|
||
[JsonIgnore]
|
||
public string FingerprintStatus => HasFingerprint ? "Отпечаток зарегистрирован" : "Отпечатка нет";
|
||
|
||
[JsonIgnore]
|
||
public string AccessStatus => IsAdministrator ? "Администратор" : "Сотрудник";
|
||
}
|
||
|
||
public sealed class AttendanceRecord
|
||
{
|
||
public string Id { get; set; } = UlidGenerator.New();
|
||
public string EmployeeId { get; set; } = "";
|
||
public string EmployeeName { get; set; } = "";
|
||
public DateTimeOffset OccurredAtUtc { get; set; }
|
||
public int ReaderIndex { get; set; }
|
||
public string EventType { get; set; } = "Приход";
|
||
public bool NotificationDelivered { get; set; }
|
||
public string? NotificationError { get; set; }
|
||
|
||
[JsonIgnore]
|
||
public string LocalTime => OccurredAtUtc.ToLocalTime().ToString("dd.MM.yyyy HH:mm:ss");
|
||
|
||
[JsonIgnore]
|
||
public string DeliveryStatus => NotificationDelivered ? "Отправлено" : string.IsNullOrWhiteSpace(NotificationError) ? "Не настроено" : "Ошибка отправки";
|
||
}
|
||
|
||
public sealed class TerminalSettings
|
||
{
|
||
public int ReaderIndex { get; set; }
|
||
public bool StartWithWindows { get; set; } = true;
|
||
public string AdminPinSalt { get; set; } = "";
|
||
public string AdminPinHash { get; set; } = "";
|
||
public int DuplicateScanGuardSeconds { get; set; } = 120;
|
||
public bool TelegramEnabled { get; set; }
|
||
public string TelegramBotToken { get; set; } = "";
|
||
public string TelegramChatId { get; set; } = "";
|
||
public bool MaxEnabled { get; set; }
|
||
public string MaxBotToken { get; set; } = "";
|
||
public string MaxChatId { get; set; } = "";
|
||
}
|
||
|
||
public sealed class TerminalState
|
||
{
|
||
public List<EmployeeRecord> Employees { get; set; } = [];
|
||
public List<AttendanceRecord> Attendance { get; set; } = [];
|
||
public TerminalSettings Settings { get; set; } = new();
|
||
}
|