using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;

namespace XingTang.Sdk
{
    /// <summary>
    /// 坐席操作记录
    /// </summary>
    [SugarTable("call_cti_seatingoperation")]
    public class XingtangSeatOperation
    {
        [SugarColumn(IsPrimaryKey = true)]
        public int Id { get; set; }

        /// <summary>
        /// 工号
        /// </summary>
        public string? UserCode { get; set; }

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

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

        public string? GetExecutionStateText()
        {
            if(!ExecutionState.HasValue) return string.Empty;
            
            return OperationDictionary.TryGetValue(ExecutionState.Value, out var text)
                ? text
                : "未知";
        }

        /// <summary>
        /// 操作时间
        /// </summary>
        public DateTime? ExecutionTime { get; set; }

        /// <summary>
        /// 通道号
        /// </summary>
        public int? Channel { get; set; }

        /// <summary>
        /// 公司号
        /// </summary>
        public string? CompanyId { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remark { get; set; }

        //弃用
        public DateTime? EndTime { get; set; }

        public string? UserData { get; set; }

        #region 自建

        public bool IsSync { get; set; }

        public int Tries { get; set; }

        [SugarColumn(IsEnableUpdateVersionValidation = true)]
        public string Ver { get; set; }

        #endregion
        
        public static Dictionary<int, string> OperationDictionary = new()
        {
            { 0, "签入" },
            { 1, "接听" },
            { 2, "置忙" },
            { 3, "置闲" },
            { 16, "签出" },
            { 17, "呼出" },
            { 30, "挂机" },
        };
    }
}