private void Import(XmlElement termSetElement, TermGroup parentGroup) { string termSetName = termSetElement.GetAttribute("Name"); LoadWorkingLanguage(parentGroup.TermStore); TermSet termSet = null; ExceptionHandlingScope scope = new ExceptionHandlingScope(_ctx); using (scope.StartScope()) { using (scope.StartTry()) { termSet = parentGroup.TermSets.GetByName(termSetName); _ctx.Load(termSet); } using (scope.StartCatch()) { } } _ctx.ExecuteQuery(); if (termSet == null || termSet.ServerObjectIsNull == null || termSet.ServerObjectIsNull.Value) { _cmdlet.WriteVerbose(string.Format("Creating Term Set: {0}", termSetName)); int lcid = _workingLanguage; Guid id = Guid.NewGuid(); if (!string.IsNullOrEmpty(termSetElement.GetAttribute("Id"))) { id = new Guid(termSetElement.GetAttribute("Id")); } termSet = parentGroup.CreateTermSet(termSetName, id, lcid); if (!string.IsNullOrEmpty(termSetElement.GetAttribute("Contact"))) { termSet.Contact = termSetElement.GetAttribute("Contact"); } if (!string.IsNullOrEmpty(termSetElement.GetAttribute("Description"))) { termSet.Description = termSetElement.GetAttribute("Description"); } if (!string.IsNullOrEmpty(termSetElement.GetAttribute("CustomSortOrder"))) { termSet.CustomSortOrder = termSetElement.GetAttribute("CustomSortOrder"); } if (!string.IsNullOrEmpty(termSetElement.GetAttribute("IsAvailableForTagging"))) { termSet.IsAvailableForTagging = bool.Parse(termSetElement.GetAttribute("IsAvailableForTagging")); } if (!string.IsNullOrEmpty(termSetElement.GetAttribute("Owner"))) { termSet.Owner = termSetElement.GetAttribute("Owner"); } termSet.IsOpenForTermCreation = true; parentGroup.TermStore.CommitAll(); _ctx.Load(termSet); _ctx.ExecuteQuery(); } XmlNodeList stakeholderNodes = termSetElement.SelectNodes("./Stakeholders/Stakeholder"); if (stakeholderNodes != null && stakeholderNodes.Count > 0) { bool modified = false; foreach (XmlElement stakeholderElement in stakeholderNodes) { string stakeholder = stakeholderElement.GetAttribute("Value"); if (!termSet.Stakeholders.Contains(stakeholder)) { termSet.AddStakeholder(stakeholder); } } if (modified) { _ctx.ExecuteQuery(); } } XmlNodeList termsNodes = termSetElement.SelectNodes("./Terms/Term"); if (termsNodes != null && termsNodes.Count > 0) { foreach (XmlElement termElement in termsNodes) { Import(termElement, termSet); } } if (!string.IsNullOrEmpty(termSetElement.GetAttribute("IsOpenForTermCreation"))) { bool isOpenForTermCreation = bool.Parse(termSetElement.GetAttribute("IsOpenForTermCreation")); if (isOpenForTermCreation != termSet.IsOpenForTermCreation && termSet.Name != "Hashtags") { var orphanedTermsTermSet = termSet.TermStore.OrphanedTermsTermSet; termSet.Context.Load(orphanedTermsTermSet, o => o.Id); termSet.Context.ExecuteQuery(); if (orphanedTermsTermSet.Id != termSet.Id) { termSet.IsOpenForTermCreation = isOpenForTermCreation; termSet.Context.ExecuteQuery(); } } } _LocalNavTermSetId = termSet.Id; //Feature 152 }
public void AddStakeholder(string stakeHolderName) { m_termSet.AddStakeholder(stakeHolderName); }
public void AddStakeholder(string stakeholder) { _termSet.AddStakeholder(stakeholder); _termSet.Context.ExecuteQuery(); }