feat: add DOCX workbench and Word automation

This commit is contained in:
codex
2026-07-30 13:18:54 +03:00
parent 1bda2c155d
commit 958bad6823
6 changed files with 240 additions and 0 deletions
@@ -0,0 +1,26 @@
using DocumentAutomation.Shared;
namespace DocxWorkbench.Core;
public interface IDocumentInspector
{
DocumentInspectionResult Inspect(string docxPath);
}
public interface IWordDocumentService
{
Task<WordDocumentResult> BuildDocumentAsync(WordDocumentBuildRequest request, IProgress<string>? progress, CancellationToken cancellationToken);
Task<WordPreviewResult> ExportPdfAsync(string docxPath, string outputPdfPath, CancellationToken cancellationToken);
}
public static class DocumentInputValidation
{
public static void Validate(WordDocumentBuildRequest request)
{
if (!File.Exists(request.TemplatePath)) throw new FileNotFoundException("Шаблон DOCX не найден.", request.TemplatePath);
if (!File.Exists(request.BodyPath)) throw new FileNotFoundException("Файл тела документа не найден.", request.BodyPath);
if (!request.TemplatePath.EndsWith(".docx", StringComparison.OrdinalIgnoreCase)) throw new ArgumentException("Шаблон должен быть DOCX.");
if (Path.GetFullPath(request.TemplatePath).Equals(Path.GetFullPath(request.OutputDocxPath), StringComparison.OrdinalIgnoreCase)) throw new InvalidOperationException("Нельзя перезаписывать исходный шаблон.");
Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(request.OutputDocxPath))!);
}
}