public JsonResult Reindex(ReimportClass context) { //Check permission if (!IsAuthorized()) { return(JsonHelper.GetJsonWithWrapper(null, false, "You are not authorized for this request type.", null)); } bool valid = true; string filter = string.Format(" base.CTID = '{0}'", context.Ctid); int processed = 0; string returnStatus = ""; //Do the request switch (context.TypeName) { case "credential": case "CredentialProfile": ElasticServices.Credential_UpdateIndex(filter, ref processed); break; case "organization": case "QAOrganization": ElasticServices.Organization_UpdateIndex(filter, ref processed); break; case "AssessmentProfile": case "assessment": ElasticServices.Assessment_UpdateIndex(filter, ref processed); break; case "LearningOpportunityProfile": case "learningopportunity": ElasticServices.LearningOpp_UpdateIndex(filter, ref processed); break; default: valid = false; returnStatus = "Profile not handled"; return(JsonHelper.GetJsonWithWrapper(null, valid, returnStatus, null)); //break; } if (processed > 0) { returnStatus = "Seems to have worked, try searching again."; } else { valid = false; returnStatus = "Hmmm - didn't seem to work."; } //Return the result return(JsonHelper.GetJsonWithWrapper(null, valid, returnStatus, null)); }
public bool Import(ThisEntity entity, ref SaveStatus status) { //do a get, and add to cache before updating if (entity.Id > 0) { //note could cause problems verifying after an import (i.e. shows cached version. Maybe remove from cache after completion. var detail = GetDetail(entity.Id); } bool isValid = new EntityMgr().Save(entity, ref status); List <string> messages = new List <string>(); if (entity.Id > 0) { if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false) { //update cache new CacheManager().PopulateEntityRelatedCaches(entity.RowId); //update Elastic if (Utilities.UtilityManager.GetAppKeyValue("usingElasticLearningOppSearch", false)) { ElasticServices.LearningOpp_UpdateIndex(entity.Id); } else { new SearchPendingReindexManager().Add(7, entity.Id, 1, ref messages); if (messages.Count > 0) { status.AddWarningRange(messages); } } } else { new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE, entity.Id, 1, ref messages); new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages); if (messages.Count > 0) { status.AddWarningRange(messages); } } CacheManager.RemoveItemFromCache("lopp", entity.Id); } return(isValid); }