Gismatullin.ISEbd-21.STO.Co.../ServiceStation/ServiceSourceBusinessLogic/OfficePackage/AbstractSaveToWord.cs

74 lines
3.3 KiB
C#
Raw Normal View History

2024-08-15 15:59:47 +04:00
using ServiceSourceBusinessLogic.OfficePackage.HelperEnums;
using ServiceSourceBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServiceSourceBusinessLogic.OfficePackage {
public abstract class AbstractSaveToWord {
public byte[]? CreateDoc(WordInfo info) {
CreateParagraph(new WordParagraph {
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24"})},
TextProperties = new WordTextProperties {
Size = "24",
JustificationType = WordJustificationType.Center,
}
});
foreach (var work_client in info.WorksClients) {
CreateParagraph(new WordParagraph {
Texts = new List<(string, WordTextProperties)> {($"Номера работы:{work_client.WorkId}/Дата:{work_client.Date}/" +
$"Сумма:{work_client.Price}", new WordTextProperties {
Bold = true, Size = "24"
})},
TextProperties = new WordTextProperties {
Size = "24",
JustificationType = WordJustificationType.Both
}
});
foreach (var client in work_client._Clients) {
CreateParagraph(new WordParagraph {
Texts = new List<(string, WordTextProperties)> {($"Номер клиента:{client.client_id}/ФИО клиента:{client.client_fio}",
new WordTextProperties {
Bold = false, Size = "24"
})},
TextProperties = new WordTextProperties {
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
CreateParagraph(new WordParagraph {
Texts = new List<(string, WordTextProperties)> {
($"Итого:{work_client.TotalCount}", new WordTextProperties {
Bold = true,
Size = "24"
})
},
TextProperties = new WordTextProperties {
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
var doucment = SaveWord(info);
return doucment;
}
// Создание документа
protected abstract void CreateWord(WordInfo info);
// Создание абзаца с текстом
protected abstract void CreateParagraph(WordParagraph paragraph);
// Сохранение файла
protected abstract byte[]? SaveWord(WordInfo info);
}
}