protected override bool GenerateMessage() { if (_queryEntity == null) { _queryEntity = ConstructDocumentQuery(); } _queryEntity.DocumentStartIndex = _pageIndex * _batchSize; _endDocumentIndex = _queryEntity.DocumentStartIndex + _batchSize - 1; if (_totalDocumentCount < _endDocumentIndex) { _endDocumentIndex = _totalDocumentCount; } var isGetDocumentsFromSearch = false; var documentIdList = new List <string>(); if (_parametersExportLoadFile.ExportLoadFileInfo != null) { switch (_parametersExportLoadFile.ExportLoadFileInfo.DocumentSelection) { case DocumentSelection.SavedQuery: isGetDocumentsFromSearch = true; documentIdList = GetDocumentsBySearch(_queryEntity); break; case DocumentSelection.Tag: documentIdList = DocumentBO.GetDocumentsForExportJob(_queryEntity.QueryObject.MatterId, _dataset.CollectionId, _parametersExportLoadFile.ExportLoadFileInfo.TagId, _totalDocumentCount, _documentsRetrievalbatchSize, "tag"); break; default: documentIdList = DocumentBO.GetDocumentsForExportJob(_queryEntity.QueryObject.MatterId, _dataset.CollectionId, string.Empty, _totalDocumentCount, _documentsRetrievalbatchSize, "all"); break; } } #region Assertion //Pre condition before send message to next worker documentIdList.ShouldNotBe(null); documentIdList.LongCount().ShouldBeGreaterThan(0); #endregion if (isGetDocumentsFromSearch) //Search use batch retrieval { Send(documentIdList); _pageIndex++; if (_pageIndex * _batchSize < _totalDocumentCount) { return(false); } } else //All & Tag options retrieved in bulk batch from DB { Tracer.Info("Documents retrieved from database for export on All/Tag options - document count {0}", documentIdList.Count); Send(documentIdList); //Send all documents by _batchsize } LogMessage(true, "Export Startup Worker successfully completed."); return(true); }