Промежуточное сохранение.

This commit is contained in:
Programmist73 2023-03-19 12:53:48 +04:00
parent d38144af20
commit e2034af97d
7 changed files with 28 additions and 29 deletions

View File

@ -16,8 +16,6 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
//Реализация бизнес-логики отчётов
public class ReportLogic : IReportLogic
{
private readonly IWorkPieceStorage _workPieceStorage;
private readonly IManufactureStorage _manufactureStorage;
private readonly IOrderStorage _orderStorage;
@ -29,13 +27,13 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
private readonly AbstractSaveToPdf _saveToPdf;
//инициализируем поля класса через контейнер
public ReportLogic(IManufactureStorage manufactureStorage, IWorkPieceStorage
workPieceStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel,
public ReportLogic(IManufactureStorage manufactureStorage,
IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel,
AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_manufactureStorage = manufactureStorage;
_workPieceStorage = workPieceStorage;
_orderStorage = orderStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
@ -57,10 +55,10 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
TotalCount = 0
};
foreach (var workPieces in manufacture.ManufactureWorkPieces)
foreach (var workPiece in manufacture.ManufactureWorkPieces)
{
record.WorkPieces.Add(new (workPieces.Value.Item1.WorkPieceName, workPieces.Value.Item2));
record.TotalCount += workPieces.Value.Item2;
record.WorkPieces.Add(new (workPiece.Value.Item1.WorkPieceName, workPiece.Value.Item2));
record.TotalCount += workPiece.Value.Item2;
}
list.Add(record);
@ -84,18 +82,18 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
.ToList();
}
//Сохранение заготовок в файл-Word
public void SaveWorkPiecesToWordFile(ReportBindingModel model)
//Сохранение мороженных в файл-Word
public void SaveManufacturesToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список заготовок",
WorkPieces = _workPieceStorage.GetFullList()
Title = "Список изделий",
Manufactures = _manufactureStorage.GetFullList()
});
}
//Сохранение заготовок с указаеним продуктов в файл-Excel
//Сохранение заготовок с указаеним изделий в файл-Excel
public void SaveManufactureWorkPieceToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfo

View File

@ -43,13 +43,13 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
rowIndex++;
foreach (var (Manufacure, Count) in mwp.Manufactures)
foreach (var (WorkPiece, Count) in mwp.WorkPieces)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = Manufacure,
Text = WorkPiece,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});

View File

@ -27,12 +27,12 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
});
//заполнение абзацев текстом
foreach (var workPiece in info.WorkPieces)
foreach (var manufacture in info.Manufactures)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (workPiece.WorkPieceName + " ", new WordTextProperties { Bold = true, Size = "24", }),
(workPiece.Cost.ToString(), new WordTextProperties { Size = "24" }) },
Texts = new List<(string, WordTextProperties)> { (manufacture.ManufactureName + " ", new WordTextProperties { Bold = true, Size = "24", }),
(manufacture.Price.ToString(), new WordTextProperties { Size = "24" }) },
TextProperties = new WordTextProperties
{
Size = "24",

View File

@ -15,6 +15,6 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty;
//список заготовок для вывода и сохранения
public List<WorkPieceViewModel> WorkPieces { get; set; } = new();
public List<ManufactureViewModel> Manufactures { get; set; } = new();
}
}

View File

@ -17,7 +17,9 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
public class SaveToExcel : AbstractSaveToExcel
{
private SpreadsheetDocument? _spreadsheetDocument;
private SharedStringTablePart? _shareStringPart;
private Worksheet? _worksheet;
//Настройка стилей для файла
@ -28,6 +30,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
//настройка шрифта простого текста
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
var fontUsual = new Font();
fontUsual.Append(new FontSize() { Val = 12D });
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
@ -68,8 +71,8 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
//стиль границ ячейки - незакрашенный (для заголовка) и закрашенный
var borders = new Borders() { Count = 2U };
var borderNoBorder = new Border();
var borderNoBorder = new Border();
borderNoBorder.Append(new LeftBorder());
borderNoBorder.Append(new RightBorder());
borderNoBorder.Append(new TopBorder());
@ -77,26 +80,23 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
borderNoBorder.Append(new DiagonalBorder());
var borderThin = new Border();
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
var rightBorder = new RightBorder()
{
Style = BorderStyleValues.Thin
};
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
var bottomBorder = new BottomBorder()
{
Style = BorderStyleValues.Thin
};
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
borderThin.Append(leftBorder);

View File

@ -62,10 +62,10 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
{
return;
}
var paragraph = _section.AddParagraph(pdfParagraph.Text);
paragraph.Format.SpaceAfter = "1cm";
paragraph.Format.Alignment =
GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
paragraph.Style = pdfParagraph.Style;
}
@ -111,6 +111,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
row.Cells[i].Borders.Right.Width = borderWidth;
row.Cells[i].Borders.Top.Width = borderWidth;
row.Cells[i].Borders.Bottom.Width = borderWidth;
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
}

View File

@ -16,10 +16,10 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
//Получение списка заказов за определенный период
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
//Сохранение заготовок в файл-Word
void SaveWorkPiecesToWordFile(ReportBindingModel model);
//Сохранение изделий в файл-Word
void SaveManufacturesToWordFile(ReportBindingModel model);
//Сохранение заготовок с указаеним изделий в файл-Excel
//Сохранение заготовок с указанием изделий в файл-Excel
void SaveManufactureWorkPieceToExcelFile(ReportBindingModel model);
//Сохранение заказов в файл-Pdf