private List <SearchResultRow> LoadAllData(ref ReportStatus status, SearchRequest request, IReportsDataSource dataSource, LoopTimer <ReportStatus> loopTimer)
        {
            request.PageIndex = 0;
            request.GetCount  = true;

            // get the first page, with a count
            var page = GetPage(request, dataSource);

            var totalRows  = page.Summary.TotalRows;
            var totalPages = (int)Math.Ceiling((double)totalRows / request.PageSize);

            var result = page.Data;

            // getting count could have an impact on performance and is only needed for the first request
            request.GetCount = false;

            while (request.PageIndex + 1 < totalPages)
            {
                request.PageIndex++;
                page = GetPage(request, dataSource);
                if (page != null && page.Data != null && page.Data.Any())
                {
                    result.AddRange(page.Data);
                }

                status.ProgressPercentage = (int)Math.Floor(((double)100 / totalPages) * (request.PageIndex + 1) * Configuration.Exports.DataLoadPercent);

                loopTimer.Loop();
            }

            return(result);
        }
Exemple #2
0
        private void WriteRows(List <ReportColumnMapping> columnDefinitions, List <SearchResultRow> rows)
        {
            int columnIndex;

            int progressPercent = 0;

            var firstRow = rows.First();

            for (var i = 0; i < rows.Count; i++)
            {
                columnIndex = 1;
                for (var j = 0; j < firstRow.Values.Count; j++)
                {
                    var value = rows[i].Values[j].Value;

                    var columnDefinition = columnDefinitions.First(x => x.Id == rows[i].Values[j].ColumnId);

                    string dataFormat = GetDataFormat(columnDefinition);
                    int    precision  = GetPrecision(columnDefinition);

                    SetCellValue(rowIndex, columnIndex, value, dataFormat, precision);

                    columnIndex++;

                    if (ProgressCallback != null)
                    {
                        progressPercent = (int)((((double)100) / rows.Count) * i);
                        ProgressCallback.Invoke(progressPercent);
                        LoopTimer.Loop();
                    }
                }

                rowIndex++;
            }
        }