/// <summary> /// Extract term store groups /// </summary> /// <param name="configVal">Configuration values from excel</param> /// <returns>Term sets</returns> internal static TermSets FetchGroupTerms(Dictionary <string, string> configVal) { TermStoreDetails termStoreDetails = new TermStoreDetails(); termStoreDetails.TermSetName = ConfigurationManager.AppSettings["PracticeGroupTermSetName"]; termStoreDetails.CustomPropertyName = ConfigurationManager.AppSettings["CustomPropertyName"]; termStoreDetails.TermGroup = ConfigurationManager.AppSettings["PracticeGroupName"]; TermSets practiceGroupTermSets = null; using (ClientContext clientContext = MatterProvisionHelperUtility.GetClientContext(configVal["TenantAdminURL"], configVal)) { TaxonomySession taxanomySession = TaxonomySession.GetTaxonomySession(clientContext); clientContext.Load(taxanomySession, items => items.TermStores.Include( item => item.Groups, item => item.Groups.Include( group => group.Name))); clientContext.ExecuteQuery(); TermGroup termGroup = taxanomySession.TermStores[0].Groups.GetByName(termStoreDetails.TermGroup); clientContext.Load(termGroup, group => group.Name, group => group.TermSets.Include( termSet => termSet.Name, termSet => termSet.Terms.Include( term => term.Name, term => term.Id, term => term.CustomProperties, term => term.Terms.Include( termArea => termArea.Name, termArea => termArea.Id, termArea => termArea.CustomProperties, termArea => termArea.Terms.Include( termSubArea => termSubArea.Name, termSubArea => termSubArea.Id, termSubArea => termSubArea.CustomProperties))))); clientContext.ExecuteQuery(); foreach (TermSet termSet in termGroup.TermSets) { if (termSet.Name.Equals(termStoreDetails.TermSetName, StringComparison.OrdinalIgnoreCase)) { if (termStoreDetails.TermSetName.Equals(termStoreDetails.TermSetName, StringComparison.OrdinalIgnoreCase)) { practiceGroupTermSets = TermStoreOperations.GetPracticeGroupTermSetHierarchy(termSet, termStoreDetails.CustomPropertyName); } } } return(practiceGroupTermSets); } }
/// <summary> /// Extract term store groups /// </summary> /// <param name="configVal">Configuration values from excel</param> /// <returns>Term sets</returns> internal static TermSets FetchGroupTerms(Dictionary<string, string> configVal) { TermStoreDetails termStoreDetails = new TermStoreDetails(); termStoreDetails.TermSetName = ConfigurationManager.AppSettings["PracticeGroupTermSetName"]; termStoreDetails.CustomPropertyName = ConfigurationManager.AppSettings["CustomPropertyName"]; termStoreDetails.TermGroup = ConfigurationManager.AppSettings["PracticeGroupName"]; TermSets practiceGroupTermSets = null; using (ClientContext clientContext = MatterProvisionHelperUtility.GetClientContext(configVal["TenantAdminURL"], configVal)) { TaxonomySession taxanomySession = TaxonomySession.GetTaxonomySession(clientContext); clientContext.Load(taxanomySession, items => items.TermStores.Include( item => item.Groups, item => item.Groups.Include( group => group.Name))); clientContext.ExecuteQuery(); TermGroup termGroup = taxanomySession.TermStores[0].Groups.GetByName(termStoreDetails.TermGroup); clientContext.Load(termGroup, group => group.Name, group => group.TermSets.Include( termSet => termSet.Name, termSet => termSet.Terms.Include( term => term.Name, term => term.Id, term => term.CustomProperties, term => term.Terms.Include( termArea => termArea.Name, termArea => termArea.Id, termArea => termArea.CustomProperties, termArea => termArea.Terms.Include( termSubArea => termSubArea.Name, termSubArea => termSubArea.Id, termSubArea => termSubArea.CustomProperties))))); clientContext.ExecuteQuery(); foreach (TermSet termSet in termGroup.TermSets) { if (termSet.Name.Equals(termStoreDetails.TermSetName, StringComparison.OrdinalIgnoreCase)) { if (termStoreDetails.TermSetName.Equals(termStoreDetails.TermSetName, StringComparison.OrdinalIgnoreCase)) { practiceGroupTermSets = TermStoreOperations.GetPracticeGroupTermSetHierarchy(termSet, termStoreDetails.CustomPropertyName); } } } return practiceGroupTermSets; } }