//using Hotline.Caching.Interfaces;
//using Hotline.Realtimes;
//using Hotline.Settings;
//using Microsoft.Extensions.DependencyInjection;
//using Microsoft.Extensions.Hosting;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using Tr.Sdk;
//using XF.Domain.Dependency;

//namespace Hotline.Application.CallCenter.Calls
//{
//    public class CurrentWaitNumService : BackgroundService, IIgnoreDependency
//    {
//        private readonly IServiceScopeFactory _serviceScopeFactory;

//        public CurrentWaitNumService(IServiceScopeFactory serviceScopeFactory)
//        {
//            _serviceScopeFactory = serviceScopeFactory;
//        }

//        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
//        {
//            //using var scope = _serviceScopeFactory.CreateScope();
//            //var realtimeService = scope.ServiceProvider.GetRequiredService<IRealtimeService>();
//            //var _systemSettingCacheManager = scope.ServiceProvider.GetRequiredService<ISystemSettingCacheManager>();
//            //var _trClient = scope.ServiceProvider.GetRequiredService<ITrClient>();
//            //int times = 3000;//5秒
//            //var callinQueueIds = _systemSettingCacheManager.GetSetting(SettingConstants.CallInQueueId)?.SettingValue.ToList();
//            //while (!stoppingToken.IsCancellationRequested)
//            //{
//            //    try
//            //    {
//            //        int count = 0;
//            //        foreach (var id in callinQueueIds)
//            //        {
//            //            var rsp = await _trClient.QueryQueueWaitNumAsync(new Tr.Sdk.Tels.QueryQueueWaitNumRequest() { QueueId = id }, stoppingToken);
//            //            count += Convert.ToInt32(rsp.Count);
//            //        }

//            //        await realtimeService.CurrentWaitNumAsync(count, stoppingToken);
//            //    }
//            //    catch { }
//            //    await Task.Delay(times);
//            //}


//        }
//    }
//}
