本文整理汇总了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;
}
示例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();
//.........这里部分代码省略.........
示例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;
}
示例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>();
}
示例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;
}
示例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;
}