From 5367f3e85f219823390e501cac858faaaf7b785f Mon Sep 17 00:00:00 2001 From: eugeniy_ivanov Date: Tue, 17 Jan 2023 12:09:58 +0500 Subject: [PATCH] rename DoMerged => MergeFiles refact file extension validate --- .../Services/DrillingProgram/Convert/ConvertToPdf.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/AsbCloudInfrastructure/Services/DrillingProgram/Convert/ConvertToPdf.cs b/AsbCloudInfrastructure/Services/DrillingProgram/Convert/ConvertToPdf.cs index 41bd29e4..f379160b 100644 --- a/AsbCloudInfrastructure/Services/DrillingProgram/Convert/ConvertToPdf.cs +++ b/AsbCloudInfrastructure/Services/DrillingProgram/Convert/ConvertToPdf.cs @@ -11,9 +11,9 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram.Convert { internal class ConvertToPdf { - private readonly string[] fileExtension = { ".xlsx", ".xls", ".ods", ".odt", ".doc", ".docx", ".pdf" }; + private readonly string[] filesExtensions = { ".xlsx", ".xls", ".ods", ".odt", ".doc", ".docx", ".pdf" }; - public static void DoMergedAsync(IEnumerable inputFiles, string outFile) + public static void MergeFiles(IEnumerable inputFiles, string outFile) { using (FileStream stream = new FileStream(outFile, FileMode.Create)) using (Document doc = new Document()) @@ -49,7 +49,7 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram.Convert foreach (var file in filesNames) { var fileExt = Path.GetExtension(file); - if (fileExtension.All(fe => fileExt != fe)) + if (!filesExtensions.Contains(fileExt)) { throw new FileFormatException($"Файл с именем: {file} - неподдерживаемого формата. Он не может быть добавлен в список файлов для конвертации и слияния в общий файл программы бурения."); } @@ -66,12 +66,11 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram.Convert { var fileExt = Path.GetExtension(fileName.inputFile); if (fileExt != ".pdf") - { - //FileInfo fileInfo = new FileInfo(fileName.inputFile); + { await StartConvertProcessAsync(fileName.inputFile, fileName.convertedFile, token); } } - DoMergedAsync(listFileNames.Select(c => c.convertedFile), resultPath); + MergeFiles(listFileNames.Select(c => c.convertedFile), resultPath); } } }