123456789101112131415161718192021222324252627282930313233 |
- using Hotline.Caching.Interfaces;
- using Hotline.CallCenter.Tels;
- using Hotline.DI;
- using Hotline.Share.Enums.CallCenter;
- using Hotline.Share.Notifications.NewRockCallCenter;
- using MediatR;
- using XF.Domain.Cache;
- namespace Hotline.Application.Handlers.CallCenter.ExtState
- {
- [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
- public class OfflineNotificationHandler: INotificationHandler<OfflineNotification>
- {
- private readonly ITelRepository _telRepository;
- private readonly ITelCacheManager _telCacheManager;
- private readonly ITypedCache<Tel> _typedCache;
- public OfflineNotificationHandler(ITelRepository telRepository, ITelCacheManager telCacheManager, ITypedCache<Tel> typedCache)
- {
- _telRepository = telRepository;
- _telCacheManager = telCacheManager;
- _typedCache = typedCache;
- }
- public async Task Handle(OfflineNotification notification, CancellationToken cancellationToken)
- {
- var telModel = _telCacheManager.GetTel(notification.TelNo);
- telModel.TelStatus = ETelStatus.Offline;
- await _telRepository.UpdateAsync(telModel, cancellationToken);
- _typedCache.Set(notification.TelNo, telModel);
- }
- }
- }
|