コード例 #1
0
        public static string GetTermIdForTerm(string term, Guid termSetId, ClientContext clientContext)
        {
            string termId = string.Empty;

            //Get term set from ID
            TaxonomySession tSession = TaxonomySession.GetTaxonomySession(clientContext);
            TermStore       ts       = tSession.GetDefaultSiteCollectionTermStore();
            TermSet         tset     = ts.GetTermSet(termSetId);

            LabelMatchInformation lmi = new LabelMatchInformation(clientContext);

            lmi.Lcid            = 1033;
            lmi.TrimUnavailable = true;
            lmi.TermLabel       = term;

            //Search for matching terms in the term set based on label
            TermCollection termMatches = tset.GetTerms(lmi);

            clientContext.Load(tSession);
            clientContext.Load(ts);
            clientContext.Load(tset);
            clientContext.Load(termMatches);

            clientContext.ExecuteQuery();

            //Set term ID to first match
            if (termMatches != null && termMatches.Count() > 0)
            {
                termId = termMatches.First().Id.ToString();
            }

            return(termId);
        }
        public string WriteTerms(TermCollection terms)
        {
            var tabInt = 0;

            if (terms.Count > 0)
            {
                html += "\n<ul class=\"CustomSP2013GlobalNav\">\n";

                foreach (Term subTerm in terms)
                {
                    try
                    {
                        html += "<li class=\"\"><a class=\"dynamic\" tabindex=\"" + tabInt + "\" href=\"" + subTerm.LocalCustomProperties["_Sys_Nav_SimpleLinkUrl"] + "\">" + subTerm.Name + "</a>";
                        WriteTerms(subTerm.Terms);
                        html += "</li>\n";
                    }

                    catch
                    {
                        html += "<li class=\"\"><a  class=\"dynamic\" tabindex=\"" + tabInt + "\" href=\"#\">" + subTerm.Name + "</a>";
                        WriteTerms(subTerm.Terms);
                        html += "</li>\n";
                    }
                }

                html += "</ul>\n";
            }
            return(html);
        }
        public string writeTerms(TermCollection terms)
        {
            var tabInt = 0;

            if (terms.Count > 0)
            {
                //html += "\n<ul class=\"CustomSP2013GlobalNav\">\n";
                html += "\n<ul class=\"\">\n";

                foreach (Term subTerm in terms)
                {
                    try
                    {
                        html += "<li class=\"\"><a  tabindex=\"" + tabInt + "\" onclick=\"window.opener.location.href = this.href; return false;\" href=\"" + subTerm.LocalCustomProperties["_Sys_Nav_SimpleLinkUrl"] + "\">" + subTerm.Name + "</a>";
                        writeTerms(subTerm.Terms);
                        html += "</li>\n";
                    }

                    catch
                    {
                        html += "<li class=\"\"><a   tabindex=\"" + tabInt + "\" onclick=\"window.opener.location.href = this.href; return false;\" href=\"#\">" + subTerm.Name + "</a>";
                        writeTerms(subTerm.Terms);
                        html += "</li>\n";
                    }

                    //tabInt++;
                }

                html += "</ul>\n";
            }
            return(html);
        }
コード例 #4
0
        //GetItems
        //GetTaxanomy
        public List <SelectListItem> GetTaxanomy(ClientContext context)
        {
            List <SelectListItem> items    = new List <SelectListItem>();
            TermCollection        terms    = null;
            TaxonomySession       taxonomy = TaxonomySession.GetTaxonomySession(context);

            if (taxonomy != null)
            {
                TermStore termStore = taxonomy.GetDefaultKeywordsTermStore();
                if (termStore != null)
                {
                    TermGroup termGroup = termStore.Groups.GetByName(TERMGROUPNAME);
                    TermSet   termSet   = termGroup.TermSets.GetByName(TERMSETNAME);
                    terms = termSet.GetAllTerms();

                    context.Load(terms);
                    context.ExecuteQuery();

                    foreach (var term in terms)
                    {
                        items.Add(new SelectListItem {
                            Text = term.Name, Value = term.Id.ToString()
                        });
                    }
                }
            }
            return(items);
        }
コード例 #5
0
        private string addWorkBoxesForRecordsClasses(WBTaxonomy recordsTypes, TermCollection recordsClassesTerms)
        {
            if (recordsClassesTerms.Count == 0)
            {
                return("");
            }

//            string finalHtml = "<ul class=\"wbf-my-work-boxes-list wbf-records-classes\">\n";
            string finalHtml = "";

            foreach (Term recordsClassTerm in recordsClassesTerms)
            {
                string html = addWorkBoxesForRecordsClass(recordsTypes, recordsClassTerm.Terms);

                if (html != "" || ShowAllRecordsTypes)
                {
//                    html = "<li class=\"wbf-records-class\">\n" + recordsClassTerm.Name + "\n" + html + "</li>\n";
                    html       = "<tr><td colspan=\"5\" class=\"wbf-records-class\">\n" + recordsClassTerm.Name + "</td></tr>\n" + html;
                    finalHtml += html;
                }
            }

//            finalHtml += "</ul>\n";

            return(finalHtml);
        }
コード例 #6
0
        /// <summary>
        /// This extension method will give all the terms for a give path mentioned
        /// </summary>
        /// <param name="termSet">From which term set, we need to find a given term path</param>
        /// <param name="path">The path name to search</param>
        /// <param name="clientContext">The sharepoint client context object</param>
        /// <returns></returns>
        public static TermCollection GetTermsByPath(this TermSet termSet, String path, ClientContext clientContext)
        {
            TermCollection termCollection         = termSet.GetAllTerms();
            TermCollection termCollectionToReturn = null;

            clientContext.Load(termCollection,
                               tc => tc.Include(
                                   t => t.Name,
                                   t => t.PathOfTerm,
                                   t => t.TermsCount
                                   ));
            clientContext.ExecuteQuery();
            foreach (Term term in termCollection)
            {
                if (term.PathOfTerm == path)
                {
                    //Get all the terms under that path
                    if (term.TermsCount > 0)
                    {
                        termCollectionToReturn = term.LoadTerms(clientContext);
                    }
                }
            }
            return(termCollectionToReturn);
        }
