本文整理汇总了C#中Group.CreateTermSet方法的典型用法代码示例。如果您正苦于以下问题:C# Group.CreateTermSet方法的具体用法?C# Group.CreateTermSet怎么用?C# Group.CreateTermSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group.CreateTermSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportTermSet
public void ImportTermSet(Group termGroup, XElement termSetElement, bool recurse = true)
{
try
{
//Get the termset name
string termSetName = (string)termSetElement.Attribute("Name");
//Check if the termset exists
TermSet termSet = (from termset in termGroup.TermSets where termset.Name == termSetName select termset).SingleOrDefault();
//If it doesn't exist, create it
if (termSet == null)
{
termSet = termGroup.CreateTermSet(termSetName);
}
//Create all the child terms in the termset
if (recurse)
{
foreach (XElement childElement in termSetElement.Elements())
{
ImportTerm(termSet, childElement, recurse);
}
}
}
catch (Exception e)
{
}
}
示例2: Import
private void Import(XmlElement termSetElement, Group parentGroup)
{
string termSetName = termSetElement.GetAttribute("Name");
TermSet termSet = null;
try
{
termSet = parentGroup.TermSets[termSetName];
}
catch (ArgumentException) {}
if (termSet == null)
{
Logger.Write("Creating Term Set: {0}", termSetName);
int lcid = parentGroup.TermStore.WorkingLanguage;
if (!string.IsNullOrEmpty(termSetElement.GetAttribute("Id")))
{
Guid id = new Guid(termSetElement.GetAttribute("Id"));
termSet = parentGroup.CreateTermSet(termSetName, id, lcid);
}
else
termSet = parentGroup.CreateTermSet(termSetName, lcid);
if (!string.IsNullOrEmpty(termSetElement.GetAttribute("Contact")))
termSet.Contact = termSetElement.GetAttribute("Contact");
if (!string.IsNullOrEmpty(termSetElement.GetAttribute("Description")))
termSet.Description = termSetElement.GetAttribute("Description");
if (!string.IsNullOrEmpty(termSetElement.GetAttribute("CustomSortOrder")))
termSet.CustomSortOrder = termSetElement.GetAttribute("CustomSortOrder");
if (!string.IsNullOrEmpty(termSetElement.GetAttribute("IsAvailableForTagging")))
termSet.IsAvailableForTagging = bool.Parse(termSetElement.GetAttribute("IsAvailableForTagging"));
if (!string.IsNullOrEmpty(termSetElement.GetAttribute("Owner")))
termSet.Owner = termSetElement.GetAttribute("Owner");
termSet.IsOpenForTermCreation = true;
}
#if SP2013
// Updated provided by John Calvert
XmlNodeList propertyNodes = termSetElement.SelectNodes("./CustomProperties/CustomProperty");
if (propertyNodes != null && propertyNodes.Count > 0)
{
foreach (XmlElement propertyElement in propertyNodes)
{
termSet.SetCustomProperty(propertyElement.GetAttribute("Name"),
propertyElement.GetAttribute("Value"));
}
}
// End update
#endif
parentGroup.TermStore.CommitAll();//TEST
XmlNodeList termsNodes = termSetElement.SelectNodes("./Terms/Term");
if (termsNodes != null && termsNodes.Count > 0)
{
foreach (XmlElement termElement in termsNodes)
{
Import(termElement, termSet);
}
}
if (!string.IsNullOrEmpty(termSetElement.GetAttribute("IsOpenForTermCreation")) && termSet.TermStore.OrphanedTermsTermSet != termSet)
termSet.IsOpenForTermCreation = bool.Parse(termSetElement.GetAttribute("IsOpenForTermCreation"));
}