protected void checkAllButton_OnClick(object sender, EventArgs e) { TermCollection terms = teams.TermSet.Terms; recursivelyUpdateTeams(terms); teams.CommitAll(); }
/// <summary> /// Creates a new Subject Tag /// </summary> void CreateNewTag() { // It appears that a TaxonomySession will always run as the current user, even if elevated. // See: http://scle.me/1skLGCY var currentSiteGuid = SPContext.Current.Site.ID; var oldContext = HttpContext.Current; HttpContext.Current = null; SPSecurity.RunWithElevatedPrivileges(() => { using (SPSite elevatedSite = new SPSite(currentSiteGuid)) { WBTaxonomy wbTax = WBTaxonomy.GetSubjectTags(elevatedSite); _path = String.Concat(_path, "/", txtTagName.Text); Term rootSubjectTagTerm = wbTax.GetSelectedTermByPath(_path); // Try and get the tag, but don't auto create WBSubjectTag subjectTag = null; if (rootSubjectTagTerm != null) { lblValidationMessage.Text = "The term you are trying to create already exists"; } else { rootSubjectTagTerm = wbTax.GetSelectedTermByPath(_path, true); // Now create } if (rootSubjectTagTerm != null) { subjectTag = new WBSubjectTag(wbTax, rootSubjectTagTerm); if (subjectTag == null) { return; } subjectTag.PageContent = htmlDescription.Html; if (htmlExternalContact.Html.ToLower() != "<div> </div>") { subjectTag.ExternalContact = htmlExternalContact.Html; } SPUser pickedUser = ppInternalContact.WBxGetSingleResolvedUser(elevatedSite.RootWeb); if (pickedUser != null) { subjectTag.InternalContactLoginName = pickedUser.LoginName; } /*if (ppInternalContact.Entities != null && ppInternalContact.Entities.Count > 0) * { * PickerEntity pe = (PickerEntity)ppInternalContact.Entities[0]; * subjectTag.InternalContactLoginName = pe.DisplayText; * }*/ wbTax.CommitAll(); } else { lblValidationMessage.Text = "Your new tag could not be created, please contact support"; } } }); HttpContext.Current = oldContext; }