本文整理汇总了C#中TermStore类的典型用法代码示例。如果您正苦于以下问题:C# TermStore类的具体用法?C# TermStore怎么用?C# TermStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TermStore类属于命名空间,在下文中一共展示了TermStore类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:ADefWebserver,项目名称:PnP,代码行数:27,代码来源:MMSSyncManager.cs
示例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);
}
}
开发者ID:ADefWebserver,项目名称:PnP,代码行数:27,代码来源:MMSSyncManager.cs
示例3: LookupTermSet
public static TermSet LookupTermSet(TermStore tesmStore, TaxonomyFieldDefinition taxFieldModel)
{
return LookupTermSet(tesmStore,
taxFieldModel.TermSetName,
taxFieldModel.TermSetId,
taxFieldModel.TermSetLCID
);
}
开发者ID:Uolifry,项目名称:spmeta2,代码行数:8,代码来源:TaxonomyFieldModelHandler.cs
示例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();
}
开发者ID:Luviz,项目名称:OfficeDev1.MAssinment,代码行数:8,代码来源:CustomTaxonomi.ODA1.cs
示例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;
}
开发者ID:ricardocarneiro,项目名称:sharepoint-3,代码行数:10,代码来源:ManagedMetadataManager.cs
示例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;
}
开发者ID:Uolifry,项目名称:spmeta2,代码行数:10,代码来源:TaxonomyFieldModelHandler.cs
示例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
);
}
开发者ID:Whoopsss,项目名称:spmeta2,代码行数:15,代码来源:TaxonomyFieldModelHandler.cs
示例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();
}
开发者ID:NicolajLarsen,项目名称:PnP,代码行数:15,代码来源:TaxonomyHelper.cs
示例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;
}
开发者ID:chrisdee,项目名称:Solutions,代码行数:16,代码来源:Form1.cs
示例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);
}
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:16,代码来源:SPOTermStore.cs
示例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;
}
开发者ID:modulexcite,项目名称:TrainingContent,代码行数:16,代码来源:TaxonomyHelper.cs
示例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;
}
开发者ID:karayakar,项目名称:spmeta2,代码行数:46,代码来源:TaxonomyFieldModelHandler.cs
示例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;
}
开发者ID:modulexcite,项目名称:TrainingContent,代码行数:17,代码来源:TaxonomyHelper.cs
示例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;
}
开发者ID:ejaya2,项目名称:PowerShell-SPOCmdlets,代码行数:19,代码来源:ExportTermsHelper.cs
示例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();
}
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:22,代码来源:ImportTerms.cs
示例16: ConnectTaxonomyField
public static void ConnectTaxonomyField(TaxonomyField field, TaxonomySession session, TermStore termStore, string termGroup, string termSetName, bool isOpen = false, bool createValuesInEditForm = false)
{
if (field == null || session == null || termStore == null) { return; }
Group group = termStore.Groups.GetByName(termGroup);
if (group != null)
{
TermSet termSet = group.TermSets.GetByName(termSetName);
// connect the field to the specified term
if (termSet != null)
{
field.SspId = termSet.TermStore.Id;
field.TermSetId = termSet.Id;
field.Open = isOpen && termSet.IsOpenForTermCreation;
field.CreateValuesInEditForm = field.Open && createValuesInEditForm;
}
}
field.TargetTemplate = string.Empty;
field.AnchorId = Guid.Empty;
field.Update();
}
开发者ID:ricardocarneiro,项目名称:sharepoint-3,代码行数:23,代码来源:TaxonomyHelper.cs
示例17: ImportGroup
public void ImportGroup(TermStore termStore, XElement groupElement, bool recurse = true)
{
//Get the group name
string groupName = (string)groupElement.Attribute("Name");
//Check if the group exists
Group group = (from termgroup in termStore.Groups where termgroup.Name == groupName select termgroup).SingleOrDefault();
//If it doesn't exist, create it
if (group == null)
{
group = termStore.CreateGroup(groupName);
}
//Create all child term sets in the group
if (recurse)
{
foreach (XElement childElement in groupElement.Elements())
{
ImportTermSet(group, childElement, recurse);
}
}
}
开发者ID:ashwnacharya,项目名称:SPMetadataManager,代码行数:23,代码来源:Importer.cs
示例18: 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();
//.........这里部分代码省略.........
开发者ID:karayakar,项目名称:spmeta2,代码行数:101,代码来源:TaxonomyFieldModelHandler.cs
示例19: GetTermSetFromGroup
/// <summary>
/// Gets the term set from group.
/// </summary>
/// <param name="termStore">The term store.</param>
/// <param name="group">The group.</param>
/// <param name="termSetName">Name of the term set.</param>
/// <returns>The term set for the specified store, group and term set name.</returns>
public TermSet GetTermSetFromGroup(TermStore termStore, Group group, string termSetName)
{
using (var timeTracker = this.timeTracker.BeginTimeTrackerScope(TimeTrackerKey))
{
return this.decorated.GetTermSetFromGroup(termStore, group, termSetName);
}
}
开发者ID:andresglx,项目名称:Dynamite,代码行数:14,代码来源:MonitoredTaxonomyService.cs
示例20: GetTermsForTermSetInternal
private IList<Term> GetTermsForTermSetInternal(TermStore termStore, string termStoreGroupName, string termSetName)
{
if (termStore == null)
{
throw new ArgumentNullException("termStore");
}
if (string.IsNullOrEmpty(termStoreGroupName))
{
throw new ArgumentNullException("termStoreGroupName");
}
if (string.IsNullOrEmpty(termSetName))
{
throw new ArgumentNullException("termSetName");
}
IList<Term> termsList = new List<Term>();
Group group = GetGroupFromTermStore(termStore, termStoreGroupName);
TermSet termSet = this.GetTermSetFromGroup(termStore, group, termSetName);
return GetTermsForTermSetInternal(termStore, group, termSet);
}
开发者ID:GSoft-SharePoint,项目名称:Dynamite-2010,代码行数:24,代码来源:TaxonomyService.cs
注:本文中的TermStore类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论