コード例 #7
0
ファイル: XmlExport.cs プロジェクト: cntmnl/DEV-GIT
        private static void RecursiveTermManagement(XElement elt, TermCollection collectionTerm)
        {
            foreach (Term term in collectionTerm)
              {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Exporting XML Term [" + term.Name + "]");

            XElement __childEl = new XElement("Term", string.Empty);
            __childEl.Add(new XAttribute("name", term.Name));
            __childEl.Add(new XAttribute("id", term.Id));
            __childEl.Add(new XAttribute("language", term.TermSet.Group.TermStore.Languages[0]));

            foreach (Label lbl in term.Labels)
            {
              XElement __labelEl = new XElement("Label", string.Empty);
              __labelEl.Add(new XAttribute("name", lbl.Value));
              __labelEl.Add(new XAttribute("language", lbl.Language));
              __labelEl.Add(new XAttribute("isdefault", lbl.IsDefaultForLanguage));
              __childEl.Add(__labelEl);
            }

            elt.Add(__childEl);

            if (term.TermsCount > 0)
              XmlExport.RecursiveTermManagement(__childEl, term.Terms);
              }
        }
コード例 #8
0
        public static void CreateNewOrder(ClientContext ctx, Order order)
        {
            List     list = ctx.Web.GetListByTitle("Customer Orders");
            ListItem item = list.AddItem(new ListItemCreationInformation());

            item["SW_Customer"]    = order.Customer;
            item["SW_AmountMoney"] = order.Amount;
            item.Update();

            TermCollection termCollection = OrderListHelper.GetTaxonomyTermSet(ctx);
            List <KeyValuePair <Guid, String> > products_ordered = new List <KeyValuePair <Guid, string> >();

            foreach (var termItem in termCollection)
            {
                foreach (var productItem in order.Products)
                {
                    if (termItem.Name.ToString() == productItem)
                    {
                        products_ordered.Add(new KeyValuePair <Guid, string>(termItem.Id, termItem.Name.ToString()));
                    }
                }
            }
            item.SetTaxonomyFieldValues("{854C4414-A6AB-46B2-A18B-D8BD4C46E960}".ToGuid(), products_ordered);

            ctx.ExecuteQuery();
        }
コード例 #9
0
 private void ProcessTerms(ClientContext context, TermCollection terms, int indentLevel)
 {
     if (terms != null && terms.Count > 0)
     {
         WriteOutput("<Terms>");
         foreach (var term in terms)
         {
             context.Load(term,
                          t => t.Id,
                          t => t.Name,
                          t => t.TermSet.Id,
                          t => t.TermSet.Name,
                          t => t.TermSet.Group.Id,
                          t => t.TermSet.Group.Name
                          );
             context.ExecuteQueryRetry();
             WriteOutput(string.Format("<Term Name=\"{0}\" Id=\"{1}\"></Term>", term.Name, term.Id));
             context.Load(term.Terms);
             context.ExecuteQueryRetry();
             if (term.Terms != null && term.Terms.Count > 0)
             {
                 ProcessTerms(context, term.Terms, (indentLevel + 1));
             }
         }
         WriteOutput("</Terms>");
     }
 }
コード例 #10
0
        public SpRulesDataSet Import()
        {
            try
            {
                var data = new SpRulesDataSet();

                using (var spClientContext = CreateClientContext(_appSettings))
                {
                    _termColl = initTermCollection(spClientContext);
                    LoadCategories(data, spClientContext);
                    LoadPages(data, spClientContext);
                    CullEmptyCategories(data);
                    ScrapeHomePage(data).GetAwaiter().GetResult();
                    ScrapeCategoryPages(data).GetAwaiter().GetResult();
                    ScrapeCategoryPages(data, true).GetAwaiter().GetResult();
                    LoadUrlTerms(data, spClientContext);
                }
                return(data);
            }
            catch (Exception ex)
            {
                _log.LogError(ex, "error importing from sharepoint");
                throw;
            }
        }
コード例 #11
0
        public AweCsomeTag Search(TaxonomyTypes taxonomyType, string termSetName, string groupName, string query)
        {
            GetTermSet(taxonomyType, termSetName, groupName, false, out TermStore termStore, out TermSet termSet);
            TermCollection allTerms = termSet.Terms;

            _clientContext.Load(termSet, q => q.Name);
            _clientContext.Load(allTerms);
            _clientContext.ExecuteQuery();
            var rootTag = new AweCsomeTag
            {
                Children      = new List <AweCsomeTag>(),
                Name          = termSet.Name,
                Id            = termSet.Id,
                TermStoreName = termStore.Name
            };

            foreach (var term in allTerms)
            {
                rootTag.Children.Add(GetTermChildren(term, rootTag));
            }
            if (query != null)
            {
                SearchInsideTaxonomy(rootTag, query);
            }

            return(rootTag);
        }
コード例 #12
0
 private void ProcessTerms(ClientContext context, TermCollection terms, int indentLevel)
 {
     if (terms != null && terms.Count > 0)
     {
         foreach (var term in terms)
         {
             context.Load(term,
                          t => t.Id,
                          t => t.Name,
                          t => t.TermSet.Id,
                          t => t.TermSet.Name,
                          t => t.TermSet.Group.Id,
                          t => t.TermSet.Group.Name
                          );
             context.ExecuteQueryRetry();
             WriteOutput(string.Format("{0},{1},{2},{3},{4}{5},{6}",
                                       term.TermSet.Group.Name,
                                       term.TermSet.Group.Id,
                                       term.TermSet.Name,
                                       term.TermSet.Id,
                                       string.Format("{0}", new String(',', (indentLevel * 2))),
                                       term.Name,
                                       term.Id
                                       ));
             context.Load(term.Terms);
             context.ExecuteQueryRetry();
             if (term.Terms != null && term.Terms.Count > 0)
             {
                 ProcessTerms(context, term.Terms, (indentLevel + 1));
             }
         }
     }
 }
コード例 #13
0
        public HtmlTextWriter buildItems(HtmlTextWriter writer, TermCollection terms)
        {
            //TermSet termSet = navTerms.GetTaxonomyTermSet();

            //if (navTerms.IsNavigationTermSet)
            if (terms.Count > 0)
            {
                Level++;

                foreach (var term in terms)
                {
                    try
                    {
                        var navTerm = NavigationTerm.GetAsResolvedByWeb(term, Site.OpenWeb(),
                                                                        StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);
                        if (navTerm.ExcludeFromGlobalNavigation)
                        {
                            continue;
                        }

                        buildItem(writer, navTerm);
                    }
                    catch (Exception)
                    {
                    }
                }
                Level--;
            }
            return(writer);
        }
コード例 #14
0
        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());
        }
