当前位置: 首页>>代码示例>>C#>>正文


C# TermStore.GetTermSet方法代码示例

本文整理汇总了C#中TermStore.GetTermSet方法的典型用法代码示例。如果您正苦于以下问题:C# TermStore.GetTermSet方法的具体用法?C# TermStore.GetTermSet怎么用?C# TermStore.GetTermSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TermStore的用法示例。


在下文中一共展示了TermStore.GetTermSet方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddTermSet

        private static TermSet AddTermSet(ClientContext clientContext, TermStore termStore, TermGroup termGroup)
        {
            var termSetId = new Guid("56ca0eea-635e-4cc1-ac35-fc2040f4cfe5");
            var termSet = termStore.GetTermSet(termSetId);
            clientContext.Load(termSet, ts => ts.Terms);
            clientContext.ExecuteQuery();

            if (termSet.ServerObjectIsNull.Value)
            {
                termSet = termGroup.CreateTermSet("Taxonomy Navigation", termSetId, 1033);
                termSet.SetCustomProperty("_Sys_Nav_IsNavigationTermSet", "True");
                clientContext.Load(termSet, ts => ts.Terms);
                clientContext.ExecuteQuery();
            }

            return termSet;
        }
开发者ID:modulexcite,项目名称:TrainingContent,代码行数:17,代码来源:TaxonomyHelper.cs

