Пример #1
0
        public async Task <ActionResult> Reset(string id)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageIndexes))
            {
                return(Forbid());
            }

            var luceneIndexSettings = await _luceneIndexSettingsService.GetSettingsAsync(id);

            if (luceneIndexSettings != null)
            {
                if (!_luceneIndexManager.Exists(id))
                {
                    await _luceneIndexingService.CreateIndexAsync(luceneIndexSettings);

                    await _luceneIndexingService.ProcessContentItemsAsync(id);
                }
                else
                {
                    _luceneIndexingService.ResetIndex(id);
                    await _luceneIndexingService.ProcessContentItemsAsync(id);
                }

                _notifier.Success(H["Index <em>{0}</em> reset successfully.", id]);
            }

            return(RedirectToAction(nameof(Index)));
        }
Пример #2
0
        public async Task <ActionResult> Reset(string id)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageIndexes))
            {
                return(Forbid());
            }

            if (!_luceneIndexManager.Exists(id))
            {
                return(NotFound());
            }

            _luceneIndexingService.ResetIndex(id);
            await _luceneIndexingService.ProcessContentItemsAsync(id);

            _notifier.Success(H["Index <em>{0}</em> reset successfully.", id]);

            return(RedirectToAction("Index"));
        }
Пример #3
0
        public async Task <ActionResult> CreatePOST(AdminEditViewModel model)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageIndexes))
            {
                return(Unauthorized());
            }

            ValidateModel(model);

            if (_luceneIndexManager.Exists(model.IndexName))
            {
                ModelState.AddModelError(nameof(AdminEditViewModel.IndexName), S["An index named {0} already exists."]);
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                // We call Rebuild in order to reset the index state cursor too in case the same index
                // name was also used previously.
                _luceneIndexingService.RebuildIndex(model.IndexName);
                await _luceneIndexingService.ProcessContentItemsAsync();
            }
            catch (Exception e)
            {
                _notifier.Error(H["An error occurred while creating the index"]);
                Logger.LogError("An error occurred while creating an index", e);
                return(View(model));
            }

            _notifier.Success(H["Index <em>{0}</em> created successfully", model.IndexName]);

            return(RedirectToAction("Index"));
        }