using Hotline.Share.Enums.CallCenter;
using SqlSugar;
using System.Drawing;
using XF.Domain.Repository;

namespace Hotline.CallCenter.Tels
{
    public class TelCallModel: CreationEntity
    {
        /// <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; private set; }

        /// <summary>
        /// 外呼状态时长（单位：秒）
        /// </summary>
        [SugarColumn(ColumnDescription = "外呼状态时长（单位：秒）")]
        public double RestDuration { get; private set; }

        public TelCallModel(string telId, string telNo, string userId, string userName)
        {
            TelId = telId; TelNo = telNo; UserId = userId; UserName = userName; StartTime = DateTime.Now;
        }

        public TelCallModel()
        {
                
        }

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