Esempio n. 1
0
        private static string GetValueFromTermStore(string siteCollectionUrl, TraceWriter log)
        {
            string value = string.Empty;

            using (ClientContext context = new AuthenticationContext(siteCollectionUrl).GetAuthenticationContext())
            {
                TaxonomySession session = TaxonomySession.GetTaxonomySession(context);
                TermStore       store   = session.GetDefaultSiteCollectionTermStore();
                context.Load(store,
                             s => s.Name,
                             s => s.Groups.Include(
                                 g => g.Name,
                                 g => g.TermSets.Include(
                                     ts => ts.Name,
                                     ts => ts.CustomProperties,
                                     ts => ts.Terms.Include(
                                         t => t.Name,
                                         t => t.CustomProperties
                                         ))));

                context.ExecuteQueryRetry();
                log.Info($"Loaded taxonomy data");

                if (session != null && store != null)
                {
                    value = GetValueFromTermGroup(store, log, context);
                }
            }

            return(value);
        }