diff --git a/Diner/DinerContracts/BindingModels/ReportBindingModel.cs b/Diner/DinerContracts/BindingModels/ReportBindingModel.cs new file mode 100644 index 0000000..dcab5ea --- /dev/null +++ b/Diner/DinerContracts/BindingModels/ReportBindingModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DinerContracts.BindingModels +{ + public class ReportBindingModel + { + public string FileName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set;} + } +} diff --git a/Diner/DinerContracts/BusinessLogicsContracts/IReportLogic.cs b/Diner/DinerContracts/BusinessLogicsContracts/IReportLogic.cs new file mode 100644 index 0000000..32c17af --- /dev/null +++ b/Diner/DinerContracts/BusinessLogicsContracts/IReportLogic.cs @@ -0,0 +1,24 @@ +using DinerContracts.BindingModels; +using DinerContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DinerContracts.BusinessLogicsContracts +{ + public interface IReportLogic + { + // Получение списка компонент с указанием, в каких изделиях используются + List GetProductComponent(); + // Получение списка заказов за определенный период + List GetOrders(ReportBindingModel model); + // Сохранение компонент в файл-Word + void SaveComponentsToWorldFile(ReportBindingModel model); + // Сохранение компонент с указаеним продуктов в файл-Excel + void SaveProductComponentToExcelFile(ReportBindingModel model); + // Сохранение заказов в файл-Pdf + void SaveOrdersToPdfFile(ReportBindingModel model); + } +} diff --git a/Diner/DinerContracts/SearchModels/OrderSearchModel.cs b/Diner/DinerContracts/SearchModels/OrderSearchModel.cs index 4b7490d..13bd858 100644 --- a/Diner/DinerContracts/SearchModels/OrderSearchModel.cs +++ b/Diner/DinerContracts/SearchModels/OrderSearchModel.cs @@ -9,5 +9,7 @@ namespace DinerContracts.SearchModels public class OrderSearchModel { public int? ID { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } } } diff --git a/Diner/DinerContracts/ViewModels/ReportOrdersViewModel.cs b/Diner/DinerContracts/ViewModels/ReportOrdersViewModel.cs new file mode 100644 index 0000000..97939e6 --- /dev/null +++ b/Diner/DinerContracts/ViewModels/ReportOrdersViewModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DinerContracts.ViewModels +{ + public class ReportOrdersViewModel + { + public int ID { get; set; } + public DateTime DateCreate { get; set; } + public string ProductName { get; set; } = string.Empty; + public double Sum { get; set; } + } +} diff --git a/Diner/DinerContracts/ViewModels/ReportSnackFoodsViewModel.cs b/Diner/DinerContracts/ViewModels/ReportSnackFoodsViewModel.cs new file mode 100644 index 0000000..e1232ff --- /dev/null +++ b/Diner/DinerContracts/ViewModels/ReportSnackFoodsViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DinerContracts.ViewModels +{ + public class ReportSnackFoodsViewModel + { + public string ComponentName { get; set; } = string.Empty; + public int TotalCount { get; set; } + public List<(string Product, int count)> Products { get; set; } = new(); + } +} diff --git a/Diner/DineryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/Diner/DineryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs new file mode 100644 index 0000000..9715ecd --- /dev/null +++ b/Diner/DineryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -0,0 +1,84 @@ +using DineryBusinessLogic.OfficePackage.HelperEnums; +using DineryBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DineryBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToExcel + { + public void CreateReport(ExcelInfo info) { + CreateExcel(info); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = 1, + Text = info.Title, + StyleInfo = ExcelStyleInfoType.Title + }); + + MergeCells(new ExcelMergeParameters + { + CellFromName = "A1", + CellToName = "C1" + }); + + uint rowIndex = 2; + foreach (var pc in info.ProductComponents) { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = pc.ComponentName, + StyleInfo = ExcelStyleInfoType.Title + }); + rowIndex++; + foreach (var (Product, Count) in pc.Products) { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = Product, + 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.Title + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = pc.TotalCount.ToString(), + StyleInfo = ExcelStyleInfoType.Title + }); + rowIndex++; + } + SaveExcel(info); + } + // Создание excel-файла + protected abstract void CreateExcel(ExcelInfo info); + // Добавляем новую ячейку в лист + protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParameters); + // Объединение ячеек + protected abstract void MergeCells(ExcelMergeParameters mergeParams); + // Сохранение файла + protected abstract void SaveExcel(ExcelInfo info); + } +} diff --git a/Diner/DineryBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/Diner/DineryBusinessLogic/OfficePackage/AbstractSaveToWord.cs new file mode 100644 index 0000000..6ebc4d4 --- /dev/null +++ b/Diner/DineryBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -0,0 +1,43 @@ +using DineryBusinessLogic.OfficePackage.HelperEnums; +using DineryBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DineryBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToWord + { + public void CreateDoc(WordInfo 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 component in info.Components) { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> { (component.ComponentName, new WordTextProperties { Size = "24", }) }, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.both + } + }); + } + } + // Создание doc-файла + protected abstract void CreateWord(WordInfo info); + // Создание абзаца с текстом + protected abstract void CreateParagraph(WordParagraph paragraph); + // Сохранение файла + protected abstract void SaveWord(WordInfo info); + } +} diff --git a/Diner/DineryBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs new file mode 100644 index 0000000..25b799c --- /dev/null +++ b/Diner/DineryBusinessLogic/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 DineryBusinessLogic.OfficePackage.HelperEnums +{ + public enum ExcelStyleInfoType + { + Title, + Text, + TextWithBorder + } +} diff --git a/Diner/DineryBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs new file mode 100644 index 0000000..b7aaeb7 --- /dev/null +++ b/Diner/DineryBusinessLogic/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 DineryBusinessLogic.OfficePackage.HelperEnums +{ + public enum PdfParagraphAlignmentType + { + Center, + Left, + Right + } +} diff --git a/Diner/DineryBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs new file mode 100644 index 0000000..d4ce216 --- /dev/null +++ b/Diner/DineryBusinessLogic/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 DineryBusinessLogic.OfficePackage.HelperEnums +{ + public enum WordJustificationType + { + Center, + both + } +} diff --git a/Diner/DineryBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs new file mode 100644 index 0000000..b776988 --- /dev/null +++ b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs @@ -0,0 +1,18 @@ +using DineryBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DineryBusinessLogic.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/Diner/DineryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs new file mode 100644 index 0000000..5cc810e --- /dev/null +++ b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -0,0 +1,17 @@ +using DinerContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; + +namespace DineryBusinessLogic.OfficePackage.HelperModels +{ + public class ExcelInfo + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public List ProductComponents { get; set; } = new(); + } +} diff --git a/Diner/DineryBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs new file mode 100644 index 0000000..1e51fbd --- /dev/null +++ b/Diner/DineryBusinessLogic/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 DineryBusinessLogic.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/Diner/DineryBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs new file mode 100644 index 0000000..f4b948a --- /dev/null +++ b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -0,0 +1,19 @@ +using DinerContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace DineryBusinessLogic.OfficePackage.HelperModels +{ + public class PdfInfo + { + 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/Diner/DineryBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs new file mode 100644 index 0000000..067323e --- /dev/null +++ b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs @@ -0,0 +1,16 @@ +using DineryBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DineryBusinessLogic.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/Diner/DineryBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs new file mode 100644 index 0000000..710aae9 --- /dev/null +++ b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs @@ -0,0 +1,16 @@ +using DineryBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DineryBusinessLogic.OfficePackage.HelperModels +{ + public class PdfRowParameters + { + public List Text { get; set; } = new(); + public string Style { get; set; } = string.Empty; + public PdfParagraphAlignmentType ParagraphAlignment { get; set; } + } +} diff --git a/Diner/DineryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs new file mode 100644 index 0000000..cb39efa --- /dev/null +++ b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -0,0 +1,16 @@ +using DinerContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DineryBusinessLogic.OfficePackage.HelperModels +{ + public class WordInfo + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public List Components { get; set; } = new(); + } +} diff --git a/Diner/DineryBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs new file mode 100644 index 0000000..dc10037 --- /dev/null +++ b/Diner/DineryBusinessLogic/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 DineryBusinessLogic.OfficePackage.HelperModels +{ + public class WordParagraph + { + public List<(string, WordTextProperties)> Texts { get; set; } = new(); + public WordTextProperties? TextProperties { get; set; } + } +} diff --git a/Diner/DineryBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs new file mode 100644 index 0000000..64e00bb --- /dev/null +++ b/Diner/DineryBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs @@ -0,0 +1,16 @@ +using DineryBusinessLogic.OfficePackage.HelperEnums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DineryBusinessLogic.OfficePackage.HelperModels +{ + public class WordTextProperties + { + public string Size { get; set; } = string.Empty; + public bool Bold { get; set; } + public WordJustificationType JustificationType { get; set; } + } +}