Пример #1
0
        /// <summary>
        /// Maps the assigning authority.
        /// </summary>
        /// <param name="otherId">The other identifier.</param>
        /// <returns>AssigningAuthority.</returns>
        /// <exception cref="System.InvalidOperationException">If the assigning authority is not found.</exception>
        private static AssigningAuthority MapAssigningAuthority(otherID otherId)
        {
            var metadataService = ApplicationContext.Current.GetService <IMetadataRepositoryService>();

            String assigningAuthorityName = otherId.assigningAuthorityName;

            // sometimes codes are used underneath the authority name we have to differentiate between these as they are different identifiers
            if (!String.IsNullOrEmpty(otherId.code))
            {
                Uri r = null;
                if (Uri.TryCreate(assigningAuthorityName, UriKind.Absolute, out r))
                {
                    assigningAuthorityName += "/" + otherId.code;
                }
                else
                {
                    assigningAuthorityName += "." + otherId.code;
                }
            }

            // lookup by NSID
            var assigningAuthority = metadataService.FindAssigningAuthority(a => a.DomainName == assigningAuthorityName).FirstOrDefault();

            if (assigningAuthority != null)
            {
                return(assigningAuthority);
            }

            ShowWarningMessage($"Warning, unable to locate assigning authority by NSID using value: {assigningAuthorityName}, will attempt to lookup by URL");

            // lookup by URL
            assigningAuthority = metadataService.FindAssigningAuthority(a => a.Url == assigningAuthorityName).FirstOrDefault();

            if (assigningAuthority != null)
            {
                return(assigningAuthority);
            }

            ShowWarningMessage($"Warning, unable to locate assigning authority by URL using value: {otherId.assigningAuthorityName}, will attempt to lookup by OID");

            // lookup by OID
            assigningAuthority = metadataService.FindAssigningAuthority(a => a.Oid == assigningAuthorityName).FirstOrDefault();

            if (assigningAuthority == null)
            {
                ShowErrorOnNotFound($"Error, {emergencyMessage} Unable to locate assigning authority using NSID, URL, or OID. Has {otherId.assigningAuthorityName} been added to the OpenIZ assigning authority list?");
            }

            return(assigningAuthority);
        }
Пример #2
0
 /// <summary>
 /// Maps the entity identifier.
 /// </summary>
 /// <param name="otherId">The other identifier.</param>
 /// <returns>Returns an entity identifier.</returns>
 private static EntityIdentifier MapEntityIdentifier(otherID otherId)
 {
     return(new EntityIdentifier(MapAssigningAuthority(otherId), otherId.Value));
 }