Beispiel #1
0
        private void DeployDefinition(object modelHost, SPWeb web, SearchSettingsDefinition definition)
        {
            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioning,
                Object           = web,
                ObjectType       = typeof(SPWeb),
                ObjectDefinition = definition,
                ModelHost        = modelHost
            });

            ProcessObject(web, definition);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioned,
                Object           = web,
                ObjectType       = typeof(SPWeb),
                ObjectDefinition = definition,
                ModelHost        = modelHost
            });

            web.Update();
        }
        private void DeployAtSiteLevel(object modelHost, SPSite site, SearchSettingsDefinition definition)
        {
            var web = site.RootWeb;

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioning,
                Object           = web,
                ObjectType       = typeof(SPWeb),
                ObjectDefinition = definition,
                ModelHost        = modelHost
            });

            if (!string.IsNullOrEmpty(definition.SearchCenterUrl))
            {
                SetSearchCenterUrlAtSiteLevel(web, definition.SearchCenterUrl);
            }

            var searchSettings = GetCurrentSearchConfigAtSiteLevel(web);

            if (searchSettings != null)
            {
                if (definition.UseParentResultsPageUrl.HasValue)
                {
                    searchSettings.Inherit = definition.UseParentResultsPageUrl.Value;
                }

                if (!string.IsNullOrEmpty(definition.UseCustomResultsPageUrl))
                {
                    var url = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
                    {
                        Context = web,
                        Value   = definition.UseCustomResultsPageUrl
                    }).Value;


                    searchSettings.ResultsPageAddress = url;
                }

                SetCurrentSearchConfigAtSiteLevel(web, searchSettings);
            }

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioned,
                Object           = web,
                ObjectType       = typeof(SPWeb),
                ObjectDefinition = definition,
                ModelHost        = modelHost
            });

            web.Update();
        }
Beispiel #3
0
        private void DeployAtSiteLevel(object modelHost, Site site, SearchSettingsDefinition definition)
        {
            var csomModelHost = modelHost.WithAssertAndCast <CSOMModelHostBase>("modelHost", value => value.RequireNotNull());

            var web = site.RootWeb;

            var context = web.Context;

            context.Load(web);
            context.Load(web, w => w.AllProperties);

            context.ExecuteQueryWithTrace();

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioning,
                Object           = web,
                ObjectType       = typeof(Web),
                ObjectDefinition = definition,
                ModelHost        = modelHost
            });

            if (!string.IsNullOrEmpty(definition.SearchCenterUrl))
            {
                SetSearchCenterUrlAtSiteLevel(csomModelHost, web, definition.SearchCenterUrl);
            }

            var searchSettings = GetCurrentSearchConfigAtSiteLevel(web);

            if (searchSettings != null)
            {
                if (definition.UseParentResultsPageUrl.HasValue)
                {
                    searchSettings.Inherit = definition.UseParentResultsPageUrl.Value;
                }

                if (!string.IsNullOrEmpty(definition.UseCustomResultsPageUrl))
                {
                    var url = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
                    {
                        Context = csomModelHost,
                        Value   = definition.UseCustomResultsPageUrl
                    }).Value;


                    searchSettings.ResultsPageAddress = url;
                }

                SetCurrentSearchConfigAtSiteLevel(csomModelHost, web, searchSettings);
            }

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioned,
                Object           = web,
                ObjectType       = typeof(Web),
                ObjectDefinition = definition,
                ModelHost        = modelHost
            });

            web.Update();
            context.ExecuteQueryWithTrace();
        }
Beispiel #4
0
 public static ModelNode AddSearchSettings(this ModelNode model, SearchSettingsDefinition definition, Action <ModelNode> action)
 {
     return(model.AddDefinitionNode(definition, action));
 }
Beispiel #5
0
 public static ModelNode AddSearchSettings(this ModelNode model, SearchSettingsDefinition definition)
 {
     return(AddSearchSettings(model, definition, null));
 }
Beispiel #6
0
 public static TModelNode AddSearchSettings <TModelNode>(this TModelNode model, SearchSettingsDefinition definition,
                                                         Action <SearchSettingsModelNode> action)
     where TModelNode : ModelNode, ISearchSettingsHostModelNode, new()
 {
     return(model.AddTypedDefinitionNode(definition, action));
 }
Beispiel #7
0
 public static TModelNode AddSearchSettings <TModelNode>(this TModelNode model, SearchSettingsDefinition definition)
     where TModelNode : ModelNode, ISearchSettingsHostModelNode, new()
 {
     return(AddSearchSettings(model, definition, null));
 }
Beispiel #8
0
 private void ProcessObject(SPWeb web, SearchSettingsDefinition definition)
 {
     // web.AllProperties["SRCH_ENH_FTR_URL_SITE"] = string.
 }