private void IndexContent_Raised(object sender, EventNotificationEventArgs e) { if (e.RaiserId == LocalRaiserId) { return; } this.ProcessRequestInternal(IndexRequestItem.Parse((string)e.Param)); }
public virtual void ProcessRequest(string indexRequest) { if (string.IsNullOrEmpty(indexRequest)) { return; } var request = IndexRequestItem.Parse(indexRequest); if (request == null) { return; } if (string.IsNullOrEmpty(request.Action)) { return; } switch (request.Action) { case IndexRequestItem.REINDEX: if (request.Content != null) { _contentIndexRepository.IndexContent(request.Content, request.IncludeChild); } break; case IndexRequestItem.REMOVE: if (request.Content != null) { _contentIndexRepository.RemoveContentIndex(request.Content, request.IncludeChild); } break; case IndexRequestItem.REMOVE_LANGUAGE: if (request.Content != null) { _contentIndexRepository.RemoveContentLanguageBranch(request.Content); } break; case IndexRequestItem.REINDEXSITE: if (request.Content != null) { _contentIndexRepository.ReindexSite(request.Content); } break; case IndexRequestItem.CALCULATESIZE: var folderSize = _contentIndexRepository.GetIndexFolderSize(); var store = typeof(ServerInfomation).GetOrCreateStore(); store.Save(new ServerInfomation() { IndexSize = folderSize, LocalRaiserId = LocalRaiserId, Name = Environment.MachineName, InRecovering = IndexRecoveryService.IN_RECOVERING, InHealthChecking = IndexHealthCheckService.IS_HEALTH_CHECK }); break; case IndexRequestItem.RESETINDEX: var resetRequest = (ResetIndexRequestItem)request; if (resetRequest.TargetMachine != null && resetRequest.TargetMachine != Guid.Empty) { if (LocalRaiserId == resetRequest.TargetMachine.Value) { _contentIndexRepository.ResetIndexDirectory(); } } else { _contentIndexRepository.ResetIndexDirectory(); } break; case IndexRequestItem.RECOVERINDEX: var recoverRequest = (RecoverIndexRequestItem)request; if (recoverRequest.TargetMachine != null && recoverRequest.TargetMachine != Guid.Empty) { if (LocalRaiserId == recoverRequest.TargetMachine.Value) { _indexRecoveryService.RecoverIndex(true); } } else { _indexRecoveryService.RecoverIndex(true); } break; default: break; } }