using DeviceRepair.Models.Attr;
using DeviceRepair.Models.Enum;
using Newtonsoft.Json;
using TsSFCDevice.Client.Biz.Base.Utils;
using System.Linq;

namespace TsSFCDevice.Client.Biz.His
{
    public class TagDataHistory
    {
        [JsonProperty("CheckType", NullValueHandling = NullValueHandling.Ignore)]
        public string CheckType
        {
            get;
            set;
        }

        [JsonProperty("Operator", NullValueHandling = NullValueHandling.Ignore)]
        public int OperationUser
        {
            get;
            set;
        }

        /// <summary>
        /// Tag编号
        /// </summary>
        [HistoryFilterField(Code = "TagNo", CtlType = HistoryFilterCtlType.TextBox, DefaultValue = "0", Description = "Tag编号", ShowSequence = 1)]
        [HistoryGridField(Description = "Tag编号", ShowSequence = 1)]
        [JsonProperty("TagAutoID", NullValueHandling = NullValueHandling.Ignore)]
        public string TagAutoID
        {
            get;
            set;
        }

        [HistoryFilterField(Code = "EquipNo", CtlType = HistoryFilterCtlType.TextBox, DefaultValue = "", Description = "设备编号", ShowSequence = 2)]
        [HistoryGridField(Description = "设备编号", ShowSequence = 2)]
        [JsonProperty("EquipmentDisPlayID", NullValueHandling = NullValueHandling.Ignore)]
        public string EquipmentDisPlayID
        {
            get;
            set;
        }

        [HistoryGridField(Description = "设备名称", ShowSequence = 3)]
        [JsonProperty("EquipmentName", NullValueHandling = NullValueHandling.Ignore)]
        public string EquipmentName
        {
            get;
            set;
        }

        [HistoryGridField(Description = "更改前选项", ShowSequence = 4)]
        [JsonProperty("oValue", NullValueHandling = NullValueHandling.Ignore)]
        public string oValue
        {
            get;
            set;
        }

        [HistoryGridField(Description = "更改后选项", ShowSequence = 5)]
        [JsonProperty("nValue", NullValueHandling = NullValueHandling.Ignore)]
        public string nValue
        {
            get;
            set;
        }

        [HistoryGridField(Description = "更改前描述", ShowSequence = 6)]
        [JsonProperty("oDetailsOfIssue", NullValueHandling = NullValueHandling.Ignore)]
        public string oDetailsOfIssue
        {
            get;
            set;
        }

        [HistoryGridField(Description = "更改后描述", ShowSequence = 7)]
        [JsonProperty("nDetailsOfIssue", NullValueHandling = NullValueHandling.Ignore)]
        public string nDetailsOfIssue
        {
            get;
            set;
        }

        [HistoryGridField(Description = "操作人", ShowSequence = 9)]
        [JsonProperty("OperatorName", NullValueHandling = NullValueHandling.Ignore)]
        public string OperatorName
        {
            get
            {
                var us = Utility.SystemRuntimeInfo.CurrentUsersCaches.FirstOrDefault(x => x.Id == OperationUser);
                return (us?.UserCode) ?? "N/A";
            }
        }

        [HistoryGridField(Description = "操作时间", ShowSequence = 10)]
        [JsonProperty("OperationOn", NullValueHandling = NullValueHandling.Ignore)]
        public string OperationOn
        {
            get;
            set;
        }


        [HistoryGridField(Description = "操作客户端", ShowSequence = 11)]
        [JsonProperty("OperationClient", NullValueHandling = NullValueHandling.Ignore)]
        public string OperationClient
        {
            get;
            set;
        }
    }
}
