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


C# TermStore类代码示例

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


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

示例1: GetTermGroup

        private TermGroup GetTermGroup(ClientContext ctx, TermStore termStore, string groupName)
        {
            TermGroup _termGroup = termStore.Groups.GetByName(groupName);

            ctx.Load(_termGroup, group => group.Name, group => group.Id, group => group.Description,
                group => group.TermSets.Include(
                        termSet => termSet.Name,
                        termSet => termSet.Id));

            try
            {
                ctx.ExecuteQuery();
                if(!_termGroup.ServerObjectIsNull.Value)
                {
                    return _termGroup;
                }
                else
                {
                    return null;
                }

            }
            catch(Exception _ex)
            {
                return null;
            }
        }
开发者ID:ADefWebserver,项目名称:PnP,代码行数:27,代码来源:MMSSyncManager.cs

示例2: MoveTermGroup

        public void MoveTermGroup(ClientContext sourceCtx, ClientContext targetCtx, string termGroup)
        {
          
            this._termStoreOperations = new List<TermOperation>();

            this.sourceTermStore = this.GetTermStoreObject(sourceCtx);
            this.targetTermStore = this.GetTermStoreObject(targetCtx);

            this.sourceTermGroup = this.GetTermGroup(sourceCtx, sourceTermStore, termGroup);
            this.targetTermGroup = this.GetTermGroup(targetCtx, targetTermStore, termGroup);

            if (sourceTermGroup == null)
            {
                return;
            }
            if (targetTermGroup != null)
            {
                if (sourceTermGroup.Id != targetTermGroup.Id)
                {
                    throw new Exception("The Term groups have different ID's. I don't know how to work it.");
                }
            }
            else
            {
                this.CreateTargetNewTermGroup(sourceCtx, targetCtx, sourceTermGroup, targetTermStore);
            }
        }
开发者ID:ADefWebserver,项目名称:PnP,代码行数:27,代码来源:MMSSyncManager.cs

示例3: LookupTermSet

 public static TermSet LookupTermSet(TermStore tesmStore, TaxonomyFieldDefinition taxFieldModel)
 {
     return LookupTermSet(tesmStore,
         taxFieldModel.TermSetName,
         taxFieldModel.TermSetId,
         taxFieldModel.TermSetLCID
         );
 }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:8,代码来源:TaxonomyFieldModelHandler.cs

示例4: GenODA1Terms

		internal static void GenODA1Terms(TermStore defaultTermStore) {
			var ProductTS = defaultTermStore.GenerateGroup("ODA1", ConstGUIDs.GUID_G_ODA1)
				.GenerateTermSet("Product", ConstGUIDs.GUID_TS_PRODUCT);

			ProductTS.AddTerm("Virus Protection", ConstGUIDs.GUID_T_VP);
			ProductTS.AddTerm("Spam Protection", ConstGUIDs.GUID_T_SP);
			ProductTS.AddTerm("Internet Filtering", ConstGUIDs.GUID_T_IF).Context.ExecuteQuery(); 
		}
开发者ID:Luviz,项目名称:OfficeDev1.MAssinment,代码行数:8,代码来源:CustomTaxonomi.ODA1.cs

示例5: ManagedMetadataManager

        public ManagedMetadataManager(TermStore termStore, string groupName)
        {
            if (termStore == null) throw new ArgumentNullException("termStore");

            Delimiter = ",";
            UseDefaultImporter = false;
            Encoding = Encoding.UTF8;
            _termStore = termStore;
            _groupName = groupName;
        }
开发者ID:ricardocarneiro,项目名称:sharepoint-3,代码行数:10,代码来源:ManagedMetadataManager.cs

