Beispiel #1
0
 private void CreateTerm(ClientContext context, TermStore termStore, ShTerm shTerm, TermSetItem parentTerm)
 {
     var spTerm = termStore.GetTerm(shTerm.Id);
     context.Load(spTerm, t => t.Terms);
     context.ExecuteQuery();
     if (spTerm.ServerObjectIsNull != null && spTerm.ServerObjectIsNull.Value)
     {
         spTerm = parentTerm.CreateTerm(shTerm.Title, termStore.DefaultLanguage, shTerm.Id);
         if (!string.IsNullOrEmpty(shTerm.CustomSortOrder)) spTerm.CustomSortOrder = shTerm.CustomSortOrder;
         spTerm.IsAvailableForTagging = !shTerm.NotAvailableForTagging;
         foreach(var prop in shTerm.CustomProperties) {
             spTerm.SetCustomProperty(prop.Key, prop.Value);
         }
         foreach (var prop in shTerm.LocalCustomProperties)
         {
             spTerm.SetLocalCustomProperty(prop.Key, prop.Value);
         }
         context.Load(spTerm);
         context.ExecuteQuery();
     }
     foreach (ShTerm childTerm in shTerm.Terms)
     {
         CreateTerm(context, termStore, childTerm, spTerm);
     }
 }
Beispiel #2
0
        private void AddTermsToConfig(ClientContext context, TermSetItem spTerm, ShTermSetItem shTermSetItem)
        {
            context.Load(spTerm, t => t.Terms.Include(
                item => item.Id,
                item => item.IsAvailableForTagging,
                item => item.IsDeprecated,
                item => item.IsReused,
                item => item.Description,
                item => item.Name,
                item => item.LocalCustomProperties,
                item => item.Labels));
            context.ExecuteQuery();

            foreach (var spChildTerm in spTerm.Terms)
            {
                var shTerm = new ShTerm(spChildTerm.Id, spChildTerm.Name);
                foreach (var label in spChildTerm.Labels)
                {
                    shTerm.Labels.Add(new ShTermLabel
                    {
                        Language = label.Language,
                        Value = label.Value,
                        IsDefaultForLanguage = label.IsDefaultForLanguage
                    });
                }
                shTerm.LocalCustomProperties = spChildTerm.LocalCustomProperties;

                AddTermsToConfig(context, spChildTerm, shTerm);
                shTermSetItem.Terms.Add(shTerm);
            }
        }