
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Models.Models.LOGDB
{

    /// <summary>
    /// RUCS UDP 通讯日志
    /// </summary>
    [Table("TBL_RUCS_UDP_LOG"), Comment("RUCS UDP 通讯日志")]
    //  方向 索引
    [Index(nameof(DIRECTION), Name = "Index_DIRECTION")]

    [Index(nameof(ID), IsUnique = true)]

    [Index(nameof(DATETIME), Name = "Index_DATETIME")]
    public class TBL_RUCS_UDP_LOG
    {
        /// <summary>
        /// 自增id
        /// </summary>
        [Key, Column(TypeName = "int"), Comment("id,自增长"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }

        /// <summary>
        /// 生产者根据时间精确到mS生产ID 
        /// </summary>
        [  Column(TypeName = "nvarchar(100)"), Comment("生产者根据时间精确到mS生产ID ")]
        public string UDP_ID { get; set; }


        /// <summary>
        /// 时间（精确到mS）
        /// </summary>

        [Required, Column(TypeName = "datetime"), Comment("时间（精确到mS）")]

        public DateTime DATETIME { get; set; }


        /// <summary>
        /// RCU MAC地址 
        /// </summary>
        [Required, Column(TypeName = "nvarchar(100)"), Comment("RCU MAC地址 ")]
        public string MAC { get; set; }


        /// <summary>
        /// 方向
        /// </summary>
        [ Column(TypeName = "nvarchar(10)"), Comment("方向")]
        public string DIRECTION { get; set; }



        /// <summary>
        /// 源 IP 
        /// </summary>
        [ Column(TypeName = "nvarchar(50)"), Comment("源 IP ")]
        public string SOURCE_IP { get; set; }


        /// <summary>
        /// 源 UDP 端口 
        /// </summary>
        [ Column(TypeName = "nvarchar(10)"), Comment("源 UDP 端口 ")]
        public string SOURCE_PORT { get; set; }


        /// <summary>
        /// 目的地 IP 
        /// </summary>
        [ Column(TypeName = "nvarchar(50)"), Comment("目的地 IP ")]
        public string DESTINATION { get; set; }


        /// <summary>
        /// 目的地 UDP 端口 
        /// </summary>
        [ Column(TypeName = "nvarchar(10)"), Comment("目的地 UDP 端口 ")]
        public string DESTINATION_PORT { get; set; }



        /// <summary>
        /// 距离同一个端口上一包接收间隔
        /// </summary>
        [ Column(TypeName = "int"), Comment("距离同一个端口上一包接收间隔")]
        public int RCV_TIMEOUT { get; set; }

        /// <summary>
        /// 距离同一个端口上一包发送间隔 
        /// </summary>
        [ Column(TypeName = "int"), Comment("距离同一个端口上一包发送间隔 ")]
        public int SED_TIMEOUT { get; set; }


        /// <summary>
        /// 重发次数 
        /// </summary>
        [ Column(TypeName = "int"), Comment("重发次数 ")]
        public int RETRY_COUNT { get; set; }



        /// <summary>
        /// 长度 
        /// </summary>
        [ Column(TypeName = "int"), Comment("长度 ")]
        public int LENGTH { get; set; }


        /// <summary>
        /// 内容
        /// </summary>
        [ Column(TypeName = "nvarchar(1000)"), Comment("加密内容")]
        public string CONTENT_ENCRYPT { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        [ Column(TypeName = "nvarchar(1000)"), Comment("解密内容")]
        public string CONTENT_DECRYPT { get; set; }

        /// <summary>
        /// 处理耗时 
        /// </summary>
        [ Column(TypeName = "int"), Comment("处理耗时 ")]
        public int PROCESSING_TIMESPENT { get; set; }

        /// <summary>
        /// 数据是否有效  
        /// </summary>
        [ Column(TypeName = "int"), Comment("数据是否有效 0 无效")]
        public int DATA_VALID { get; set; }

        /// <summary>
        /// 处理结果 处理结果 0  失败 1 OK
        /// </summary>
        [Column(TypeName = "int"), Comment("处理结果 0  失败")]
        public int RESULT { get; set; }



        /// <summary>
        /// 关联MSG ID  
        /// </summary>
        [ Column(TypeName = "int"), Comment("关联MSG ID  ")]
        public int MSG_ID { get; set; }


        /// <summary>
        /// 关联TCP ID
        /// </summary>
        [ Column(TypeName = "int"), Comment("关联TCP ID ")]         
        public int TCP_ID { get; set; }

        /// <summary>
        /// 备注
        /// </summary>

        [Column(TypeName = "nvarchar(520)"), Comment("备注")]

        public string REMARK { get; set; }

        /// <summary>
        /// 端口两次通讯时差
        /// </summary>

        [Column(TypeName = "int"), Comment("端口两次通讯时差")]
        public int Prot_TimeOut { get; set; }


        [Column(TypeName = "nvarchar(50)"), Comment("通讯命令")]
        public string UDP_CMD { get; set; } = string.Empty;


        /// <summary>
        /// 接收间隔 
        /// </summary>
        [Column(TypeName = "int"), Comment("接收间隔时间（精确到mS）")]

        public int RevDelayDateTime { get; set; }

        /// <summary>
        /// 组包时间 prot_timeout
        /// </summary>
        [Column(TypeName = "datetime"), Comment("组包时间（精确到mS）")]
        public DateTime PackageTime { get; set; }

        /// <summary>
        /// 接收时间 
        /// </summary>
        [Column(TypeName = "datetime"), DefaultValue(null), Comment("接收时间")]
        public DateTime ReceiptTime { get; set; } = DateTime.Now;

    }
}