示例6: LookupTerm

        public static Term LookupTerm(TermStore tesmStore, TaxonomyFieldDefinition taxFieldModel)
        {
            if (taxFieldModel.TermId.HasValue)
                return tesmStore.GetTerm(taxFieldModel.TermId.Value);

            if (!string.IsNullOrEmpty(taxFieldModel.TermName))
                return tesmStore.GetTerms(taxFieldModel.TermName, taxFieldModel.TermLCID, false).FirstOrDefault();

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

示例7: LookupTermSet

        public static TermSet LookupTermSet(SPSite site, TermStore tesmStore, TaxonomyFieldDefinition taxFieldModel)
        {
            return LookupTermSet(tesmStore,

                taxFieldModel.TermGroupName,
                taxFieldModel.TermGroupId,
                taxFieldModel.IsSiteCollectionGroup,

                site,

                taxFieldModel.TermSetName,
                taxFieldModel.TermSetId,
                taxFieldModel.TermSetLCID
                );
        }
开发者ID:Whoopsss,项目名称:spmeta2,代码行数:15,代码来源:TaxonomyFieldModelHandler.cs

示例8: AddLanguages

        private static void AddLanguages(ClientContext clientContext, TermStore termStore)
        {
            clientContext.Load(clientContext.Web, w => w.ServerRelativeUrl);
            clientContext.Load(termStore, ts => ts.Languages);
            clientContext.ExecuteQuery();

            var languages = new int[] { 1031, 1033, 1036, 1053 };
            Array.ForEach(languages, l => { 
                if (!termStore.Languages.Contains(l)) 
                    termStore.AddLanguage(l); 
            });

            termStore.CommitAll();
            clientContext.ExecuteQuery();
        }
开发者ID:NicolajLarsen,项目名称:PnP,代码行数:15,代码来源:TaxonomyHelper.cs

示例9: termstorefromWebApp

        public static TermStore termstorefromWebApp(SPSite site)
        {
            TaxonomySession session = new TaxonomySession(site);

            //ThroubleShooting problem during get termstore
            // http://sharepoint.stackexchange.com/questions/4097/why-are-taxonomy-term-stores-always-empty
            //http://blog.henryong.com/2012/03/20/sharepoint-dev-getting-null-taxonomysession-and-argumentoutofrangeexception-errors-on-termstore-objects/

            // 1st way;
            termStore = session.TermStores["Managed Metadata Service"];

            // 2nd way;
            // termStore = session.DefaultKeywordsTermStore;//Try  session.DefaultSiteCollectionTermStore

            return termStore;
        }
开发者ID:chrisdee,项目名称:Solutions,代码行数:16,代码来源:Form1.cs

示例10: SPOTermStore

        public SPOTermStore(TermStore termStore)
        {
            _termStore = termStore;

            if (_termStore.ServerObjectIsNull == null)
            {
                _termStore.Context.Load(_termStore);
                _termStore.Context.Load(_termStore, ts => ts.ContentTypePublishingHub);
                _termStore.Context.ExecuteQuery();
            }

            if (_termStore.IsPropertyAvailable("DefaultLanguage"))
                SetProp("DefaultLanguage", _termStore.DefaultLanguage, false);
            if (_termStore.IsPropertyAvailable("WorkingLanguage"))
                SetProp("WorkingLanguage", _termStore.WorkingLanguage, false);
        }
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:16,代码来源:SPOTermStore.cs

示例11: AddGroup

        private static TermGroup AddGroup(ClientContext clientContext, TermStore termStore)
        {
            var groupId = new Guid("8de44223-5a8f-41cd-b0e2-5634b0bb953b");
            var termGroup = termStore.GetGroup(groupId);
            clientContext.Load(termGroup);
            clientContext.ExecuteQuery();

            if (termGroup.ServerObjectIsNull.Value)
            {
                termGroup = termStore.CreateGroup("Taxonomy Navigation", groupId);
                clientContext.Load(termGroup);
                clientContext.ExecuteQuery();
            }

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

示例12: LookupTerm

        public static Term LookupTerm(SPSite site, TermStore tesmStore, TaxonomyFieldDefinition taxFieldModel)
        {
            Group currentGroup = null;

            var termGroupName = taxFieldModel.TermGroupName;
            var groupId = taxFieldModel.TermGroupId;
            var isSiteCollectionGroup = taxFieldModel.IsSiteCollectionGroup;

            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);
            }

            // TODO
            // that should also check if the TermSet is there, so to scope the term 

            if (currentGroup != null)
            {
                if (taxFieldModel.TermId.HasValue)
                    return tesmStore.GetTerm(taxFieldModel.TermId.Value);

                if (!string.IsNullOrEmpty(taxFieldModel.TermName))
                {
                    return tesmStore.GetTerms(taxFieldModel.TermName, taxFieldModel.TermLCID, false)
                                    .FirstOrDefault(t => t.TermSet.Group.Name == currentGroup.Name);
                }
            }
            else
            {
                if (taxFieldModel.TermId.HasValue)
                    return tesmStore.GetTerm(taxFieldModel.TermId.Value);

                if (!string.IsNullOrEmpty(taxFieldModel.TermName))
                    return tesmStore.GetTerms(taxFieldModel.TermName, taxFieldModel.TermLCID, false).FirstOrDefault();
            }

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

示例13: 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

示例14: Export

        public XmlDocument Export(TermStore termStore)
        {
            if (termStore == null)
                throw new ArgumentNullException("termStore", "The TermStore object is null.");

            LoadLanguages(termStore);
            XmlElement termStoreElement = AddTermStoreElement(null, termStore);
            var groups = termStore.Groups;
            if (!termStore.IsObjectPropertyInstantiated("Groups") || !termStore.Groups.AreItemsAvailable)
            {
                _ctx.Load(groups);
                _ctx.ExecuteQuery();
            }
            foreach (TermGroup group in groups)
            {
                Export(termStoreElement, group);
            }
            return _xml;
        }
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:19,代码来源:ExportTermsHelper.cs

示例15: Import

        public void Import(TermStore parentTermStore)
        {
            if (parentTermStore == null)
                throw new ArgumentNullException("parentTermStore", "The parent TermStore object is null.");

            if (_xml.DocumentElement.Name == "Groups")
            {
                XmlNodeList groupNodes = _xml.SelectNodes("./Groups/Group");
                if (groupNodes == null || groupNodes.Count == 0)
                    return;

                foreach (XmlElement groupElement in groupNodes)
                {
                    Import(groupElement, parentTermStore);
                }
            }
            else if (_xml.DocumentElement.Name == "Group")
            {
                Import(_xml.DocumentElement, parentTermStore);
            }
            parentTermStore.CommitAll();
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:22,代码来源:ImportTerms.cs


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