本文整理汇总了C#中Term.CreateTerm方法的典型用法代码示例。如果您正苦于以下问题:C# Term.CreateTerm方法的具体用法?C# Term.CreateTerm怎么用?C# Term.CreateTerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Term
的用法示例。
在下文中一共展示了Term.CreateTerm方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTerm
public static Term CreateTerm(this SPSite site, Term term, string name)
{
if (term.Terms.All(x => x.Name != name))
{
var returnterm = term.CreateTerm(name, int.Parse(site.RootWeb.Language.ToString()));
returnterm.TermStore.CommitAll();
return returnterm;
}
return term.Terms.FirstOrDefault(x => x.Name == name);
}
示例2: CustomArea
private static void CustomArea(CustomAreaOfLaw aol, Term AOLTerm)
{
foreach (CustomSubAreaOfLaw asol in aol.Saol)
{
Console.WriteLine("\t\tCreating sub area of law " + asol.name);
Term ASOLTerm = AOLTerm.CreateTerm(asol.name, 1033, Guid.NewGuid());
if (asol.properties.ContainsKey("SAOLFolders") && !string.IsNullOrWhiteSpace(asol.properties["SAOLFolders"]))
{
ASOLTerm.SetCustomProperty("FolderNames", asol.properties["SAOLFolders"]);
}
if (asol.properties.ContainsKey("SAOLContentType") && !string.IsNullOrWhiteSpace(asol.properties["SAOLContentType"]))
{
ASOLTerm.SetCustomProperty("ContentTypeName", asol.properties["SAOLContentType"]);
}
if (asol.properties.ContainsKey("SAOLDocumentTemplate") && !string.IsNullOrWhiteSpace(asol.properties["SAOLDocumentTemplate"]))
{
ASOLTerm.SetCustomProperty("DocumentTemplates", asol.properties["SAOLDocumentTemplate"]);
}
if (asol.properties.ContainsKey("SAOLIsFolder") && !string.IsNullOrWhiteSpace(asol.properties["SAOLIsFolder"]))
{
ASOLTerm.SetCustomProperty("isNoFolderStructurePresent", asol.properties["SAOLIsFolder"]);
}
}
}
示例3: CreateTerm
public static Term CreateTerm(Term term, Guid termGuid, string nameString, int LCID)
{
term.RequireNotNull("term");
nameString.RequireNotNullOrEmpty("nameString");
Term newTerm = null;
if (!Guid.Empty.Equals(termGuid))
{
newTerm = term.CreateTerm(nameString, LCID, termGuid);
}
else
{
newTerm = term.CreateTerm(nameString, LCID);
}
return newTerm;
}
示例4: ProcessSubTerms
private void ProcessSubTerms(ClientContext sourceClientContext, ClientContext targetClientContext, TermSet targetTermSet, Term targetTerm, Term sourceTerm, List<int> languagesToProcess, int defaultLanguage)
{
TermCollection sourceTerms = sourceTerm.Terms;
sourceClientContext.Load(sourceTerms, terms => terms.Include(
term => term.Name,
term => term.Description,
term => term.Id,
term => term.IsDeprecated,
term => term.IsAvailableForTagging,
term => term.LocalCustomProperties,
term => term.CustomProperties,
term => term.Labels.Include(label => label.Value, label => label.Language, label => label.IsDefaultForLanguage),
term => term.TermSet, termset => termset.Id));
sourceClientContext.ExecuteQuery();
foreach (Term subSourceTerm in sourceTerm.Terms)
{
Term reusedTerm = targetTerm.TermStore.GetTerm(subSourceTerm.Id);
targetClientContext.Load(reusedTerm);
targetClientContext.ExecuteQuery();
Term childTargetTerm;
if (reusedTerm.ServerObjectIsNull.Value)
{
childTargetTerm = targetTerm.CreateTerm(subSourceTerm.Name, defaultLanguage, subSourceTerm.Id);
targetClientContext.Load(childTargetTerm, term => term.IsDeprecated,
term => term.CustomProperties,
term => term.LocalCustomProperties);
targetClientContext.ExecuteQuery();
UpdateTerm(sourceClientContext, targetClientContext, subSourceTerm, childTargetTerm, languagesToProcess);
}
else
{
childTargetTerm = targetTerm.ReuseTerm(reusedTerm, false);
}
targetClientContext.Load(childTargetTerm);
targetClientContext.ExecuteQuery();
targetTermSet.TermStore.UpdateCache();
ProcessSubTerms(sourceClientContext, targetClientContext, targetTermSet, childTargetTerm, subSourceTerm, languagesToProcess, defaultLanguage);
}
}
示例5: CreateChildTerm
private static void CreateChildTerm(Term parent, TermInit child)
{
Term newTerm = parent.CreateTerm(child.TermName, 1033, child.TermID);
if (child.ChildTerms != null) {
foreach (TermInit childterm in child.ChildTerms) {
CreateChildTerm(newTerm, childterm);
}
}
}
示例6: RecursiveTermCreation
private static void RecursiveTermCreation(IEnumerable<XElement> descendants, Term term, bool copyId, int LCID)
{
foreach (XElement xTerm in descendants)
{
Term __childTerm;
if (copyId)
{
__childTerm = term.CreateTerm(xTerm.Attribute("name").Value, LCID, new Guid(xTerm.Attribute("id").Value));
}
else
{
__childTerm = term.CreateTerm(xTerm.Attribute("name").Value, LCID);
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Importing TermSet [" + __childTerm.Name + "]");
foreach (XElement label in xTerm.Elements("Label"))
{
if ((!label.Attribute("name").Value.Equals(__childTerm.Name)))
__childTerm.CreateLabel(label.Attribute("name").Value, Convert.ToInt32(label.Attribute("language").Value), Convert.ToBoolean(label.Attribute("isdefault").Value));
}
if (xTerm.Elements("Term").Count() > 0)
RecursiveTermCreation(xTerm.Elements("Term"), __childTerm, copyId, LCID);
}
}
示例7: ImportTerm
public void ImportTerm(Term parentTerm, XElement termElement, bool recurse = true)
{
try
{
//Get the LCID.
//TODO: Support importing LCIDs
int lcid = CultureInfo.CurrentCulture.LCID;
//Get the term name
string termName = (string)termElement.Attribute("Name");
//Check if the term exist
Term term = parentTerm.GetTerms(termName, lcid, true, StringMatchOption.ExactMatch, 1, false).FirstOrDefault();
//If the term does not exist, create it
if (term == null)
{
term = parentTerm.CreateTerm(termName, lcid);
}
//Create the child terms
if (recurse)
{
foreach (XElement childElement in termElement.Elements())
{
ImportTerm(term, childElement, recurse);
}
}
}
catch (Exception e)
{
}
}
示例8: ProcessTerms
private static void ProcessTerms(XmlNode termSetTerms, TermSet termSet, Term currentTerm)
{
Term newTerm;
foreach (XmlNode termsNames in termSetTerms.SelectNodes("Term"))
{
string strTermName = termsNames.Attributes["Name"].Value;
if (currentTerm != null)
{
newTerm = currentTerm.CreateTerm(strTermName, termStore.DefaultLanguage);
}
else
{
newTerm = termSet.CreateTerm(strTermName, termStore.DefaultLanguage);
// termStore.CommitAll();
}
termStore.CommitAll();
Console.WriteLine(strTermName);
//ProcessLabels
foreach (XmlNode labelNames in termsNames.SelectSingleNode("Labels").ChildNodes)
{
string strLCID = labelNames.Attributes["lcid"].Value;
string strLabelName = labelNames.Attributes["Name"].Value;
string strTermDescription = labelNames.Attributes["Description"].Value;
if (Convert.ToInt32(strLCID) != termStore.DefaultLanguage)
{
newTerm.CreateLabel(strLabelName, Convert.ToInt32(strLCID), true);
termStore.CommitAll();
}
newTerm.SetDescription(strTermDescription, Convert.ToInt32(strLCID));
termStore.CommitAll();
Console.WriteLine(strLCID);
Console.WriteLine(strLabelName);
}
foreach (XmlNode subTerms in termsNames.SelectNodes("Terms"))
{
ProcessTerms(subTerms, termSet, newTerm);
}
}
}