using Hotline.CallCenter.Devices;
using Hotline.Share.Requests;
using XF.Domain.Dependency;

namespace Hotline.CallCenter.Manage
{
    public class VoiceFileDomainService:IVoiceFileDomainService, IScopeDependency
    {
        private readonly IDeviceManager _deviceManager;

        public VoiceFileDomainService(IDeviceManager deviceManager)
        {
            _deviceManager = deviceManager;
        }

        /// <summary>
        /// 查询语音文件
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<List<string>> VoiceQueryListAsync(CancellationToken cancellationToken)
        {
            var result = await _deviceManager.VoiceQueryListAsync(cancellationToken);
            var list =  result.Replace(".dat","").Replace(".pcm","").Split("|").ToList();

            return list.Distinct().ToList();
        }

        /// <summary>
        /// 删除语音文件（多个文件使用“|”分隔）
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task RemoveVoiceFileAsync(RemoveVoiceFileRequest request, CancellationToken cancellationToken)
        {
            await _deviceManager.RemoveVoiceFileAsync(request.VoiceFileNames, cancellationToken);
        }


    }
}
