public void Handle(CommentQueryResult message)
        {
            if (message.Dtos.Any())
            {
                if (Data.SkipComments % 1000 == 0)
                {
                    _entityIndexer.OptimizeCommentIndex();
                }

                Data.CommentsRetrievedCount += message.Dtos.Length;

                foreach (var comment in message.Dtos)
                {
                    _entityIndexer.AddCommentIndex(comment);
                }

                if (Data.CommentsRetrievedCount == message.QueryResultCount)
                {
                    Data.CommentsRetrievedCount = 0;
                    Data.SkipComments          += PageSize;

                    Send(new CommentQuery {
                        Hql = string.Format(CommentsHql, Data.SkipComments, PageSize), IgnoreMessageSizeOverrunFailure = true, Params = _param
                    });
                }
            }
            else
            {
                _entityIndexer.OptimizeCommentIndex();
                SendLocal(new IndexExistingEntitiesDoneLocalMessage {
                    SagaId = Data.OuterSagaId
                });
                MarkAsComplete();
            }
        }
 private void AddCommentIndex(CommentDTO commentDto)
 {
     RebuildOrAction(() => _entityIndexer.AddCommentIndex(commentDto, DocumentIndexOptimizeSetup.DeferredOptimize));
 }
 private void AddCommentIndex(CommentDTO commentDto)
 {
     _entityIndexer.AddCommentIndex(commentDto);
     _entityIndexer.OptimizeCommentIndex();
 }