This commit is contained in:
2022-03-24 00:18:26 +00:00
parent ce8bdcd67e
commit 94e9632caf
4 changed files with 25 additions and 9 deletions

View File

@@ -13,9 +13,8 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
using System.IO.Compression;
using CsvHelper;
using ChoETL;
using System;
using System.Globalization;
namespace AyaNova.Api.Controllers
{
@@ -101,11 +100,11 @@ namespace AyaNova.Api.Controllers
switch (format)
{
case "csv":
using (StreamWriter file = System.IO.File.CreateText(outputSourceFullPath))
using (var csv = new CsvHelper.CsvWriter(file, CultureInfo.InvariantCulture))
using (var w = new ChoCSVWriter(outputSourceFullPath).WithFirstLineHeader().ThrowAndStopOnMissingField(false).WithMaxScanRows(100))
{
var dat = await ((IExportAbleObject)biz).GetExportData(selectedRequest, Guid.Empty);
csv.WriteRecords(dat);
//max scan rows means how many rows it will scan to determine field types so this affects tags because it will scan the first 100 to see the maximum tag count then only ever output that many
var dat = await ((IExportAbleObject)biz).GetExportData(selectedRequest, Guid.Empty);//todo: jobify
w.Write(ToDynamicList(dat));
}
break;
case "json":
@@ -131,7 +130,7 @@ namespace AyaNova.Api.Controllers
catch (ReportRenderTimeOutException)
{
log.LogInformation($"RenderExport timeout data list key: {selectedRequest.DataListKey}, record count:{selectedRequest.SelectedRowIds.LongLength}, user:{UserNameFromContext.Name(HttpContext.Items)} ");
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "timeout - select fewer records"));
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "timeout - select fewer records"));
}
}