using SqlSugar;
using System.ComponentModel;
using XF.Domain.Repository;

namespace Hotline.CallCenter.Calls
{
    [Description("分机通话保持记录")]
    public class TelHold: CreationModificationEntity
    {
        /// <summary>
        /// 分机Id
        /// </summary>
        public string TelId { get; set; }

        /// <summary>
        /// 分机号（冗余）
        /// </summary>
        public string TelNo { get; set; }

        /// <summary>
        /// 用户Id
        /// </summary>
        public string UserId { get; set; }

        /// <summary>
        /// 用户名称（冗余）
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// 开始休息时间
        /// </summary>
        [SugarColumn(ColumnDescription ="开始保持时间")]
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 结束保持时间
        /// </summary>
        [SugarColumn(ColumnDescription ="结束保持时间")]
        public DateTime? EndTime { get; set; }

        /// <summary>
        /// 保持时长（单位：秒）
        /// </summary>
        [SugarColumn(ColumnDescription ="保持时长（单位：秒）")]
        public double HoldDuration { get; private set; }

        /// <summary>
        /// 通话Id
        /// </summary>
        public string CallId { get; set; }

        public TelHold()
        {

        }

        public TelHold(string telId,string telNo,string userId,string userName,string callId)
        {
            TelId = telId; 
            TelNo = telNo;
            UserId = userId;
            UserName = userName;
            CallId = callId;
        }

        public void EndHold()
        {
            EndTime = DateTime.Now;
            HoldDuration = (EndTime.Value - StartTime).TotalSeconds;
        }

    }
}
