2024-08-19 17:49:44 +04:00
|
|
|
|
using ServiceStationBusinessLogic.OfficePackage.HelperEnums;
|
|
|
|
|
using ServiceStationBusinessLogic.OfficePackage.HelperModels;
|
2024-08-15 15:59:47 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2024-08-19 17:49:44 +04:00
|
|
|
|
namespace ServiceStationBusinessLogic.OfficePackage {
|
2024-08-15 15:59:47 +04:00
|
|
|
|
public abstract class AbstractSaveToWord {
|
|
|
|
|
|
|
|
|
|
public byte[]? CreateDoc(WordInfo info) {
|
2024-08-27 16:29:09 +04:00
|
|
|
|
|
|
|
|
|
CreateWord(info);
|
|
|
|
|
|
2024-08-15 15:59:47 +04:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|