コード例 #15
0
        /// <summary>
        /// Updates a single-value managed metatada column
        /// </summary>
        /// <param name="taxonomyTerm"></param>
        /// <param name="item"></param>
        /// <param name="fieldToUpdate"></param>
        public static void UpdateMMField(string taxonomyTerm, SPListItem item, string fieldToUpdate)
        {
            //Get the metadata taxonomy field, a taxonomy session, the term store, and a collection of term sets in the store
            TaxonomyField   managedMetadataField = item.ParentList.Fields[fieldToUpdate] as TaxonomyField;
            Guid            tsId        = managedMetadataField.TermSetId;
            Guid            termStoreId = managedMetadataField.SspId;
            TaxonomySession tSession    = new TaxonomySession(item.ParentList.ParentWeb.Site);
            TermStore       tStore      = tSession.TermStores[termStoreId];
            TermSet         tSet        = tStore.GetTermSet(tsId);
            TermCollection  terms       = tSet.GetTerms(taxonomyTerm, false);
            Term            term        = null;

            //If term doesn't exist, create it in the term store
            if (terms.Count == 0)
            {
                Console.WriteLine("Creating term in managed metadata, {0}", taxonomyTerm);
                term = tSet.CreateTerm(taxonomyTerm, tStore.Languages[0]);
                tStore.CommitAll();
            }
            else
            {
                term = terms[0];
            }

            //Set the managed metadata field to the term retrieved from the term store
            managedMetadataField.SetFieldValue(item, term);
            item.Update();
        }
コード例 #16
0
        /// <summary>
        /// This method will check if the term exists and if it exists, it will return the reference to that term
        /// </summary>
        /// <param name="termSet">The term set underwhich, the term exists check will happen</param>
        /// <param name="clientContext">The sharepoint client context object</param>
        /// <param name="path">The term path under which we need to check for a term existence</param>
        /// <param name="termNameToRetrieve">The term that needs to be retrieved from a given term</param>
        /// <param name="term">The term reference that will be returned back to the caller</param>
        /// <returns></returns>
        public static bool TermExists(this TermSet termSet, ClientContext clientContext, string termNameToRetrieve, ref Term term)
        {
            TermCollection termCollection = termSet.GetAllTerms();

            clientContext.Load(termCollection,
                               tc => tc.Include(
                                   t => t.Name,
                                   t => t.PathOfTerm,
                                   t => t.TermsCount,
                                   t => t.Parent.Name

                                   ));
            clientContext.ExecuteQuery();
            foreach (Term currentTerm in termCollection)
            {
                string pathOfTerm = currentTerm.PathOfTerm;
                //ClientResult<string> pathOfTerm = currentTerm.GetPath(1033);
                if (currentTerm.Name.ToLower() == termNameToRetrieve.ToLower())
                {
                    term = currentTerm;
                    return(true);
                }
            }
            return(false);
        }
コード例 #17
0
ファイル: SchoolHelper.cs プロジェクト: spdavid/SP2016
        internal static List <SelectListItem> getTaxItems(ClientContext ctx)
        {
            List <SelectListItem> items = new List <SelectListItem>();

            TermStore      store = ctx.Site.GetDefaultKeywordsTermStore();
            TermSet        tset  = store.GetTermSet("{3D4C7DE0-3867-44C3-871A-C36DEC4E1970}".ToGuid());
            TermCollection terms = tset.Terms;

            ctx.Load(terms);
            ctx.Load(terms, tms => tms.Include(l => l.Labels));

            ctx.ExecuteQuery();

            foreach (Term t in terms)
            {
                SelectListItem item = new SelectListItem();

                item.Value = t.Id.ToString();
                item.Text  = t.Labels.Where(l => l.Language == 1033).FirstOrDefault().Value;
                items.Add(item);
            }


            return(items);
        }
コード例 #18
0
        /// <summary>
        /// Initializing Client List By Loading TermGroup
        /// </summary>
        /// <param name="clientContext">Client Context</param>
        /// <param name="termGroup">Term Group</param>
        /// <param name="termSetName">Term Store</param>
        /// <returns>Client List</returns>
        public static List <Client> IntializeClientObject(ClientContext clientContext, TermGroup termGroup, string termSetName)
        {
            Client         client;
            List <Client>  clients  = new List <Client>();
            TermSet        termSet  = termGroup.TermSets.GetByName(termSetName);
            TermCollection termColl = termSet.Terms;

            clientContext.Load(termColl);
            // Execute the query to the server
            clientContext.ExecuteQuery();
            foreach (Term term in termColl)
            {
                client      = new Client();
                client.Name = term.Name;
                foreach (KeyValuePair <string, string> termProperty in term.CustomProperties)
                {
                    if (termProperty.Key.Equals(Constants.URLDictKey))
                    {
                        client.Url = termProperty.Value;
                    }
                }
                clients.Add(client);
            }
            return(clients);
        }
コード例 #19
0
 public static Term GetByName(this TermCollection termSets, string name)
 {
     if (String.IsNullOrEmpty(name))
     {
         throw new ArgumentException("Term set name cannot be empty", "name");
     }
     return(termSets.SingleOrDefault(termSet => string.Equals(termSet.Name, name)));
 }
コード例 #20
0
ファイル: TeamManagement.aspx.cs プロジェクト: OliSharpe/wbf
        protected void checkAllButton_OnClick(object sender, EventArgs e)
        {
            TermCollection terms = teams.TermSet.Terms;

            recursivelyUpdateTeams(terms);

            teams.CommitAll();
        }
