|
@ -37,7 +37,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
/// <param name="sheetName">页签名称</param>
|
|
|
/// <param name="sheetName">页签名称</param>
|
|
|
/// <param name="data">数据</param>
|
|
|
/// <param name="data">数据</param>
|
|
|
/// <param name="chunkSize">缓存文件行数</param>
|
|
|
/// <param name="chunkSize">缓存文件行数</param>
|
|
|
public async Task<string> WriteDataToExcelInParallel(string sheetName, List<T> data, int chunkSize,string zipFileName, List<SaSeEdiCompareSumReport> sumdata) |
|
|
public async Task<string> WriteDataToExcelInParallel(string sheetName, List<T> data, int chunkSize,string zipFileName, List<SaSeEdiCompareSumReport> sumdata,bool isFinish) |
|
|
{ |
|
|
{ |
|
|
var count = data.Count / 1000000 + ((data.Count % 1000000) > 0 ? 1 : 0); |
|
|
var count = data.Count / 1000000 + ((data.Count % 1000000) > 0 ? 1 : 0); |
|
|
for (var i = 1; i <= count; i++) |
|
|
for (var i = 1; i <= count; i++) |
|
@ -61,54 +61,55 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
string[] filePaths = excelFiles.Select(x => x.FileName).ToArray(); |
|
|
if(isFinish) |
|
|
string zipPath = zipFileName; |
|
|
|
|
|
using (var archive = ZipFile.Open(zipPath, ZipArchiveMode.Create)) |
|
|
|
|
|
{ |
|
|
{ |
|
|
foreach (var file in filePaths) |
|
|
string[] filePaths = excelFiles.Select(x => x.FileName).ToArray(); |
|
|
|
|
|
string zipPath = zipFileName; |
|
|
|
|
|
using (var archive = ZipFile.Open(zipPath, ZipArchiveMode.Create)) |
|
|
{ |
|
|
{ |
|
|
archive.CreateEntryFromFile(file, Path.GetFileName(file)); |
|
|
foreach (var file in filePaths) |
|
|
|
|
|
{ |
|
|
|
|
|
archive.CreateEntryFromFile(file, Path.GetFileName(file)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < count; i++) |
|
|
for (var i = 0; i < count; i++) |
|
|
{ |
|
|
|
|
|
var filelist = excelFiles.Select(p => p.FileName).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var file in filelist) |
|
|
|
|
|
{ |
|
|
{ |
|
|
File.Delete(file); |
|
|
var filelist = excelFiles.Select(p => p.FileName).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var file in filelist) |
|
|
|
|
|
{ |
|
|
|
|
|
File.Delete(file); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
using (FileStream fileStream = new FileStream(zipPath, FileMode.Open)) |
|
|
using (FileStream fileStream = new FileStream(zipPath, FileMode.Open)) |
|
|
{ |
|
|
|
|
|
var minioClient = new MinioClient(EndPoint, AccessKey, SecretKey, ""); |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
{ |
|
|
await minioClient.PutObjectAsync(BucketName, "host/"+zipPath, fileStream, fileStream.Length, "application/zip").ConfigureAwait(false); |
|
|
var minioClient = new MinioClient(EndPoint, AccessKey, SecretKey, ""); |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
await minioClient.PutObjectAsync(BucketName, "host/" + zipPath, fileStream, fileStream.Length, "application/zip").ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
|
|
|
Console.WriteLine($"上传文件到 MinIO 时发生错误: {ex.Message}"); |
|
|
|
|
|
} |
|
|
|
|
|
finally |
|
|
|
|
|
{ |
|
|
|
|
|
if (fileStream != null) |
|
|
|
|
|
{ |
|
|
{ |
|
|
fileStream.Close(); |
|
|
Console.WriteLine($"上传文件到 MinIO 时发生错误: {ex.Message}"); |
|
|
File.Delete(zipPath); |
|
|
} |
|
|
|
|
|
finally |
|
|
|
|
|
{ |
|
|
|
|
|
if (fileStream != null) |
|
|
|
|
|
{ |
|
|
|
|
|
fileStream.Close(); |
|
|
|
|
|
File.Delete(zipPath); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
//using (FileStream fileStream = new FileStream(zipPath, FileMode.Open))
|
|
|
|
|
|
//{
|
|
|
|
|
|
// return fileStream.GetAllBytes();
|
|
|
|
|
|
//}
|
|
|
|
|
|
return zipFileName; |
|
|
return zipFileName; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|