91 lines
3.1 KiB
C#
91 lines
3.1 KiB
C#
using System;
|
|
using XP.Common.License.Enums;
|
|
|
|
namespace XP.Common.License.Implementations
|
|
{
|
|
/// <summary>
|
|
/// 授权检查结果(不可变)| License check result (immutable)
|
|
/// </summary>
|
|
public sealed class LicenseCheckResult
|
|
{
|
|
/// <summary>
|
|
/// 消息最大长度 | Maximum message length
|
|
/// </summary>
|
|
private const int MaxMessageLength = 512;
|
|
|
|
/// <summary>
|
|
/// 是否授权成功 | Whether authorization is successful
|
|
/// </summary>
|
|
public bool IsAuthorized { get; }
|
|
|
|
/// <summary>
|
|
/// 结果消息(最大512字符)| Result message (maximum 512 characters)
|
|
/// </summary>
|
|
public string Message { get; }
|
|
|
|
/// <summary>
|
|
/// 授权模式 | License mode
|
|
/// </summary>
|
|
public LicenseMode LicenseMode { get; }
|
|
|
|
/// <summary>
|
|
/// 模块ID | Module ID
|
|
/// </summary>
|
|
public ushort ModuleId { get; }
|
|
|
|
/// <summary>
|
|
/// 授权到期日期 | License expiration date
|
|
/// </summary>
|
|
public DateTime? ExpirationDate { get; }
|
|
|
|
/// <summary>
|
|
/// SMA到期日期 | SMA expiration date
|
|
/// </summary>
|
|
public DateTime? SmaDate { get; }
|
|
|
|
/// <summary>
|
|
/// 浮动许可IP地址 | Floating license IP address
|
|
/// </summary>
|
|
public string? FloatingLicenseIp { get; }
|
|
|
|
/// <summary>
|
|
/// 浮动许可端口 | Floating license port
|
|
/// </summary>
|
|
public string? FloatingLicensePort { get; }
|
|
|
|
/// <summary>
|
|
/// 构造函数 | Constructor
|
|
/// </summary>
|
|
/// <param name="isAuthorized">是否授权成功 | Whether authorization is successful</param>
|
|
/// <param name="message">结果消息 | Result message</param>
|
|
/// <param name="licenseMode">授权模式 | License mode</param>
|
|
/// <param name="moduleId">模块ID | Module ID</param>
|
|
/// <param name="expirationDate">授权到期日期 | License expiration date</param>
|
|
/// <param name="smaDate">SMA到期日期 | SMA expiration date</param>
|
|
/// <param name="floatingLicenseIp">浮动许可IP地址 | Floating license IP address</param>
|
|
/// <param name="floatingLicensePort">浮动许可端口 | Floating license port</param>
|
|
public LicenseCheckResult(
|
|
bool isAuthorized,
|
|
string message,
|
|
LicenseMode licenseMode,
|
|
ushort moduleId,
|
|
DateTime? expirationDate,
|
|
DateTime? smaDate,
|
|
string? floatingLicenseIp,
|
|
string? floatingLicensePort)
|
|
{
|
|
IsAuthorized = isAuthorized;
|
|
Message = string.IsNullOrEmpty(message)
|
|
? string.Empty
|
|
: message.Length > MaxMessageLength
|
|
? message[..MaxMessageLength]
|
|
: message;
|
|
LicenseMode = licenseMode;
|
|
ModuleId = moduleId;
|
|
ExpirationDate = expirationDate;
|
|
SmaDate = smaDate;
|
|
FloatingLicenseIp = floatingLicenseIp;
|
|
FloatingLicensePort = floatingLicensePort;
|
|
}
|
|
}
|
|
} |