本文整理汇总了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;
}
}
示例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);
}
}
示例3: LookupTermSet
public static TermSet LookupTermSet(TermStore tesmStore, TaxonomyFieldDefinition taxFieldModel)
{
return LookupTermSet(tesmStore,
taxFieldModel.TermSetName,
taxFieldModel.TermSetId,
taxFieldModel.TermSetLCID
);
}
示例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();
}
示例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;
}
示例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;
}
示例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
);
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}