コード例 #21
0
        public string writeTerms(TermCollection terms)
        {
            if (terms.Count > 0)
            {
                html += "\n<ul class=\"GlobalNav\">\n";
                foreach (Term subTerm in terms)
                {
                    String hoverText = "";
                    String hyperLink = "";
                    String imgURL    = "";
                    try
                    {
                        hoverText = (subTerm.LocalCustomProperties["_Sys_Nav_HoverText"] != null) ? subTerm.LocalCustomProperties["_Sys_Nav_HoverText"] : "";
                    }
                    catch
                    {
                        hoverText = "";
                    }
                    if (subTerm.CustomProperties.TryGetValue("imgURL", out imgURL))
                    {
                        try
                        {
                            hyperLink = (subTerm.LocalCustomProperties["_Sys_Nav_SimpleLinkUrl"] != null) ? subTerm.LocalCustomProperties["_Sys_Nav_SimpleLinkUrl"] : "#";
                            html     += "<li><a href=\"" + hyperLink + "\" " + "title=\"" + hoverText + "\">" + "<img src=\"" + imgURL + "\" alt=\"" + subTerm.Name + "\" height=\"150\" width=\"150\"></a>";
                            writeTerms(subTerm.Terms);
                            html += "</li>\n";
                        }
                        catch
                        {
                            html += "<li><a href=\"#\">" + subTerm.Name + "</a>";
                            writeTerms(subTerm.Terms);
                            html += "</li>\n";
                        }
                    }
                    else
                    {
                        try
                        {
                            hyperLink = (subTerm.LocalCustomProperties["_Sys_Nav_SimpleLinkUrl"] != null) ? subTerm.LocalCustomProperties["_Sys_Nav_SimpleLinkUrl"] : "#";
                            html     += "<li><a href=\"" + hyperLink + "\" " + "title=\"" + hoverText + "\">" + subTerm.Name + "</a>";
                            writeTerms(subTerm.Terms);
                            html += "</li>\n";
                        }

                        catch
                        {
                            html += "<li><a href=\"#\">" + subTerm.Name + "</a>";
                            writeTerms(subTerm.Terms);
                            html += "</li>\n";
                        }
                    }
                }

                html += "</ul>\n";
            }
            return(html);
        }
コード例 #22
0
        public ActionResult BuyAuctions()
        {
            var model = new SearchAdvertisementViewModel();

            model.FilterList.Add(new SelectListItem {
                Value = "PriceAsc", Text = "Pris (Stigande)"
            });
            model.FilterList.Add(new SelectListItem {
                Value = "PriceDesc", Text = "Pris (Fallande)"
            });
            model.FilterList.Add(new SelectListItem {
                Value = "DateAsc", Text = "Datum (Stigande)"
            });
            model.FilterList.Add(new SelectListItem {
                Value = "DateDesc", Text = "Datum (Fallande)"
            });


            SharePointContext spContext = Session["SpContext"] as SharePointContext;

            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                TaxonomySession taxonomySession = TaxonomySession.GetTaxonomySession(clientContext);

                if (taxonomySession != null)
                {
                    TermStore           termStore    = taxonomySession.GetDefaultSiteCollectionTermStore();
                    TermGroupCollection termGroupCol = termStore.Groups;
                    clientContext.Load(termGroupCol, t => t.Where(y => y.Name == "Advertisements"));
                    clientContext.ExecuteQuery();

                    TermGroup termGroup = termGroupCol.FirstOrDefault();
                    if (termGroup != null)
                    {
                        TermSet        termSet = termGroup.TermSets.GetByName("Categories");
                        TermCollection terms   = termSet.GetAllTerms();
                        clientContext.Load(termSet);
                        clientContext.Load(terms);
                        clientContext.ExecuteQuery();

                        foreach (Term term in terms)
                        {
                            SelectListItem newItem = new SelectListItem {
                                Value = term.Name, Text = term.Name
                            };
                            model.CategoryList.Add(newItem);
                        }
                    }
                }
            }

            model.CategoryList.OrderBy(x => x.Text);
            model.CategoryList.Insert(0, new SelectListItem {
                Value = "Alla", Text = "Alla"
            });
            return(View(model));
        }
コード例 #23
0
        // Update the objects in the Taxonomy TermSet to match the objects specified
        // in the TermSetGoal object that was read from the XML file.
        static void SyncTermSet(TermSet termSet, TermSetGoal termSetGoal)
        {
            // Load the tree of terms as a flat list.
            Log("Loading terms...");
            TermCollection allTerms = termSet.GetAllTerms();

            Program.clientContext.Load(allTerms,
                                       allTermsArg => allTermsArg.Include(Program.termRetrievals)
                                       );

            Program.ExecuteQuery(); // WCF CALL #2

            Program.itemsById = new Dictionary <Guid, Wrapper>();
            Wrapper termSetWrapper = new Wrapper(termSet, termSet.Id, Guid.Empty, termSet.Name);

            Program.itemsById.Add(termSetWrapper.Id, termSetWrapper);

            foreach (Term term in allTerms)
            {
                Guid parentItemId = termSet.Id;
                if (!term.Parent.ServerObjectIsNull.Value)
                {
                    parentItemId = term.Parent.Id;
                }
                Program.itemsById.Add(term.Id, new Wrapper(term, term.Id, parentItemId, term.Name));
            }

            foreach (Wrapper wrapper in Program.itemsById.Values)
            {
                if (wrapper != termSetWrapper)
                {
                    Program.itemsById[wrapper.ParentId].ChildTerms.Add(wrapper);
                }
            }

            Log("Step 1: Adds and Moves");
            ProcessAddsAndMoves(termSetWrapper, termSetGoal);

            Log("Step 2: Deletes");
            ProcessDeletes(termSetWrapper, termSetGoal); // Step 2

            Log("Step 3: Property Updates");

            Log("Querying auxiliary data");
            foreach (Wrapper wrapper in Program.itemsById.Values)
            {
                if (wrapper != termSetWrapper)
                {
                    wrapper.TermDescription = ((Term)wrapper.Item).GetDescription(Program.lcid);
                }
            }
            Program.ExecuteQuery();                              // WCF CALL #3

            ProcessPropertyUpdates(termSetWrapper, termSetGoal); // Step 3
            Program.ExecuteQuery();                              // WCF CALL #4
        }
コード例 #24
0
        public TermCollectionInstance(ObjectInstance prototype, TermCollection termCollection)
            : this(prototype)
        {
            if (termCollection == null)
            {
                throw new ArgumentNullException("termCollection");
            }

            m_termCollection = termCollection;
        }
コード例 #25
0
        private string GetTermIdForTaxonomyField(TaxonomyField field, string term, ListItem pendingItem, Microsoft.SharePoint.Client.File pendingFile)
        {
            if (_terms == null)
            {
                _terms = new Dictionary <string, IDictionary <string, string> >();
            }

            if (!_terms.Keys.Contains(field.Title))
            {
                _terms[field.Title] = new Dictionary <string, string>();
            }

            if (_terms[field.Title].Keys.Contains(term))
            {
                return(_terms[field.Title][term].ToString());
            }

            var termId = string.Empty;

            //before we go forward,save pending item
            pendingItem.Update();
            ctx.Load(pendingFile);
            ctx.ExecuteQuery();

            TaxonomySession tSession = TaxonomySession.GetTaxonomySession(ctx);

            ctx.Load(tSession.TermStores);
            ctx.ExecuteQuery();
            TermStore ts   = tSession.TermStores.First();
            TermSet   tset = ts.GetTermSet(field.TermSetId);

            LabelMatchInformation lmi = new LabelMatchInformation(ctx);

            lmi.Lcid            = 1033;
            lmi.TrimUnavailable = true;
            lmi.TermLabel       = term;

            TermCollection termMatches = tset.GetTerms(lmi);

            ctx.Load(tSession);
            ctx.Load(ts);
            ctx.Load(tset);
            ctx.Load(termMatches);

            ctx.ExecuteQuery();

            if (termMatches != null && termMatches.Count() > 0)
            {
                termId = termMatches.First().Id.ToString();
            }

            _terms[field.Title][term] = termId;

            return(termId);
        }
