|
@@ -11,6 +11,7 @@ using Hotline.Caching.Interfaces;
|
|
using Hotline.CallCenter.Configs;
|
|
using Hotline.CallCenter.Configs;
|
|
using Microsoft.Extensions.Options;
|
|
using Microsoft.Extensions.Options;
|
|
using Hotline.Share.Dtos.CallCenter;
|
|
using Hotline.Share.Dtos.CallCenter;
|
|
|
|
+using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
namespace Hotline.CallCenter.Tels;
|
|
namespace Hotline.CallCenter.Tels;
|
|
|
|
|
|
@@ -23,23 +24,31 @@ public class TelDomainService : ITelDomainService, IScopeDependency
|
|
private readonly IRealtimeService _realtimeService;
|
|
private readonly IRealtimeService _realtimeService;
|
|
private readonly ITelCacheManager _telCacheManager;
|
|
private readonly ITelCacheManager _telCacheManager;
|
|
private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
|
|
private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
|
|
|
|
+ private readonly IOptionsSnapshot<CallCenterConfiguration> _callcenterOptions;
|
|
|
|
+ private readonly string _callcenterType;
|
|
|
|
|
|
public TelDomainService(
|
|
public TelDomainService(
|
|
- INewRockDeviceManager newRockDeviceManager,
|
|
|
|
|
|
+ IServiceProvider serviceProvider,
|
|
ITelRepository telRepository,
|
|
ITelRepository telRepository,
|
|
ITelRestRepository telRestRepository,
|
|
ITelRestRepository telRestRepository,
|
|
ITelHoldRepository telHoldRepository,
|
|
ITelHoldRepository telHoldRepository,
|
|
IRealtimeService realtimeService,
|
|
IRealtimeService realtimeService,
|
|
ITelCacheManager telCacheManager,
|
|
ITelCacheManager telCacheManager,
|
|
- IOptionsSnapshot<AppConfiguration> appOptions)
|
|
|
|
|
|
+ IOptionsSnapshot<AppConfiguration> appOptions,
|
|
|
|
+ IOptionsSnapshot<CallCenterConfiguration> callcenterOptions)
|
|
{
|
|
{
|
|
- _newRockDeviceManager = newRockDeviceManager;
|
|
|
|
_telRepository = telRepository;
|
|
_telRepository = telRepository;
|
|
_telRestRepository = telRestRepository;
|
|
_telRestRepository = telRestRepository;
|
|
_telHoldRepository = telHoldRepository;
|
|
_telHoldRepository = telHoldRepository;
|
|
_realtimeService = realtimeService;
|
|
_realtimeService = realtimeService;
|
|
_telCacheManager = telCacheManager;
|
|
_telCacheManager = telCacheManager;
|
|
_appOptions = appOptions;
|
|
_appOptions = appOptions;
|
|
|
|
+ _callcenterOptions = callcenterOptions;
|
|
|
|
+ _callcenterType = appOptions.Value.GetDefaultAppScopeConfiguration().CallCenterType;
|
|
|
|
+ if (_callcenterType == AppDefaults.CallCenterType.XunShi)
|
|
|
|
+ {
|
|
|
|
+ _newRockDeviceManager = serviceProvider.GetRequiredService<INewRockDeviceManager>();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -49,7 +58,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
|
|
/// <param name="cancellationToken"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public Task<List<Tel>> QueryTelsAsync(CancellationToken cancellationToken)
|
|
public Task<List<Tel>> QueryTelsAsync(CancellationToken cancellationToken)
|
|
- => _newRockDeviceManager.QueryTelsAsync(_options.Value.NewRock, cancellationToken);
|
|
|
|
|
|
+ => _newRockDeviceManager.QueryTelsAsync(_callcenterOptions.Value.NewRock, cancellationToken);
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 查询所有分机组
|
|
/// 查询所有分机组
|
|
@@ -57,7 +66,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
|
|
/// <param name="cancellationToken"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public Task<List<TelGroup>> QueryTelGroupsAsync(CancellationToken cancellationToken)
|
|
public Task<List<TelGroup>> QueryTelGroupsAsync(CancellationToken cancellationToken)
|
|
- => _newRockDeviceManager.QueryTelGroupsAsync(_options.Value.NewRock, cancellationToken);
|
|
|
|
|
|
+ => _newRockDeviceManager.QueryTelGroupsAsync(_callcenterOptions.Value.NewRock, cancellationToken);
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 分机休息审批流程开始
|
|
/// 分机休息审批流程开始
|
|
@@ -129,7 +138,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
|
|
|
|
|
|
//await _newRockDeviceManager.TelRestAsync(telRest.TelNo, cancellationToken);
|
|
//await _newRockDeviceManager.TelRestAsync(telRest.TelNo, cancellationToken);
|
|
|
|
|
|
- if (_options.Value.CallCenterType == AppDefaults.CallCenterType.XunShi)
|
|
|
|
|
|
+ if (_callcenterType == AppDefaults.CallCenterType.XunShi)
|
|
{
|
|
{
|
|
telRest.StartTime = DateTime.Now;
|
|
telRest.StartTime = DateTime.Now;
|
|
telRest.ApplyStatus = ETelRestApplyStatus.Resting;
|
|
telRest.ApplyStatus = ETelRestApplyStatus.Resting;
|
|
@@ -138,7 +147,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
|
|
var tel = _telCacheManager.GetTel(telRest.TelNo);
|
|
var tel = _telCacheManager.GetTel(telRest.TelNo);
|
|
foreach (var group in tel.Groups)
|
|
foreach (var group in tel.Groups)
|
|
{
|
|
{
|
|
- await _newRockDeviceManager.ModifyGroupExtAsync(_options.Value.NewRock, group.No, group.Distribution, group.Voice, tel.No, true, cancellationToken);
|
|
|
|
|
|
+ await _newRockDeviceManager.ModifyGroupExtAsync(_callcenterOptions.Value.NewRock, group.No, group.Distribution, group.Voice, tel.No, true, cancellationToken);
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
}
|
|
}
|
|
@@ -190,7 +199,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
|
|
//更新分机组
|
|
//更新分机组
|
|
foreach (var group in telCache.Groups)
|
|
foreach (var group in telCache.Groups)
|
|
{
|
|
{
|
|
- await _newRockDeviceManager.ModifyGroupExtAsync(_options.Value.NewRock, group.No, group.Distribution, group.Voice, "", true, cancellationToken);
|
|
|
|
|
|
+ await _newRockDeviceManager.ModifyGroupExtAsync(_callcenterOptions.Value.NewRock, group.No, group.Distribution, group.Voice, "", true, cancellationToken);
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
@@ -212,7 +221,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
|
|
var tel = await _telRepository.GetAsync(telId, cancellationToken);
|
|
var tel = await _telRepository.GetAsync(telId, cancellationToken);
|
|
if (tel is null)
|
|
if (tel is null)
|
|
throw new UserFriendlyException("无效分机编号");
|
|
throw new UserFriendlyException("无效分机编号");
|
|
- await _newRockDeviceManager.HoldAsync(_options.Value.NewRock, tel.No, cancellationToken);
|
|
|
|
|
|
+ await _newRockDeviceManager.HoldAsync(_callcenterOptions.Value.NewRock, tel.No, cancellationToken);
|
|
await _telHoldRepository.AddAsync(new Calls.TelHold() { TelId = telId, TelNo = tel.No, UserId = userId, UserName = userName, CallId = callId }, cancellationToken);
|
|
await _telHoldRepository.AddAsync(new Calls.TelHold() { TelId = telId, TelNo = tel.No, UserId = userId, UserName = userName, CallId = callId }, cancellationToken);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -228,7 +237,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
|
|
var tel = await _telRepository.GetAsync(telId, cancellationToken);
|
|
var tel = await _telRepository.GetAsync(telId, cancellationToken);
|
|
if (tel is null)
|
|
if (tel is null)
|
|
throw new UserFriendlyException("无效分机编号");
|
|
throw new UserFriendlyException("无效分机编号");
|
|
- await _newRockDeviceManager.UnHoldAsync(_options.Value.NewRock, tel.No, cancellationToken);
|
|
|
|
|
|
+ await _newRockDeviceManager.UnHoldAsync(_callcenterOptions.Value.NewRock, tel.No, cancellationToken);
|
|
var holdingTel = await _telHoldRepository.GetAsync(d => d.TelId == telId && d.TelNo == tel.No && d.UserId == userId && d.CallId == callId && !d.EndTime.HasValue);
|
|
var holdingTel = await _telHoldRepository.GetAsync(d => d.TelId == telId && d.TelNo == tel.No && d.UserId == userId && d.CallId == callId && !d.EndTime.HasValue);
|
|
if (holdingTel is null)
|
|
if (holdingTel is null)
|
|
throw new UserFriendlyException("未找到分机保持信息");
|
|
throw new UserFriendlyException("未找到分机保持信息");
|
|
@@ -248,7 +257,7 @@ public class TelDomainService : ITelDomainService, IScopeDependency
|
|
var tel = await _telRepository.GetAsync(telId, cancellationToken);
|
|
var tel = await _telRepository.GetAsync(telId, cancellationToken);
|
|
if (tel is null)
|
|
if (tel is null)
|
|
throw new UserFriendlyException("无效分机编号");
|
|
throw new UserFriendlyException("无效分机编号");
|
|
- await _newRockDeviceManager.MuteAsync(_options.Value.NewRock, tel.No, cancellationToken);
|
|
|
|
|
|
+ await _newRockDeviceManager.MuteAsync(_callcenterOptions.Value.NewRock, tel.No, cancellationToken);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -262,6 +271,6 @@ public class TelDomainService : ITelDomainService, IScopeDependency
|
|
var tel = await _telRepository.GetAsync(telId, cancellationToken);
|
|
var tel = await _telRepository.GetAsync(telId, cancellationToken);
|
|
if (tel is null)
|
|
if (tel is null)
|
|
throw new UserFriendlyException("无效分机编号");
|
|
throw new UserFriendlyException("无效分机编号");
|
|
- await _newRockDeviceManager.MuteAsync(_options.Value.NewRock, tel.No, cancellationToken);
|
|
|
|
|
|
+ await _newRockDeviceManager.MuteAsync(_callcenterOptions.Value.NewRock, tel.No, cancellationToken);
|
|
}
|
|
}
|
|
}
|
|
}
|