A Client refer to term store client termSet
        /// <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;
        }
Example #2
0
        /// <summary>
        /// String method to updating the view for site collection
        /// </summary>
        /// <param name="selectedField">Field which is being selected</param>
        /// <param name="client">Client object</param>
        /// <param name="clientContext">Context of client</param>
        /// <param name="list">List object</param>
        /// <param name="targetView">Targeted view</param>
        /// <returns>Selected field</returns>
        private static string UpdateFields(string selectedField, Client client, ClientContext clientContext, List list, View targetView)
        {
            List<string> updateFields = ConfigurationManager.AppSettings["ColumnName"].Split(';').ToList();
            ErrorMessage.ShowMessage("\nUpdating View for site collection " + client.ClientName, ErrorMessage.MessageType.Notification);
            foreach (string field in updateFields)
            {
                try
                {
                    if (!string.IsNullOrEmpty(field))
                    {
                        selectedField = field;
                        if (!targetView.ViewFields.Contains(field))
                        {
                            targetView.ViewFields.Add(field);
                            targetView.Update();
                            list.Update();

                            clientContext.Load(list);
                            clientContext.ExecuteQuery();
                        }
                    }
                }
                catch (Exception)
                {
                    ErrorMessage.ShowMessage(selectedField + " field failed to update/unavailable for site collection " + client.ClientName, ErrorMessage.MessageType.Error);
                }
            }

            return selectedField;
        }