コード例 #26
0
		private static List<Product> ParceProducts(TermCollection tc) {
			List<Product> ret = new List<Product>();
			foreach(Term term in tc) {
				Product p = new Product() {
					Guid = term.Id.ToString(),
					Label = term.Name
				};
				ret.Add(p);
			}
			return ret;
		}
コード例 #27
0
        private void PopulateListView(WBTaxonomy teams, TermCollection terms)
        {
            Literal literal = new Literal();

            string html = ""; // tempStyling();

            html += addChildTeamsFromTerms(teams, terms);

            literal.Text = html;

            this.Controls.Add(literal);
        }
コード例 #28
0
ファイル: TeamManagement.aspx.cs プロジェクト: OliSharpe/wbf
        private void recursivelyUpdateTeams(TermCollection terms)
        {
            foreach (Term term in terms)
            {
                WBTeam team = new WBTeam(teams, term);

                team.IndividualCommit = false;
                team.Update();

                recursivelyUpdateTeams(term.Terms);
            }
        }
コード例 #29
0
        public static TermCollection GetTaxonomyTermSet(ClientContext ctx)
        {
            TermStore      store          = ctx.Site.GetDefaultSiteCollectionTermStore();
            TermGroup      group          = store.GetTermGroupByName("Luis");
            TermSet        termSet        = group.TermSets.GetByName("Products");
            TermCollection TermCollection = termSet.Terms;

            ctx.Load(TermCollection);
            ctx.ExecuteQuery();

            return(TermCollection);
        }
コード例 #30
0
        private TermCollection initTermCollection(ClientContext ctx)
        {
            TaxonomySession taxonomySession = TaxonomySession.GetTaxonomySession(ctx);
            TermStore       termStore       = taxonomySession.TermStores.GetByName("Managed Metadata Service");
            TermGroup       termGroup       = termStore.Groups.GetByName("Site Collection - rules.ssw.com.au");
            TermSet         termSet         = termGroup.TermSets.GetByName("Home Navigation");
            TermCollection  termColl        = termSet.Terms;

            ctx.Load(termColl);
            ctx.ExecuteQuery();
            return(termColl);
        }
コード例 #31
0
        public TermSetLookup(TaxonomyField taxonomyField, TermSet termSet)
        {
            this.taxonomyField = taxonomyField;
            this.terms         = termSet.GetAllTerms();

            Program.clientContext.Load(this.terms,
                                       termsArg => termsArg.Include(
                                           termArg => termArg.Id,
                                           termArg => termArg.Name
                                           )
                                       );
        }
コード例 #32
0
ファイル: WBRecordsManager.cs プロジェクト: OliSharpe/wbf
        internal void PopulateWithFunctionalAreas(WBLocationTreeState treeState, TreeNodeCollection treeNodeCollection, String viewMode, WBTermCollection <WBTerm> teamFunctionalAreas)
        {
            bool expandNodes = true;

            if (teamFunctionalAreas.Count > 2)
            {
                expandNodes = false;
            }

            List <WBTerm> sortedTerms = new List <WBTerm>();

            foreach (WBTerm term in teamFunctionalAreas)
            {
                sortedTerms.Add(term);
            }
            sortedTerms = sortedTerms.OrderBy(o => o.Name).ToList();

            foreach (WBTerm functionalArea in sortedTerms)
            {
                SPFolder folder = null;

                if (viewMode != VIEW_MODE__NEW)
                {
                    folder = this.Libraries.GetMasterFolderByPath(functionalArea.Name);

                    if (folder == null)
                    {
                        WBLogging.Debug("Couldn't find folder for functional area: " + functionalArea.Name);
                        continue;
                    }
                }
                else
                {
                    WBLogging.Debug("View mode = " + viewMode);
                }


                WBFunctionalAreaTreeNode functionalAreaTreeNode = new WBFunctionalAreaTreeNode(functionalArea, folder);
                TreeNode node = functionalAreaTreeNode.AsTreeNode();

                node.Expanded         = expandNodes;
                node.PopulateOnDemand = false;
                node.SelectAction     = TreeNodeSelectAction.Expand;

                treeNodeCollection.Add(node);

                WBTaxonomy     recordsTypes = this.RecordsTypesTaxonomy;
                TermCollection terms        = recordsTypes.TermSet.Terms;

                PopulateWithRecordsTypes(treeState, node.ChildNodes, viewMode, folder, functionalArea, recordsTypes, terms);
            }
        }
