public Scope EnsureSiteScope(SPSite site, string scopeName, string displayGroupName, string searchPagePath)
        {
            // remotescopes class retrieves information via search web service so we run this as the search service account
            RemoteScopes remoteScopes = new RemoteScopes(SPServiceContext.GetContext(site));

            // see if there is an existing scope
            Scope scope = remoteScopes.GetScopesForSite(new Uri(site.Url)).Cast<Scope>().FirstOrDefault(s => s.Name == scopeName);

            // only add if the scope doesn't exist already
            if (scope == null)
            {
                scope = remoteScopes.AllScopes.Create(scopeName, string.Empty, new Uri(site.Url), true, searchPagePath, ScopeCompilationType.AlwaysCompile);
            }

            // see if there is an existing display group
            ScopeDisplayGroup displayGroup = remoteScopes.GetDisplayGroupsForSite(new Uri(site.Url)).Cast<ScopeDisplayGroup>().FirstOrDefault(d => d.Name == displayGroupName);

            // add if the display group doesn't exist
            if (displayGroup == null)
            {
                displayGroup = remoteScopes.AllDisplayGroups.Create(displayGroupName, string.Empty, new Uri(site.Url), true);
            }

            // add scope to display group if not already added
            if (!displayGroup.Contains(scope))
            {
                displayGroup.Add(scope);
                displayGroup.Update();
            }

            // optionally force a scope compilation so this is available immediately
            remoteScopes.StartCompilation();

            return scope;
        }
Beispiel #2
0
        public Scope EnsureSiteScope(SPSite site, string scopeName, string displayGroupName, string searchPagePath)
        {
            // remotescopes class retrieves information via search web service so we run this as the search service account
            RemoteScopes remoteScopes = new RemoteScopes(SPServiceContext.GetContext(site));

            // see if there is an existing scope
            Scope scope = remoteScopes.GetScopesForSite(new Uri(site.Url)).Cast <Scope>().FirstOrDefault(s => s.Name == scopeName);

            // only add if the scope doesn\"t exist already
            if (scope == null)
            {
                scope = remoteScopes.AllScopes.Create(scopeName, string.Empty, new Uri(site.Url), true, searchPagePath, ScopeCompilationType.AlwaysCompile);
            }

            // see if there is an existing display group
            ScopeDisplayGroup displayGroup = remoteScopes.GetDisplayGroupsForSite(new Uri(site.Url)).Cast <ScopeDisplayGroup>().FirstOrDefault(d => d.Name == displayGroupName);

            // add if the display group doesn\"t exist
            if (displayGroup == null)
            {
                displayGroup = remoteScopes.AllDisplayGroups.Create(displayGroupName, string.Empty, new Uri(site.Url), true);
            }

            // add scope to display group if not already added
            if (!displayGroup.Contains(scope))
            {
                displayGroup.Add(scope);
                displayGroup.Update();
            }

            // optionally force a scope compilation so this is available immediately
            remoteScopes.StartCompilation();

            return(scope);
        }
Beispiel #3
0
        public RemoteScopesInstance(ScriptEngine engine, RemoteScopes remoteScopes)
            : base(engine)
        {
            m_remoteScopes = remoteScopes;

            PopulateFunctions();
        }
Beispiel #4
0
        public static void PopulateScopes(Dictionary <string, string> scopeLookup)
        {
            Logger.Instance.Info("Entered PopulateScopes", DiagnosticsCategories.eCaseSearch);
            SPSecurity.RunWithElevatedPrivileges(
                delegate
            {
                using (SPSite currentSite = new SPSite(SPContext.Current.Site.ID))
                {
                    RemoteScopes remoteScopes = new RemoteScopes(SPServiceContext.GetContext(currentSite));

                    foreach (Scope scope in remoteScopes.GetScopesForSite(new System.Uri(currentSite.Url)))
                    {
                        scopeLookup[scope.Name.ToLower()] = scope.Filter;
                    }
                }
            }
                );
        }
Beispiel #5
0
 protected RemoteScopesInstance(ObjectInstance prototype, RemoteScopes remoteScopes)
     : base(prototype)
 {
     m_remoteScopes = remoteScopes;
 }