12345678910111213141516171819202122232425262728293031323334 |
- using Hotline.Caches;
- using Hotline.CallCenter.Tels;
- using Hotline.Share.Enums.CallCenter;
- using Hotline.Share.Notifications;
- using MediatR;
- using XF.Domain.Cache;
- namespace Hotline.Application.Handlers.CallCenter.ExtState
- {
- public class OnlineNotificationHandler : INotificationHandler<OnlineNotification>
- {
- private readonly ITelRepository _telRepository;
- private readonly ITelCacheManager _telCacheManager;
- private readonly ITypedCache<Tel> _typedCache;
- public OnlineNotificationHandler(ITelRepository telRepository, ITelCacheManager telCacheManager, ITypedCache<Tel> typedCache)
- {
- _telRepository = telRepository;
- _telCacheManager = telCacheManager;
- _typedCache = typedCache;
- }
- /// <summary>Handles a notification</summary>
- /// <param name="notification">The notification</param>
- /// <param name="cancellationToken">Cancellation token</param>
- public async Task Handle(OnlineNotification notification, CancellationToken cancellationToken)
- {
- var telModel = _telCacheManager.GetTel(notification.TelNo);
- telModel.TelStatus = ETelStatus.Ready;
- telModel.RegisterIP = notification.RegisterIP;
- await _telRepository.UpdateAsync(telModel,cancellationToken);
- _typedCache.Update(notification.TelNo, x => telModel);
- }
- }
- }
|