コード例 #33
0
 private void AddTerms(TermCollection _termCollection,bool isroot)
 {
     LogHelper.Log("Isroot:" + isroot);
     if (_termCollection.Count() > 0)
     {                
         foreach (var t in _termCollection)
         {
             if (t.CustomProperties.ContainsKey(Constants.AutoTaggable))//redundant in case the whole termset is loaded but no other way
             {
                 AddLabels(t); // in case of termset.
                 if(!isroot && t.Terms.Count > 0) // in case of subterm
                 {
                     
                     foreach(var tt in t.Terms)
                     {
                         if(tt.CustomProperties.ContainsKey(Constants.AutoTaggable))
                         {
                             
                             AddLabels(tt);
                         }
                     }
                 }
             }
             else
             {
                 if (!isroot && t.Terms.Count > 0)
                 {                            
                     foreach (var tt in t.Terms)
                     {
                         if (tt.CustomProperties.ContainsKey(Constants.AutoTaggable))
                         {
                             AddLabels(tt);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #34
0
        public TaxonomyTerms(ClientContext ctx, string TermSetId,Guid AnchorId)
        {
            
            bool IsRootTerm = false;
            LogHelper.Log("Inside TaxonomyTerms termsetid:" + TermSetId);
            CurrentContext = ctx;
            _TermsDictionary = new Dictionary<TermKey, string>();
            var _taxSession = TaxonomySession.GetTaxonomySession(CurrentContext);
            
            var _termStore = _taxSession.GetDefaultSiteCollectionTermStore();
            
            var _termSet = _termStore.GetTermSet(new Guid(TermSetId));
            TermCollection _termCollection=null;

            
            if(AnchorId == Guid.Empty)
            {
                CustomPropertyMatchInformation match = new CustomPropertyMatchInformation(ctx);
                match.CustomPropertyName = Constants.AutoTaggable;
                match.CustomPropertyValue = "1";
                match.TrimUnavailable = true;
                match.StringMatchOption = StringMatchOption.ExactMatch;
                _termCollection = _termSet.GetTermsWithCustomProperty(match);
                CurrentContext.Load(_termCollection,
                terms => terms.Include(
                     tt => tt.Id, tt => tt.Labels), terms => terms.Include(tt => tt.CustomProperties));
                IsRootTerm = true;
            }
            else
            {
                //No way to match a property when taking terms of a term. The CustomPropertyMatch...only works when
                //getting terms from a _termSet. Tried to deal with LoadQuery but no way to query terms based on their properties
                var _targetTerm = _termSet.GetTerm(AnchorId);
                _termCollection = _targetTerm.Terms;
                CurrentContext.Load(_termCollection,
                terms => terms.Include(
                     tt => tt.Id, tt => tt.Labels,
                     tt => tt.CustomProperties,
                     tt=>tt.Terms,tt=>tt.Terms.Include(ttt=>ttt.Labels)));
            }
            if (keywords == null || (DateTime.Now - LastRefreshedKeywords).Minutes > Constants.KeywordIntervalRefresh)
            {
                lock (locker)
                {
                    if (keywords == null || (DateTime.Now - LastRefreshedKeywords).Minutes > Constants.KeywordIntervalRefresh)
                    {
                        keywords = _taxSession.GetDefaultKeywordsTermStore().KeywordsTermSet.GetAllTerms();
                        ctx.Load(keywords);
                        CurrentContext.ExecuteQuery();
                        LastRefreshedKeywords = DateTime.Now;
                        LogHelper.Log("Refreshed the keyword list",LogSeverity.Error);
                    }
                }
            }
            else
            {
                CurrentContext.ExecuteQuery();
            }
            
            LogHelper.Log("Inside TaxonomyTerms " + _termCollection.Count);
            AddTerms(_termCollection, IsRootTerm);
        }
コード例 #35
0
        private void CreateStackOTerms(Stack<Tuple<string, Guid>> rowStack, TermCollection allTerms, TermSet termSet)
        {
            var arrayStack = rowStack.ToArray();
               for(int x = 0; x < arrayStack.Length; ++x)
            {
                var currentItem = arrayStack[x];
                if(currentItem.Item2 == Guid.Empty)
                {
                    var newGuid = Guid.NewGuid();
                    if (x != 0)
                    {
                        var previousTermId = arrayStack[x - 1].Item2;
                        var previousTerm = allTerms.FirstOrDefault(o=>o.Id == previousTermId);
                        //termSet.Context.Load(previousTerm);

                        if (previousTerm.IsReused && previousTerm.IsSourceTerm == false)
                        {
                            // get term
                            var sourceTerm = previousTerm.SourceTerm;
                            termSet.Context.Load(sourceTerm, sc=>sc.Id, sc => sc.Terms, sc => sc.Terms.Include(t => t.Name, t => t.Id));
                            termSet.Context.ExecuteQuery();

                            var sourceNewTerm = sourceTerm.Terms.FirstOrDefault(trm => trm.Name == currentItem.Item1);

                            // not in the original either
                            if (sourceNewTerm == null)
                            {
                                // add new term
                                var newTerm = sourceTerm.CreateTerm(currentItem.Item1, 1033, newGuid);
                                // reuse it in the term-set we are iterating
                                previousTerm.ReuseTerm(newTerm, false);
                            }
                            else{
                                previousTerm.ReuseTerm(sourceNewTerm, false);
                                newGuid = sourceNewTerm.Id;
                            }

                        }
                        else
                        {
                            previousTerm.CreateTerm(currentItem.Item1, 1033, newGuid);
                        }

                    }
                    else
                    {
                        // Create a new term at the root of the termset
                        termSet.CreateTerm(currentItem.Item1, 1033, newGuid);
                    }
                    arrayStack[x] = Tuple.Create(currentItem.Item1, newGuid);

                    allTerms = termSet.GetAllTerms();
                    termSet.Context.Load(allTerms, ax => ax.Include(t => t.Terms, t => t.PathOfTerm, t => t.IsReused, t => t.SourceTerm, t => t.IsSourceTerm, t => t.IsPinned, t => t.Name, t => t.Id, t => t.Parent, t => t.PathOfTerm, t => t.Parent.Name, t => t.Parent.Id));
                    termSet.Context.ExecuteQuery();

                }
            }
        }
コード例 #36
0
 private void ProcessTerms(ClientContext context, TermCollection terms, int indentLevel)
 {
     if (terms != null && terms.Count > 0)
     {
         foreach (var term in terms)
         {
             context.Load(term,
                 t => t.Id,
                 t => t.Name,
                 t => t.TermSet.Id,
                 t => t.TermSet.Name,
                 t => t.TermSet.Group.Id,
                 t => t.TermSet.Group.Name
                 );
             context.ExecuteQueryRetry();
             WriteOutput(string.Format("{0},{1},{2},{3},{4}{5},{6}",
                          term.TermSet.Group.Name,
                          term.TermSet.Group.Id,
                          term.TermSet.Name,
                          term.TermSet.Id,
                          string.Format("{0}", new String(',', (indentLevel * 2))),
                          term.Name,
                          term.Id
                          ));
             context.Load(term.Terms);
             context.ExecuteQueryRetry();
             if (term.Terms != null && term.Terms.Count > 0)
             {
                 ProcessTerms(context, term.Terms, (indentLevel + 1));
             }
         }
     }
 }
コード例 #37
0
ファイル: Program.cs プロジェクト: chrisdee/Solutions
        public TermSetLookup(TaxonomyField taxonomyField, TermSet termSet)
        {
            this.taxonomyField = taxonomyField;
            this.terms = termSet.GetAllTerms();

            Program.clientContext.Load(this.terms,
              termsArg => termsArg.Include(
                termArg => termArg.Id,
                termArg => termArg.Name
              )
            );
        }
コード例 #38
0
ファイル: Taxonomy.cs プロジェクト: Microsoft/mattercenter
        /// <summary>
        /// This method will get all client term properties such as ID and URL
        /// </summary>
        /// <param name="termColl">The taxonomy client terms</param>
        /// <param name="termStoreDetails">The term store details which the UI has sent to the clients</param>
        /// <param name="clientTermSet">The ClientTermSets object to which all the client terms are added</param>
        /// <returns></returns>
        private ClientTermSets GetClientTermProperties(TermCollection termColl, TermStoreDetails termStoreDetails, ClientTermSets clientTermSet)
        {
            try
            {
                foreach (Term term in termColl)
                {
                    Client tempTermPG = new Client();
                    tempTermPG.Name = term.Name;
                    if (term.CustomProperties.Count > 0)
                    {
                        tempTermPG.Url = string.Empty;
                        tempTermPG.Id = string.Empty;
                        foreach (KeyValuePair<string, string> customProperty in term.CustomProperties)
                        {
                            if (customProperty.Key.Equals(termStoreDetails.CustomPropertyName, StringComparison.Ordinal))
                            {
                                tempTermPG.Url = customProperty.Value;
                            }

                            if (customProperty.Key.Equals(taxonomySettings.ClientCustomPropertiesId, StringComparison.Ordinal))
                            {
                                tempTermPG.Id = customProperty.Value;
                            }
                        }
                    }
                    if(!string.IsNullOrWhiteSpace(tempTermPG.Id) && !string.IsNullOrWhiteSpace(tempTermPG.Url))
                    {
                        clientTermSet.ClientTerms.Add(tempTermPG);
                    }                    
                }
                return clientTermSet;
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
コード例 #39
0
 /// <summary>
 /// Method to get client terms
 /// </summary>
 /// <param name="clientDetails">client term sets</param>
 /// <param name="clientIdProperty">client id property</param>
 /// <param name="clientUrlProperty">client url property</param>
 /// <param name="fillteredTerms">term collection</param>
 private static void GetClientTerms(ClientTermSets clientDetails, string clientIdProperty, string clientUrlProperty, TermCollection fillteredTerms)
 {
     Client client;
     foreach (Term term in fillteredTerms)
     {
         if (term.CustomProperties.ContainsKey(clientIdProperty) && term.CustomProperties.ContainsKey(clientUrlProperty))
         {
             client = new Client();
             client.ClientName = term.Name;
             client.ClientId = term.CustomProperties[clientIdProperty];
             client.ClientUrl = term.CustomProperties[clientUrlProperty];
             clientDetails.ClientTerms.Add(client);
         }
     }
 }
コード例 #40
0
        /// <summary>
        /// Method to get client term sets
        /// </summary>
        /// <param name="fillteredTerms">term collection</param>
        /// <param name="clientIdProperty">client id property</param>
        /// <param name="clientPropertyName">client property name</param>
        /// <returns>returns client term sets</returns>
        private static ClientTermSets GetClientTermSets(TermCollection fillteredTerms, string clientIdProperty, string clientPropertyName)
        {
            ClientTermSets clientDetails = new ClientTermSets();
            clientDetails.ClientTerms = new List<Client>();

            foreach (Term term in fillteredTerms)
            {
                if (term.CustomProperties.ContainsKey(clientIdProperty) && term.CustomProperties.ContainsKey(clientPropertyName))
                {
                    Client client = new Client();
                    client.ClientName = term.Name;
                    client.ClientId = term.CustomProperties[clientIdProperty];
                    client.ClientUrl = term.CustomProperties[clientPropertyName];
                    clientDetails.ClientTerms.Add(client);
                }
            }
            return clientDetails;
        }
コード例 #41
0
ファイル: ExcelExport.cs プロジェクト: cntmnl/DEV-GIT
        private static void RecursiveRowManagement(int level, Worksheet sheet, TermCollection collectionTerm)
        {
            foreach (Term term in collectionTerm)
              {
            WorksheetRow row = sheet.Table.Rows.Add();

            for (int i = 0; i < level; i++)
            {
              row.Cells.Add("");
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Exporting XLS Term [" + term.Name + "]");

            foreach (Label lbl in term.Labels)
            {
              row.Cells.Add(lbl.Value);
              row.Cells.Add(new WorksheetCell(lbl.Language.ToString(), DataType.Number));
            }

            if (term.TermsCount > 0)
              ExcelExport.RecursiveRowManagement(level + 1, sheet, term.Terms);

              }
        }
コード例 #42
0
 public TaxonomyTerms(ClientContext ctx)
 {
     if (keywords == null || (DateTime.Now - LastRefreshedKeywords).Minutes > Constants.KeywordIntervalRefresh)
     {
         lock (locker)
         {
             if (keywords == null || (DateTime.Now - LastRefreshedKeywords).Minutes > Constants.KeywordIntervalRefresh)
             {
                 var _taxSession = TaxonomySession.GetTaxonomySession(ctx);
                 keywords = _taxSession.GetDefaultKeywordsTermStore().KeywordsTermSet.GetAllTerms();
                 ctx.Load(keywords);
                 ctx.ExecuteQuery();
                 LastRefreshedKeywords = DateTime.Now;
                 LogHelper.Log("Refreshed the keyword list", LogSeverity.Error);
             }
         }
     }
 }
コード例 #43
0
ファイル: Taxonomy.cs プロジェクト: Microsoft/mattercenter
        /// <summary>
        /// This method will update the taxonomy hierarchy object with custom properties that needs to be send to client. This is a recursive function
        /// and it will loop until a term does not have any child terms
        /// </summary>
        /// <param name="termCollection">The Term Collection object to which terms will be added</param>
        /// <param name="termStoreDetails">The term store details which the client has sent</param>
        /// <param name="parentTerm">The parent term from where the custom properties are read and assign to its child terms</param>
        /// <returns></returns>
        private void GetChildTermsWithCustomProperties(TermCollection termCollection, 
            TermStoreDetails termStoreDetails, Term parentTerm, JsonWriter jw, string siteColumnName, int termLevelHierarchyPosition)
        {
            try
            {
                //var subAreaTerms = new List<SubareaTerm>();
                foreach (Term term in termCollection)
                {
                    if (term.Name != taxonomySettings.ClientTermSetName)
                    {
                        jw.WriteStartObject();
                        jw.WritePropertyName("termName");
                        jw.WriteValue(term.Name);
                        jw.WritePropertyName("id");
                        jw.WriteValue(Convert.ToString(term.Id, CultureInfo.InvariantCulture));
                        jw.WritePropertyName("parentTermName");
                        jw.WriteValue(parentTerm.Name);
                        jw.WritePropertyName("siteColumnName");
                        jw.WriteValue(siteColumnName);
                        IDictionary<string, string> childCustomProperties = term.CustomProperties;
                        IDictionary<string, string> parentCustomProperties = parentTerm.CustomProperties;
                        foreach (KeyValuePair<string, string> parentProperty in parentTerm.CustomProperties)
                        {
                            //if the key is present in the parent and not in the child, add that key value to the child custom properties
                            if (!childCustomProperties.Keys.Contains(parentProperty.Key))
                            {
                                if (parentProperty.Key.Equals(termStoreDetails.CustomPropertyName, StringComparison.Ordinal))
                                {
                                    childCustomProperties.Add(parentProperty.Key, parentProperty.Value);
                                }
                                else if (parentProperty.Key.Equals(taxonomySettings.SubAreaOfLawDocumentTemplates, StringComparison.Ordinal))
                                {
                                    childCustomProperties.Add(parentProperty.Key, parentProperty.Value);
                                }
                                else
                                {
                                    childCustomProperties.Add(parentProperty.Key, parentProperty.Value);
                                }
                            }

                            //If the key is present in both and parent and child and if child value is empty and the parent value is not empty,
                            //update the child value with the parent value for the same key
                            if (childCustomProperties.Keys.Contains(parentProperty.Key) && childCustomProperties[parentProperty.Key] == string.Empty)
                            {
                                childCustomProperties[parentProperty.Key] = parentProperty.Value;
                            }
                        }

                        //Add the custom properties to the subAreaTerms list collection
                        foreach (KeyValuePair<string, string> customProperty in childCustomProperties)
                        {
                            if (customProperty.Key.Equals(termStoreDetails.CustomPropertyName, StringComparison.Ordinal))
                            {
                                jw.WritePropertyName("documentTemplates");
                                jw.WriteValue(customProperty.Value);
                            }
                            else if (customProperty.Key.Equals(taxonomySettings.SubAreaCustomPropertyFolderNames, StringComparison.Ordinal))
                            {

                                jw.WritePropertyName("folderNames");
                                jw.WriteValue(customProperty.Value);
                            }
                            else if (customProperty.Key.Equals(taxonomySettings.SubAreaCustomPropertyisNoFolderStructurePresent, StringComparison.Ordinal))
                            {
                                jw.WritePropertyName("isNoFolderStructurePresent");
                                if (generalSettings.IsBackwardCompatible)
                                {
                                    if(customProperty.Value.ToLower()==ServiceConstants.IS_FOLDER_STRUCTURE_PRESENT_FALSE.ToLower())
                                    {
                                        jw.WriteValue(ServiceConstants.IS_FOLDER_STRUCTURE_PRESENT_TRUE);
                                    }
                                    else if (customProperty.Value.ToLower() == ServiceConstants.IS_FOLDER_STRUCTURE_PRESENT_TRUE.ToLower())
                                    {
                                        jw.WriteValue(ServiceConstants.IS_FOLDER_STRUCTURE_PRESENT_FALSE);
                                    }                                    
                                }
                                else
                                {
                                    jw.WriteValue(customProperty.Value);
                                }
                                
                                
                            }
                            else if (customProperty.Key.Equals(taxonomySettings.SubAreaOfLawDocumentTemplates, StringComparison.Ordinal))
                            {
                                jw.WritePropertyName("documentTemplateNames");
                                jw.WriteValue(customProperty.Value);
                            }
                        }
                        //Increment the level
                        level = level + 1;
                        //Check if we need to get more terms.
                        if (level <= taxonomySettings.Levels)
                        {
                            if (term.TermsCount > 0)
                            {
                                if(level==4)
                                {
                                    jw.WritePropertyName(taxonomySettings.Level4Name);
                                }
                                //The app will support upto five level of hierarchy
                                if (level == 5)
                                {
                                    jw.WritePropertyName(taxonomySettings.Level5Name);
                                }
                                jw.WriteStartArray();
                                TermCollection termCollLevel4 = term.LoadTerms(clientContext);
                                siteColumnName = configuration.GetSection("ContentTypes").GetSection("ManagedColumns")["ColumnName"+ level];
                                //Recursive function which will call it self until a given term does not have any child terms
                                GetChildTermsWithCustomProperties(termCollLevel4, termStoreDetails, term, jw, siteColumnName, termLevelHierarchyPosition);
                                jw.WriteEndArray();
                            }
                        }
                        jw.WriteEndObject();
                    }
                }             
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
コード例 #44
0
ファイル: Utility.cs プロジェクト: Microsoft/mattercenter
 /// <summary>
 /// To load and execute the Term collection
 /// </summary>
 /// <param name="clientContext">Client Context</param>
 /// <param name="termColl">Term Collection</param>
 private static void LoadExecute(ClientContext clientContext, TermCollection termColl)
 {
     clientContext.Load(termColl, practicegroup => practicegroup.Include(
         item => item.Name,
         item => item.Id,
         item => item.Terms.Include(
             areaOfLaw => areaOfLaw.Name,
             areaOfLaw => areaOfLaw.Id,
             areaOfLaw => areaOfLaw.Terms.Include(
                 subAreaOfLaw => subAreaOfLaw.Name,
                 subAreaOfLaw => subAreaOfLaw.Id,
                 subAreaOfLaw => subAreaOfLaw.CustomProperties
                 )
             )
         ));
     // Execute the query to the server
     clientContext.ExecuteQuery();
 }
コード例 #45
0
 private void ProcessTerms(ClientContext context, TermCollection terms, int indentLevel)
 {
     if (terms != null && terms.Count > 0)
     {
         WriteOutput("<Terms>");
         foreach (var term in terms)
         {
             context.Load(term,
                 t => t.Id,
                 t => t.Name,
                 t => t.TermSet.Id,
                 t => t.TermSet.Name,
                 t => t.TermSet.Group.Id,
                 t => t.TermSet.Group.Name
                 );
             context.ExecuteQueryRetry();
             WriteOutput(string.Format("<Term Name=\"{0}\" Id=\"{1}\"></Term>", term.Name, term.Id));
             context.Load(term.Terms);
             context.ExecuteQueryRetry();
             if (term.Terms != null && term.Terms.Count > 0)
             {
                 ProcessTerms(context, term.Terms, (indentLevel + 1));
             }
         }
         WriteOutput("</Terms>");
     }
 }