Beispiel #1
0
        public static string GetStudy(string agency, Guid id)
        {
            try
            {
                MultilingualString.CurrentCulture = "en-GB";

                var client = ToolkitHelper.RestClient();

                // Retrieve the requested item from the Repository.
                // Populate the item's children, so we can display information about them.
                IVersionable item = client.client.GetLatestItem(id, agency,
                                                                ChildReferenceProcessing.Populate);
                // Use a graph search to find a list of all items that
                // directly reference this item.
                GraphSearchFacet facet = new GraphSearchFacet();
                facet.TargetItem            = item.CompositeId;
                facet.UseDistinctResultItem = true;
                var references = client.client.GetRepositoryItemDescriptionsByObject(facet);
                var referencingItemDescription = (from a in references
                                                  where a.ItemType == new Guid("0a63fcf6-ffdd-4214-b38c-147d6689d6a1")
                                                  select a).FirstOrDefault();
                for (int i = 1; i < 3; i++)
                {
                    if (referencingItemDescription != null)
                    {
                        referencingItemDescription = GetReference(referencingItemDescription.AgencyId, referencingItemDescription.Identifier);
                    }
                }
                if (referencingItemDescription == null)
                {
                    return(null);
                }
                else
                {
                    return(referencingItemDescription.DisplayLabel);
                }
            }
            catch
            {
                return(null);
            }
        }
Beispiel #2
0
        public static List <RepositoryItemMetadata> GetReferences(string agency, Guid id)
        {
            MultilingualString.CurrentCulture = "en-GB";

            var client = ToolkitHelper.RestClient();

            // Retrieve the requested item from the Repository.
            // Populate the item's children, so we can display information about them.
            IVersionable item = client.client.GetLatestItem(id, agency,
                                                            ChildReferenceProcessing.Populate);
            // Use a graph search to find a list of all items that
            // directly reference this item.
            GraphSearchFacet facet = new GraphSearchFacet();

            facet.TargetItem            = item.CompositeId;
            facet.UseDistinctResultItem = true;

            var referencingItemDescriptions = client.client.GetRepositoryItemDescriptionsByObject(facet).ToList();

            return(referencingItemDescriptions);
        }