Ejemplo n.º 1
0
 /// <summary>
 /// Constructor to inject required dependencies
 /// </summary>
 /// <param name="generalSettings"></param>
 /// <param name="taxonomySettings"></param>
 /// <param name="logTables"></param>
 /// <param name="spoAuthorization"></param>
 /// <param name="customLogger"></param>
 public Taxonomy(IOptions<GeneralSettings> generalSettings, 
     IOptions<TaxonomySettings> taxonomySettings,
     IOptions<ContentTypesConfig> contentTypeSettings,
     IOptions<LogTables> logTables,
     ISPOAuthorization spoAuthorization, ICustomLogger customLogger, 
     IConfigurationRoot configuration)
 {
     this.generalSettings = generalSettings.Value;
     this.taxonomySettings = taxonomySettings.Value;
     this.contentTypeSettings = contentTypeSettings.Value;
     this.logTables = logTables.Value;
     this.spoAuthorization = spoAuthorization;
     taxonomyResponseVM = new TaxonomyResponseVM();
     this.customLogger = customLogger;
     
     this.configuration = configuration;
 }       
Ejemplo n.º 2
0
 /// <summary>
 /// This method will return the taxonomy hierarchy either for the practice group term set or for client term sets
 /// </summary>
 /// <typeparam name="T">The return type from this class</typeparam>
 /// <param name="clientContext">The sharepoint client context</param>
 /// <param name="termStoreDetails">The term store deatils that client has passed to we apiu</param>
 /// <param name="generalSettings">The general settings config values</param>
 /// <param name="taxonomySettings">The taxonomy settings config values</param>
 /// <returns></returns>
 public TaxonomyResponseVM GetTaxonomyHierarchy(Client client,  TermStoreDetails termStoreDetails)
 {            
     try
     {
         using (clientContext = spoAuthorization.GetClientContext(client.Url))
         {
             TaxonomySession taxonomySession = TaxonomySession.GetTaxonomySession(clientContext);
             TermStore termStore;
             clientContext.Load(taxonomySession.TermStores);
             clientContext.ExecuteQuery();
             termStore = taxonomySession.TermStores[0];
             clientContext.Load(
                 termStore,
                 store => store.Name,
                 store => store.Groups.Include(
                     group => group.Name));
             clientContext.ExecuteQuery();
             taxonomyResponseVM = GetTaxonomyHierarchy(termStore, termStoreDetails);
         }
     }
     catch(Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         throw;
     }
     return taxonomyResponseVM;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Iterates through the taxonomy hierarchy for the specified term set group.
 /// </summary>
 /// <param name="clientContext">Client content for specified site</param>
 /// <param name="termStore">Term Store object</param>
 /// <param name="termStoreDetails">Term Store object containing Term store data</param>
 /// <returns>Fetch Group Terms Status</returns>
 private TaxonomyResponseVM GetTaxonomyHierarchy (TermStore termStore, TermStoreDetails termStoreDetails)
 {
     try {
         if (generalSettings.IsTenantDeployment)
         {
             foreach (TermGroup termGroup in termStore.Groups)
             {
                 if (termGroup.Name == termStoreDetails.TermGroup)
                 {
                     taxonomyResponseVM = FetchGroupTerms(termGroup, termStoreDetails);
                     break;
                 }
             }
         }
         else
         {
             TermGroup termGroup = termStore.GetSiteCollectionGroup(clientContext.Site, false);
             taxonomyResponseVM = FetchGroupTerms(termGroup, termStoreDetails);
         }
     }
     catch(Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         throw;
     }           
     return taxonomyResponseVM;
 }