From a445a2307d1a8f76f7eeb32d0d548c04418346cc Mon Sep 17 00:00:00 2001 From: ujijrujijr Date: Tue, 28 May 2024 14:34:16 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=B5=D0=BB=D0=B0=D1=8E=20=D1=81=D0=BE?= =?UTF-8?q?=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=20pdf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ReportImplementerLogic.cs | 59 +++- .../ComputerShopBusinessLogic.csproj | 4 + .../AbstractSaveToExcelImplementer.cs | 194 +++++++++++ .../AbstractSaveToPdfImplementer.cs | 47 +++ .../AbstractSaveToWordImplementer.cs | 87 +++++ .../HelperEnums/ExcelStyleInfoType.cs | 15 + .../HelperEnums/PdfParagraphAlignmentType.cs | 15 + .../HelperEnums/WordJustificationType.cs | 14 + .../HelperModels/ExcelCellParameters.cs | 18 + .../HelperModels/ExcelInfoImplementer.cs | 24 ++ .../HelperModels/ExcelMergeParameters.cs | 15 + .../HelperModels/PdfInfoImplementer.cs | 18 + .../HelperModels/PdfParagraph.cs | 16 + .../HelperModels/PdfRowParameters.cs | 16 + .../HelperModels/WordInfoImplementer.cs | 16 + .../HelperModels/WordParagraph.cs | 14 + .../HelperModels/WordTextProperties.cs | 16 + .../Implements/SaveToExcelImplementer.cs | 324 ++++++++++++++++++ .../Implements/SaveToPdfImplementer.cs | 113 ++++++ .../Implements/SaveToWordImplementer.cs | 139 ++++++++ .../BindingModels/ReportBindingModel.cs | 5 + .../IReportImplementerLogic.cs | 2 +- .../StorageContracts/IOrderStorage.cs | 4 +- .../ReportOrderAssemblyViewModel.cs | 3 + .../ViewModels/RequestViewModel.cs | 7 +- .../Implements/OrderStorage.cs | 11 +- .../Implements/RequestStorage.cs | 60 +++- .../Models/Request.cs | 22 +- .../Controllers/HomeController.cs | 82 ++++- ComputerShopImplementerApp/Program.cs | 3 + .../Views/Home/ConnectRequestAssembly.cshtml | 2 +- .../Views/Home/DeleteRequest.cshtml | 4 +- .../Home/ReportOrdersAssembliesToFile.cshtml | 66 ++++ .../Views/Shared/_Layout.cshtml | 12 +- .../Controllers/OrderController.cs | 53 ++- .../Controllers/RequestController.cs | 4 +- ComputerShopRestApi/Program.cs | 6 + 37 files changed, 1448 insertions(+), 62 deletions(-) create mode 100644 ComputerShopBusinessLogic/OfficePackage/AbstractSaveToExcelImplementer.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/AbstractSaveToPdfImplementer.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/AbstractSaveToWordImplementer.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoImplementer.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfInfoImplementer.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperModels/WordInfoImplementer.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/Implements/SaveToExcelImplementer.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/Implements/SaveToPdfImplementer.cs create mode 100644 ComputerShopBusinessLogic/OfficePackage/Implements/SaveToWordImplementer.cs create mode 100644 ComputerShopImplementerApp/Views/Home/ReportOrdersAssembliesToFile.cshtml diff --git a/ComputerShopBusinessLogic/BusinessLogics/ReportImplementerLogic.cs b/ComputerShopBusinessLogic/BusinessLogics/ReportImplementerLogic.cs index 6b16867..546f796 100644 --- a/ComputerShopBusinessLogic/BusinessLogics/ReportImplementerLogic.cs +++ b/ComputerShopBusinessLogic/BusinessLogics/ReportImplementerLogic.cs @@ -3,6 +3,8 @@ using ComputerShopContracts.BusinessLogicContracts; using ComputerShopContracts.SearchModels; using ComputerShopContracts.StorageContracts; using ComputerShopContracts.ViewModels; +using GarmentFactoryBusinessLogic.OfficePackage; +using GarmentFactoryBusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; @@ -17,36 +19,77 @@ namespace ComputerShopBusinessLogic.BusinessLogics private readonly IRequestStorage _requestStorage; private readonly IOrderStorage _orderStorage; - public ReportImplementerLogic(IAssemblyStorage assemblyStorage, IRequestStorage requestStorage, IOrderStorage orderStorage) + private readonly AbstractSaveToExcelImplementer _saveToExcel; + private readonly AbstractSaveToWordImplementer _saveToWord; + private readonly AbstractSaveToPdfImplementer _saveToPdf; + + public ReportImplementerLogic(IAssemblyStorage assemblyStorage, IRequestStorage requestStorage, IOrderStorage orderStorage, + AbstractSaveToExcelImplementer saveToExcel, AbstractSaveToWordImplementer saveToWord, AbstractSaveToPdfImplementer saveToPdf) { _assemblyStorage = assemblyStorage; _requestStorage = requestStorage; _orderStorage = orderStorage; + _saveToExcel = saveToExcel; + _saveToWord = saveToWord; + _saveToPdf = saveToPdf; } /// /// Отчёт для doc/xls /// /// - public List GetReportOrdersAssemblies(List selectedOrders) + public List GetReportOrdersAssemblies(/*List*/List selectedOrders) { return _orderStorage.GetOrdersAssemblies(selectedOrders); } /// - /// Отчёт для почты/страницы + /// Отчёт для почты/страницы в формате PDF /// /// - public List GetReportOrdersByDates(UserSearchModel currentUser, ReportBindingModel report) + public List GetReportOrdersByDates(ReportBindingModel report) { - return _orderStorage.GetOrdersInfoByDates(currentUser, report); + return _orderStorage.GetOrdersInfoByDates(report); } public void SaveReportOrderAssembliesToWordFile(ReportBindingModel model) { - throw new NotImplementedException(); + _saveToWord.CreateDoc(new WordInfoImplementer + { + FileName = model.FileName, + Title = "Список сборок по выбранным заявкам", + OrderAssemblies = GetReportOrdersAssemblies(model.Ids) + });; + //throw new NotImplementedException(); } public void SaveReportOrderAssembliesToExcelFile(ReportBindingModel model) { - throw new NotImplementedException(); + _saveToExcel.CreateReport(new ExcelInfoImplementer + { + FileName = model.FileName, + OrderAssemblies = GetReportOrdersAssemblies(model.Ids) + }); + //throw new NotImplementedException(); } - } + + //!!!ИСПРАВИТЬ + public void SaveReportOrdersByDatesToPdfFile(ReportBindingModel model) + { + if (model.DateFrom == null) + { + throw new ArgumentException("Дата начала не задана"); + } + + if (model.DateTo == null) + { + throw new ArgumentException("Дата окончания не задана"); + } + _saveToPdf.CreateDoc(new PdfInfoImplementer + { + FileName = model.FileName, + Title = "Список участников", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo!.Value, + Orders = GetReportOrdersByDates(model) + }); + } + } } diff --git a/ComputerShopBusinessLogic/ComputerShopBusinessLogic.csproj b/ComputerShopBusinessLogic/ComputerShopBusinessLogic.csproj index 4a07bc8..3a6dc76 100644 --- a/ComputerShopBusinessLogic/ComputerShopBusinessLogic.csproj +++ b/ComputerShopBusinessLogic/ComputerShopBusinessLogic.csproj @@ -7,7 +7,11 @@ + + + + diff --git a/ComputerShopBusinessLogic/OfficePackage/AbstractSaveToExcelImplementer.cs b/ComputerShopBusinessLogic/OfficePackage/AbstractSaveToExcelImplementer.cs new file mode 100644 index 0000000..879879b --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/AbstractSaveToExcelImplementer.cs @@ -0,0 +1,194 @@ +using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums; +using GarmentFactoryBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToExcelImplementer + { + public void CreateReport(ExcelInfoImplementer info) + { + CreateExcel(info); + + //!!!2 абзаца ниже - настройка заголовков, исправить скорее всего + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = 1, + Text = info.Title1, + StyleInfo = ExcelStyleInfoType.Title + }); + + //MergeCells(new ExcelMergeParameters + //{ + // CellFromName = "A1", + // CellToName = "C1" + //}); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = 1, + Text = info.Title2, + StyleInfo = ExcelStyleInfoType.Title + }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = 1, + Text = info.Title3, + StyleInfo = ExcelStyleInfoType.Title + }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "D", + RowIndex = 1, + Text = info.Title4, + StyleInfo = ExcelStyleInfoType.Title + }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "E", + RowIndex = 1, + Text = info.Title5, + StyleInfo = ExcelStyleInfoType.Title + }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "F", + RowIndex = 1, + Text = info.Title6, + StyleInfo = ExcelStyleInfoType.Title + }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "G", + RowIndex = 1, + Text = info.Title7, + StyleInfo = ExcelStyleInfoType.Title + }); + + uint rowIndex = 2; + foreach (var orderAs in info.OrderAssemblies) + { + int cnt_of_assemblies = orderAs.Assemblies.Count; + int assemblyIndex = 0; + foreach (var assembly in orderAs.Assemblies) + { + if (!string.IsNullOrEmpty(assembly.AssemblyName) && !string.IsNullOrEmpty(assembly.AssemblyCategory) && assembly.AssemblyPrice != 0) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = orderAs.OrderId.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = orderAs.DateCreateOrder.ToShortDateString(), + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = orderAs.OrderSum.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "D", + RowIndex = rowIndex, + Text = orderAs.OrderStatus.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "E", + RowIndex = rowIndex, + Text = assembly.AssemblyName, + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "F", + RowIndex = rowIndex, + Text = assembly.AssemblyCategory, + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "G", + RowIndex = rowIndex, + Text = assembly.AssemblyPrice.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + } + assemblyIndex++; + if (assemblyIndex < cnt_of_assemblies && !string.IsNullOrEmpty(assembly.AssemblyName) && !string.IsNullOrEmpty(assembly.AssemblyCategory) && assembly.AssemblyPrice != 0) + { + rowIndex++; + } + } + + rowIndex++; + + // foreach (var (Component, Count) in tc.Components) + // { + // InsertCellInWorksheet(new ExcelCellParameters + // { + // ColumnName = "B", + // RowIndex = rowIndex, + // Text = Component, + // StyleInfo = ExcelStyleInfoType.TextWithBorder + // }); + + // InsertCellInWorksheet(new ExcelCellParameters + // { + // ColumnName = "C", + // RowIndex = rowIndex, + // Text = Count.ToString(), + // StyleInfo = ExcelStyleInfoType.TextWithBorder + // }); + + // rowIndex++; + // } + + // InsertCellInWorksheet(new ExcelCellParameters + // { + // ColumnName = "A", + // RowIndex = rowIndex, + // Text = "Итого", + // StyleInfo = ExcelStyleInfoType.Text + // }); + // InsertCellInWorksheet(new ExcelCellParameters + // { + // ColumnName = "C", + // RowIndex = rowIndex, + // Text = tc.TotalCount.ToString(), + // StyleInfo = ExcelStyleInfoType.Text + // }); + // rowIndex++; + + } + + SaveExcel(info); + } + protected abstract void CreateExcel(ExcelInfoImplementer info); + protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); + protected abstract void MergeCells(ExcelMergeParameters excelParams); + protected abstract void SaveExcel(ExcelInfoImplementer info); + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/AbstractSaveToPdfImplementer.cs b/ComputerShopBusinessLogic/OfficePackage/AbstractSaveToPdfImplementer.cs new file mode 100644 index 0000000..bdfe23e --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/AbstractSaveToPdfImplementer.cs @@ -0,0 +1,47 @@ +using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums; +using GarmentFactoryBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToPdfImplementer + { + public void CreateDoc(PdfInfoImplementer info) + { + //CreatePdf(info); + //CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); + //CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); + + //CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "3cm" }); + + //CreateRow(new PdfRowParameters + //{ + // Texts = new List { "Номер", "Дата заказа", "Текстиль", "Статус", "Сумма" }, + // Style = "NormalTitle", + // ParagraphAlignment = PdfParagraphAlignmentType.Center + //}); + + //foreach (var order in info.Orders) + //{ + // CreateRow(new PdfRowParameters + // { + // Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.TextileName, order.Status.ToString(), order.Sum.ToString() }, + // Style = "Normal", + // ParagraphAlignment = PdfParagraphAlignmentType.Left + // }); + //} + //CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth }); + + //SavePdf(info); + } + protected abstract void CreatePdf(PdfInfoImplementer info); + protected abstract void CreateParagraph(PdfParagraph paragraph); + protected abstract void CreateTable(List columns); + protected abstract void CreateRow(PdfRowParameters rowParameters); + protected abstract void SavePdf(PdfInfoImplementer info); + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/AbstractSaveToWordImplementer.cs b/ComputerShopBusinessLogic/OfficePackage/AbstractSaveToWordImplementer.cs new file mode 100644 index 0000000..5f7fa3e --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/AbstractSaveToWordImplementer.cs @@ -0,0 +1,87 @@ +using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums; +using GarmentFactoryBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToWordImplementer + { + public void CreateDoc(WordInfoImplementer info) + { + CreateWord(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 orderAs in info.OrderAssemblies) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { + ("Заказ №" + orderAs.OrderId.ToString() + " - " + orderAs.DateCreateOrder.ToShortDateString() + " - " + orderAs.OrderStatus + " - " + orderAs.OrderSum, new WordTextProperties {Size = "24", Bold=true}) + }, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + foreach (var assembly in orderAs.Assemblies) + { + if (!string.IsNullOrEmpty(assembly.AssemblyName) && !string.IsNullOrEmpty(assembly.AssemblyCategory) && assembly.AssemblyPrice != 0) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> { + //(orderAs.OrderId.ToString() + "\n", new WordTextProperties {Size = "24", Bold=true}), + //(orderAs.DateCreateOrder.ToShortDateString() + " - ", new WordTextProperties { Size = "24" }), + //(orderAs.OrderSum.ToString() + " - ", new WordTextProperties { Size = "24" }), + //(orderAs.OrderStatus.ToString() + " - ", new WordTextProperties { Size = "24" }), + (assembly.AssemblyName + " - ", new WordTextProperties { Size = "24" }), + (assembly.AssemblyCategory + " - ", new WordTextProperties { Size = "24" }), + (assembly.AssemblyPrice.ToString(), new WordTextProperties { Size = "24" }) + }, TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } + + } + } + SaveWord(info); + } + + /// + /// Создание doc-файла + /// + /// + protected abstract void CreateWord(WordInfoImplementer info); + + /// + /// Создание абзаца с текстом + /// + /// + /// + protected abstract void CreateParagraph(WordParagraph paragraph); + + /// + /// Сохранение файла + /// + /// + protected abstract void SaveWord(WordInfoImplementer info); + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/ComputerShopBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs new file mode 100644 index 0000000..400fd1e --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperEnums +{ + public enum ExcelStyleInfoType + { + Title, + Text, + TextWithBorder + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs b/ComputerShopBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs new file mode 100644 index 0000000..1942bac --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperEnums +{ + public enum PdfParagraphAlignmentType + { + Center, + Left, + Rigth + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs b/ComputerShopBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs new file mode 100644 index 0000000..77144da --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperEnums +{ + public enum WordJustificationType + { + Center, + Both + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs b/ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs new file mode 100644 index 0000000..accfe64 --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs @@ -0,0 +1,18 @@ +using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels +{ + public class ExcelCellParameters + { + public string ColumnName { get; set; } = string.Empty; + public uint RowIndex { get; set; } + public string Text { get; set; } = string.Empty; + public string CellReference => $"{ColumnName}{RowIndex}"; + public ExcelStyleInfoType StyleInfo { get; set; } + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoImplementer.cs b/ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoImplementer.cs new file mode 100644 index 0000000..885f224 --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelInfoImplementer.cs @@ -0,0 +1,24 @@ +using ComputerShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels +{ + public class ExcelInfoImplementer + { + public string FileName { get; set; } = string.Empty; + //public string Title { get; set; } = string.Empty; + //!!!Мб поставить string.Empty, названия задать в ReportImplementerLogic + public string Title1 { get; set; } = "ID заказа"; + public string Title2 { get; set; } = "Дата заказа"; + public string Title3 { get; set; } = "Стоимость заказа"; + public string Title4 { get; set; } = "Статус заказа"; + public string Title5 { get; set; } = "Название сборки"; + public string Title6 { get; set; } = "Категория сборки"; + public string Title7 { get; set; } = "Цена сборки"; + public List OrderAssemblies { get; set; } = new(); + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs b/ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs new file mode 100644 index 0000000..fffd328 --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels +{ + public class ExcelMergeParameters + { + public string CellFromName { get; set; } = string.Empty; + public string CellToName { get; set; } = string.Empty; + public string Merge => $"{CellFromName}:{CellToName}"; + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfInfoImplementer.cs b/ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfInfoImplementer.cs new file mode 100644 index 0000000..31129bd --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfInfoImplementer.cs @@ -0,0 +1,18 @@ +using ComputerShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels +{ + public class PdfInfoImplementer + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public DateTime DateFrom { get; set; } + public DateTime DateTo { get; set; } + public List Orders { get; set; } = new(); + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs new file mode 100644 index 0000000..d78b2f2 --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs @@ -0,0 +1,16 @@ +using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels +{ + public class PdfParagraph + { + public string Text { get; set; } = string.Empty; + public string Style { get; set; } = string.Empty; + public PdfParagraphAlignmentType ParagraphAlignment { get; set; } + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs new file mode 100644 index 0000000..0b04a46 --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs @@ -0,0 +1,16 @@ +using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels +{ + public class PdfRowParameters + { + public List Texts { get; set; } = new(); + public string Style { get; set; } = string.Empty; + public PdfParagraphAlignmentType ParagraphAlignment { get; set; } + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperModels/WordInfoImplementer.cs b/ComputerShopBusinessLogic/OfficePackage/HelperModels/WordInfoImplementer.cs new file mode 100644 index 0000000..c3e595c --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperModels/WordInfoImplementer.cs @@ -0,0 +1,16 @@ +using ComputerShopContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels +{ + public class WordInfoImplementer + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public List OrderAssemblies { get; set; } = new(); + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs b/ComputerShopBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs new file mode 100644 index 0000000..4600728 --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels +{ + public class WordParagraph + { + public List<(string, WordTextProperties)> Texts { get; set; } = new(); + public WordTextProperties? TextProperties { get; set; } + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs b/ComputerShopBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs new file mode 100644 index 0000000..f5458ba --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs @@ -0,0 +1,16 @@ +using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels +{ + public class WordTextProperties + { + public string Size { get; set; } = string.Empty; + public bool Bold { get; set; } + public WordJustificationType JustificationType { get; set; } + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/Implements/SaveToExcelImplementer.cs b/ComputerShopBusinessLogic/OfficePackage/Implements/SaveToExcelImplementer.cs new file mode 100644 index 0000000..68c71fb --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/Implements/SaveToExcelImplementer.cs @@ -0,0 +1,324 @@ +using DocumentFormat.OpenXml.Office2010.Excel; +using DocumentFormat.OpenXml.Office2013.Excel; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Spreadsheet; +using DocumentFormat.OpenXml; +using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums; +using GarmentFactoryBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.Implements +{ + public class SaveToExcelImplementer : AbstractSaveToExcelImplementer + { + private SpreadsheetDocument? _spreadsheetDocument; + private SharedStringTablePart? _shareStringPart; + private Worksheet? _worksheet; + + /// + /// Настройка стилей для файла + /// + /// + // WorkbookPart содержит информацию о стилях для ячеек в рабочей книге, добавление стилей в неё + private static void CreateStyles(WorkbookPart workbookpart) + { + var sp = workbookpart.AddNewPart(); + sp.Stylesheet = new Stylesheet(); + + var fonts = new Fonts() { Count = 2U, KnownFonts = true }; + + //Создание шрифтов для основного текста и заголовка (в ячейке A1) + var fontUsual = new Font(); + fontUsual.Append(new FontSize() { Val = 12D }); + fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U }); + fontUsual.Append(new FontName() { Val = "Times New Roman" }); + fontUsual.Append(new FontFamilyNumbering() { Val = 2 }); + fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor }); + + var fontTitle = new Font(); + fontTitle.Append(new Bold()); + fontTitle.Append(new FontSize() { Val = 14D }); + fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U }); + fontTitle.Append(new FontName() { Val = "Times New Roman" }); + fontTitle.Append(new FontFamilyNumbering() { Val = 2 }); + fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor }); + + fonts.Append(fontUsual); + fonts.Append(fontTitle); + + + //Создание заливок ячеек + var fills = new Fills() { Count = 2U }; + + var fill1 = new Fill(); + fill1.Append(new PatternFill() { PatternType = PatternValues.None }); + + var fill2 = new Fill(); + fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 }); + + fills.Append(fill1); + fills.Append(fill2); + + //Создание границ (без границ и с тонкими границами (исп., где название и кол-во компонента)) + var borders = new Borders() { Count = 2U }; + + var borderNoBorder = new Border(); + borderNoBorder.Append(new LeftBorder()); + borderNoBorder.Append(new RightBorder()); + borderNoBorder.Append(new TopBorder()); + borderNoBorder.Append(new BottomBorder()); + borderNoBorder.Append(new DiagonalBorder()); + + var borderThin = new Border(); + + 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); + borderThin.Append(rightBorder); + borderThin.Append(topBorder); + borderThin.Append(bottomBorder); + borderThin.Append(new DiagonalBorder()); + + borders.Append(borderNoBorder); + borders.Append(borderThin); + + var cellStyleFormats = new CellStyleFormats() { Count = 1U }; + var cellFormatStyle = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U }; + + cellStyleFormats.Append(cellFormatStyle); + + //Создание 3 стилей ячеек + var cellFormats = new CellFormats() { Count = 3U }; + var cellFormatFont = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyFont = true }; + var cellFormatFontAndBorder = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 1U, FormatId = 0U, ApplyFont = true, ApplyBorder = true }; + var cellFormatTitle = new CellFormat() { NumberFormatId = 0U, FontId = 1U, FillId = 0U, BorderId = 0U, FormatId = 0U, Alignment = new Alignment() { Vertical = VerticalAlignmentValues.Center, WrapText = true, Horizontal = HorizontalAlignmentValues.Center }, ApplyFont = true }; + + cellFormats.Append(cellFormatFont); + cellFormats.Append(cellFormatFontAndBorder); + cellFormats.Append(cellFormatTitle); + + var cellStyles = new CellStyles() { Count = 1U }; + + cellStyles.Append(new CellStyle() { Name = "Normal", FormatId = 0U, BuiltinId = 0U }); + + var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats() { Count = 0U }; + + var tableStyles = new TableStyles() { Count = 0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" }; + + var stylesheetExtensionList = new StylesheetExtensionList(); + + var stylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" }; + stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); + stylesheetExtension1.Append(new SlicerStyles() { DefaultSlicerStyle = "SlicerStyleLight1" }); + + var stylesheetExtension2 = new StylesheetExtension() { Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" }; + stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); + stylesheetExtension2.Append(new TimelineStyles() { DefaultTimelineStyle = "TimeSlicerStyleLight1" }); + + stylesheetExtensionList.Append(stylesheetExtension1); + stylesheetExtensionList.Append(stylesheetExtension2); + + sp.Stylesheet.Append(fonts); + sp.Stylesheet.Append(fills); + sp.Stylesheet.Append(borders); + sp.Stylesheet.Append(cellStyleFormats); + sp.Stylesheet.Append(cellFormats); + sp.Stylesheet.Append(cellStyles); + sp.Stylesheet.Append(differentialFormats); + sp.Stylesheet.Append(tableStyles); + sp.Stylesheet.Append(stylesheetExtensionList); + } + + /// + /// Получение номера стиля из типа + /// + /// + /// + private static uint GetStyleValue(ExcelStyleInfoType styleInfo) + { + return styleInfo switch + { + ExcelStyleInfoType.Title => 2U, + ExcelStyleInfoType.TextWithBorder => 1U, + ExcelStyleInfoType.Text => 0U, + _ => 0U, + }; + } + + protected override void CreateExcel(ExcelInfoImplementer info) + { + _spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook); + // Создание книги (в ней хранятся листы) + var workbookpart = _spreadsheetDocument.AddWorkbookPart(); + workbookpart.Workbook = new Workbook(); + + CreateStyles(workbookpart); + + // Получение/создание хранилища текстов для книги + _shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType().Any() + ? _spreadsheetDocument.WorkbookPart.GetPartsOfType().First() + : _spreadsheetDocument.WorkbookPart.AddNewPart(); + + // Создание SharedStringTable, если его нет + if (_shareStringPart.SharedStringTable == null) + { + _shareStringPart.SharedStringTable = new SharedStringTable(); + } + + // Создание листа в книге + var worksheetPart = workbookpart.AddNewPart(); + worksheetPart.Worksheet = new Worksheet(new SheetData()); + + // Добавление столбцов с заданной шириной + // Save the stylesheet formats + //stylesPart.Stylesheet.Save(); + + // Create custom widths for columns + Columns lstColumns = worksheetPart.Worksheet.GetFirstChild(); + if (lstColumns == null) + { + lstColumns = new Columns(); + } + // Min = 1, Max = 1 ==> Apply this to column 1 (A) + // Min = 2, Max = 2 ==> Apply this to column 2 (B) + // Width = 25 ==> Set the width to 25 + // CustomWidth = true ==> Tell Excel to use the custom width + lstColumns.Append(new Column() { Min = 1, Max = 1, Width = 10, CustomWidth = true }); + lstColumns.Append(new Column() { Min = 2, Max = 2, Width = 10, CustomWidth = true }); + lstColumns.Append(new Column() { Min = 3, Max = 3, Width = 20, CustomWidth = true }); + lstColumns.Append(new Column() { Min = 4, Max = 4, Width = 10, CustomWidth = true }); + lstColumns.Append(new Column() { Min = 5, Max = 5, Width = 20, CustomWidth = true }); + lstColumns.Append(new Column() { Min = 6, Max = 6, Width = 20, CustomWidth = true }); + lstColumns.Append(new Column() { Min = 7, Max = 7, Width = 20, CustomWidth = true }); + worksheetPart.Worksheet.InsertAt(lstColumns, 0); + + // Добавление листа в книгу + var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets()); + var sheet = new Sheet() + { + Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart), + SheetId = 1, + Name = "Лист" + }; + sheets.Append(sheet); + + _worksheet = worksheetPart.Worksheet; + } + + protected override void InsertCellInWorksheet(ExcelCellParameters excelParams) + { + if (_worksheet == null || _shareStringPart == null) + { + return; + } + var sheetData = _worksheet.GetFirstChild(); + if (sheetData == null) + { + return; + } + + // Ищем строку, либо добавляем ее + Row row; + if (sheetData.Elements().Where(r => r.RowIndex! == excelParams.RowIndex).Any()) + { + row = sheetData.Elements().Where(r => r.RowIndex! == excelParams.RowIndex).First(); + } + else + { + row = new Row() { RowIndex = excelParams.RowIndex }; + sheetData.Append(row); + } + + // Ищем нужную ячейку + Cell cell; + if (row.Elements().Where(c => c.CellReference!.Value == excelParams.CellReference).Any()) + { + cell = row.Elements().Where(c => c.CellReference!.Value == excelParams.CellReference).First(); + } + else + { + // Все ячейки должны быть последовательно друг за другом расположены + // нужно определить, после какой вставлять + Cell? refCell = null; + foreach (Cell rowCell in row.Elements()) + { + if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0) + { + refCell = rowCell; + break; + } + } + + var newCell = new Cell() { CellReference = excelParams.CellReference }; + row.InsertBefore(newCell, refCell); + + cell = newCell; + } + + // вставляем новый текст + _shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text))); + _shareStringPart.SharedStringTable.Save(); + + cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements().Count() - 1).ToString()); + cell.DataType = new EnumValue(CellValues.SharedString); + cell.StyleIndex = GetStyleValue(excelParams.StyleInfo); + } + + protected override void MergeCells(ExcelMergeParameters excelParams) + { + if (_worksheet == null) + { + return; + } + MergeCells mergeCells; + + if (_worksheet.Elements().Any()) + { + mergeCells = _worksheet.Elements().First(); + } + else + { + mergeCells = new MergeCells(); + + if (_worksheet.Elements().Any()) + { + _worksheet.InsertAfter(mergeCells, _worksheet.Elements().First()); + } + else + { + _worksheet.InsertAfter(mergeCells, _worksheet.Elements().First()); + } + } + + var mergeCell = new MergeCell() + { + Reference = new StringValue(excelParams.Merge) + }; + mergeCells.Append(mergeCell); + } + + protected override void SaveExcel(ExcelInfoImplementer info) + { + if (_spreadsheetDocument == null) + { + return; + } + _spreadsheetDocument.WorkbookPart!.Workbook.Save(); + _spreadsheetDocument.Close(); + } + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/Implements/SaveToPdfImplementer.cs b/ComputerShopBusinessLogic/OfficePackage/Implements/SaveToPdfImplementer.cs new file mode 100644 index 0000000..3fe5771 --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/Implements/SaveToPdfImplementer.cs @@ -0,0 +1,113 @@ +using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums; +using GarmentFactoryBusinessLogic.OfficePackage.HelperModels; +using MigraDoc.DocumentObjectModel; +using MigraDoc.DocumentObjectModel.Tables; +using MigraDoc.Rendering; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.Implements +{ + public class SaveToPdfImplementer : AbstractSaveToPdfImplementer + { + private Document? _document; + private Section? _section; + private Table? _table; + + private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type) + { + return type switch + { + PdfParagraphAlignmentType.Center => ParagraphAlignment.Center, + PdfParagraphAlignmentType.Left => ParagraphAlignment.Left, + PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right, + _ => ParagraphAlignment.Justify, + }; + } + + private static void DefineStyles(Document document) + { + var style = document.Styles["Normal"]; + style.Font.Name = "Times New Roman"; + style.Font.Size = 14; + + style = document.Styles.AddStyle("NormalTitle", "Normal"); + style.Font.Bold = true; + } + + protected override void CreatePdf(PdfInfoImplementer info) + { + _document = new Document(); + DefineStyles(_document); + + _section = _document.AddSection(); + } + + protected override void CreateParagraph(PdfParagraph pdfParagraph) + { + if (_section == null) + { + return; + } + var paragraph = _section.AddParagraph(pdfParagraph.Text); + paragraph.Format.SpaceAfter = "1cm"; + paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment); + paragraph.Style = pdfParagraph.Style; + } + + protected override void CreateTable(List columns) + { + if (_document == null) + { + return; + } + _table = _document.LastSection.AddTable(); + + foreach (var elem in columns) + { + _table.AddColumn(elem); + } + } + + protected override void CreateRow(PdfRowParameters rowParameters) + { + if (_table == null) + { + return; + } + var row = _table.AddRow(); + for (int i = 0; i < rowParameters.Texts.Count; ++i) + { + row.Cells[i].AddParagraph(rowParameters.Texts[i]); + + if (!string.IsNullOrEmpty(rowParameters.Style)) + { + row.Cells[i].Style = rowParameters.Style; + } + + Unit borderWidth = 0.5; + + row.Cells[i].Borders.Left.Width = borderWidth; + 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; + } + } + + protected override void SavePdf(PdfInfoImplementer info) + { + var renderer = new PdfDocumentRenderer(true) + { + Document = _document + }; + renderer.RenderDocument(); + renderer.PdfDocument.Save(info.FileName); + } + } +} diff --git a/ComputerShopBusinessLogic/OfficePackage/Implements/SaveToWordImplementer.cs b/ComputerShopBusinessLogic/OfficePackage/Implements/SaveToWordImplementer.cs new file mode 100644 index 0000000..e19fbff --- /dev/null +++ b/ComputerShopBusinessLogic/OfficePackage/Implements/SaveToWordImplementer.cs @@ -0,0 +1,139 @@ +using DocumentFormat.OpenXml; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Wordprocessing; +using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums; +using GarmentFactoryBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GarmentFactoryBusinessLogic.OfficePackage.Implements +{ + public class SaveToWordImplementer : AbstractSaveToWordImplementer + { + private WordprocessingDocument? _wordDocument; + private Body? _docBody; + + /// + /// Получение типа выравнивания + /// + /// + /// + private static JustificationValues GetJustificationValues(WordJustificationType type) + { + return type switch + { + WordJustificationType.Both => JustificationValues.Both, + WordJustificationType.Center => JustificationValues.Center, + _ => JustificationValues.Left, + }; + } + + /// + /// Настройки страницы + /// + /// + private static SectionProperties CreateSectionProperties() + { + var properties = new SectionProperties(); + + var pageSize = new PageSize + { + Orient = PageOrientationValues.Portrait + }; + + properties.AppendChild(pageSize); + + return properties; + } + + /// + /// Задание форматирования для абзаца + /// + /// + /// + private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties) + { + if (paragraphProperties == null) + { + return null; + } + + var properties = new ParagraphProperties(); + + properties.AppendChild(new Justification() + { + Val = GetJustificationValues(paragraphProperties.JustificationType) + }); + + properties.AppendChild(new SpacingBetweenLines + { + LineRule = LineSpacingRuleValues.Auto + }); + + properties.AppendChild(new Indentation()); + + var paragraphMarkRunProperties = new ParagraphMarkRunProperties(); + if (!string.IsNullOrEmpty(paragraphProperties.Size)) + { + paragraphMarkRunProperties.AppendChild(new FontSize { Val = paragraphProperties.Size }); + } + properties.AppendChild(paragraphMarkRunProperties); + + return properties; + } + + protected override void CreateWord(WordInfoImplementer info) + { + _wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document); + MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart(); + mainPart.Document = new Document(); + _docBody = mainPart.Document.AppendChild(new Body()); + } + + protected override void CreateParagraph(WordParagraph paragraph) + { + if (_docBody == null || paragraph == null) + { + return; + } + var docParagraph = new Paragraph(); + + docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties)); + + foreach (var run in paragraph.Texts) + { + var docRun = new Run(); + + var properties = new RunProperties(); + properties.AppendChild(new FontSize { Val = run.Item2.Size }); + if (run.Item2.Bold) + { + properties.AppendChild(new Bold()); + } + docRun.AppendChild(properties); + + docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve }); + + docParagraph.AppendChild(docRun); + } + + _docBody.AppendChild(docParagraph); + } + + protected override void SaveWord(WordInfoImplementer info) + { + if (_docBody == null || _wordDocument == null) + { + return; + } + _docBody.AppendChild(CreateSectionProperties()); + + _wordDocument.MainDocumentPart!.Document.Save(); + + _wordDocument.Close(); + } + } +} diff --git a/ComputerShopContracts/BindingModels/ReportBindingModel.cs b/ComputerShopContracts/BindingModels/ReportBindingModel.cs index 5edb012..4e2bbe0 100644 --- a/ComputerShopContracts/BindingModels/ReportBindingModel.cs +++ b/ComputerShopContracts/BindingModels/ReportBindingModel.cs @@ -11,5 +11,10 @@ namespace ComputerShopContracts.BindingModels public string FileName { get; set; } = string.Empty; public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } + + public int UserId { get; set; } + + //Id выбранных записей + public List? Ids { get; set; } } } diff --git a/ComputerShopContracts/BusinessLogicContracts/IReportImplementerLogic.cs b/ComputerShopContracts/BusinessLogicContracts/IReportImplementerLogic.cs index 04360c2..49eb950 100644 --- a/ComputerShopContracts/BusinessLogicContracts/IReportImplementerLogic.cs +++ b/ComputerShopContracts/BusinessLogicContracts/IReportImplementerLogic.cs @@ -15,7 +15,7 @@ namespace ComputerShopContracts.BusinessLogicContracts /// Получение отчёта для word/excel /// /// - List GetReportOrdersAssemblies(List selectedOrders); + List GetReportOrdersAssemblies(List selectedOrders); /// /// Получение отчёта для почты diff --git a/ComputerShopContracts/StorageContracts/IOrderStorage.cs b/ComputerShopContracts/StorageContracts/IOrderStorage.cs index 607c173..5ac5734 100644 --- a/ComputerShopContracts/StorageContracts/IOrderStorage.cs +++ b/ComputerShopContracts/StorageContracts/IOrderStorage.cs @@ -18,7 +18,7 @@ namespace ComputerShopContracts.StorageContracts OrderViewModel? Update(OrderBindingModel model); OrderViewModel? Delete(OrderBindingModel model); //получение данных о заказах для отчётов - List GetOrdersAssemblies(List model); - List GetOrdersInfoByDates(UserSearchModel currentUser, ReportBindingModel report); + List GetOrdersAssemblies(List model); + List GetOrdersInfoByDates(ReportBindingModel report); } } diff --git a/ComputerShopContracts/ViewModels/ReportOrderAssemblyViewModel.cs b/ComputerShopContracts/ViewModels/ReportOrderAssemblyViewModel.cs index 50b3125..fedbd30 100644 --- a/ComputerShopContracts/ViewModels/ReportOrderAssemblyViewModel.cs +++ b/ComputerShopContracts/ViewModels/ReportOrderAssemblyViewModel.cs @@ -3,6 +3,7 @@ using ComputerShopDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -18,5 +19,7 @@ namespace ComputerShopContracts.ViewModels //данные о сборках public List<(string AssemblyName, string AssemblyCategory, double AssemblyPrice)> Assemblies { get; set; } + + //public Dictionary Assemblies { get; set; } } } diff --git a/ComputerShopContracts/ViewModels/RequestViewModel.cs b/ComputerShopContracts/ViewModels/RequestViewModel.cs index 807ccc3..6573699 100644 --- a/ComputerShopContracts/ViewModels/RequestViewModel.cs +++ b/ComputerShopContracts/ViewModels/RequestViewModel.cs @@ -34,9 +34,14 @@ namespace ComputerShopContracts.ViewModels public RequestViewModel() { } [JsonConstructor] - public RequestViewModel(Dictionary requestOrders) + public RequestViewModel(Dictionary requestOrders, AssemblyViewModel assembly) { this.RequestOrders = requestOrders.ToDictionary(x => x.Key, x => x.Value as IOrderModel); + this.Assembly = assembly as IAssemblyModel; } + //public RequestViewModel(Dictionary requestOrders) + //{ + // this.RequestOrders = requestOrders.ToDictionary(x => x.Key, x => x.Value as IOrderModel); + //} } } diff --git a/ComputerShopDatabaseImplement/Implements/OrderStorage.cs b/ComputerShopDatabaseImplement/Implements/OrderStorage.cs index 3607374..895461c 100644 --- a/ComputerShopDatabaseImplement/Implements/OrderStorage.cs +++ b/ComputerShopDatabaseImplement/Implements/OrderStorage.cs @@ -55,17 +55,18 @@ namespace ComputerShopDatabaseImplement.Implements } //получение данных сборок по выбранным заказам для отчёта (doc/xls) - public List GetOrdersAssemblies(List selectedModels) + public List GetOrdersAssemblies(List/**/ selectedModels) { using var context = new ComputerShopDatabase(); //id заказов, которые выбрал пользователь - List id_of_selected_models = selectedModels.Select(x => x.Id).ToList(); + //List id_of_selected_models = selectedModels.Select(x => x.Id).ToList(); //те заказы из бд, которые выбрал пользователь и имеют сборку + //МБ ИЗМЕНИТЬ, И СДЕЛАТЬ ВЫВОД ВСЕХ ЗАЯВОК (В ТОМ ЧИСЛЕ БЕЗ СБОРОК) return context.Orders.Include(x => x.Requests) .ThenInclude(x => x.Request) .ThenInclude(x => x.Assembly) - .Where(x => id_of_selected_models.Contains(x.Id) && x.Requests.Any(r => r.Request.Assembly != null)) + .Where(x => selectedModels.Contains(x.Id) && x.Requests.Any(r => r.Request.Assembly != null)) .ToList() .Select(x => new ReportOrderAssemblyViewModel { @@ -79,13 +80,13 @@ namespace ComputerShopDatabaseImplement.Implements } //получение заказов (все, что создал сам пользователь) за период с расшифровкой по заявкам и сборкам для отчёта (почта/страница) - public List GetOrdersInfoByDates(UserSearchModel currentUser, ReportBindingModel report) + public List GetOrdersInfoByDates(ReportBindingModel report) { using var context = new ComputerShopDatabase(); return context.Orders.Include(x => x.Requests) .ThenInclude(x => x.Request) .ThenInclude(x => x.Assembly) - .Where(x => x.UserId == currentUser.Id && x.DateCreate >= report.DateFrom && x.DateCreate <= report.DateTo) + .Where(x => x.UserId == report.UserId && x.DateCreate >= report.DateFrom && x.DateCreate <= report.DateTo) .ToList() .Select(x => new ReportOrdersViewModel { diff --git a/ComputerShopDatabaseImplement/Implements/RequestStorage.cs b/ComputerShopDatabaseImplement/Implements/RequestStorage.cs index 51c1dd2..d5742d4 100644 --- a/ComputerShopDatabaseImplement/Implements/RequestStorage.cs +++ b/ComputerShopDatabaseImplement/Implements/RequestStorage.cs @@ -118,7 +118,7 @@ namespace ComputerShopDatabaseImplement.Implements using var transaction = context.Database.BeginTransaction(); try { - var request = context.Requests.FirstOrDefault(x => x.Id == model.Id); + var request = context.Requests.Include(x => x.Orders).ThenInclude(x => x.Order).Include(x => x.Assembly).FirstOrDefault(x => x.Id == model.Id); if (request == null) { return null; @@ -141,9 +141,28 @@ namespace ComputerShopDatabaseImplement.Implements using var context = new ComputerShopDatabase(); var request = context.Requests .Include(x => x.Orders) + .ThenInclude(x => x.Order) + .Include(x => x.Assembly) .FirstOrDefault(y => y.Id == model.Id); + if (request != null) { + double assemblyPrice; + if (request.Assembly == null) + { + assemblyPrice = 0; + } + else + { + assemblyPrice = request.Assembly.Price; + } + //var ordersOfRequest = context.RequestOrders.Where(x => x.RequestId == model.Id).ToList(); + foreach (Order order_request in request.RequestOrders.Values) + { + //Если была связанная сборка, то вычитание стоимости сборки, иначе -0 + //order_request.ChangeSum(-(request.Assembly?.Price ?? 0)); + order_request.ChangeSum(-assemblyPrice); + } context.Requests.Remove(request); context.SaveChanges(); return request.GetViewModel; @@ -154,15 +173,40 @@ namespace ComputerShopDatabaseImplement.Implements public bool ConnectRequestAssembly(RequestBindingModel model) { using var context = new ComputerShopDatabase(); - var request = context.Requests.FirstOrDefault(x => x.Id == model.Id); - var assembly = context.Assemblies.FirstOrDefault(x => x.Id == model.AssemblyId); - if (request == null || assembly == null) + var request = context.Requests.Include(x => x.Orders).ThenInclude(x => x.Order).Include(x => x.Assembly).FirstOrDefault(x => x.Id == model.Id); + + if (request != null) { - return false; + // Если у заявки до этого уже была другая связанная сборка + // вычитание стоимости сборки из всех связанных чеков + if (request.Assembly != null) + { + foreach (Order order_of_request in request.RequestOrders.Values) + { + order_of_request.ChangeSum(-request.Assembly.Price); + context.SaveChanges(); + } + } + + //Поиск заявки, с которой надо связать + var newAssembly = context.Assemblies.FirstOrDefault(x => x.Id == model.AssemblyId); + + if (newAssembly == null) { + return false; + } + + // Прибавление к стоимости всех связанных заказов стоимость новой сборки + foreach (Order order_of_request in request.RequestOrders.Values) + { + order_of_request.ChangeSum(newAssembly.Price); + context.SaveChanges(); + } + + // Запоминание новой сборки в заявке + request.ConnectAssembly(context, model); + return true; } - request.ConnectAssembly(context, model); - context.SaveChanges(); - return true; + return false; } } } diff --git a/ComputerShopDatabaseImplement/Models/Request.cs b/ComputerShopDatabaseImplement/Models/Request.cs index 86e4b68..68b4441 100644 --- a/ComputerShopDatabaseImplement/Models/Request.cs +++ b/ComputerShopDatabaseImplement/Models/Request.cs @@ -96,16 +96,16 @@ namespace ComputerShopDatabaseImplement.Models { var currentRequest = context.Requests.First(x => x.Id == Id); //стоимость сборки, связанной с заявкой (или 0, если заявка не связана со сборкой) - double price_of_assembly = (currentRequest.Assembly.Price != null) ? currentRequest.Assembly.Price : 0; + double price_of_assembly = (currentRequest.AssemblyId != null) ? context.Assemblies.First(x => x.Id == currentRequest.AssemblyId).Price : 0; - var requestOrders = context.RequestOrders.Where(x => x.RequestId == model.Id).ToList(); + var oldRequestOrders = context.RequestOrders.Where(x => x.RequestId == model.Id).ToList(); //удаление тех заказов, которых нет в модели (+ изменение суммы у удаляемых заказов) //ИЗМЕНЕНО: удаление всех заказов - if (requestOrders != null && requestOrders.Count > 0) + if (oldRequestOrders != null && oldRequestOrders.Count > 0) { //var delOrders = requestOrders.Where(x => !model.RequestOrders.ContainsKey(x.OrderId)); - var delOrders = requestOrders; + var delOrders = oldRequestOrders; foreach (var delOrder in delOrders) { context.RequestOrders.Remove(delOrder); @@ -136,21 +136,9 @@ namespace ComputerShopDatabaseImplement.Models //Связывание заявки со сборкой (+ изменение суммы у соответствующих заказов) public void ConnectAssembly(ComputerShopDatabase context, RequestBindingModel model) { - //стоимость старой сборки (или 0, если её не было) - double price_of_old_assembly = (Assembly.Price != null) ? Assembly.Price : 0; - AssemblyId = model.AssemblyId; Assembly = context.Assemblies.First(x => x.Id == model.AssemblyId); - //изменение стоимости всех связанных заказов - foreach (var request_order in model.RequestOrders) - { - var connectedOrder = context.Orders.First(x => x.Id == request_order.Key); - //вычитание из стоимости заказа старой сборки - connectedOrder.ChangeSum(-price_of_old_assembly); - //прибавление стоимости новой сборки - connectedOrder.ChangeSum(Assembly.Price); - context.SaveChanges(); - } + context.SaveChanges(); } } } diff --git a/ComputerShopImplementerApp/Controllers/HomeController.cs b/ComputerShopImplementerApp/Controllers/HomeController.cs index 000126b..3d3a0f7 100644 --- a/ComputerShopImplementerApp/Controllers/HomeController.cs +++ b/ComputerShopImplementerApp/Controllers/HomeController.cs @@ -447,11 +447,25 @@ namespace ComputerShopImplementerApp.Controllers } ViewBag.Requests = await APIUser.GetRequestRequestAsync>($"api/request/getrequests?userId={APIUser.User.Id}"); //ViewBag.Orders = APIUser.GetRequest>($"api/order/getorders?userId={APIUser.User.Id}"); - ViewBag.Assemblies = APIUser.GetRequest>($"api/") + ViewBag.Assemblies = APIUser.GetRequest>($"api/assembly/getassemblies"); return View(); } + [HttpPost] + public void ConnectRequestAssembly(int request, int assembly) + { + if (APIUser.User == null) + { + throw new Exception("Вход только авторизованным"); + } + APIUser.PostRequest("api/request/connectRequestAssembly", new RequestBindingModel + { + Id = request, + AssemblyId = assembly + }); + Response.Redirect("Requests"); + } @@ -482,9 +496,71 @@ namespace ComputerShopImplementerApp.Controllers } - // ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ + //ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ ОТЧЁТЫ - [HttpGet] + [HttpGet] + public IActionResult ReportOrdersAssembliesToFile() + { + if (APIUser.User == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Orders = APIUser.GetRequest>($"api/order/getorders?userId={APIUser.User.Id}"); + //ViewBag.Statuses = + return View(); + } + + [HttpPost] + public void ReportOrdersAssembliesToFile(int[] orders, string type) + { + if (APIUser.User == null) + { + Redirect("Index"); + throw new Exception("Вход только авторизованным"); + } + if (orders.Length <= 0) + { + throw new Exception("Выберите хотя бы 1 заказ"); + } + if (string.IsNullOrEmpty(type)) + { + throw new Exception("Неверный тип отчета"); + } + + //Преобразование массива в список + List ids = new List(); + foreach (var item in orders) + { + ids.Add(item); + } + + if (type == "docx") + { + APIUser.PostRequest("api/order/createreporttowordfile", new ReportBindingModel + { + Ids = ids, + //FileName = "C:\\ReportsCourseWork\\wordfile.docx" + FileName = "C:\\!КУРСОВАЯ\\Сборки по выбранным заказам.docx" + }); + Response.Redirect("Index"); + } + + if (type == "xlsx") + { + APIUser.PostRequest("api/order/createreporttoexcelfile", new ReportBindingModel + { + Ids = ids, + //FileName = "C:\\ReportsCourseWork\\wordfile.docx" + FileName = "C:\\!КУРСОВАЯ\\Сборки по выбранным заказам.xlsx" + }); + Response.Redirect("Index"); + } + } + + + // ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ + + [HttpGet] public IActionResult Privacy() { if (APIUser.User == null) diff --git a/ComputerShopImplementerApp/Program.cs b/ComputerShopImplementerApp/Program.cs index 71b858d..d412fe8 100644 --- a/ComputerShopImplementerApp/Program.cs +++ b/ComputerShopImplementerApp/Program.cs @@ -24,6 +24,9 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); + +//builder.Services.AddTransient(); + // Add services to the container. builder.Services.AddControllersWithViews(); diff --git a/ComputerShopImplementerApp/Views/Home/ConnectRequestAssembly.cshtml b/ComputerShopImplementerApp/Views/Home/ConnectRequestAssembly.cshtml index 0c66490..16f3a6c 100644 --- a/ComputerShopImplementerApp/Views/Home/ConnectRequestAssembly.cshtml +++ b/ComputerShopImplementerApp/Views/Home/ConnectRequestAssembly.cshtml @@ -55,7 +55,7 @@
-
+
diff --git a/ComputerShopImplementerApp/Views/Home/DeleteRequest.cshtml b/ComputerShopImplementerApp/Views/Home/DeleteRequest.cshtml index a817718..8981301 100644 --- a/ComputerShopImplementerApp/Views/Home/DeleteRequest.cshtml +++ b/ComputerShopImplementerApp/Views/Home/DeleteRequest.cshtml @@ -17,11 +17,11 @@
- +
- +
diff --git a/ComputerShopImplementerApp/Views/Home/ReportOrdersAssembliesToFile.cshtml b/ComputerShopImplementerApp/Views/Home/ReportOrdersAssembliesToFile.cshtml new file mode 100644 index 0000000..b9896cf --- /dev/null +++ b/ComputerShopImplementerApp/Views/Home/ReportOrdersAssembliesToFile.cshtml @@ -0,0 +1,66 @@ +@using ComputerShopContracts.ViewModels +@{ + ViewData["Title"] = "Create report with assemblies by orders"; +} + +
+
+

