66 lines
3.1 KiB
C#
66 lines
3.1 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace Fitness_core_BE.Models
|
|
{
|
|
public class AccessDevice
|
|
{
|
|
[Key]
|
|
public Guid DeviceId { get; set; }
|
|
public string DeviceName { get; set; }
|
|
|
|
// DEPRECATED: connection details now live on the on-prem agent (Fitness_core_BE.Models.Agent),
|
|
// not in the cloud. Kept nullable so existing rows survive; no new code should read/write these.
|
|
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
|
|
public string? PublicIp { get; set; }
|
|
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
|
|
public string? Port { get; set; }
|
|
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
|
|
public string? UserName { get; set; }
|
|
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
|
|
public string? Password { get; set; }
|
|
|
|
public Guid FKClientId { get; set; }
|
|
[ForeignKey("FKClientId")]
|
|
public Client Client { get; set; }
|
|
|
|
// The agent that currently owns this LAN device. Commands are dispatched only
|
|
// to this agent, which prevents a second agent for the same gym receiving them.
|
|
public Guid? FKAgentId { get; set; }
|
|
[ForeignKey(nameof(FKAgentId))]
|
|
public Agent? Agent { get; set; }
|
|
|
|
// Stable serial/device identifier reported by ISAPI. Used to re-claim the same
|
|
// cloud row after reinstalling the desktop agent instead of creating duplicates.
|
|
[MaxLength(160)]
|
|
public string? HardwareId { get; set; }
|
|
|
|
// Which Place (physical zone) this terminal sits in. Null = unscoped: reachable by
|
|
// every plan regardless of that plan's Places (keeps pre-existing devices and
|
|
// plans without any place restriction working unchanged). Unique when set --
|
|
// exactly one device per place for now (see Models/Place.cs).
|
|
public Guid? FKPlaceId { get; set; }
|
|
[ForeignKey(nameof(FKPlaceId))]
|
|
public Place? Place { get; set; }
|
|
|
|
public bool IsActive { get; set; } = true;
|
|
public DateTime? LastSeenAt { get; set; }
|
|
// Explicit reachability reported by the on-prem agent. LastSeenAt remains
|
|
// the last successful terminal operation; health reports are tracked
|
|
// separately so status does not depend on browser polling.
|
|
public bool IsReachable { get; set; }
|
|
public DateTime? LastHealthReportedAt { get; set; }
|
|
public DateTime CreatedAt { get; set; }= DateTime.UtcNow;
|
|
|
|
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
|
|
public void SetPassword(string plainText)
|
|
=> Password = EncryptionHelper.Encrypt(plainText);
|
|
|
|
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
|
|
public string GetPlainTextPassword()
|
|
=> EncryptionHelper.Decrypt(Password!);
|
|
}
|
|
}
|