forked from ddrilling/AsbCloudServer
rename DoMerged => MergeFiles
refact file extension validate
This commit is contained in:
parent
3e128c5cba
commit
5367f3e85f
@ -11,9 +11,9 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram.Convert
|
|||||||
{
|
{
|
||||||
internal class ConvertToPdf
|
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<string> inputFiles, string outFile)
|
public static void MergeFiles(IEnumerable<string> inputFiles, string outFile)
|
||||||
{
|
{
|
||||||
using (FileStream stream = new FileStream(outFile, FileMode.Create))
|
using (FileStream stream = new FileStream(outFile, FileMode.Create))
|
||||||
using (Document doc = new Document())
|
using (Document doc = new Document())
|
||||||
@ -49,7 +49,7 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram.Convert
|
|||||||
foreach (var file in filesNames)
|
foreach (var file in filesNames)
|
||||||
{
|
{
|
||||||
var fileExt = Path.GetExtension(file);
|
var fileExt = Path.GetExtension(file);
|
||||||
if (fileExtension.All(fe => fileExt != fe))
|
if (!filesExtensions.Contains(fileExt))
|
||||||
{
|
{
|
||||||
throw new FileFormatException($"Файл с именем: {file} - неподдерживаемого формата. Он не может быть добавлен в список файлов для конвертации и слияния в общий файл программы бурения.");
|
throw new FileFormatException($"Файл с именем: {file} - неподдерживаемого формата. Он не может быть добавлен в список файлов для конвертации и слияния в общий файл программы бурения.");
|
||||||
}
|
}
|
||||||
@ -67,11 +67,10 @@ namespace AsbCloudInfrastructure.Services.DrillingProgram.Convert
|
|||||||
var fileExt = Path.GetExtension(fileName.inputFile);
|
var fileExt = Path.GetExtension(fileName.inputFile);
|
||||||
if (fileExt != ".pdf")
|
if (fileExt != ".pdf")
|
||||||
{
|
{
|
||||||
//FileInfo fileInfo = new FileInfo(fileName.inputFile);
|
|
||||||
await StartConvertProcessAsync(fileName.inputFile, fileName.convertedFile, token);
|
await StartConvertProcessAsync(fileName.inputFile, fileName.convertedFile, token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DoMergedAsync(listFileNames.Select(c => c.convertedFile), resultPath);
|
MergeFiles(listFileNames.Select(c => c.convertedFile), resultPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user