예제 #1
0
        public List <string> GetRecipientAddresses(Agreement agreement, string senderJwt)
        {
            List <string> recipientAddresses = new List <string>();

            try
            {
                string internalId = agreement.GetRecipientId();
                var    sender     = _participants.FirstOrDefault(p => p.ProvideJWT == senderJwt);
                if (sender != null)
                {
                    var partner = sender.Partners.FirstOrDefault(p => p.IdMapping.ContainsKey(internalId));
                    if (partner != null)
                    {
                        var recipient = _participants.FirstOrDefault(p => p.ParticipantId == partner.PartnerParticipantId);
                        if (recipient != null)
                        {
                            recipientAddresses.Add(recipient.Address);
                        }
                        else
                        {
                            _logger.LogError("recipient not found for participant {0}", partner.PartnerParticipantId);
                        }
                    }
                    else
                    {
                        _logger.LogError("partner not found for id {0}", internalId);
                    }
                }
                else
                {
                    _logger.LogError("sender not found for JWT {0}", senderJwt);
                }
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex, "Unexpected error in GetRecipientAddress");
            }


            return(recipientAddresses);
        }