Ejemplo n.º 1
0
        public ActionResult Index()
        {
            if (!CheckPermission(StandardPermissions.FullAccess))
            {
                return(new HttpUnauthorizedResult());
            }

            WorkContext.Breadcrumbs.Add(T(KoreWebLocalizableStrings.Indexing.Title));

            IndexEntry indexEntry;

            try
            {
                indexEntry = indexingService.GetIndexEntry(KoreWebConstants.Indexing.DefaultIndexName);

                if (indexEntry == null)
                {
                    ViewBag.Message = string.Format(
                        "<div class=\"alert alert-info\">{0}</div>", T(KoreWebLocalizableStrings.Indexing.NoSearchIndexToManage));
                }
            }
            catch (Exception e)
            {
                indexEntry = null;
                Logger.ErrorFormat(e, "Search index couldn't be read.");

                ViewBag.Message = string.Format(
                    "<div class=\"alert alert-warning\">{0}</div>", T(KoreWebLocalizableStrings.Indexing.SearchIndexMayBeCorrupted));
            }

            ViewBag.Title = T(KoreWebLocalizableStrings.Indexing.Title);
            return(PartialView("Kore.Web.Areas.Admin.Indexing.Views.Indexing.Index", indexEntry));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            var viewModel = new IndexViewModel {
                IndexEntries  = Enumerable.Empty <IndexEntry>(),
                IndexProvider = _indexManager.GetSearchIndexProvider()
            };

            if (_indexManager.HasIndexProvider())
            {
                viewModel.IndexEntries = _indexManager.GetSearchIndexProvider().List().Select(x => {
                    try {
                        return(_indexingService.GetIndexEntry(x));
                    }
                    catch (Exception e) {
                        Logger.Error(e, "Index couldn't be read: " + x);
                        return(new IndexEntry {
                            IndexName = x,
                            IndexingStatus = IndexingStatus.Unavailable
                        });
                    }
                });
            }

            // Services.Notifier.Information(T("The index might be corrupted. If you can't recover click on Rebuild."));

            return(View(viewModel));
        }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            var viewModel = new IndexViewModel {
                IndexEntry = _indexingService.GetIndexEntry(DefaultIndexName)
            };

            if (viewModel.IndexEntry == null)
            {
                Services.Notifier.Information(T("There is no search index to manage for this site."));
            }

            return(View(viewModel));
        }
Ejemplo n.º 4
0
        public ActionResult Index()
        {
            var viewModel = new IndexViewModel();

            try {
                viewModel.IndexEntry = _indexingService.GetIndexEntry(DefaultIndexName);

                if (viewModel.IndexEntry == null)
                {
                    Services.Notifier.Information(T("There is no search index to manage for this site."));
                }
            }
            catch (Exception e) {
                Logger.Error(e, "Search index couldn't be read.");
                Services.Notifier.Information(T("The index might be corrupted. If you can't recover click on Rebuild."));
            }

            return(View(viewModel));
        }
Ejemplo n.º 5
0
        public ActionResult Index()
        {
            if (!CheckPermission(StandardPermissions.FullAccess, T("Not allowed to manage the search index.")))
            {
                return(new HttpUnauthorizedResult());
            }

            WorkContext.Breadcrumbs.Add(T("Indexing"));

            IndexEntry indexEntry;

            try
            {
                indexEntry = indexingService.GetIndexEntry(DefaultIndexName);

                if (indexEntry == null)
                {
                    notifier.Information(T("There is no search index to manage for this site."));
                }
            }
            catch (Exception e)
            {
                indexEntry = null;
                Logger.ErrorFormat(e, "Search index couldn't be read.");

                notifier.Information(T("The index might be corrupted. If you can't recover click on Rebuild."));
            }

            if (indexEntry == null)
            {
                notifier.Information(T("There is currently no search index."));
            }
            else if (indexEntry.LastUpdateUtc == DateTime.MinValue)
            {
                notifier.Information(T("The search index has not been built yet."));
            }
            else
            {
                if (indexEntry.DocumentCount == 0)
                {
                    notifier.Information(T("The search index does not contain any document."));
                }
                else
                {
                    notifier.Information(T("The search index contains {0} document(s).", indexEntry.DocumentCount));
                }

                if (indexEntry.Fields.Any())
                {
                    notifier.Information(T("The search index contains the following fields: {0}.", string.Join(", ", indexEntry.Fields)));
                }
                else
                {
                    notifier.Information(T("The search index does not contain any field."));
                }

                notifier.Information(T("The search index was last updated {0}.", indexEntry.LastUpdateUtc));

                switch (indexEntry.IndexingStatus)
                {
                case IndexingStatus.Rebuilding:
                    notifier.Information(T("The indexing process is currently being rebuilt."));
                    break;

                case IndexingStatus.Updating:
                    notifier.Information(T("The indexing process is currently being updated."));
                    break;
                }
            }

            var sb = new StringBuilder();

            if (indexEntry != null)
            {
                sb.AppendFormat("<form method=\"post\" action=\"{0}\">", Url.Action("Rebuild"));
                sb.AppendFormat("<div class=\"form-group\"><label>{0}</label><br />", T("Rebuild the search index for a fresh start:"));
                sb.AppendFormat("<button class=\"btn btn-primary\" type=\"submit\"><i class=\"cx-icon cx-icon-refresh\"></i>&nbsp;{0}</button></div>", T("Rebuild"));
                sb.Append("</form>");
            }

            var result = new ControlContentResult(sb.ToString())
            {
                Title = T("Search Index")
            };

            return(result);
        }