public Task <bool> Handle(UpdateUserEventCommand request, CancellationToken cancellationToken) { // var user = await _userRepository.GetUserByOtherIdAsync(request.OtherId); // if (user == null) // { // await _bus.RaiseEvent( // new DomainNotification(request.Id.ToString(), "未找到对应的数据", StatusCodes.Status404NotFound), // cancellationToken); // return false; // } // // user.ContactNumber = request.ContactNumber; // user.UserName = request.UserName; // // await _userRepository.UpdateAsync(user); // // if (await Commit()) // { // // await _bus.RaiseEvent(new SetCacheEvent(user, _cacheKeyManager.BuildCacheEntityKey(user.Id), // // _cacheKeyManager.CacheTime), cancellationToken); // // await _bus.RaiseEvent(new RemoveCacheListEvent(_cacheKeyManager.CacheKeyListPrefix), cancellationToken); // } // // return true; return(Task.FromResult(true)); }
public Task Handle(UpdateUserEvent @event) { _logger.LogInformation("Handling 'UpdateUserEvent' event", @event.Id, AppDomain.CurrentDomain.FriendlyName, @event); TimeSpan timeSpan = TimeSpan.FromMinutes(_cacheKeyManager.CacheTime); _locker.PerformActionWithLock(_cacheKeyManager.BuilerRedisEventLockKey(@event), timeSpan, () => { var command = new UpdateUserEventCommand( @event.OtherId, @event.UserName, @event.ContactNumber ); _bus.SendCommand(command).Wait(); if (_notifications.HasNotifications()) { var(errorCode, errorMessage) = _notifications.GetNotificationMessage(); _logger.LogError( $"Handling 'UpdateUserEvent' event Error Code:{errorCode},Message:{errorMessage}", @event); } }); return(Task.CompletedTask); }