public override string Execute() { const int NumberOfItemsInBulkIndexAction = 10; // Use this if you need to delete (only) Widgets from the index during development. //_client.Delete<WidgetSearchResultItem>(x => x.GetType().Name.Exists() | !x.GetType().Name.Exists()); // Get our widgets from the datasource, through the WidgetRepository var widgets = _widgetRepository.GetWidgets(102); // Convert them to a format which will give the required // results with a multilingual Unified Search. var listOfItemsToPush = _widgetSearchResultItemService.GetListToPushToTheIndex(widgets); var count = listOfItemsToPush.Count; var i = 0; while (i <= count) { var itemsToPush = listOfItemsToPush.Skip(i).Take(NumberOfItemsInBulkIndexAction); // Always push a list of items, never push them one by one, to // limit the number of calls to Episerver Find and improve performance. _client.Index(itemsToPush); i += NumberOfItemsInBulkIndexAction; if (_stopSignaled) { OnStatusChanged(StopSignaledMessage); break; } } // Clear old items from the index. var conversionSucceeded = int.TryParse(ConfigurationManager.AppSettings["MaxAgeIndexedWidgetSearchResultItemInDays"], out var maxAgeIndexedWidgetSearchResultItemInDays); var feedbackMessage = new StringBuilder(); if (!conversionSucceeded) { return("Error converting AppSetting to integer for MaxAgeIndexedWidgetSearchResultItemInDays"); } var deleteByQueryResult = _client.Delete <WidgetSearchResultItem>(x => x.DateIndexed.Before(DateTime.Today.AddDays(-maxAgeIndexedWidgetSearchResultItemInDays))); if (deleteByQueryResult.Ok) { feedbackMessage.Append($" Deleted items from the index which were not re-indexed for the last {maxAgeIndexedWidgetSearchResultItemInDays} days."); } return($"Pushed {count} widgets to the index."); }
public IList <Widget> GetWidgets() { return(_repo.GetWidgets()); }
public async Task <IEnumerable <Widget> > GetWidgets() { return(await _widgetRepository.GetWidgets()); }
public async Task <List <Models.Widget> > GetWidgets(int count) { var allWidgets = await widgetRepository.GetWidgets(); return(allWidgets.Take(count).ToList()); }
public WidgetModel[] GetWidgets(int offset, int limit) { (offset, limit) = RangeHelper.CheckRange(offset, limit, 20); return(_widgetRepository.GetWidgets(offset, limit)); }