private string ReplaceRelativeURl(Match match) { string uri = match.Value.Substring(match.Value.IndexOf("\"") + 1); uri = uri.Substring(0, uri.IndexOf("\"")); var paramstring = uri.Substring(uri.LastIndexOf("?") + 1); var sep = new string[] { "&" }; string[] parameters = paramstring.Split(sep, StringSplitOptions.None); var paramNameValue = new Dictionary <string, string>(); foreach (var p in parameters) { var param = p.Split('='); paramNameValue.Add(param[0], param[1]); } var term = _termColl.Where(t => t.Id == Guid.Parse(paramNameValue["TermId"])).FirstOrDefault(); if (term != null) { var newUri = RuleExtensions.ToFileName(term.Name); return("/" + newUri); } else { _log.LogWarning("Couldn't resolve SharePoint Relative URL: {SpRelativeUrl} from the term store", match.Value); return(match.Value); } }
private static IList <Term> GetTermsForLabelInternal(TermStore termStore, Group termStoreGroup, TermSet termSet, string termLabel) { if (termStore == null) { throw new ArgumentNullException("termStore"); } if (termStoreGroup == null) { throw new ArgumentNullException("termStoreGroup"); } if (termSet == null) { throw new ArgumentNullException("termSet"); } if (string.IsNullOrEmpty(termLabel)) { throw new ArgumentNullException("termLabel"); } TermCollection termCollection = termSet.GetAllTerms(); return(termCollection.Where((term) => { return term.Labels.Any(label => label.Value == termLabel); }).ToList()); }
public static Guid GetKeyword(string label) { var keyword = keywords.Where(k => k.Name.ToLowerInvariant() == label.ToLowerInvariant()).SingleOrDefault(); if (keyword != null) { return(keyword.Id); } else { return(Guid.Empty); } }
private static Term GetTermByName(ClientContext ctx, string issueCategory) { TermStore store = ctx.Site.GetDefaultSiteCollectionTermStore(); TermSet termSet = store.GetTermSet("{3D4C7DE0-3867-44C3-871A-C36DEC4E1970}".ToGuid()); TermCollection terms = termSet.Terms; ctx.Load(terms); ctx.ExecuteQuery(); Term term = terms.Where(t => t.Name == issueCategory).FirstOrDefault(); return(term); }