BusyNotificationHandler.cs 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. using Hotline.Caches;
  2. using Hotline.CallCenter.Tels;
  3. using Hotline.Share.Enums.CallCenter;
  4. using Hotline.Share.Notifications;
  5. using MediatR;
  6. using XF.Domain.Cache;
  7. namespace Hotline.Application.Handlers.CallCenter.ExtState
  8. {
  9. public class BusyNotificationHandler:INotificationHandler<BusyNotification>
  10. {
  11. private readonly ITelRepository _telRepository;
  12. private readonly ITelCacheManager _telCacheManager;
  13. private readonly ITypedCache<Tel> _typedCache;
  14. public BusyNotificationHandler(ITelRepository telRepository, ITelCacheManager telCacheManager, ITypedCache<Tel> typedCache)
  15. {
  16. _telRepository = telRepository;
  17. _telCacheManager = telCacheManager;
  18. _typedCache = typedCache;
  19. }
  20. public async Task Handle(BusyNotification notification, CancellationToken cancellationToken)
  21. {
  22. var telModel = _telCacheManager.GetTel(notification.TelNo);
  23. telModel.TelStatus = ETelStatus.Active;
  24. //await _telRepository.UpdateAsync(telModel, cancellationToken);
  25. _typedCache.Update(telModel.No,x=>telModel);
  26. }
  27. }
  28. }