using Hotline.Share.Enums.CallCenter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XF.Domain.Repository;

namespace Hotline.CallCenter.Calls
{
    public class TelActionRecord : CreationEntity
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserId { get; set; }

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

        /// <summary>
        /// 分机号
        /// </summary>
        public string TelNo { get; set; }

        /// <summary>
        /// 分机组
        /// </summary>
        public string QueueId { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? EndTime { get; set; }

        /// <summary>
        /// 动作类型
        /// </summary>
        public EActionType ActionType { get; set; }

        /// <summary>
        /// 用时
        /// </summary>

        public double Duration { get; private set; }

        public TelActionRecord()
        {

        }

        public TelActionRecord(string userId, string userName, string telNo, string queueId, EActionType actionType)
        {
            UserId = userId; UserName = userName; TelNo = telNo; QueueId = queueId; ActionType = actionType; StartTime = DateTime.Now;
        }


        public void EndAction()
        {
            EndTime = DateTime.Now;
            Duration = Math.Round(((double)(EndTime.Value - StartTime).TotalSeconds), 2);
        }
    }
}
