コード例 #1
0
        private string GetCatalogueName(Guid searchIndexPipeId)
        {
            var searchManager = PublishingManager.GetManager(PublishingConfig.SearchProviderName);
            var pipeSettings  = searchManager.GetPipeSettings <SearchIndexPipeSettings>();
            var pipe          = pipeSettings.SingleOrDefault(p => p.Id == searchIndexPipeId);

            if (pipe != null)
            {
                if (!SystemManager.CurrentContext.IsMultisiteMode)
                {
                    return(pipe.CatalogName);
                }
                else
                {
                    var siteId = SystemManager.CurrentContext.CurrentSite.Id;

                    IList <Guid> sites;
                    if (pipe.PublishingPoint.IsSharedWithAllSites)
                    {
                        sites = MultisiteManager.GetManager().GetSites().Select(s => s.Id).ToList();
                    }
                    else
                    {
                        sites = this.GetSitesByPoint(pipe.PublishingPoint).Select(l => l.SiteId).ToList();
                    }

                    if (sites.Contains(siteId))
                    {
                        return(pipe.CatalogName);
                    }
                }
            }
            return(string.Empty);
        }
コード例 #2
0
        private static bool TryInitialize(ConfigElementList <SearchIndexStartupElement> indexes, out WarmupParameters parameters)
        {
            parameters = null;

            if (!(indexes?.Count > 0))
            {
                return(false);
            }

            var publishingManager = PublishingManager.GetManager(PublishingConfig.SearchProviderName);

            if (publishingManager == null)
            {
                return(false);
            }

            var searchService = ServiceBus.ResolveService <ISearchService>();

            if (searchService == null)
            {
                return(false);
            }

            parameters = new WarmupParameters
            {
                PublishingAdminService = new PublishingAdminService(),
                PublishingManager      = publishingManager,
                SearchService          = searchService,
                Indexes        = ((IList <SearchIndexStartupElement>)indexes).OrderBy(i => i.WithBackgroundIndexing),
                WorkerDelegate = new SystemManager.RunWithElevatedPrivilegeDelegate(DoWarmup)
            };

            return(true);
        }
コード例 #3
0
ファイル: FeedModel.cs プロジェクト: tvetan/feather-widgets
        /// <inheritdoc />
        public virtual FeedViewModel GetViewModel()
        {
            var viewModel = new FeedViewModel();

            viewModel.InsertionOption = this.InsertionOption;
            viewModel.CssClass        = this.CssClass;

            if (this.FeedId != null && this.FeedId != Guid.Empty)
            {
                RssPipeSettings pipe = PublishingManager.GetManager().GetPipeSettings <RssPipeSettings>().Where(p => p.Id == this.FeedId).FirstOrDefault();
                if (pipe != null)
                {
                    string url   = RouteHelper.ResolveUrl(String.Concat("~/", Config.Get <PublishingConfig>().FeedsBaseURl, "/", pipe.UrlName), UrlResolveOptions.Absolute);
                    string title = (!string.IsNullOrEmpty(this.TextToDisplay)) ? HttpUtility.HtmlEncode(this.TextToDisplay) : string.Empty;

                    if (this.InsertionOption == FeedInsertionOption.AddressBarOnly || this.InsertionOption == FeedInsertionOption.PageAndAddressBar)
                    {
                        viewModel.HeadLink = string.Format(
                            CultureInfo.CurrentCulture,
                            @"<link rel=""alternate"" type=""application/rss+xml"" title=""{0}"" href=""{1}""/>",
                            title,
                            url);
                    }
                    if (this.InsertionOption == FeedInsertionOption.PageOnly || this.InsertionOption == FeedInsertionOption.PageAndAddressBar)
                    {
                        viewModel.Title           = title;
                        viewModel.Url             = url;
                        viewModel.Tooltip         = this.Tooltip;
                        viewModel.OpenInNewWindow = this.OpenInNewWindow;
                    }
                }
            }

            return(viewModel);
        }
コード例 #4
0
        public static IEnumerable <IDocument> GetNewsDocs(string[] providers, Guid searchIndexGuid, out int hitCount, Guid[] categories = null, string terms = null, int skip = 0, int take = 0, string[] orderToSortResults = null)
        {
            ISearchService searchService = ServiceBus.ResolveService <ISearchService>();
            ISearchQuery   searchQuery   = ObjectFactory.Resolve <ISearchQuery>();
            var            queryBuilder  = ObjectFactory.Resolve <IQueryBuilder>();

            //Note: Make sure the Index item has been re-generated via sitfinity's backend to get proper results
            //Guid.Parse("6894B15C-7836-6C70-9642-FF00005F0421")
            var publishingPoint = PublishingManager.GetManager("SearchPublishingProvider")
                                  .GetPublishingPoint(searchIndexGuid) as PublishingPoint;
            string catalogName = (publishingPoint.PipeSettings.First(p => p.PipeName == "SearchIndex") as SearchIndexPipeSettings).CatalogName;

            var orderBy = orderToSortResults != null ? orderToSortResults : new string[] { "PublicationDate DESC" };


            //searchQuery.IndexName = AppSettingsUtility.GetValue<string>("NewsCatalogName");
            searchQuery.IndexName   = catalogName;
            searchQuery.OrderBy     = orderBy;
            searchQuery.Skip        = skip;
            searchQuery.Take        = take;
            searchQuery.SearchGroup = BuildQuery(categories, providers);

            var resultSet = searchService.Search(searchQuery);

            hitCount = resultSet.HitCount;

            log.InfoFormat("search cate:{0}, limit:{1}, hit:{2}", catalogName, take, hitCount);


            return(resultSet.SetContentLinks());
        }
コード例 #5
0
        protected void DeleteSearchIndex(string searchIndexName, Guid publishingPointId)
        {
            var transaction = Guid.NewGuid().ToString();
            var manager     = PublishingManager.GetManager(PublishingConfig.SearchProviderName, transaction);
            var pp          = manager.GetPublishingPoint(publishingPointId);

            foreach (var settings in pp.PipeSettings)
            {
                manager.DeletePipeSettings(settings);
            }
            manager.DeletePublishingPoint(pp);
            TransactionManager.CommitTransaction(transaction);

            var service = ServiceBus.ResolveService <ISearchService>();

            service.DeleteIndex(searchIndexName);
        }