LicensesModel.cs 1.73 KB
using HHECS.Infrastructure.CommonHelper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HHECS.Application.Licenses
{
    /// <summary>
    /// 授权模型
    /// </summary>
    public class LicenseModel
    {
        /// <summary>
        /// 机器码,与程序内置的要一致
        /// </summary>
        public string CustomMachineCode { get; set; }

        /// <summary>
        /// 客户名称
        /// </summary>
        public string CustomName { get; set; }

        /// <summary>
        /// 最后使用时间
        /// </summary>
        public DateTime LastUseTime { get; set; }

        /// <summary>
        /// 过期时间expire
        /// </summary>
        public DateTime ExpireTime { get; set; }

        /// <summary>
        /// 身份类型
        /// </summary>
        public LicenseType CustomRole { get; set; }

        public override string ToString()
        {
            if (CustomRole != LicenseType.Free)
            {
                return $"授权给:{CustomName} / 版本:{CustomRole.ToDescriptionOrString()} / 到期日:{ExpireTime:yyyy-MM-dd HH:mm:ss}";
            }
            else
            {
                return $"授权给:{CustomName} / 版本:{CustomRole.ToDescriptionOrString()}";
            }
        }
    }

    /// <summary>
    /// 几种角色类型
    /// </summary>
    [Serializable]
    public enum LicenseType
    {
        /// <summary>
        /// 试用版
        /// </summary>
        [Description("试用版")]
        Trial = 0,

        /// <summary>
        /// 正式版
        /// </summary>
        [Description("正式版")]
        Free = 1
    }
}