Exemplo n.º 1
0
        private static void ProcessTermSet(XmlNode termGroup)
        {
            foreach (XmlNode termSets in termGroup.ChildNodes)
            {
                //ProcessTermSet
                string strTermSetName   = termSets.Attributes["Name"].Value;
                string strTermSetNameFr = termSets.Attributes["NameFr"].Value;

                //Get TermSetCollection
                TermSetCollection termSetColl = group.TermSets;

                //Find termSet that we want to Import to
                TermSet thisTermSet = termSetColl.Where(g => g.Name == strTermSetName).SingleOrDefault();

                if (thisTermSet != null)
                {
                    //Get Current TermSet
                    termSet = thisTermSet;
                    //Delete the current TermSet and all the associate terms
                    termSet.Delete();
                    termStore.CommitAll();
                }

                //Create the TermSet
                termSet = group.CreateTermSet(strTermSetName, 1033);
                termStore.CommitAll();

                Console.WriteLine(strTermSetName);

                //ProcessTerms
                ProcessTerms(termSets.FirstChild, termSet, null);
            }
        }
        // Create the goal objects in the specified term store
        static void ImportTermSet(TermStore termStore, TermSetGoal termSetGoal)
        {
            Log("Setting up term set \"" + termSetGoal.Name + "\"");
            Group group = termStore.Groups.FirstOrDefault(g => g.Name == termSetGoal.GroupName);

            if (group == null)
            {
                Log("Creating missing group \"" + termSetGoal.GroupName + "\"");
                group = termStore.CreateGroup(termSetGoal.GroupName);
            }

            TermSet termSet = termStore.GetTermSet(termSetGoal.Id);

            if (termSet != null)
            {
                Log("Deleting existing term set \"" + termSetGoal.Name + "\"");
                termSet.Delete();
                termStore.CommitAll();
            }

            Log("Creating new term set \"" + termSetGoal.Name + "\"");
            termSet = group.CreateTermSet(termSetGoal.Name, termSetGoal.Id);
            termStore.CommitAll();

            ImportTerms(termSet, termSetGoal);

            termStore.CommitAll();
        }
Exemplo n.º 3
0
        public static NavigationTermSet CriarItemNaTermStore(string url, string urlweb, Guid NavTermSetId, Guid TaggingTermSetId)
        {
            SPSite site = new SPSite(url);

            SPWeb web = site.AllWebs[urlweb];

            TaxonomySession taxonomySession = new TaxonomySession(site);

            if (taxonomySession.TermStores.Count == 0)
            {
                throw new InvalidOperationException("O Serviço de taxonomia não existe");
            }

            TermStore termStore = taxonomySession.TermStores[0];

            TermSet existingTermSet = termStore.GetTermSet(NavTermSetId);

            if (existingTermSet != null)
            {
                existingTermSet.Delete();
                termStore.CommitAll();
            }


            Group   siteCollectionGroup = termStore.GetSiteCollectionGroup(web.Site);
            TermSet termSet             = siteCollectionGroup.CreateTermSet("Teste01", NavTermSetId);

            termStore.CommitAll();

            NavigationTermSet navTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, web,
                                                                                StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);

            termStore.CommitAll();

            navTermSet.IsNavigationTermSet = true;

            navTermSet.TargetUrlForChildTerms.Value = "/en/Pages/default.aspx";

            NavigationTerm term1 = navTermSet.CreateTerm("Term 1", NavigationLinkType.SimpleLink);

            term1.SimpleLinkUrl = "http://h9j/pt/Paginas/default.aspx";
            termStore.CommitAll();

            /*
             * NavigationTerm term2 = navTermSet.CreateTerm("Term 2", NavigationLinkType.FriendlyUrl, Guid.NewGuid());
             *
             * term2.FriendlyUrlSegment.Value = "PAgInicial";
             *
             * term2.TargetUrl.Value = "/en/Pages/default.aspx";
             */


            termStore.CommitAll();

            return(navTermSet);
        }
