コード例 #1
0
        public HttpResponseMessage RebuildMenu(string database, bool languageDependent = true, string sortBy = "Title", bool buildSearchIndex = true)
        {
            var statusCode = HttpStatusCode.Created;
            List <DatabaseMessage> result = null;

            _logger.Info("RebuildMenu - started");
            try
            {
                string path;

                path = System.Web.HttpContext.Current.Server.MapPath(Settings.Current.General.Paths.PxDatabasesPath);
                path = System.IO.Path.Combine(path, database);


                result = AdminTool.GenerateDatabase(path, languageDependent, sortBy);

                // Clear all caches
                PXWeb.Management.PxContext.CacheController.Clear();

                //Force that databases are read again
                PXWeb.DatabasesSettings databases = (PXWeb.DatabasesSettings)PXWeb.Settings.Current.General.Databases;
                databases.ResetDatabases();

                if (PXWeb.Settings.Current.Features.General.SearchEnabled && buildSearchIndex)
                {
                    PXWeb.DatabaseSettings    db          = (PXWeb.DatabaseSettings)PXWeb.Settings.Current.GetDatabase(database);
                    PXWeb.SearchIndexSettings searchIndex = (PXWeb.SearchIndexSettings)db.SearchIndex;

                    // Check that the status has not been changed by another system before updating it
                    if (searchIndex.Status != SearchIndexStatusType.Indexing)
                    {
                        searchIndex.Status = SearchIndexStatusType.WaitingCreate;
                        db.Save();

                        BackgroundWorker.PxWebBackgroundWorker.HandleSearchIndex(database);
                    }
                }
                _logger.Info("RebuildMenu - finished without error");
            }
            catch (Exception e)
            {
                statusCode = HttpStatusCode.InternalServerError;
                _logger.Error(e.Message);
            }
            return(Request.CreateResponse(statusCode, result));
        }
コード例 #2
0
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            string path;

            path = Server.MapPath(Settings.Current.General.Paths.PxDatabasesPath);
            path = System.IO.Path.Combine(path, cboSelectDb.SelectedValue);

            bool langDependent = false;

            if (string.Compare(cboLanguageDependent.SelectedValue, "true", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                langDependent = true;
            }

            // Clear all caches
            PXWeb.Management.PxContext.CacheController.Clear();

            grdResult.DataSource = AdminTool.GenerateDatabase(path, langDependent, cboSortOrder.SelectedValue);
            grdResult.DataBind();

            //Force that databases are read again
            PXWeb.DatabasesSettings databases = (PXWeb.DatabasesSettings)PXWeb.Settings.Current.General.Databases;
            databases.ResetDatabases();

            if (PXWeb.Settings.Current.Features.General.SearchEnabled)
            {
                if (chkCreateIndex.Checked)
                {
                    PXWeb.DatabaseSettings    db          = (PXWeb.DatabaseSettings)PXWeb.Settings.Current.GetDatabase(cboSelectDb.SelectedValue);
                    PXWeb.SearchIndexSettings searchIndex = (PXWeb.SearchIndexSettings)db.SearchIndex;

                    // Check that the status has not been changed by another system before updating it
                    if (searchIndex.Status != SearchIndexStatusType.Indexing)
                    {
                        searchIndex.Status = SearchIndexStatusType.WaitingCreate;
                        db.Save();
                    }
                    InfoBox.Visible = true;
                }
            }
        }