コード例 #1
0
        public async Task <bool> ReceiveEmailQueueConsumer(ReceiveEmailQueue message)
        {
            _logger.LogDebug($"Consumer Get Queue {JsonConvert.SerializeObject(message)} ready");

            var playerId = message.PlayerId;

            string key = string.Format(RedisKey.UnreadEmailCount, playerId);
            long   ttl = await _redisDb.KeyTimeToLive(key);

            if (ttl > 0)
            {
                var unreadEmailCount = await _redisDb.StringGet <int>(key);

                await _mudProvider.UpdateUnreadEmailCount(playerId, unreadEmailCount);

                return(false);
            }



            var emails = await _emailDomainService.GetMyEmails(playerId);

            var myReceivedEmails = await _playerEmailDomainService.GetMyReceivedEmails(playerId);

            var notReceivedEmails = emails.Where(x => !myReceivedEmails.Select(x => x.EmailId).Contains(x.Id)).ToList();

            foreach (var email in notReceivedEmails)
            {
                var playerEmail = new PlayerEmailEntity
                {
                    CreateDate = DateTime.Now,
                    ExpiryDate = email.ExpiryDate,
                    EmailId    = email.Id,
                    Status     = EmailStatusEnum.未读,
                    PlayerId   = playerId
                };

                await _playerEmailDomainService.Add(playerEmail);
            }

            if (await Commit())
            {
                await _bus.RaiseEvent(new ReceivedEmailEvent(playerId)).ConfigureAwait(false);
            }

            return(true);
        }
コード例 #2
0
 public async Task Update(PlayerEmailEntity item)
 {
     await _playerEmailRepository.Update(item);
 }
コード例 #3
0
 public async Task Add(PlayerEmailEntity item)
 {
     await _playerEmailRepository.Add(item);
 }