本文整理汇总了C#中TermStore.CommitAll方法的典型用法代码示例。如果您正苦于以下问题:C# TermStore.CommitAll方法的具体用法?C# TermStore.CommitAll怎么用?C# TermStore.CommitAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TermStore
的用法示例。
在下文中一共展示了TermStore.CommitAll方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteGroupIfExists
private void DeleteGroupIfExists(TermStore defaultSiteCollectionTermStore, Guid testGroupId)
{
Group existingTestGroup = defaultSiteCollectionTermStore.GetGroup(testGroupId);
if (existingTestGroup != null)
{
foreach (var termSet in existingTestGroup.TermSets)
{
termSet.Delete();
}
existingTestGroup.Delete();
defaultSiteCollectionTermStore.CommitAll();
}
}
示例2: 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();
}
示例3: CreateTermSet
private TermSet CreateTermSet(TermStore termStore, Guid termSetID, SPWeb currentWeb, TermStoreType tsType)
{
//termSet is null. Create new termSet, and set the property in the property bag.
Group siteCollectionGroup = termStore.GetSiteCollectionGroup(currentWeb.Site);
//Group navTermsGroup = termStore.Groups["Navigation"]; //TODO: Get this from configuration or passed in.
string termStoreName = (tsType == TermStoreType.Global) ? string.Format("Global_Nav_For{0}", termSetID) : string.Format("Local_Nav_For{0}", termSetID);
TermSet newTermSet = siteCollectionGroup.CreateTermSet(termStoreName, termSetID);
NavigationTermSet navTermSet = NavigationTermSet.GetAsResolvedByWeb(newTermSet, currentWeb, StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);
navTermSet.IsNavigationTermSet = true;
navTermSet.TargetUrlForChildTerms.Value = "~site/SitePages/Home.aspx";
uint langID = (uint) currentWeb.Locale.LCID;
string webTemplateID = Convert.ToString(currentWeb.Site.RootWeb.AllProperties["MARTA.WebTemplateID"]);
string termStoreType = (tsType == TermStoreType.Global) ? "Global" : "Local";
string termMap = SPUtility.GetLocalizedString(string.Format("$Resources:MARTANavigation,{0}_{1}", webTemplateID, termStoreType) , "MARTANavigation", langID);
string relativeURL = currentWeb.Site.ServerRelativeUrl;
BuildNavTerms(navTermSet, termMap, relativeURL);
termStore.CommitAll();
return newTermSet;
//Add this to the property bag of the web as well.
}
示例4: Import
public void Import(TermStore parentTermStore)
{
if (parentTermStore == null || parentTermStore.ServerObjectIsNull.Value)
throw new ArgumentNullException("parentTermStore", "The parent TermStore object is null.");
LoadWorkingLanguage(parentTermStore);
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();
parentTermStore.Context.ExecuteQuery();
}
示例5: DeleteTermGroupsImplementation
private void DeleteTermGroupsImplementation(ClientContext cc, TermStore termStore)
{
cc.Load(termStore.Groups, p => p.Include(t => t.Name, t => t.TermSets.Include(s => s.Name, s => s.Terms.Include(q => q.IsDeprecated, q => q.ReusedTerms))));
cc.ExecuteQueryRetry();
foreach (var termGroup in termStore.Groups.ToList())
{
DeleteTermGroupImplementation(cc, termGroup);
}
var siteCollectionGroup = termStore.GetSiteCollectionGroup(cc.Site, true);
cc.Load(siteCollectionGroup, t => t.Name, t => t.TermSets.Include(s => s.Name, s => s.Terms.Include(q => q.IsDeprecated, q => q.ReusedTerms)));
cc.ExecuteQueryRetry();
DeleteTermGroupImplementation(cc, siteCollectionGroup, true);
termStore.CommitAll();
termStore.UpdateCache();
cc.ExecuteQueryRetry();
}
示例6: ImportTerms
private static void ImportTerms(string filePath, string urlSPSite)
{
using (SPSite site = new SPSite(urlSPSite))
{
// function that return termstore from site.
termStore = termstorefromWebApp(site);
XmlDocument doc = new XmlDocument();
doc.Load(filePath);
XmlNode termGroup = doc.SelectSingleNode("/Groups/Group");
ProcessGroup(termGroup);
termStore.CommitAll();
}
}
示例7: 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();
}
示例8: CreateTargetNewTermGroup
private void CreateTargetNewTermGroup(ClientContext sourceClientContext, ClientContext targetClientContext, TermGroup sourceTermGroup, TermStore targetTermStore)
{
try
{
this._destinationTermGroup = targetTermStore.CreateGroup(sourceTermGroup.Name, sourceTermGroup.Id);
if(!string.IsNullOrEmpty(sourceTermGroup.Description))
{
this._destinationTermGroup.Description = sourceTermGroup.Description;
}
TermOperation _op = new TermOperation();
_op.Term = sourceTermGroup.Name;
_op.Id = sourceTermGroup.Id.ToString();
_op.Operation = "Add";
_op.Type = "TermGroup";
this._termStoreOperations.Add(_op);
TermSetCollection _sourceTermSetCollection = sourceTermGroup.TermSets;
if (_sourceTermSetCollection.Count > 0)
{
foreach (TermSet _sourceTermSet in _sourceTermSetCollection)
{
sourceClientContext.Load(_sourceTermSet,
set => set.Name,
set => set.Description,
set => set.Id,
set => set.Terms.Include(
term => term.Name,
term => term.Id),
term => term.Description,
term => term.Contact);
sourceClientContext.ExecuteQuery();
TermSet _targetTermSet = _destinationTermGroup.CreateTermSet(_sourceTermSet.Name, _sourceTermSet.Id, targetTermStore.DefaultLanguage);
if(!string.IsNullOrEmpty(_sourceTermSet.Description))
{
_targetTermSet.Description = _sourceTermSet.Description;
}
foreach(Term _sourceTerm in _sourceTermSet.Terms)
{
Term _targetTerm = _targetTermSet.CreateTerm(_sourceTerm.Name, targetTermStore.DefaultLanguage, _sourceTerm.Id);
_op = new TermOperation();
_op.Term = _sourceTerm.Name;
_op.Id = _sourceTerm.Id.ToString();
_op.Operation = "Add";
_op.Type = "Term";
this._termStoreOperations.Add(_op);
}
}
}
try
{
targetClientContext.ExecuteQuery();
targetTermStore.CommitAll();
}
catch
{
throw;
}
}
catch
{
throw;
}
}