示例2: LookupTermSet

        public static TermSet LookupTermSet(ClientRuntimeContext context, TermStore termStore,
            Site site,
            string termGroupName, Guid? termGroupId, bool? isSiteCollectionGroup,
            string termSetName, Guid? termSetId, int termSetLCID)
        {
            var storeContext = context;

            TermGroup currenGroup = null;

            if (!string.IsNullOrEmpty(termGroupName))
            {
                currenGroup = termStore.Groups.GetByName(termGroupName);

                storeContext.Load(currenGroup);
                storeContext.ExecuteQueryWithTrace();
            }
            else if (termGroupId != null && termGroupId.HasGuidValue())
            {
                currenGroup = termStore.Groups.GetById(termGroupId.Value);

                storeContext.Load(currenGroup);
                storeContext.ExecuteQueryWithTrace();
            }
            else if (isSiteCollectionGroup == true)
            {
                currenGroup = termStore.GetSiteCollectionGroup(site, false);

                storeContext.Load(currenGroup);
                storeContext.ExecuteQueryWithTrace();
            }

            if (!string.IsNullOrEmpty(termSetName))
            {
                if (currenGroup != null && (currenGroup.ServerObjectIsNull == false))
                {
                    TermSet termSet = null;

                    var scope = new ExceptionHandlingScope(storeContext);
                    using (scope.StartScope())
                    {
                        using (scope.StartTry())
                        {
                            termSet = currenGroup.TermSets.GetByName(termSetName);
                            storeContext.Load(termSet);
                        }

                        using (scope.StartCatch())
                        {

                        }
                    }

                    storeContext.ExecuteQueryWithTrace();

                    if (termSet != null && termSet.ServerObjectIsNull == false)
                    {
                        storeContext.Load(termSet, g => g.Id);
                        storeContext.ExecuteQueryWithTrace();

                        return termSet;
                    }
                }
                else
                {
                    var termSets = termStore.GetTermSetsByName(termSetName, termSetLCID);

                    storeContext.Load(termSets);
                    storeContext.ExecuteQueryWithTrace();

                    return termSets.FirstOrDefault();
                }
            }

            if (termSetId.HasGuidValue())
            {
                if (currenGroup != null && (currenGroup.ServerObjectIsNull == false))
                {
                    TermSet termSet = null;

                    var scope = new ExceptionHandlingScope(storeContext);
                    using (scope.StartScope())
                    {
                        using (scope.StartTry())
                        {
                            termSet = currenGroup.TermSets.GetById(termSetId.Value);
                            storeContext.Load(termSet);
                        }

                        using (scope.StartCatch())
                        {

                        }
                    }

                    storeContext.ExecuteQueryWithTrace();

                    if (termSet != null && termSet.ServerObjectIsNull == false)
                    {
                        storeContext.Load(termSet, g => g.Id);
                        storeContext.ExecuteQueryWithTrace();
//.........这里部分代码省略.........
开发者ID:karayakar,项目名称:spmeta2,代码行数:101,代码来源:TaxonomyFieldModelHandler.cs

示例3: LookupTermSet

        public static TermSet LookupTermSet(
            TermStore tesmStore,
            string termGroupName, Guid? groupId, bool? isSiteCollectionGroup, SPSite site,
            string termSetName, Guid? termSetId, int termSetLCID)
        {
            Group currentGroup = null;

            if (!string.IsNullOrEmpty(termGroupName))
            {
                currentGroup = tesmStore.Groups.FirstOrDefault(g => g.Name.ToUpper() == termGroupName.ToUpper());
            }
            else if (groupId != null && groupId.HasGuidValue())
            {
                currentGroup = tesmStore.GetGroup(groupId.Value);
            }
            else if (isSiteCollectionGroup.HasValue && isSiteCollectionGroup.Value)
            {
                currentGroup = tesmStore.GetSiteCollectionGroup(site);
            }

            if (termSetId.HasGuidValue())
            {
                if (currentGroup != null)
                    return currentGroup.TermSets.FirstOrDefault(t => t.Id == termSetId.Value);

                return tesmStore.GetTermSet(termSetId.Value);
            }

            if (!string.IsNullOrEmpty(termSetName))
            {
                if (currentGroup != null)
                    return currentGroup.TermSets.FirstOrDefault(t => t.Name.ToUpper() == termSetName.ToUpper());

                return tesmStore.GetTermSets(termSetName, termSetLCID).FirstOrDefault();
            }

            return null;
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:38,代码来源:TaxonomyFieldModelHandler.cs

示例4: ExportTermSet

        /// <summary>
        /// Exports the full list of terms from all termsets in all termstores.
        /// </summary>
        /// <param name="site">The site to export the termsets from</param>
        /// <param name="termSetId">The ID of the termset to export</param>
        /// <param name="includeId">if true, Ids of the the taxonomy items will be included</param>
        /// <param name="termStore">The term store to export the termset from</param>
        /// <param name="delimiter">if specified, this delimiter will be used. Notice that IDs will be delimited with ;# from the label</param>
        /// <returns></returns>
        public static List<string> ExportTermSet(this Site site, Guid termSetId, bool includeId, TermStore termStore, string delimiter = "|")
        {
            var clientContext = site.Context;
            var termsString = new List<string>();
            TermCollection terms = null;

            if (termSetId != Guid.Empty)
            {
                var termSet = termStore.GetTermSet(termSetId);
                terms = termSet.Terms;
                clientContext.Load(terms, t => t.IncludeWithDefaultProperties(s => s.TermSet), t => t.IncludeWithDefaultProperties(s => s.TermSet.Group));
            }

            clientContext.ExecuteQueryRetry();

            if (terms.Any())
            {
                foreach (var term in terms)
                {
                    var groupName = DenormalizeName(term.TermSet.Group.Name);
                    var termsetName = DenormalizeName(term.TermSet.Name);
                    var termName = DenormalizeName(term.Name);
                    clientContext.ExecuteQueryRetry();
                    var groupPath = string.Format("{0}{1}", groupName, (includeId) ? string.Format(";#{0}", term.TermSet.Group.Id.ToString()) : "");
                    var termsetPath = string.Format("{0}{1}", termsetName, (includeId) ? string.Format(";#{0}", term.TermSet.Id.ToString()) : "");
                    var termPath = string.Format("{0}{1}", termName, (includeId) ? string.Format(";#{0}", term.Id.ToString()) : "");
                    termsString.Add(string.Format("{0}{3}{1}{3}{2}", groupPath, termsetPath, termPath, delimiter));

                    if (term.TermsCount > 0)
                    {
                        var subTermPath = string.Format("{0}{3}{1}{3}{2}", groupPath, termsetPath, termPath, delimiter);

                        termsString.AddRange(ParseSubTerms(subTermPath, term, includeId, delimiter, clientContext));
                    }

                    termsString.Add(string.Format("{0}{3}{1}{3}{2}", groupPath, termsetPath, termPath, delimiter));
                }
            }

            return termsString.Distinct().ToList<string>();
        }
开发者ID:ipbhattarai,项目名称:PnP,代码行数:50,代码来源:TaxonomyExtensions.cs

示例5: LookupTermSet

        public static TermSet LookupTermSet(ClientRuntimeContext context, TermStore termStore,
            string termSetName, Guid? termSetId, int termSetLCID)
        {
            var storeContext = context;

            if (!string.IsNullOrEmpty(termSetName))
            {
                var termSets = termStore.GetTermSetsByName(termSetName, termSetLCID);

                storeContext.Load(termSets);
                storeContext.ExecuteQueryWithTrace();

                return termSets.FirstOrDefault();
            }

            if (termSetId.HasGuidValue())
            {
                TermSet termSet = null;

                var scope = new ExceptionHandlingScope(storeContext);
                using (scope.StartScope())
                {
                    using (scope.StartTry())
                    {
                        termSet = termStore.GetTermSet(termSetId.Value);
                        storeContext.Load(termSet);
                    }

                    using (scope.StartCatch())
                    {

                    }
                }

                storeContext.ExecuteQueryWithTrace();

                if (termSet != null && termSet.ServerObjectIsNull == false)
                {
                    storeContext.Load(termSet, g => g.Id);
                    storeContext.ExecuteQueryWithTrace();

                    return termSet;
                }
            }

            return null;
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:47,代码来源:TaxonomyFieldModelHandler.cs

示例6: LookupTermSet

        public static TermSet LookupTermSet(TermStore tesmStore, string termSetName, Guid? termSetId, int termSetLCID)
        {
            if (termSetId.HasGuidValue())
                return tesmStore.GetTermSet(termSetId.Value);

            if (!string.IsNullOrEmpty(termSetName))
                return tesmStore.GetTermSets(termSetName, termSetLCID).FirstOrDefault();

            return null;
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:10,代码来源:TaxonomyFieldModelHandler.cs


注:本文中的TermStore.GetTermSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。