Пример #1
0
        /// <summary>
        /// Function to add terms Navigation
        /// </summary>
        /// <param name="term"></param>        
        /// <param name="navigation">Objeto Navegación</param>
        /// <returns></returns>
        public bool AddTermsNavigation(string term, TaxonomyNavigationValue navigation)
        {
            try
            {
                var session = new TaxonomySession(SpSite);
                var termStore = session.TermStores[NameTermStore];
                var group = termStore.Groups[NameGroup];
                TermSet termSet;
                try
                {
                    termSet = group.TermSets[term];
                }
                catch (Exception)
                {

                    termSet = group.CreateTermSet(term);

                }
                var navTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, SpSite.RootWeb, StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);
                navTermSet.IsNavigationTermSet = true;
                if (navigation != null)
                {
                    var termNav = navTermSet.CreateTerm(navigation.Name, navigation.TypeLink);
                    termNav.SimpleLinkUrl = navigation.Link;
                }
                termStore.CommitAll();
                return true;
            }
            catch (Exception exception)
            {
                Logger.Error(string.Concat("Error GetAllTerms", exception.Message));
                return false;
            }
        }
Пример #2
0
        /// <summary>
        /// Add the terms of navigation
        /// </summary>
        /// <param name="site"> Sitio</param>
        /// <param name="termStore"> Nombre del servicio de metadatos </param>
        /// <param name="group">Group </param>
        /// <param name="term"> Termino </param>
        /// <param name="navigationList">Lista con los elementos de Navegacion</param>
        /// <returns></returns>
        public static bool AddTermNavigation(this SPSite site, string termStore, string @group, string term, TaxonomyNavigationValue navigationList)
        {
            try
            {
                var taxonomy = new Entities.Artefacts.Taxonomy(site,Logger, termStore, group);
                return taxonomy.AddTermsNavigation(term, navigationList);

            }
            catch (Exception exception)
            {
                Logger.Error(string.Concat("Error AddTermNavigation", exception.Message));
                return false;
            }

        }