/// <summary> /// Finds all pages of a page type below a PageReference. Does not filter on anything. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pageLink">PageReference to search below</param> /// <param name="recursive">Whether to search recursively</param> /// <param name="culture">The culture of the page to search.</param> /// <returns></returns> public IEnumerable <T> FindPagesOfType <T>(ContentReference pageLink, bool recursive, CultureInfo culture) where T : IContent { if (pageLink == null || pageLink.ID == 0) { return(new List <T>()); } // If culture isn't set, just retrieve pages the normal way. if (culture == null) { return((recursive) ? _contentLoader.GetDescendents(pageLink) .Where(p => _contentLoader.Get <IContent>(p) is T) .Select(_contentLoader.Get <T>) : _contentLoader.GetChildren <T>(pageLink)); } // If culture is set, find the pages filtering on culture. // Could probably combine this with the above culture-ignorant calls, but don't have time to test these calls properly for pages not using separate languages. if (recursive) { var pages = GetPagesFromReferenceList <T>(_contentLoader.GetDescendents(pageLink)); return(pages.Where(p => p.LanguageBranch().Equals(culture.TwoLetterISOLanguageName)).ToList()); } else { return(_contentLoader.GetChildren <T>(pageLink, culture)); } }
public ActionResult Index() { var promotions = GetPromotions(_contentLoader.GetDescendents(GetCampaignRoot())) .ToList(); return(View(new PromotionsViewModel { Promotions = promotions })); }
public IReadOnlyCollection <T> GetPageTreeAllLanguagesDocuments(IContent root, bool includeDeleted = false) { var results = new List <T>(); results.AddRange(GetPageAllLanguagesContentDocuments(root.ContentLink, includeDeleted)); var descendants = _contentLoader.GetDescendents(root.ContentLink); foreach (var descendant in descendants) { results.AddRange(GetPageAllLanguagesContentDocuments(descendant, includeDeleted)); } return(results); }
public Task <List <PageListItem> > LoadALlPages() { var pages = contentLoader.GetDescendents(ContentReference.StartPage); var result = new List <PageListItem>(); foreach (var item in pages) { var page = contentLoader.Get <PageData>(item); if (page.ContentLink != ContentReference.StartPage || page.ParentLink != ContentReference.StartPage) { var parents = contentLoader.GetAncestors(page.ContentLink); var url = page.URLSegment; foreach (var parent in parents) { if (parent is PageData pageData && pageData.ContentLink != ContentReference.StartPage) { url = pageData.URLSegment + "/" + url; } } if (!result.Any(x => x.Key == page.ContentLink.ToString())) { result.Add(new PageListItem() { Key = page.ContentLink.ToString(), Name = page.Name, Type = page.PageTypeName, Url = url }); } } } return(Task.FromResult(result)); }
public override List <Feed> Build() { var generatedFeeds = new List <Feed>(); var feed = GenerateFeedEntity() ?? throw new ArgumentNullException($"{nameof(GenerateFeedEntity)} returned null"); var entries = new List <Entry>(); var catalogReferences = _contentLoader.GetDescendents(_referenceConverter.GetRootLink()); foreach (var catalogReference in catalogReferences) { var catalogContent = _contentLoader.Get <CatalogContentBase>(catalogReference); var entry = GenerateEntry(catalogContent); if (entry != null) { entries.Add(entry); } } feed.Entries = entries; generatedFeeds.Add(feed); return(generatedFeeds); }
public IndexingStatus UpdateStructure(IContent root, string indexName) { var language = CultureInfo.CurrentCulture; if (root is ILocale locale && locale.Language != null && !CultureInfo.InvariantCulture.Equals(locale.Language)) { language = locale.Language; } Logger.Information($"Performing recursive update, starting from {root.ContentLink}, in language {language}"); var status = Update(root, indexName); var descendents = _contentLoader.GetDescendents(root.ContentLink); var contents = _contentLoader.GetItems(descendents, language); foreach (var content in contents) { var childStatus = Update(content, indexName); if (childStatus == IndexingStatus.Error && status != IndexingStatus.Error) { status = IndexingStatus.PartialError; } } return(status); }
/// <summary> /// Searches the specified query. /// </summary> /// <param name="query">The query.</param> /// <returns>An <see cref="IEnumerable{T}"/> of <see cref="SearchResult"/>.</returns> public override IEnumerable <SearchResult> Search(Query query) { if (String.IsNullOrWhiteSpace(value: query?.SearchQuery) || query.SearchQuery.Trim().Length < 2) { return(Enumerable.Empty <SearchResult>()); } List <SearchResult> searchResultList = new List <SearchResult>(); string str = query.SearchQuery.Trim(); IEnumerable <ContentReference> settings = contentLoader.GetDescendents(contentLink: settingsService.SettingsRoot); foreach (ContentReference contentReference in settings) { if (!contentLoader.TryGet(contentLink: contentReference, content: out SettingsBase setting)) { continue; } if (setting.Name.IndexOf(value: str, comparisonType: StringComparison.OrdinalIgnoreCase) < 0) { continue; } searchResultList.Add(CreateSearchResult(contentData: setting)); if (searchResultList.Count == query.MaxResults) { break; } } return(searchResultList); }
public ContentSearchViewModel SearchContent(FilterOptionViewModel filterOptions) { var model = new ContentSearchViewModel { FilterOption = filterOptions, Hits = new List <SearchHit>() }; if (!filterOptions.Q.IsNullOrEmpty()) { var siteId = SiteDefinition.Current.Id; var contentReferences = _contentLoader.GetDescendents(ContentReference.StartPage); var result = contentReferences.Select(x => _contentLoader.Get <IContent>(x)) .OfType <FoundationPageData>() .Where(x => x.Name.ToLowerInvariant().StartsWith(filterOptions.Q)) .Select(x => new SearchHit { Title = x.Name, Url = _urlResolver.GetUrl(x.ContentLink), Excerpt = x.PageDescription, ImageUri = _urlResolver.GetUrl(x.PageImage) }) .Skip((filterOptions.Page - 1) * filterOptions.PageSize) .Take(filterOptions.PageSize); model.Hits = result; } return(model); }
public void GetAllBlobs() { _blobResolver = ServiceLocator.Current.GetInstance <IBlobFactory>(); var globalAssetsRoot = EPiServer.Web.SiteDefinition.Current.GlobalAssetsRoot; var mediaChildRefs = _readRepo.GetDescendents(globalAssetsRoot); foreach (var child in mediaChildRefs) { var image = _readRepo.TryGet <ImageData>(child, out var imageData); if (!image) { continue; } var blobLink = UrlHelper.GetExternalUrlNoHttpContext(imageData.ContentLink); if (!RemoteFileExists(blobLink)) { continue; } CompressBlob(imageData); } _log.Error( $"Success: Optimized {ImageCompressor.OptimizedImagesCount} images (Saved: {ImageCompressor.TotallySavedMbs} mb)." + $"\nSkipped {ImageCompressor.SkippedImagesCount} images."); }
public override List <Feed> Build() { List <Feed> generatedFeeds = new List <Feed>(); Feed feed = GenerateFeedEntity() ?? throw new ArgumentNullException($"{nameof(GenerateFeedEntity)} returned null"); IEnumerable <ContentReference> catalogReferences = _contentLoader.GetDescendents(_referenceConverter.GetRootLink()); IEnumerable <CatalogContentBase> items = _contentLoader.GetItems(catalogReferences, CreateDefaultLoadOption()).OfType <CatalogContentBase>(); List <Entry> entries = new List <Entry>(); foreach (CatalogContentBase catalogContent in items) { try { Entry entry = GenerateEntry(catalogContent); if (entry != null) { entries.Add(entry); } } catch (Exception ex) { _logger.Error($"Failed to generate GoogleProductFeed entry for ContentGuid={catalogContent.ContentGuid}", ex); } } feed.Entries = entries; generatedFeeds.Add(feed); return(generatedFeeds); }
public JsonResult Test(Guid id) { var errorResponse = new WebhookExecutionResponse { Success = false, Response = "Unable to execute webhook. This is probably caused by suitable content being unavailable below the selected parent." }; var webhook = _repo.GetWebhook(id); if (webhook.ParentId > 0) { var parentRef = new ContentReference(webhook.ParentId); if (ContentReference.IsNullOrEmpty(parentRef)) { return(Json(errorResponse)); } var parentContent = _contentLoader.Get <IContent>(parentRef); if (parentContent == null) { return(Json(errorResponse)); } var testEventType = webhook.EventTypes?.Select(x => _repo.GetEventTypes().FirstOrDefault(y => y.Key.Equals(x)))?.FirstOrDefault(x => x != null) ?? Constants.PublishEvent; if (webhook.ContentTypes == null || !webhook.ContentTypes.Any() || webhook.ContentTypes.Contains(parentContent.ContentTypeID)) { return(Json(webhook.Execute(parentContent, testEventType, _repo), JsonRequestBehavior.AllowGet)); } else { var childRef = _contentLoader.GetDescendents(parentRef).FirstOrDefault(x => webhook.ContentTypes.Contains(_contentLoader.Get <IContent>(x).ContentTypeID)); if (childRef != null) { return(Json(webhook.Execute(_contentLoader.Get <IContent>(childRef), testEventType, _repo), JsonRequestBehavior.AllowGet)); } } } return(Json(errorResponse, JsonRequestBehavior.AllowGet)); }
private void contentEvents_PublishedContent(object sender, ContentEventArgs e) { if (!(e.Content is SettingsPage)) { return; } var settingPage = _contentLoader.GetDescendents(ContentReference.RootPage).Select(_contentLoader.Get <SettingsPage>).OfType <SettingsPage>().FirstOrDefault(); _settingsPage = settingPage; }
public override IEnumerable <SearchResult> Search(Query query) { var searchPhrase = query.SearchQuery.ToLowerInvariant(); var contentReferences = _contentLoader.GetDescendents(ContentReference.StartPage); var result = contentReferences.Select(x => _contentLoader.Get <IContent>(x)) .OfType <PageData>() .Where(x => x.Name.ToLowerInvariant().StartsWith(searchPhrase)).Select(CreateSearchResult); return(result); }
public virtual IEnumerable <ContentIndexingResult> IndexFrom(ContentReference contentLink) { var mainContent = ContentLoader.Get <IContent>(contentLink); var contentReferencesToIndex = ContentLoader.GetDescendents(contentLink); var contentsToIndex = ContentLoader.GetItems(contentReferencesToIndex, CultureInfo.InvariantCulture).ToList(); // Add main content to list contentsToIndex.Insert(0, mainContent); return(ContentIndexer.Index(contentsToIndex)); }
private IEnumerable <ContentReference> GetDescendentsOfType <T>(ContentReference contentReference) where T : ContentData { foreach (var reference in ContentLoader.GetDescendents(contentReference)) { var contentItem = ContentLoader.Get <ContentData>(reference, LanguageSelector.AutoDetect()) as T; if (contentItem == null) { continue; } yield return(reference); } }
public IEnumerable <ContentData> GetContentsByTag(Tag tag, ContentReference rootContentReference) { if (tag?.PermanentLinks == null) { return(Enumerable.Empty <ContentData>()); } var descendantContentReferences = _contentLoader.GetDescendents(rootContentReference)?.ToArray(); if (descendantContentReferences == null || !descendantContentReferences.Any()) { return(Enumerable.Empty <ContentData>()); } return(tag .PermanentLinks .Select(TagsHelper.GetContentReference) .Where(contentLink => descendantContentReferences.FirstOrDefault(p => p.ID == contentLink.ID) != null) .Select(contentReference => _contentLoader.Get <PageData>(contentReference)) .Cast <ContentData>() .ToList()); }
public ActionResult Index(Models.LocationListPage currentPage) { // Filter: Not support yet //var query = SearchClient.Instance.Search<LocationItemPage.LocationItemPage>() // .PublishedInCurrentLanguage() // .FilterOnReadAccess(); //if (currentPage.FilterArea != null) //{ // foreach (var filterBlock in currentPage.FilterArea.FilteredItems) // { // var b = _contentLoader.Get<BlockData>(filterBlock.ContentLink) as IFilterBlock; // if (b != null) // { // query = b.AddFilter(query); // } // } // foreach (var filterBlock in currentPage.FilterArea.FilteredItems) // { // var b = _contentLoader.Get<BlockData>(filterBlock.ContentLink) as IFilterBlock; // if (b != null) // { // query = b.ApplyFilter(query, Request.QueryString); // } // } //} //var locations = query.OrderBy(x => x.PageName) // .Take(500) // .StaticallyCacheFor(new System.TimeSpan(0, 1, 0)).GetContentResult(); var contentReferences = _contentLoader.GetDescendents(ContentReference.StartPage); var locations = contentReferences.Select(x => _contentLoader.Get <IContent>(x)) .OfType <LocationItemPage.Models.LocationItemPage>() .OrderBy(x => x.Name) .Take(500); var model = new LocationListViewModel(currentPage) { Locations = locations, MapCenter = GetMapCenter(), //UserLocation = GetMapCenter(), QueryString = _httpContextAccessor.HttpContext.Request.Query }; return(View(model)); }
private Dictionary <StartPage, IEnumerable <SitePageData> > GetStartPagesWithDescendants() { var dictionary = new Dictionary <StartPage, IEnumerable <SitePageData> >(); var startPages = _contentLoader.GetChildren <StartPage>(SiteDefinition.Current.RootPage, new LoaderOptions { LanguageLoaderOption.MasterLanguage() }); foreach (var startPage in startPages) { var descendants = _contentLoader.GetDescendents(startPage.ContentLink).ToSitePageData().Where(p => !(p.Robots is null) && !p.Robots.ToLower().Contains("noindex") && !(p is IExcludeFromSiteMap)); dictionary.Add(startPage, descendants); } return(dictionary); }
public virtual int IndexProductsWithCategories() { int numberOfProductsSentToSannsyn = 0; // Get all catalogs to index var catalogRoots = GetCatalogRoots(); foreach (var catalogRoot in catalogRoots) { _logger.Debug("Indexing products in catalog: {0}", catalogRoot.ToString()); IEnumerable <ContentReference> contentLinks = _contentLoader.GetDescendents(catalogRoot); var availableLocalizations = GetAvailableLocalizations(); foreach (CultureInfo culture in availableLocalizations) { int allContentsCount = contentLinks.Count(); for (var i = 0; i < allContentsCount; i += _bulkSize) { IEnumerable <EntryContentBase> products = GetEntriesToIndex(_bulkSize, contentLinks, culture, i); // First get indexable content items Dictionary <string, EntryContentBase> indexableContentItems = GetIndexableContentItems(products); // Get models Sannsyn can index List <SannsynUpdateEntityModel> sannsynObjects = GetUpdateModels(indexableContentItems); numberOfProductsSentToSannsyn = numberOfProductsSentToSannsyn + sannsynObjects.Count; _logger.Debug("Sending {0} entries to Sannsyn index", sannsynObjects.Count); SannsynUpdateModel sannsynModel = new SannsynUpdateModel(); sannsynModel.Service = _configuration.Service; sannsynModel.Updates = sannsynObjects; _sannsynUpdateService.SendToSannsyn(sannsynModel); } } _logger.Debug("Done sending {0} entries to Sannsyn index", numberOfProductsSentToSannsyn); } return(numberOfProductsSentToSannsyn); }
public List <IContent> ListContentFromRoot(int bulkSize, ContentReference rootLink, List <LanguageBranch> languages) { List <ContentReference> contentReferences = _contentLoader.GetDescendents(rootLink).ToList(); List <IContent> contentList = new List <IContent>(); while (contentReferences.Count > 0) { List <IContent> bulkContents = ListContent(contentReferences.Take(bulkSize).ToList(), languages).ToList(); bulkContents.RemoveAll(_indexer.SkipIndexing); bulkContents.RemoveAll(_indexer.IsExcludedType); contentList.AddRange(bulkContents); var removeCount = contentReferences.Count >= bulkSize ? bulkSize : contentReferences.Count; contentReferences.RemoveRange(0, removeCount); } return(contentList); }
public ActionResult Get(int contentTypeId, string language, string properties, string keyword = "") { var contentType = _contentTypeRepository.Load(contentTypeId); var catalogContent = Type.GetType("EPiServer.Commerce.Catalog.ContentTypes.CatalogContentBase, EPiServer.Business.Commerce", false)?.IsAssignableFrom(contentType.ModelType) ?? false; var contentReferences = _contentLoader.GetDescendents(!catalogContent ? ContentReference.RootPage : GetContentLink(1, 1, 0)); var contents = GetItemsWithFallback(contentReferences, language); contents = contents.Where(o => o.ContentTypeID == contentTypeId).ToList(); if (!string.IsNullOrWhiteSpace(keyword)) { contents = contents.Where(o => o.Name.IndexOf(keyword, StringComparison.CurrentCultureIgnoreCase) >= 0); } var models = contents.Select(o => _contentModelMapper.TransformContent(o, false, properties)); return(new ContentResult { Content = JsonConvert.SerializeObject(models), ContentType = "application/json", }); }
public ActionResult Index(Models.LocationItemPage currentPage) { var model = new LocationItemViewModel(currentPage); if (!ContentReference.IsNullOrEmpty(currentPage.Image)) { model.Image = _contentRepository.Get <ImageData>(currentPage.Image); } var contentReferences = _contentLoader.GetDescendents(ContentReference.StartPage); model.LocationNavigation.ContinentLocations = contentReferences.Select(x => _contentLoader.Get <IContent>(x)) .OfType <Models.LocationItemPage>() .Where(x => x.Continent == currentPage.Continent & x.ParentLink != currentPage.ParentLink) .OrderBy(x => x.Name) .Take(100); //model.LocationNavigation.CloseBy = SearchClient.Instance // .Search<LocationItemPage>() // .Filter(x => x.Continent.Match(currentPage.Continent) // & !x.PageLink.Match(currentPage.PageLink)) // .PublishedInCurrentLanguage() // .FilterForVisitor() // .OrderBy(x => x.Coordinates) // .DistanceFrom(currentPage.Coordinates) // .Take(5) // .StaticallyCacheFor(new System.TimeSpan(0, 10, 0)) // .GetContentResult(); //if (currentPage.Categories != null) //{ // model.Tags = currentPage.Categories.Select(x => _contentRepository.Get<StandardCategory>(x)); //} //var editingHints = ViewData.GetEditHints<LocationItemViewModel, LocationItemPage>(); //editingHints.AddFullRefreshFor(p => p.Image); //editingHints.AddFullRefreshFor(p => p.Categories); return(View(model)); }
public void ExportProductRecommendations(NodeContentBase node, IExportState exportState) { if (node == null) { return; } if (!_configuration.ProductRecommendationsImportUrl.IsValidProductRecommendationsImportUrl()) { return; } IEnumerable <ContentReference> descendentRefs = _contentLoader .GetDescendents(node.ContentLink); IEnumerable <ContentReference> entryRefs = _contentLoader .GetItems(descendentRefs, CultureInfo.InvariantCulture) .OfType <EntryContentBase>() .Select(c => c.ContentLink); ExportProductRecommendations(entryRefs, exportState); }
public XmlDocument BuildSiteMap() { var xDoc = new XmlDocument(); XmlNode xNode = xDoc.CreateXmlDeclaration("1.0", "utf-8", null); xDoc.AppendChild(xNode); XmlNode xUrlSet = xDoc.CreateElement("urlset"); XmlAttribute xXmlns = xDoc.CreateAttribute("xmlns"); xXmlns.Value = "http://www.sitemaps.org/schemas/sitemap/0.9"; xUrlSet.Attributes.Append(xXmlns); xDoc.AppendChild(xUrlSet); int iCounter = 0; //var query = SearchClient.Instance.Search<SitePageData>().Filter(x=>x.VisibleInMenu.Match(true)).Take(1000); //var pages = query.GetContentResult(); IList <ContentReference> descendants = _pageRepo.GetDescendents(ContentReference.StartPage).ToList(); descendants.Add(ContentReference.StartPage); foreach (var descendant in descendants) { SitePageData page; if (_pageRepo.TryGet <SitePageData>(descendant, out page) && page.VisibleInMenu) { var friendlyUrl = page.GetExternalUrl(); XmlComment xComment = xDoc.CreateComment(string.Format("{0} ({1}) - {2}", page.PageName, page.PageLink.ID, page.LanguageBranch)); XmlNode xUrlNode = xDoc.CreateElement("url"); XmlNode xLoc = xDoc.CreateElement("loc"); XmlNode xUrl = xDoc.CreateTextNode(friendlyUrl); xUrlNode.AppendChild(xComment); xLoc.AppendChild(xUrl); xUrlNode.AppendChild(xLoc); XmlNode xLastMod = xDoc.CreateElement("lastmod"); xLastMod.AppendChild(xDoc.CreateTextNode(page.Saved.ToString(TimeFormat))); xUrlNode.AppendChild(xLastMod); XmlNode xChangeFrequency = xDoc.CreateElement("changefreq"); xChangeFrequency.AppendChild(xDoc.CreateTextNode("daily")); xUrlNode.AppendChild(xChangeFrequency); XmlNode xPriority = xDoc.CreateElement("priority"); xPriority.AppendChild(xDoc.CreateTextNode(GetPriority(friendlyUrl).ToString("0.0", CultureInfo.CreateSpecificCulture("en-GB")))); xUrlNode.AppendChild(xPriority); xUrlSet.AppendChild(xUrlNode); iCounter++; } } return(xDoc); }
/// <summary> /// Loads all root descendents by default /// </summary> /// <param name="contentIndexer"></param> /// <returns></returns> public virtual IEnumerable <ContentReference> GetSearchContentReferences(IVulcanContentIndexer contentIndexer) { return(_ContentLoader.GetDescendents(contentIndexer.GetRoot().Key)); }
protected virtual List <ContentReference> GetContentReferences() { OnStatusChanged("Loading all references from database..."); return(_contentLoader.GetDescendents(ContentReference.RootPage).ToList()); }
public ActionResult Index(TestsPage currentPage) { //retrieving the start page from the current page (current page must not be a sibling of Start page) var startPage = _contentLoader.GetAncestorOrSelf <StartPage>(currentPage); //test the 'or self' part of the function - must return the currentPage var selfPage = _contentLoader.GetAncestorOrSelf <TestsPage>(currentPage); //testing the 'get ancestor' function var ancestorSitePage = _contentLoader.GetAncestor <StartPage>(currentPage); //find the first descendent with the name = 'Find a reseller' var descendentTest = _contentLoader.GetDescendent <StandardPage>(startPage, x => x.Name == "Find a reseller"); //find all the ancestors of the 'Find a reseller' page var ancestors = _contentLoader.GetAncestors(descendentTest); //find all the standard page ancestors of the 'Find a reseller' page var ancestorsPredicateType = _contentLoader.GetAncestors <StandardPage>(descendentTest); //find all the ancestors with more than 2 children Func <IContent, bool> predicateNumChildren = x => _contentLoader.GetChildren <IContentData>(x.ContentLink).Count() > 2; var ancestorsPredicateNumChildren = _contentLoader.GetAncestors(descendentTest, predicateNumChildren); //find the first product descendant of start page var descendantCurrentPage = _contentLoader.GetDescendent <ProductPage>(startPage); //find the first descendant of start page that is a standard page and starts with 'White' var descendentMultiPredicate = _contentLoader.GetDescendent <StandardPage>(startPage, x => x.Name.StartsWith("White")); //find all the product descendents of start page var descendentsProductPages = _contentLoader.GetDescendents <ProductPage>(startPage); //find all the siblings of the current page var testSiblingsCurrentPage = _contentLoader.Siblings(currentPage); //find all the product siblings of the current page var testTypedSiblingsCurrentPage = _contentLoader.Siblings <ProductPage>(currentPage); //find the next sibling by name of the page named 'alloy plan' var alloyPlanPage = _contentLoader.FirstChild <IContent>(ContentReference.StartPage); var nextSibling = _contentLoader.FollowingSibling <IContent, string>(alloyPlanPage, x => x.Name); //find the previous sibling by 'sort order' property Func <IContent, int> sortingPredicate = x => (int)x.Property["PagePeerOrder"].Value; var previousSibling = _contentLoader.PreviousSibling <ProductPage, int>(currentPage, sortingPredicate); var testValues = new TestsViewModel { TestAncestorStartPage = startPage, TestAncestorOrSelf = selfPage, TestAncestor = ancestorSitePage, TestDescendentWithPredicate = descendentTest, TestAncestors = ancestors, TestAncestorsPredicateType = ancestorsPredicateType, TestAncestorsPredicateNumChildren = ancestorsPredicateNumChildren, TestStartDescendentProductPage = descendantCurrentPage, TestDescendentMultiPredicate = descendentMultiPredicate, TestDescendentsPredicateType = descendentsProductPages, TestSiblingsCurrentPage = testSiblingsCurrentPage, TestTypedSiblingsCurrentPage = testTypedSiblingsCurrentPage, TestNextSiblingByName = nextSibling, TestPreviousSiblingBySortOrder = previousSibling, }; ViewBag.TestsObjects = testValues; var model = PageViewModel.Create(currentPage); return(View(model)); }
protected override List<ContentReference> GetContentReferences() { OnStatusChanged("Loading all references from database..."); return _contentLoader.GetDescendents(_referenceConverter.GetRootLink()).ToList(); }
private static IEnumerable <ContentReference> GetDescendantsOf(ContentReference root, IContentLoader repository) { return(repository.GetDescendents(root)); }
/// <summary> /// Starts the job /// </summary> /// <returns>A status message that will be logged</returns> public override string Execute() { IndexInformation info = new IndexInformation(); Stopwatch tmr = Stopwatch.StartNew(); IClient client = SearchClient.Instance; //Delete all client.Delete <FindProduct>(x => x.MatchType(typeof(FindProduct))); var language = LanguageSelector.MasterLanguage(); var localizationService = ServiceLocator.Current.GetInstance <LocalizationService>(); var marketService = ServiceLocator.Current.GetInstance <IMarketService>(); var allMarkets = marketService.GetAllMarkets(); var priceService = ServiceLocator.Current.GetInstance <IPriceService>(); var linksRepository = ServiceLocator.Current.GetInstance <ILinksRepository>(); // TODO: Add support for multiple catalogs. This will pick the first one. IEnumerable <ContentReference> contentLinks = contentLoader.GetDescendents(Root); int bulkSize = 100; foreach (CultureInfo availableLocalization in localizationService.AvailableLocalizations) { var market = allMarkets.FirstOrDefault(m => m.DefaultLanguage.Equals(availableLocalization)); if (market == null) { continue; } string language2 = availableLocalization.Name.ToLower(); int allContentsCount = contentLinks.Count(); for (var i = 0; i < allContentsCount; i += bulkSize) { var items = contentLoader.GetItems(contentLinks.Skip(i).Take(bulkSize), new LanguageSelector(availableLocalization.Name)); var items2 = items.OfType <IIndexableContent>().ToList(); foreach (var content in items2) { info.NumberOfProductsFound++; OnStatusChanged(String.Format("Searching product {0}/{1} - {2}", i + 1, allContentsCount, content.Name)); if (content.ShouldIndex()) { info.NumberOfProductsFoundAfterExpiredFilter++; var findProduct = content.GetFindProduct(market); if (findProduct != null) { client.Index(findProduct); info.NumberOfProductsIndexed++; } } //For long running jobs periodically check if stop is signaled and if so stop execution if (_stopSignaled) { tmr.Stop(); info.Duration = tmr.ElapsedMilliseconds; break; } } //For long running jobs periodically check if stop is signaled and if so stop execution if (_stopSignaled) { tmr.Stop(); info.Duration = tmr.ElapsedMilliseconds; break; } } } if (_stopSignaled) { return("Stop of job was called. " + info.ToString()); } tmr.Stop(); info.Duration = tmr.ElapsedMilliseconds; return(info.ToString()); }