Example #1
0
        protected override void ExecuteRequest(SearchQueryRequest searchRequest)
        {
            if (LimitAll || RowLimit > SearchResultBatchSize)
            {
#if FALSE
                int totalRows = 0;

                IBatchProcessor batchProcessor = BatchProcessor.Create();


                batchProcessor.Initialize(searchRequest, SearchResultBatchSize);


                while (batchProcessor.NotFinished)
                {
                    progress.ShowProgress(searchRequest.StartRow.Value, totalRows, remaining);

                    totalRows = GetResults(searchRequest);

                    if (!LimitAll)
                    {
                        totalRows = (RowLimit.HasValue ? RowLimit.Value : rowLimitDefault);
                    }
                    searchRequest.StartRow += SearchResultBatchSize;
                    remaining = totalRows - searchRequest.StartRow.Value;
                    //Console.WriteLine(remaining);
                    searchRequest.RowLimit = remaining < SearchResultBatchSize ? remaining : SearchResultBatchSize;

                    if (SleepBetweenQueryBatches > 0)
                    {
                        Thread.Sleep(SleepBetweenQueryBatches);
                    }
                }
#endif
                // Try to loop through all results in increments of 500
                searchRequest.RowLimit = SearchResultBatchSize;

                int totalRows = (StartRow.HasValue ? StartRow.Value : 0) + 1;
                int remaining = 0;

                while (searchRequest.StartRow < totalRows)
                {
                    progress.ShowProgress(searchRequest.StartRow.Value, totalRows, remaining);

                    totalRows = GetResults(searchRequest);

                    if (!LimitAll)
                    {
                        totalRows = (RowLimit.HasValue ? RowLimit.Value : rowLimitDefault);
                    }
                    searchRequest.StartRow += SearchResultBatchSize;
                    remaining = totalRows - searchRequest.StartRow.Value;
                    //Console.WriteLine(remaining);
                    searchRequest.RowLimit = remaining < SearchResultBatchSize ? remaining : SearchResultBatchSize;

                    if (SleepBetweenQueryBatches > 0)
                    {
                        Thread.Sleep(SleepBetweenQueryBatches);
                    }
                }
            }
            else
            {
                GetResults(searchRequest);
            }
        }