Получение списка сборок по заказам

+
+
+ + +
+
+ +
+ + +
+
+ + +
+
+
+
+
+
+
+ +@* *@ \ No newline at end of file diff --git a/ComputerShopImplementerApp/Views/Shared/_Layout.cshtml b/ComputerShopImplementerApp/Views/Shared/_Layout.cshtml index 415e4fa..88b0f27 100644 --- a/ComputerShopImplementerApp/Views/Shared/_Layout.cshtml +++ b/ComputerShopImplementerApp/Views/Shared/_Layout.cshtml @@ -3,7 +3,7 @@ - @ViewData["Title"] - GarmentFactoryClientApp + @ViewData["Title"] - ComputerShopImplementerApp @@ -32,6 +32,16 @@ + + + @* !!!СЮДА ВСТАВИТЬ 2 ССЫЛКИ НА СТРАНИЦЫ С ПОЛУЧЕНИЕМ ОТЧЁТОВ *@ + + + + + diff --git a/ComputerShopRestApi/Controllers/OrderController.cs b/ComputerShopRestApi/Controllers/OrderController.cs index cd4014a..c56d65f 100644 --- a/ComputerShopRestApi/Controllers/OrderController.cs +++ b/ComputerShopRestApi/Controllers/OrderController.cs @@ -16,10 +16,13 @@ namespace ComputerShopRestApi.Controllers private readonly IOrderLogic _logic; - public OrderController(IOrderLogic logic, ILogger logger) + private readonly IReportImplementerLogic _reportLogic; + + public OrderController(IOrderLogic logic, ILogger logger, IReportImplementerLogic reportLogic) { _logger = logger; _logic = logic; + _reportLogic = reportLogic; } [HttpGet] @@ -58,17 +61,45 @@ namespace ComputerShopRestApi.Controllers } } - //МБ ИЗМЕНИТЬ IEnumerable на List - //!!!ПОТОМ УДАЛИТЬ - //[HttpGet] - //public IEnumerable GetOrderStatuses() - //{ - // // Получаем все значения из перечисления и возвращаем как список строк - // var allStatuses = Enum.GetValues(typeof(OrderStatus)).Cast().Select(status => status.ToString()); - // return allStatuses; - //} + [HttpPost] + public void CreateReportToWordFile(ReportBindingModel model) + { + try + { + _reportLogic.SaveReportOrderAssembliesToWordFile(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + } - [HttpPost] + [HttpPost] + public void CreateReportToExcelFile(ReportBindingModel model) + { + try + { + _reportLogic.SaveReportOrderAssembliesToExcelFile(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + } + + //МБ ИЗМЕНИТЬ IEnumerable на List + //!!!ПОТОМ УДАЛИТЬ + //[HttpGet] + //public IEnumerable GetOrderStatuses() + //{ + // // Получаем все значения из перечисления и возвращаем как список строк + // var allStatuses = Enum.GetValues(typeof(OrderStatus)).Cast().Select(status => status.ToString()); + // return allStatuses; + //} + + [HttpPost] public void CreateOrder(OrderBindingModel model) { try diff --git a/ComputerShopRestApi/Controllers/RequestController.cs b/ComputerShopRestApi/Controllers/RequestController.cs index da3e4da..ef282fd 100644 --- a/ComputerShopRestApi/Controllers/RequestController.cs +++ b/ComputerShopRestApi/Controllers/RequestController.cs @@ -74,11 +74,11 @@ namespace ComputerShopRestApi.Controllers //параметры для удобного использования в swagger, потом скорее всего будет передаваться RequestBindingModel model [HttpPost] - public void ConnectRequestAssembly(int requestId, int assemblyId) + public void ConnectRequestAssembly(RequestBindingModel model) { try { - _logic.ConnectRequestAssembly(new RequestBindingModel { Id = requestId, AssemblyId = assemblyId }); + _logic.ConnectRequestAssembly(model); } catch (Exception ex) { diff --git a/ComputerShopRestApi/Program.cs b/ComputerShopRestApi/Program.cs index a956d72..0112c74 100644 --- a/ComputerShopRestApi/Program.cs +++ b/ComputerShopRestApi/Program.cs @@ -4,6 +4,8 @@ using ComputerShopContracts.StorageContracts; using ComputerShopDatabaseImplement.Implements; using ComputerShopDatabaseImplement.Models; using ComputerShopDataModels.Models; +using GarmentFactoryBusinessLogic.OfficePackage; +using GarmentFactoryBusinessLogic.OfficePackage.Implements; using Microsoft.OpenApi.Models; var Builder = WebApplication.CreateBuilder(args); @@ -31,8 +33,12 @@ Builder.Services.AddTransient(); Builder.Services.AddTransient(); Builder.Services.AddTransient(); +Builder.Services.AddTransient(); Builder.Services.AddTransient(); +Builder.Services.AddTransient(); +Builder.Services.AddTransient(); +Builder.Services.AddTransient(); Builder.Services.AddControllers(); Builder.Services.AddEndpointsApiExplorer();