using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XF.Domain.Repository;

namespace Hotline.CallCenter.Tels
{
    [Description("话机操作记录")]
    public class TelOperation : CreationEntity
    {
        /// <summary>
        /// 工号
        /// </summary>
        public string? StaffNo { get; set; }

        public string? UserId { get; set; }

        public string? UserName { get; set; }

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

        public string? GroupId { get; set; }

        /// <summary>
        /// 执行状态
        /// 0：签入 1：接听 2：置忙 3：置闲 16：签出 17：呼出 30：挂机
        /// </summary>
        public int? OperateState { get; set; }

        public string? OperateStateText { get; set; }

        public DateTime? OperateTime { get; set; }

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

        /// <summary>
        /// 时长(秒)
        /// </summary>
        [SugarColumn(ColumnDescription = "动作时长(秒)")]
        public double? Duration { get; set; }

        public int? Channel { get; set; }
        public string? CompanyId { get; set; }
        public string? Remark { get; set; }

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

    }
}