Exemplo n.º 4
0
        public static NavigationTermSet RecreateSampleNavTermSet(TestContext testContext,
                                                                 TaxonomySession taxonomySession, SPWeb web)
        {
            Console.WriteLine(testContext, "RecreateSampleNavTermSet(): START");

            // Use the first TermStore object in the list.
            if (taxonomySession.TermStores.Count == 0)
            {
                throw new InvalidOperationException("The Taxonomy Service is offline or missing.");
            }

            TermStore termStore = taxonomySession.TermStores[0];

            // Does the TermSet object already exist?
            TermSet existingTermSet = termStore.GetTermSet(TestConfig.NavTermSetId);

            if (existingTermSet != null)
            {
                Console.WriteLine(testContext, "RecreateSampleNavTermSet(): Deleting old TermSet");
                existingTermSet.Delete();
                termStore.CommitAll();
            }

            Console.WriteLine(testContext, "RecreateSampleNavTermSet(): Creating new TermSet");

            // Create a new TermSet object.
            Group   siteCollectionGroup = termStore.GetSiteCollectionGroup(web.Site);
            TermSet termSet             = siteCollectionGroup.CreateTermSet("Navigation Demo", TestConfig.NavTermSetId);

            NavigationTermSet navTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, web,
                                                                                StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);

            navTermSet.IsNavigationTermSet          = true;
            navTermSet.TargetUrlForChildTerms.Value = "~site/Pages/Topics/Topic.aspx";

            NavigationTerm term1 = navTermSet.CreateTerm("Term 1", NavigationLinkType.SimpleLink);

            term1.SimpleLinkUrl = "http://www.bing.com/";

            NavigationTerm term2  = navTermSet.CreateTerm("Term 2", NavigationLinkType.FriendlyUrl);
            NavigationTerm term2a = term2.CreateTerm("Term 2 A", NavigationLinkType.FriendlyUrl);
            NavigationTerm term2b = term2.CreateTerm("Term 2 B", NavigationLinkType.FriendlyUrl);

            NavigationTerm term3 = navTermSet.CreateTerm("Term 3", NavigationLinkType.FriendlyUrl);

            termStore.CommitAll();

            Console.WriteLine(testContext, "RecreateSampleNavTermSet(): FINISH");

            return(navTermSet);
        }
Exemplo n.º 5
0
        public static NavigationTermSet CriarItemNaTermStore(string url, string urlweb, Guid NavTermSetId, Guid TaggingTermSetId)
        {
            SPSite site = new SPSite(url);

            SPWeb web = site.AllWebs[url];

            TaxonomySession taxonomySession = new TaxonomySession(site);

            if (taxonomySession.TermStores.Count == 0)
            {
                throw new InvalidOperationException("O Serviço de taxonomia não existe");
            }

            TermStore termStore = taxonomySession.TermStores[0];

            TermSet existingTermSet = termStore.GetTermSet(NavTermSetId);

            if (existingTermSet != null)
            {
                existingTermSet.Delete();
                termStore.CommitAll();
            }


            Group             siteCollectionGroup = termStore.GetSiteCollectionGroup(web.Site);
            TermSet           termSet             = siteCollectionGroup.CreateTermSet("Teste01", NavTermSetId);
            NavigationTermSet navTermSet          = NavigationTermSet.GetAsResolvedByWeb(termSet, web,
                                                                                         StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);

            navTermSet.IsNavigationTermSet = true;

            navTermSet.TargetUrlForChildTerms.Value = "~site/Pages/Topics/Topic.aspx";

            NavigationTerm term1 = navTermSet.CreateTerm("Term 1", NavigationLinkType.SimpleLink);

            term1.SimpleLinkUrl = "https://ekisiot.sharepoint.com/";

            NavigationTerm term2 = navTermSet.CreateTerm("Term 2", NavigationLinkType.FriendlyUrl);

            NavigationTerm term2a = term2.CreateTerm("Term 2 A", NavigationLinkType.FriendlyUrl);

            NavigationTerm term2b = term2.CreateTerm("Term 2 B", NavigationLinkType.FriendlyUrl);

            NavigationTerm term3 = navTermSet.CreateTerm("Term 3", NavigationLinkType.FriendlyUrl);

            termStore.CommitAll();

            return(navTermSet);
        }
Exemplo n.º 6
0
 public void Delete()
 {
     m_termSet.Delete();
 }
Exemplo n.º 7
0
        private static void ProcessTermSet(XmlNode termGroup)
        {
            foreach (XmlNode termSets in termGroup.ChildNodes)
            {
                //ProcessTermSet
                string strTermSetName = termSets.Attributes["Name"].Value;
                string strTermSetNameFr = termSets.Attributes["NameFr"].Value;

                //Get TermSetCollection
                TermSetCollection termSetColl = group.TermSets;

                //Find termSet that we want to Import to
                TermSet thisTermSet = termSetColl.Where(g => g.Name == strTermSetName).SingleOrDefault();

                if (thisTermSet != null)
                {
                    //Get Current TermSet
                    termSet = thisTermSet;
                    //Delete the current TermSet and all the associate terms
                    termSet.Delete();
                    termStore.CommitAll();
                }

                //Create the TermSet
                termSet = group.CreateTermSet(strTermSetName, 1033);
                termStore.CommitAll();

                Console.WriteLine(strTermSetName);

                //ProcessTerms
                ProcessTerms(termSets.FirstChild, termSet, null);
            }
        }