Benutzer:MovGP0/70-489/MMS
Zur Navigation springen
Zur Suche springen
MovGP0 | Über mich | Hilfen | Artikel | Weblinks | Literatur | Zitate | Notizen | Programmierung | MSCert | Physik |
Implement Managed Metadata Service (MMS)[Bearbeiten | Quelltext bearbeiten]Manage Term Sets[Bearbeiten | Quelltext bearbeiten]Term übersetzen[Bearbeiten | Quelltext bearbeiten]using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;
using System.Globalization;
using(var site = new SPSite("http://.../"))
{
var taxonomySession = new TaxonomySession(site);
var term = taxonomySession.GetTerms("TermSetName", false).SingleOrDefault();
if(term == null) return;
var french = CultureInfo.CreateSpecificCulture("fr-fr");
term.CreateLabel("Au Revoir", french, false);
term.TermStore.CommitAll();
}
Term wiederverwenden[Bearbeiten | Quelltext bearbeiten]using(var site = new SPSite("http://.../"))
{
var taxonomySession = new TaxonomySession(site);
var sourceTermSet = taxonomySession.GetTerms("SourceTermSetName", false).SingleOrDefault();
if(sourceTermSet == null) return;
var targetTermSet = taxonomySession.GetTerms("TargetTermSetName", false).SingleOrDefault();
if(targetTermSet == null) return;
var termToReuse = sourceTermSet.GetTerms("TermName", false).SingleOrDefault();
if(termToReuse == null) return;
targetTermSet.ResuseTerm(termToReuse, false);
targetTermSet.TermStore.CommitAll();
}
Term-Einstellungen setzen[Bearbeiten | Quelltext bearbeiten]using(var site = new SPSite("http://..."))
{
var taxonomySession = new TaxonomySession(site);
var term = taxonomySession.GetTerms("TermName", false).SingleOrDefault();
if(term == null) return;
var english = CultureInfo.CreateSpecificCulture("en-US");
term.SetDescription("Some description", english.LCID);
term.SetCustomProperty("My Property", "My Value");
term.TermStore.CommitAll();
}
Groups and Permissions[Bearbeiten | Quelltext bearbeiten]using(var site = new SPSite("http://..."))
{
var taxonomySession = new TaxonomySession(site);
var termStore = taxonomySession.TermStores["Managed Metadata Service"]; // "Managed Metadata Service" is the default store
// create group and assign permissions
var termGroup = termStore.CreateGroup("Custom Group");
termGroup.AddGroupManager(@"dev\Administrator");
termGroup.AddContributor(@"dev\User");
termGroup.CommitAll();
}
Create Solutions using MMS[Bearbeiten | Quelltext bearbeiten]Implement Metadata-Driven Navigation[1][Bearbeiten | Quelltext bearbeiten]using(var site = new SPSite("http://sharepoint/sites/mms"))
{
var taxyonomySession = new TaxonomySession(site);
var termStore = taxonomySession.TermStores["Managed Metadata Service"];
var termGroup = termStore.Groups.Where(g => g.Name = "Global");
if(termGroup == null) return;
var termSet = termGroup.CreateTermSet("Navigation", Guid.NewGuid())
var navTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, site.AllWebs[0], StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);
navTermSet.IsNavigationTermSet = true;
navTermSet.TargetUrlForChildTerms.Value = "/sites/mms/_layouts/15/start.aspx";
var term1 = navTermSet.CreateTerm("Page 1", NavigationLinkType.SimpleLink);
term1.SimpleLinkUrl = "/sites/mms/SitePages/Page1.aspx";
var term2 = navTermSet.CreateTerm("Page 1", NavigationLinkType.SimpleLink);
term1.SimpleLinkUrl = "/sites/mms/SitePages/Page2.aspx";
termStore.CommitAll();
// Create a WebNavigationSettings object to set the global nav on our site
var webNavSettings = new WebNavigationSettings(site.AllWebs[0]) {
GlobalNavigation.Source = StandardNavigationSource.TaxonomyProvider,
AddNewPagesToNavigation = false,
CreateFriendlyUrlsForNewPages = false,
GlobalNavigation.TermStoreId = termStore.Id,
GlobalNavigation.TermSetId = termSet.Id
};
webNavSettings.Update(taxonomySession);
}
Use the Product Catalog and Cross-Site Publishing[2][Bearbeiten | Quelltext bearbeiten]
Use an MMS API[Bearbeiten | Quelltext bearbeiten]Using CSOM and SSOM[Bearbeiten | Quelltext bearbeiten]
Use REST in Client Applications[Bearbeiten | Quelltext bearbeiten]
Use Managed Fields[Bearbeiten | Quelltext bearbeiten]using(var site = new SPSite("http://sharepoint/sites/mms"))
{
// get term set
var taxonomySession = new TaxonomySession(site);
var termSet = taxonomySession.GetTermSets("TermSetName").Single();
// create field
var field = site.RootWeb.Fields.CreateNewField("TaxonomyFieldType", "Custom Field") as TaxonomyField;
field.SspId = termSet.TermStore.Id;
field.TermSetId = termSet.Id;
field.TargetTemplate = string.Empty;
field.AllowMultipleValues = true;
// add field to site
site.RootWeb.Fields.Add(field);
site.RootWeb.Update();
// add field to list
var fieldAdded = site.RootWeb.Fields["Custom Field"] as TaxonomyField;
var list = site.RootWeb.Lists["Custom List"];
list.Fields.Add(fieldAdded);
list.Update();
}
Referenzen[Bearbeiten | Quelltext bearbeiten]
Internetlinks[Bearbeiten | Quelltext bearbeiten]
|