From c55468a47a6984f3df87d821a2604e66952eb7c0 Mon Sep 17 00:00:00 2001 From: Sasylika4598 Date: Sat, 11 May 2024 11:59:11 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BB=D0=B0=D0=B1=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SecuritySystem/SecuritySystem.sln | 62 +- .../BusinessLogics/ReportLogic.cs | 121 ++++ .../OfficePackage/AbstractSaveToExcel.cs | 98 +++ .../OfficePackage/AbstractSaveToPdf.cs | 75 +++ .../OfficePackage/AbstractSaveToWord.cs | 54 ++ .../HelperEnums/ExcelStyleInfoType.cs | 10 + .../HelperEnums/PdfParagraphAlignmentType.cs | 9 + .../HelperEnums/WordJustificationType.cs | 8 + .../HelperModels/ExcelCellParameters.cs | 13 + .../OfficePackage/HelperModels/ExcelInfo.cs | 15 + .../HelperModels/ExcelMergeParameters.cs | 9 + .../OfficePackage/HelperModels/PdfInfo.cs | 13 + .../HelperModels/PdfParagraph.cs | 12 + .../HelperModels/PdfRowParameters.cs | 12 + .../OfficePackage/HelperModels/WordInfo.cs | 11 + .../HelperModels/WordParagraph.cs | 8 + .../HelperModels/WordTextProperties.cs | 11 + .../OfficePackage/Implements/SaveToExcel.cs | 351 ++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 98 +++ .../OfficePackage/Implements/SaveToWord.cs | 123 ++++ .../SecuritySystemBusinessLogic.csproj | 13 +- .../BindingModels/ReportBindingModel.cs | 9 + .../BusinessLogicsContracts/IReportLogic.cs | 35 + .../SearchModels/OrderSearchModel.cs | 2 + .../SecuritySystemContracts.csproj | 14 +- .../ViewModels/ReportOrdersViewModel.cs | 11 + .../ReportSecureComponentViewModel.cs | 9 + .../SecuritySystemDataModels.csproj | 14 +- .../Implements/OrderStorage.cs | 20 +- ... 20240507152841_InitialCreate.Designer.cs} | 4 +- ...ate.cs => 20240507152841_InitialCreate.cs} | 0 .../SecuritySystemDatabaseModelSnapshot.cs | 2 +- .../SecuritySystemDatabase.cs | 5 +- .../SecuritySystemDatabaseImplement.csproj | 23 +- .../Implements/OrderStorage.cs | 20 +- .../SecuritySystemFileImplement.csproj | 14 +- .../Implements/OrderStorage.cs | 21 +- .../SecuritySystemListImplement.csproj | 14 +- .../{ => Component}/FormComponent.Designer.cs | 4 +- .../{ => Component}/FormComponent.cs | 0 .../{ => Component}/FormComponent.resx | 0 .../FormComponents.Designer.cs | 0 .../{ => Component}/FormComponents.cs | 0 .../{ => Component}/FormComponents.resx | 0 .../SecuritySystemView/FormMain.Designer.cs | 50 +- SecuritySystem/SecuritySystemView/FormMain.cs | 37 +- .../SecuritySystemView/FormMain.resx | 2 +- .../{ => Order}/FormCreateOrder.Designer.cs | 10 +- .../{ => Order}/FormCreateOrder.cs | 0 .../{ => Order}/FormCreateOrder.resx | 0 SecuritySystem/SecuritySystemView/Program.cs | 11 +- .../Report/FormReportOrders.Designer.cs | 143 +++++ .../Report/FormReportOrders.cs | 95 +++ .../Report/FormReportOrders.resx | 123 ++++ .../FormReportSecureComponents.Designer.cs | 106 +++ .../Report/FormReportSecureComponents.cs | 70 ++ .../Report/FormReportSecureComponents.resx | 129 ++++ .../Report/ReportOrders.rdlc | 607 ++++++++++++++++++ .../{ => Secure}/FormSecure.Designer.cs | 18 +- .../{ => Secure}/FormSecure.cs | 0 .../{ => Secure}/FormSecure.resx | 0 .../FormSecureComponent.Designer.cs | 8 +- .../{ => Secure}/FormSecureComponent.cs | 0 .../{ => Secure}/FormSecureComponent.resx | 0 .../{ => Secure}/FormSecures.Designer.cs | 6 +- .../{ => Secure}/FormSecures.cs | 0 .../{ => Secure}/FormSecures.resx | 0 .../SecuritySystemView.csproj | 26 +- 68 files changed, 2640 insertions(+), 148 deletions(-) create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/BusinessLogics/ReportLogic.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 SecuritySystem/SecuritySystemContracts/BindingModels/ReportBindingModel.cs create mode 100644 SecuritySystem/SecuritySystemContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 SecuritySystem/SecuritySystemContracts/ViewModels/ReportOrdersViewModel.cs create mode 100644 SecuritySystem/SecuritySystemContracts/ViewModels/ReportSecureComponentViewModel.cs rename SecuritySystem/SecuritySystemDatabaseImplement/Migrations/{20240507141648_InitialCreate.Designer.cs => 20240507152841_InitialCreate.Designer.cs} (98%) rename SecuritySystem/SecuritySystemDatabaseImplement/Migrations/{20240507141648_InitialCreate.cs => 20240507152841_InitialCreate.cs} (100%) rename SecuritySystem/SecuritySystemView/{ => Component}/FormComponent.Designer.cs (98%) rename SecuritySystem/SecuritySystemView/{ => Component}/FormComponent.cs (100%) rename SecuritySystem/SecuritySystemView/{ => Component}/FormComponent.resx (100%) rename SecuritySystem/SecuritySystemView/{ => Component}/FormComponents.Designer.cs (100%) rename SecuritySystem/SecuritySystemView/{ => Component}/FormComponents.cs (100%) rename SecuritySystem/SecuritySystemView/{ => Component}/FormComponents.resx (100%) rename SecuritySystem/SecuritySystemView/{ => Order}/FormCreateOrder.Designer.cs (96%) rename SecuritySystem/SecuritySystemView/{ => Order}/FormCreateOrder.cs (100%) rename SecuritySystem/SecuritySystemView/{ => Order}/FormCreateOrder.resx (100%) create mode 100644 SecuritySystem/SecuritySystemView/Report/FormReportOrders.Designer.cs create mode 100644 SecuritySystem/SecuritySystemView/Report/FormReportOrders.cs create mode 100644 SecuritySystem/SecuritySystemView/Report/FormReportOrders.resx create mode 100644 SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.Designer.cs create mode 100644 SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.cs create mode 100644 SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.resx create mode 100644 SecuritySystem/SecuritySystemView/Report/ReportOrders.rdlc rename SecuritySystem/SecuritySystemView/{ => Secure}/FormSecure.Designer.cs (96%) rename SecuritySystem/SecuritySystemView/{ => Secure}/FormSecure.cs (100%) rename SecuritySystem/SecuritySystemView/{ => Secure}/FormSecure.resx (100%) rename SecuritySystem/SecuritySystemView/{ => Secure}/FormSecureComponent.Designer.cs (96%) rename SecuritySystem/SecuritySystemView/{ => Secure}/FormSecureComponent.cs (100%) rename SecuritySystem/SecuritySystemView/{ => Secure}/FormSecureComponent.resx (100%) rename SecuritySystem/SecuritySystemView/{ => Secure}/FormSecures.Designer.cs (97%) rename SecuritySystem/SecuritySystemView/{ => Secure}/FormSecures.cs (100%) rename SecuritySystem/SecuritySystemView/{ => Secure}/FormSecures.resx (100%) diff --git a/SecuritySystem/SecuritySystem.sln b/SecuritySystem/SecuritySystem.sln index 93d5121..a29e895 100644 --- a/SecuritySystem/SecuritySystem.sln +++ b/SecuritySystem/SecuritySystem.sln @@ -15,42 +15,102 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemListImplement EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemFileImplement", "SecuritySystemFileImplement\SecuritySystemFileImplement.csproj", "{0ACD169C-97A8-452E-A17A-19E2464F5286}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecuritySystemDatabaseImplement", "SecuritySystemDatabaseImplement\SecuritySystemDatabaseImplement.csproj", "{4AE7461C-39CC-463B-B5A1-A47ED3B9E925}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecuritySystemDatabaseImplement", "SecuritySystemDatabaseImplement\SecuritySystemDatabaseImplement.csproj", "{4AE7461C-39CC-463B-B5A1-A47ED3B9E925}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Debug|x64.ActiveCfg = Debug|x64 + {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Debug|x64.Build.0 = Debug|x64 + {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Debug|x86.ActiveCfg = Debug|x86 + {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Debug|x86.Build.0 = Debug|x86 {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Release|Any CPU.ActiveCfg = Release|Any CPU {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Release|Any CPU.Build.0 = Release|Any CPU + {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Release|x64.ActiveCfg = Release|x64 + {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Release|x64.Build.0 = Release|x64 + {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Release|x86.ActiveCfg = Release|x86 + {B4D0310E-1162-4BCF-A7E0-2AC41959C963}.Release|x86.Build.0 = Release|x86 {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Debug|x64.ActiveCfg = Debug|x64 + {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Debug|x64.Build.0 = Debug|x64 + {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Debug|x86.ActiveCfg = Debug|x86 + {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Debug|x86.Build.0 = Debug|x86 {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Release|Any CPU.ActiveCfg = Release|Any CPU {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Release|Any CPU.Build.0 = Release|Any CPU + {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Release|x64.ActiveCfg = Release|x64 + {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Release|x64.Build.0 = Release|x64 + {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Release|x86.ActiveCfg = Release|x86 + {37DD658F-D5C0-4C97-A83D-A21EE0076C55}.Release|x86.Build.0 = Release|x86 {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Debug|x64.ActiveCfg = Debug|x64 + {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Debug|x64.Build.0 = Debug|x64 + {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Debug|x86.ActiveCfg = Debug|x86 + {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Debug|x86.Build.0 = Debug|x86 {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Release|Any CPU.ActiveCfg = Release|Any CPU {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Release|Any CPU.Build.0 = Release|Any CPU + {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Release|x64.ActiveCfg = Release|x64 + {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Release|x64.Build.0 = Release|x64 + {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Release|x86.ActiveCfg = Release|x86 + {0737BCB2-EEDB-44A4-8BD2-5B5EA689A7FF}.Release|x86.Build.0 = Release|x86 {38C8A0AB-9363-4914-B967-02586827588D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {38C8A0AB-9363-4914-B967-02586827588D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38C8A0AB-9363-4914-B967-02586827588D}.Debug|x64.ActiveCfg = Debug|x64 + {38C8A0AB-9363-4914-B967-02586827588D}.Debug|x64.Build.0 = Debug|x64 + {38C8A0AB-9363-4914-B967-02586827588D}.Debug|x86.ActiveCfg = Debug|x86 + {38C8A0AB-9363-4914-B967-02586827588D}.Debug|x86.Build.0 = Debug|x86 {38C8A0AB-9363-4914-B967-02586827588D}.Release|Any CPU.ActiveCfg = Release|Any CPU {38C8A0AB-9363-4914-B967-02586827588D}.Release|Any CPU.Build.0 = Release|Any CPU + {38C8A0AB-9363-4914-B967-02586827588D}.Release|x64.ActiveCfg = Release|x64 + {38C8A0AB-9363-4914-B967-02586827588D}.Release|x64.Build.0 = Release|x64 + {38C8A0AB-9363-4914-B967-02586827588D}.Release|x86.ActiveCfg = Release|x86 + {38C8A0AB-9363-4914-B967-02586827588D}.Release|x86.Build.0 = Release|x86 {6A104362-3398-4D4E-A3D0-2F4B32858569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6A104362-3398-4D4E-A3D0-2F4B32858569}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6A104362-3398-4D4E-A3D0-2F4B32858569}.Debug|x64.ActiveCfg = Debug|x64 + {6A104362-3398-4D4E-A3D0-2F4B32858569}.Debug|x64.Build.0 = Debug|x64 + {6A104362-3398-4D4E-A3D0-2F4B32858569}.Debug|x86.ActiveCfg = Debug|x86 + {6A104362-3398-4D4E-A3D0-2F4B32858569}.Debug|x86.Build.0 = Debug|x86 {6A104362-3398-4D4E-A3D0-2F4B32858569}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A104362-3398-4D4E-A3D0-2F4B32858569}.Release|Any CPU.Build.0 = Release|Any CPU + {6A104362-3398-4D4E-A3D0-2F4B32858569}.Release|x64.ActiveCfg = Release|x64 + {6A104362-3398-4D4E-A3D0-2F4B32858569}.Release|x64.Build.0 = Release|x64 + {6A104362-3398-4D4E-A3D0-2F4B32858569}.Release|x86.ActiveCfg = Release|x86 + {6A104362-3398-4D4E-A3D0-2F4B32858569}.Release|x86.Build.0 = Release|x86 {0ACD169C-97A8-452E-A17A-19E2464F5286}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0ACD169C-97A8-452E-A17A-19E2464F5286}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0ACD169C-97A8-452E-A17A-19E2464F5286}.Debug|x64.ActiveCfg = Debug|x64 + {0ACD169C-97A8-452E-A17A-19E2464F5286}.Debug|x64.Build.0 = Debug|x64 + {0ACD169C-97A8-452E-A17A-19E2464F5286}.Debug|x86.ActiveCfg = Debug|Any CPU + {0ACD169C-97A8-452E-A17A-19E2464F5286}.Debug|x86.Build.0 = Debug|Any CPU {0ACD169C-97A8-452E-A17A-19E2464F5286}.Release|Any CPU.ActiveCfg = Release|Any CPU {0ACD169C-97A8-452E-A17A-19E2464F5286}.Release|Any CPU.Build.0 = Release|Any CPU + {0ACD169C-97A8-452E-A17A-19E2464F5286}.Release|x64.ActiveCfg = Release|x64 + {0ACD169C-97A8-452E-A17A-19E2464F5286}.Release|x64.Build.0 = Release|x64 + {0ACD169C-97A8-452E-A17A-19E2464F5286}.Release|x86.ActiveCfg = Release|Any CPU + {0ACD169C-97A8-452E-A17A-19E2464F5286}.Release|x86.Build.0 = Release|Any CPU {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Debug|x64.ActiveCfg = Debug|x64 + {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Debug|x64.Build.0 = Debug|x64 + {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Debug|x86.ActiveCfg = Debug|Any CPU + {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Debug|x86.Build.0 = Debug|Any CPU {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Release|Any CPU.ActiveCfg = Release|Any CPU {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Release|Any CPU.Build.0 = Release|Any CPU + {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Release|x64.ActiveCfg = Release|x64 + {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Release|x64.Build.0 = Release|x64 + {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Release|x86.ActiveCfg = Release|Any CPU + {4AE7461C-39CC-463B-B5A1-A47ED3B9E925}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SecuritySystem/SecuritySystemBusinessLogic/BusinessLogics/ReportLogic.cs b/SecuritySystem/SecuritySystemBusinessLogic/BusinessLogics/ReportLogic.cs new file mode 100644 index 0000000..ae29946 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/BusinessLogics/ReportLogic.cs @@ -0,0 +1,121 @@ +using SecuritySystemBusinessLogic.OfficePackage.HelperModels; +using SecuritySystemBusinessLogic.OfficePackage; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemContracts.SearchModels; +using SecuritySystemContracts.StoragesContracts; +using SecuritySystemContracts.ViewModels; + +namespace SecuritySystemBusinessLogic.BusinessLogics +{ + public class ReportLogic : IReportLogic + { + private readonly IComponentStorage _componentStorage; + private readonly ISecureStorage _secureStorage; + private readonly IOrderStorage _orderStorage; + private readonly AbstractSaveToExcel _saveToExcel; + private readonly AbstractSaveToWord _saveToWord; + private readonly AbstractSaveToPdf _saveToPdf; + public ReportLogic(ISecureStorage secureStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) + { + _secureStorage = secureStorage; + _componentStorage = componentStorage; + _orderStorage = orderStorage; + _saveToExcel = saveToExcel; + _saveToWord = saveToWord; + _saveToPdf = saveToPdf; + } + /// + /// Получение списка компонент с указанием, в каких изделиях используются + /// + /// + public List GetSecureComponent() + { + var components = _componentStorage.GetFullList(); + var secures = _secureStorage.GetFullList(); + var list = new List(); + foreach (var secure in secures) + { + var record = new ReportSecureComponentViewModel + { + SecureName = secure.SecureName, + Components = new List>(), + TotalCount = 0 + }; + foreach (var component in components) + { + if (secure.SecureComponents.ContainsKey(component.Id)) + { + record.Components.Add(new Tuple(component.ComponentName, secure.SecureComponents[component.Id].Item2)); + record.TotalCount += secure.SecureComponents[component.Id].Item2; + } + } + list.Add(record); + } + return list; + } + /// + /// Получение списка заказов за определенный период + /// + /// + /// + public List GetOrders(ReportBindingModel model) + { + return _orderStorage.GetFilteredList(new OrderSearchModel + { + DateFrom = model.DateFrom, + DateTo = model.DateTo + }) + .Select(x => new ReportOrdersViewModel + { + Id = x.Id, + DateCreate = x.DateCreate, + SecureName = x.SecureName, + Status = x.Status.ToString(), + Sum = x.Sum + }) + .ToList(); + } + /// + /// Сохранение компонент в файл-Word + /// + /// + public void SaveSecuresToWordFile(ReportBindingModel model) + { + _saveToWord.CreateDoc(new WordInfo + { + FileName = model.FileName, + Title = "Список изделий", + Secures = _secureStorage.GetFullList() + }); + } + /// + /// Сохранение компонент с указаеним продуктов в файл-Excel + /// + /// + public void SaveSecureComponentToExcelFile(ReportBindingModel model) + { + _saveToExcel.CreateReport(new ExcelInfo + { + FileName = model.FileName, + Title = "Список изделий и компонентов", + SecureComponents = GetSecureComponent() + }); + } + /// + /// Сохранение заказов в файл-Pdf + /// + /// + public void SaveOrdersToPdfFile(ReportBindingModel model) + { + _saveToPdf.CreateDoc(new PdfInfo + { + FileName = model.FileName, + Title = "Список заказов", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo!.Value, + Orders = GetOrders(model) + }); + } + } +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToExcel.cs new file mode 100644 index 0000000..1f210a2 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -0,0 +1,98 @@ +using SecuritySystemBusinessLogic.OfficePackage.HelperEnums; +using SecuritySystemBusinessLogic.OfficePackage.HelperModels; + +namespace SecuritySystemBusinessLogic.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.SecureComponents) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = pc.SecureName, + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + foreach (var secure in pc.Components) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = secure.Item1, + StyleInfo = + ExcelStyleInfoType.TextWithBroder + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = secure.Item2.ToString(), + StyleInfo = + ExcelStyleInfoType.TextWithBroder + }); + rowIndex++; + } + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = "Итого", + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = pc.TotalCount.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + } + SaveExcel(info); + } + /// + /// Создание excel-файла + /// + /// + protected abstract void CreateExcel(ExcelInfo info); + /// + /// Добавляем новую ячейку в лист + /// + /// + protected abstract void InsertCellInWorksheet(ExcelCellParameters + excelParams); + /// + /// Объединение ячеек + /// + /// + protected abstract void MergeCells(ExcelMergeParameters excelParams); + /// + /// Сохранение файла + /// + /// + protected abstract void SaveExcel(ExcelInfo info); + } +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToPdf.cs new file mode 100644 index 0000000..8cce121 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -0,0 +1,75 @@ +using SecuritySystemBusinessLogic.OfficePackage.HelperEnums; +using SecuritySystemBusinessLogic.OfficePackage.HelperModels; + +namespace SecuritySystemBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToPdf + { + public void CreateDoc(PdfInfo 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.SecureName, 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); + } + /// + /// Создание doc-файла + /// + /// + protected abstract void CreatePdf(PdfInfo info); + /// + /// Создание параграфа с текстом + /// + /// + /// + protected abstract void CreateParagraph(PdfParagraph paragraph); + /// + /// Создание таблицы + /// + /// + /// + protected abstract void CreateTable(List columns); + /// + /// Создание и заполнение строки + /// + /// + protected abstract void CreateRow(PdfRowParameters rowParameters); + /// + /// Сохранение файла + /// + /// + protected abstract void SavePdf(PdfInfo info); + } +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToWord.cs new file mode 100644 index 0000000..39b624e --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -0,0 +1,54 @@ +using SecuritySystemBusinessLogic.OfficePackage.HelperEnums; +using SecuritySystemBusinessLogic.OfficePackage.HelperModels; + +namespace SecuritySystemBusinessLogic.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 secure in info.Secures) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> { + (secure.SecureName, new WordTextProperties { Bold = true, Size = "24", }), + ("\t" + secure.Price.ToString() + " руб.", new WordTextProperties { Size = "24", }) + }, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } + SaveWord(info); + } + /// + /// Создание doc-файла + /// + /// + protected abstract void CreateWord(WordInfo info); + /// + /// Создание абзаца с текстом + /// + /// + /// + protected abstract void CreateParagraph(WordParagraph paragraph); + /// + /// Сохранение файла + /// + /// + protected abstract void SaveWord(WordInfo info); + } +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs new file mode 100644 index 0000000..74cdd25 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs @@ -0,0 +1,10 @@ +namespace SecuritySystemBusinessLogic.OfficePackage.HelperEnums +{ + public enum ExcelStyleInfoType + { + Title, + Text, + TextWithBroder + } + +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs new file mode 100644 index 0000000..1d2f318 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs @@ -0,0 +1,9 @@ +namespace SecuritySystemBusinessLogic.OfficePackage.HelperEnums +{ + public enum PdfParagraphAlignmentType + { + Center, + Left, + Rigth + } +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs new file mode 100644 index 0000000..44eab28 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs @@ -0,0 +1,8 @@ +namespace SecuritySystemBusinessLogic.OfficePackage.HelperEnums +{ + public enum WordJustificationType + { + Center, + Both + } +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs new file mode 100644 index 0000000..a9b2886 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs @@ -0,0 +1,13 @@ +using SecuritySystemBusinessLogic.OfficePackage.HelperEnums; + +namespace SecuritySystemBusinessLogic.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/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs new file mode 100644 index 0000000..8786755 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -0,0 +1,15 @@ +using SecuritySystemContracts.ViewModels; + +namespace SecuritySystemBusinessLogic.OfficePackage.HelperModels +{ + public class ExcelInfo + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public List SecureComponents + { + get; + set; + } = new(); + } +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs new file mode 100644 index 0000000..1540bb9 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs @@ -0,0 +1,9 @@ +namespace SecuritySystemBusinessLogic.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/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs new file mode 100644 index 0000000..414f726 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -0,0 +1,13 @@ +using SecuritySystemContracts.ViewModels; + +namespace SecuritySystemBusinessLogic.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/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs new file mode 100644 index 0000000..25ec635 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs @@ -0,0 +1,12 @@ +using SecuritySystemBusinessLogic.OfficePackage.HelperEnums; + +namespace SecuritySystemBusinessLogic.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/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs new file mode 100644 index 0000000..bc00c12 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs @@ -0,0 +1,12 @@ +using SecuritySystemBusinessLogic.OfficePackage.HelperEnums; + +namespace SecuritySystemBusinessLogic.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/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordInfo.cs new file mode 100644 index 0000000..05c8ce6 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -0,0 +1,11 @@ +using SecuritySystemContracts.ViewModels; + +namespace SecuritySystemBusinessLogic.OfficePackage.HelperModels +{ + public class WordInfo + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public List Secures { get; set; } = new(); + } +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs new file mode 100644 index 0000000..5999bb9 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs @@ -0,0 +1,8 @@ +namespace SecuritySystemBusinessLogic.OfficePackage.HelperModels +{ + public class WordParagraph + { + public List<(string, WordTextProperties)> Texts { get; set; } = new(); + public WordTextProperties? TextProperties { get; set; } + } +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs new file mode 100644 index 0000000..02c6211 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs @@ -0,0 +1,11 @@ +using SecuritySystemBusinessLogic.OfficePackage.HelperEnums; + +namespace SecuritySystemBusinessLogic.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/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToExcel.cs new file mode 100644 index 0000000..aee244f --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToExcel.cs @@ -0,0 +1,351 @@ +using DocumentFormat.OpenXml.Office2010.Excel; +using DocumentFormat.OpenXml.Office2013.Excel; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Spreadsheet; +using DocumentFormat.OpenXml; +using SecuritySystemBusinessLogic.OfficePackage.HelperEnums; +using SecuritySystemBusinessLogic.OfficePackage.HelperModels; + +namespace SecuritySystemBusinessLogic.OfficePackage.Implements +{ + public class SaveToExcel : AbstractSaveToExcel + { + private SpreadsheetDocument? _spreadsheetDocument; + private SharedStringTablePart? _shareStringPart; + private Worksheet? _worksheet; + /// + /// Настройка стилей для файла + /// + /// + private static void CreateStyles(WorkbookPart workbookpart) + { + var sp = workbookpart.AddNewPart(); + sp.Stylesheet = new Stylesheet(); + 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 }); + 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); + 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.TextWithBroder => 1U, + ExcelStyleInfoType.Text => 0U, + _ => 0U, + }; + } + protected override void CreateExcel(ExcelInfo 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()); + // Добавляем лист в книгу + 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(ExcelInfo info) + { + if (_spreadsheetDocument == null) + { + return; + } + _spreadsheetDocument.WorkbookPart!.Workbook.Save(); + _spreadsheetDocument.Dispose(); + } + } + +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToPdf.cs new file mode 100644 index 0000000..6384b59 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -0,0 +1,98 @@ +using MigraDoc.DocumentObjectModel; +using MigraDoc.DocumentObjectModel.Tables; +using MigraDoc.Rendering; +using SecuritySystemBusinessLogic.OfficePackage.HelperEnums; +using SecuritySystemBusinessLogic.OfficePackage.HelperModels; + +namespace SecuritySystemBusinessLogic.OfficePackage.Implements +{ + public class SaveToPdf : AbstractSaveToPdf + { + 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(PdfInfo 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(PdfInfo info) + { + var renderer = new PdfDocumentRenderer(true) + { + Document = _document + }; + renderer.RenderDocument(); + renderer.PdfDocument.Save(info.FileName); + } + } +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToWord.cs new file mode 100644 index 0000000..8cfc2e9 --- /dev/null +++ b/SecuritySystem/SecuritySystemBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -0,0 +1,123 @@ +using SecuritySystemBusinessLogic.OfficePackage.HelperEnums; +using SecuritySystemBusinessLogic.OfficePackage.HelperModels; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Wordprocessing; +using DocumentFormat.OpenXml; +using Text = DocumentFormat.OpenXml.Wordprocessing.Text; + +namespace SecuritySystemBusinessLogic.OfficePackage.Implements +{ + public class SaveToWord : AbstractSaveToWord + { + 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(WordInfo info) + { + _wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document); + MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart(); + mainPart.Document = new DocumentFormat.OpenXml.Wordprocessing.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(WordInfo info) + { + if (_docBody == null || _wordDocument == null) + { + return; + } + _docBody.AppendChild(CreateSectionProperties()); + _wordDocument.MainDocumentPart!.Document.Save(); + _wordDocument.Dispose(); + } + } + +} diff --git a/SecuritySystem/SecuritySystemBusinessLogic/SecuritySystemBusinessLogic.csproj b/SecuritySystem/SecuritySystemBusinessLogic/SecuritySystemBusinessLogic.csproj index 0cdc6b8..ee23f9b 100644 --- a/SecuritySystem/SecuritySystemBusinessLogic/SecuritySystemBusinessLogic.csproj +++ b/SecuritySystem/SecuritySystemBusinessLogic/SecuritySystemBusinessLogic.csproj @@ -4,20 +4,13 @@ net6.0 enable enable + AnyCPU;x64;x86 - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + diff --git a/SecuritySystem/SecuritySystemContracts/BindingModels/ReportBindingModel.cs b/SecuritySystem/SecuritySystemContracts/BindingModels/ReportBindingModel.cs new file mode 100644 index 0000000..cf018db --- /dev/null +++ b/SecuritySystem/SecuritySystemContracts/BindingModels/ReportBindingModel.cs @@ -0,0 +1,9 @@ +namespace SecuritySystemContracts.BindingModels +{ + public class ReportBindingModel + { + public string FileName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + } +} diff --git a/SecuritySystem/SecuritySystemContracts/BusinessLogicsContracts/IReportLogic.cs b/SecuritySystem/SecuritySystemContracts/BusinessLogicsContracts/IReportLogic.cs new file mode 100644 index 0000000..36fce98 --- /dev/null +++ b/SecuritySystem/SecuritySystemContracts/BusinessLogicsContracts/IReportLogic.cs @@ -0,0 +1,35 @@ +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.ViewModels; + +namespace SecuritySystemContracts.BusinessLogicsContracts +{ + public interface IReportLogic + { + /// + /// Получение списка компонент с указанием, в каких изделиях используются + /// + /// + List GetSecureComponent(); + /// + /// Получение списка заказов за определенный период + /// + /// + /// + List GetOrders(ReportBindingModel model); + /// + /// Сохранение компонент в файл-Word + /// + /// + void SaveSecuresToWordFile(ReportBindingModel model); + /// + /// Сохранение компонент с указаеним продуктов в файл-Excel + /// + /// + void SaveSecureComponentToExcelFile(ReportBindingModel model); + /// + /// Сохранение заказов в файл-Pdf + /// + /// + void SaveOrdersToPdfFile(ReportBindingModel model); + } +} diff --git a/SecuritySystem/SecuritySystemContracts/SearchModels/OrderSearchModel.cs b/SecuritySystem/SecuritySystemContracts/SearchModels/OrderSearchModel.cs index 500fb59..d9747e7 100644 --- a/SecuritySystem/SecuritySystemContracts/SearchModels/OrderSearchModel.cs +++ b/SecuritySystem/SecuritySystemContracts/SearchModels/OrderSearchModel.cs @@ -3,5 +3,7 @@ public class OrderSearchModel { public int? Id { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } } } diff --git a/SecuritySystem/SecuritySystemContracts/SecuritySystemContracts.csproj b/SecuritySystem/SecuritySystemContracts/SecuritySystemContracts.csproj index 413deaa..a4b5be5 100644 --- a/SecuritySystem/SecuritySystemContracts/SecuritySystemContracts.csproj +++ b/SecuritySystem/SecuritySystemContracts/SecuritySystemContracts.csproj @@ -4,21 +4,9 @@ net6.0 enable enable + AnyCPU;x64;x86 - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/SecuritySystem/SecuritySystemContracts/ViewModels/ReportOrdersViewModel.cs b/SecuritySystem/SecuritySystemContracts/ViewModels/ReportOrdersViewModel.cs new file mode 100644 index 0000000..668b898 --- /dev/null +++ b/SecuritySystem/SecuritySystemContracts/ViewModels/ReportOrdersViewModel.cs @@ -0,0 +1,11 @@ +namespace SecuritySystemContracts.ViewModels +{ + public class ReportOrdersViewModel + { + public int Id { get; set; } + public DateTime DateCreate { get; set; } + public string SecureName { get; set; } = string.Empty; + public string Status { get; set; } = string.Empty; + public double Sum { get; set; } + } +} diff --git a/SecuritySystem/SecuritySystemContracts/ViewModels/ReportSecureComponentViewModel.cs b/SecuritySystem/SecuritySystemContracts/ViewModels/ReportSecureComponentViewModel.cs new file mode 100644 index 0000000..5ee8899 --- /dev/null +++ b/SecuritySystem/SecuritySystemContracts/ViewModels/ReportSecureComponentViewModel.cs @@ -0,0 +1,9 @@ +namespace SecuritySystemContracts.ViewModels +{ + public class ReportSecureComponentViewModel + { + public string SecureName { get; set; } = string.Empty; + public int TotalCount { get; set; } + public List> Components { get; set; } = new(); + } +} diff --git a/SecuritySystem/SecuritySystemDataModels/SecuritySystemDataModels.csproj b/SecuritySystem/SecuritySystemDataModels/SecuritySystemDataModels.csproj index b2efa94..b47a234 100644 --- a/SecuritySystem/SecuritySystemDataModels/SecuritySystemDataModels.csproj +++ b/SecuritySystem/SecuritySystemDataModels/SecuritySystemDataModels.csproj @@ -4,19 +4,7 @@ net6.0 enable enable + AnyCPU;x64;x86 - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/SecuritySystem/SecuritySystemDatabaseImplement/Implements/OrderStorage.cs b/SecuritySystem/SecuritySystemDatabaseImplement/Implements/OrderStorage.cs index 00f3380..347042f 100644 --- a/SecuritySystem/SecuritySystemDatabaseImplement/Implements/OrderStorage.cs +++ b/SecuritySystem/SecuritySystemDatabaseImplement/Implements/OrderStorage.cs @@ -21,16 +21,24 @@ namespace SecuritySystemDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) - { - return new(); - } using var context = new SecuritySystemDatabase(); - return context.Orders - .Where(x => x.Id == model.Id) + var orders = context.Orders .Include(x => x.Secure) .Select(x => x.GetViewModel) .ToList(); + if (model.Id.HasValue) + { + orders = orders.Where(x => x.Id == model.Id.Value).ToList(); + } + if (model.DateFrom.HasValue) + { + orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList(); + } + if (model.DateTo.HasValue) + { + orders = orders.Where(x => x.DateCreate <= model.DateTo.Value).ToList(); + } + return orders; } public List GetFullList() diff --git a/SecuritySystem/SecuritySystemDatabaseImplement/Migrations/20240507141648_InitialCreate.Designer.cs b/SecuritySystem/SecuritySystemDatabaseImplement/Migrations/20240507152841_InitialCreate.Designer.cs similarity index 98% rename from SecuritySystem/SecuritySystemDatabaseImplement/Migrations/20240507141648_InitialCreate.Designer.cs rename to SecuritySystem/SecuritySystemDatabaseImplement/Migrations/20240507152841_InitialCreate.Designer.cs index 0f1310e..3cd6a05 100644 --- a/SecuritySystem/SecuritySystemDatabaseImplement/Migrations/20240507141648_InitialCreate.Designer.cs +++ b/SecuritySystem/SecuritySystemDatabaseImplement/Migrations/20240507152841_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using SecuritySystemDatabaseImplement; namespace SecuritySystemDatabaseImplement.Migrations { [DbContext(typeof(SecuritySystemDatabase))] - [Migration("20240507141648_InitialCreate")] + [Migration("20240507152841_InitialCreate")] partial class InitialCreate { /// @@ -20,7 +20,7 @@ namespace SecuritySystemDatabaseImplement.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.3") + .HasAnnotation("ProductVersion", "7.0.16") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/SecuritySystem/SecuritySystemDatabaseImplement/Migrations/20240507141648_InitialCreate.cs b/SecuritySystem/SecuritySystemDatabaseImplement/Migrations/20240507152841_InitialCreate.cs similarity index 100% rename from SecuritySystem/SecuritySystemDatabaseImplement/Migrations/20240507141648_InitialCreate.cs rename to SecuritySystem/SecuritySystemDatabaseImplement/Migrations/20240507152841_InitialCreate.cs diff --git a/SecuritySystem/SecuritySystemDatabaseImplement/Migrations/SecuritySystemDatabaseModelSnapshot.cs b/SecuritySystem/SecuritySystemDatabaseImplement/Migrations/SecuritySystemDatabaseModelSnapshot.cs index c7e1217..bfa036c 100644 --- a/SecuritySystem/SecuritySystemDatabaseImplement/Migrations/SecuritySystemDatabaseModelSnapshot.cs +++ b/SecuritySystem/SecuritySystemDatabaseImplement/Migrations/SecuritySystemDatabaseModelSnapshot.cs @@ -17,7 +17,7 @@ namespace SecuritySystemDatabaseImplement.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.3") + .HasAnnotation("ProductVersion", "7.0.16") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); diff --git a/SecuritySystem/SecuritySystemDatabaseImplement/SecuritySystemDatabase.cs b/SecuritySystem/SecuritySystemDatabaseImplement/SecuritySystemDatabase.cs index 875e04e..13fcc20 100644 --- a/SecuritySystem/SecuritySystemDatabaseImplement/SecuritySystemDatabase.cs +++ b/SecuritySystem/SecuritySystemDatabaseImplement/SecuritySystemDatabase.cs @@ -12,13 +12,10 @@ namespace SecuritySystemDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS01; Initial Catalog=SecuritySystemDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); - + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS02;Initial Catalog=SecuritySystemDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } - - public virtual DbSet Components { set; get; } public virtual DbSet Secures { set; get; } public virtual DbSet SecureComponents { set; get; } diff --git a/SecuritySystem/SecuritySystemDatabaseImplement/SecuritySystemDatabaseImplement.csproj b/SecuritySystem/SecuritySystemDatabaseImplement/SecuritySystemDatabaseImplement.csproj index 54624d1..f2838d1 100644 --- a/SecuritySystem/SecuritySystemDatabaseImplement/SecuritySystemDatabaseImplement.csproj +++ b/SecuritySystem/SecuritySystemDatabaseImplement/SecuritySystemDatabaseImplement.csproj @@ -4,24 +4,21 @@ net6.0 enable enable + AnyCPU;x64 - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/SecuritySystem/SecuritySystemFileImplement/Implements/OrderStorage.cs b/SecuritySystem/SecuritySystemFileImplement/Implements/OrderStorage.cs index 1e12c9b..3d4598d 100644 --- a/SecuritySystem/SecuritySystemFileImplement/Implements/OrderStorage.cs +++ b/SecuritySystem/SecuritySystemFileImplement/Implements/OrderStorage.cs @@ -26,14 +26,22 @@ namespace SecuritySystemFileImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + var orders = source.Orders + .Select(x => x.GetViewModel) + .ToList(); + if (model.Id.HasValue) { - return new(); + orders = orders.Where(x => x.Id == model.Id.Value).ToList(); } - return source.Orders - .Where(x => x.Id == model.Id) - .Select(x => GetViewModel(x)) - .ToList(); + if (model.DateFrom.HasValue) + { + orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList(); + } + if (model.DateTo.HasValue) + { + orders = orders.Where(x => x.DateCreate <= model.DateTo.Value).ToList(); + } + return orders; } public List GetFullList() diff --git a/SecuritySystem/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj b/SecuritySystem/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj index 452b64d..2c64771 100644 --- a/SecuritySystem/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj +++ b/SecuritySystem/SecuritySystemFileImplement/SecuritySystemFileImplement.csproj @@ -4,21 +4,9 @@ net6.0 enable enable + AnyCPU;x64;x86 - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/SecuritySystem/SecuritySystemListImplement/Implements/OrderStorage.cs b/SecuritySystem/SecuritySystemListImplement/Implements/OrderStorage.cs index 3bc00f8..49affc5 100644 --- a/SecuritySystem/SecuritySystemListImplement/Implements/OrderStorage.cs +++ b/SecuritySystem/SecuritySystemListImplement/Implements/OrderStorage.cs @@ -24,19 +24,22 @@ namespace SecuritySystemListImplement.Implements } public List GetFilteredList(OrderSearchModel model) { - var result = new List(); - if (!model.Id.HasValue) + var orders = _source.Orders + .Select(x => x.GetViewModel) + .ToList(); + if (model.Id.HasValue) { - return result; + orders = orders.Where(x => x.Id == model.Id.Value).ToList(); } - foreach (var order in _source.Orders) + if (model.DateFrom.HasValue) { - if (order.Id == model.Id) - { - result.Add(order.GetViewModel); - } + orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList(); } - return result; + if (model.DateTo.HasValue) + { + orders = orders.Where(x => x.DateCreate <= model.DateTo.Value).ToList(); + } + return orders; } public OrderViewModel? GetElement(OrderSearchModel model) { diff --git a/SecuritySystem/SecuritySystemListImplement/SecuritySystemListImplement.csproj b/SecuritySystem/SecuritySystemListImplement/SecuritySystemListImplement.csproj index 54624d1..64fda98 100644 --- a/SecuritySystem/SecuritySystemListImplement/SecuritySystemListImplement.csproj +++ b/SecuritySystem/SecuritySystemListImplement/SecuritySystemListImplement.csproj @@ -4,21 +4,9 @@ net6.0 enable enable + AnyCPU;x64;x86 - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/SecuritySystem/SecuritySystemView/FormComponent.Designer.cs b/SecuritySystem/SecuritySystemView/Component/FormComponent.Designer.cs similarity index 98% rename from SecuritySystem/SecuritySystemView/FormComponent.Designer.cs rename to SecuritySystem/SecuritySystemView/Component/FormComponent.Designer.cs index ffb456e..5ac97c1 100644 --- a/SecuritySystem/SecuritySystemView/FormComponent.Designer.cs +++ b/SecuritySystem/SecuritySystemView/Component/FormComponent.Designer.cs @@ -73,7 +73,7 @@ buttonSaveComponent.Location = new Point(211, 80); buttonSaveComponent.Name = "buttonSaveComponent"; buttonSaveComponent.Size = new Size(115, 29); - buttonSaveComponent.TabIndex = 1; + buttonSaveComponent.TabIndex = 2; buttonSaveComponent.Text = "Сохранить"; buttonSaveComponent.UseVisualStyleBackColor = true; buttonSaveComponent.Click += ButtonSaveComponent_Click; @@ -83,7 +83,7 @@ buttonCancel.Location = new Point(348, 80); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(122, 29); - buttonCancel.TabIndex = 5; + buttonCancel.TabIndex = 3; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Click += ButtonCancel_Click; diff --git a/SecuritySystem/SecuritySystemView/FormComponent.cs b/SecuritySystem/SecuritySystemView/Component/FormComponent.cs similarity index 100% rename from SecuritySystem/SecuritySystemView/FormComponent.cs rename to SecuritySystem/SecuritySystemView/Component/FormComponent.cs diff --git a/SecuritySystem/SecuritySystemView/FormComponent.resx b/SecuritySystem/SecuritySystemView/Component/FormComponent.resx similarity index 100% rename from SecuritySystem/SecuritySystemView/FormComponent.resx rename to SecuritySystem/SecuritySystemView/Component/FormComponent.resx diff --git a/SecuritySystem/SecuritySystemView/FormComponents.Designer.cs b/SecuritySystem/SecuritySystemView/Component/FormComponents.Designer.cs similarity index 100% rename from SecuritySystem/SecuritySystemView/FormComponents.Designer.cs rename to SecuritySystem/SecuritySystemView/Component/FormComponents.Designer.cs diff --git a/SecuritySystem/SecuritySystemView/FormComponents.cs b/SecuritySystem/SecuritySystemView/Component/FormComponents.cs similarity index 100% rename from SecuritySystem/SecuritySystemView/FormComponents.cs rename to SecuritySystem/SecuritySystemView/Component/FormComponents.cs diff --git a/SecuritySystem/SecuritySystemView/FormComponents.resx b/SecuritySystem/SecuritySystemView/Component/FormComponents.resx similarity index 100% rename from SecuritySystem/SecuritySystemView/FormComponents.resx rename to SecuritySystem/SecuritySystemView/Component/FormComponents.resx diff --git a/SecuritySystem/SecuritySystemView/FormMain.Designer.cs b/SecuritySystem/SecuritySystemView/FormMain.Designer.cs index 5ff6f2b..8388aca 100644 --- a/SecuritySystem/SecuritySystemView/FormMain.Designer.cs +++ b/SecuritySystem/SecuritySystemView/FormMain.Designer.cs @@ -32,6 +32,10 @@ справочникиToolStripMenuItem = new ToolStripMenuItem(); ComponentsToolStripMenuItem = new ToolStripMenuItem(); SecuresToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + списокКомпонентовToolStripMenuItem = new ToolStripMenuItem(); + компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); + списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); dataGridView = new DataGridView(); buttonCreateOrder = new Button(); buttonTakeOrderInWork = new Button(); @@ -45,7 +49,7 @@ // menuStrip // menuStrip.ImageScalingSize = new Size(20, 20); - menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem }); + menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem }); menuStrip.Location = new Point(0, 0); menuStrip.Name = "menuStrip"; menuStrip.Size = new Size(1043, 28); @@ -73,6 +77,34 @@ SecuresToolStripMenuItem.Text = "Изделия"; SecuresToolStripMenuItem.Click += SecuresToolStripMenuItem_Click; // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem }); + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(73, 24); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // списокКомпонентовToolStripMenuItem + // + списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; + списокКомпонентовToolStripMenuItem.Size = new Size(276, 26); + списокКомпонентовToolStripMenuItem.Text = "Список изделий"; + списокКомпонентовToolStripMenuItem.Click += ReportSecuresToolStripMenuItem_Click; + // + // компонентыПоИзделиямToolStripMenuItem + // + компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; + компонентыПоИзделиямToolStripMenuItem.Size = new Size(276, 26); + компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; + компонентыПоИзделиямToolStripMenuItem.Click += ReportComponentsSecuresToolStripMenuItem_Click; + // + // списокЗаказовToolStripMenuItem + // + списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + списокЗаказовToolStripMenuItem.Size = new Size(276, 26); + списокЗаказовToolStripMenuItem.Text = "Список заказов"; + списокЗаказовToolStripMenuItem.Click += ReportOrdersToolStripMenuItem_Click; + // // dataGridView // dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; @@ -85,7 +117,7 @@ dataGridView.RowTemplate.Height = 29; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView.Size = new Size(775, 296); - dataGridView.TabIndex = 1; + dataGridView.TabIndex = 0; // // buttonCreateOrder // @@ -93,7 +125,7 @@ buttonCreateOrder.Location = new Point(816, 56); buttonCreateOrder.Name = "buttonCreateOrder"; buttonCreateOrder.Size = new Size(216, 29); - buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.TabIndex = 1; buttonCreateOrder.Text = "Создать заказ"; buttonCreateOrder.UseVisualStyleBackColor = true; buttonCreateOrder.Click += ButtonCreateOrder_Click; @@ -104,7 +136,7 @@ buttonTakeOrderInWork.Location = new Point(816, 110); buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; buttonTakeOrderInWork.Size = new Size(216, 29); - buttonTakeOrderInWork.TabIndex = 3; + buttonTakeOrderInWork.TabIndex = 2; buttonTakeOrderInWork.Text = "Отдать на выполнение"; buttonTakeOrderInWork.UseVisualStyleBackColor = true; buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; @@ -115,7 +147,7 @@ buttonOrderReady.Location = new Point(816, 167); buttonOrderReady.Name = "buttonOrderReady"; buttonOrderReady.Size = new Size(216, 29); - buttonOrderReady.TabIndex = 4; + buttonOrderReady.TabIndex = 3; buttonOrderReady.Text = "Заказ готов"; buttonOrderReady.UseVisualStyleBackColor = true; buttonOrderReady.Click += ButtonOrderReady_Click; @@ -126,7 +158,7 @@ button4.Location = new Point(816, 230); button4.Name = "button4"; button4.Size = new Size(216, 29); - button4.TabIndex = 5; + button4.TabIndex = 4; button4.Text = "Заказ выдан"; button4.UseVisualStyleBackColor = true; button4.Click += ButtonIssuedOrder_Click; @@ -137,7 +169,7 @@ buttonRefresh.Location = new Point(816, 290); buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Size = new Size(216, 29); - buttonRefresh.TabIndex = 1; + buttonRefresh.TabIndex = 5; buttonRefresh.Text = "Обновить список"; buttonRefresh.UseVisualStyleBackColor = true; buttonRefresh.Click += ButtonRefresh_Click; @@ -177,5 +209,9 @@ private Button buttonOrderReady; private Button button4; private Button buttonRefresh; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem списокКомпонентовToolStripMenuItem; + private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/SecuritySystem/SecuritySystemView/FormMain.cs b/SecuritySystem/SecuritySystemView/FormMain.cs index 2fed95c..a9b220c 100644 --- a/SecuritySystem/SecuritySystemView/FormMain.cs +++ b/SecuritySystem/SecuritySystemView/FormMain.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using SecuritySystemContracts.BindingModels; using SecuritySystemContracts.BusinessLogicsContracts; +using SecuritySystemView.Report; namespace SecuritySystemView { @@ -8,11 +9,13 @@ namespace SecuritySystemView { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + private readonly IReportLogic _reportLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } private void FormMain_Load(object sender, EventArgs e) { @@ -136,5 +139,37 @@ namespace SecuritySystemView { LoadData(); } + + private void ReportSecuresToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveSecuresToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + } + + private void ReportComponentsSecuresToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportSecureComponents)); + if (service is FormReportSecureComponents form) + { + form.ShowDialog(); + } + } + + private void ReportOrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/SecuritySystem/SecuritySystemView/FormMain.resx b/SecuritySystem/SecuritySystemView/FormMain.resx index c17a880..6c82d08 100644 --- a/SecuritySystem/SecuritySystemView/FormMain.resx +++ b/SecuritySystem/SecuritySystemView/FormMain.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/SecuritySystem/SecuritySystemView/FormCreateOrder.Designer.cs b/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.Designer.cs similarity index 96% rename from SecuritySystem/SecuritySystemView/FormCreateOrder.Designer.cs rename to SecuritySystem/SecuritySystemView/Order/FormCreateOrder.Designer.cs index d99f108..3a7ee25 100644 --- a/SecuritySystem/SecuritySystemView/FormCreateOrder.Designer.cs +++ b/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.Designer.cs @@ -72,7 +72,7 @@ comboBoxSecure.Location = new Point(110, 9); comboBoxSecure.Name = "comboBoxSecure"; comboBoxSecure.Size = new Size(462, 28); - comboBoxSecure.TabIndex = 3; + comboBoxSecure.TabIndex = 0; comboBoxSecure.SelectedIndexChanged += ComboBoxSecure_SelectedIndexChanged; // // textBoxCount @@ -80,7 +80,7 @@ textBoxCount.Location = new Point(110, 43); textBoxCount.Name = "textBoxCount"; textBoxCount.Size = new Size(462, 27); - textBoxCount.TabIndex = 4; + textBoxCount.TabIndex = 1; textBoxCount.TextChanged += TextBoxCount_TextChanged; // // textBoxSum @@ -89,14 +89,14 @@ textBoxSum.Name = "textBoxSum"; textBoxSum.ReadOnly = true; textBoxSum.Size = new Size(462, 27); - textBoxSum.TabIndex = 5; + textBoxSum.TabIndex = 2; // // buttonSave // buttonSave.Location = new Point(370, 118); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(94, 29); - buttonSave.TabIndex = 1; + buttonSave.TabIndex = 3; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; buttonSave.Click += ButtonSave_Click; @@ -106,7 +106,7 @@ buttonCancel.Location = new Point(478, 118); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(94, 29); - buttonCancel.TabIndex = 7; + buttonCancel.TabIndex = 4; buttonCancel.Text = "Отменить"; buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Click += ButtonCancel_Click; diff --git a/SecuritySystem/SecuritySystemView/FormCreateOrder.cs b/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.cs similarity index 100% rename from SecuritySystem/SecuritySystemView/FormCreateOrder.cs rename to SecuritySystem/SecuritySystemView/Order/FormCreateOrder.cs diff --git a/SecuritySystem/SecuritySystemView/FormCreateOrder.resx b/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.resx similarity index 100% rename from SecuritySystem/SecuritySystemView/FormCreateOrder.resx rename to SecuritySystem/SecuritySystemView/Order/FormCreateOrder.resx diff --git a/SecuritySystem/SecuritySystemView/Program.cs b/SecuritySystem/SecuritySystemView/Program.cs index 98126e7..06e6dff 100644 --- a/SecuritySystem/SecuritySystemView/Program.cs +++ b/SecuritySystem/SecuritySystemView/Program.cs @@ -2,10 +2,12 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using SecuritySystemBusinessLogic.BusinessLogics; +using SecuritySystemBusinessLogic.OfficePackage; +using SecuritySystemBusinessLogic.OfficePackage.Implements; using SecuritySystemContracts.BusinessLogicsContracts; using SecuritySystemContracts.StoragesContracts; using SecuritySystemDatabaseImplement.Implements; -using System.Configuration; +using SecuritySystemView.Report; namespace SecuritySystemView { @@ -29,7 +31,6 @@ namespace SecuritySystemView } private static void ConfigureServices(ServiceCollection services) { - services.AddLogging(option => { option.SetMinimumLevel(LogLevel.Information); @@ -41,6 +42,10 @@ namespace SecuritySystemView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -48,6 +53,8 @@ namespace SecuritySystemView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/SecuritySystem/SecuritySystemView/Report/FormReportOrders.Designer.cs b/SecuritySystem/SecuritySystemView/Report/FormReportOrders.Designer.cs new file mode 100644 index 0000000..772f695 --- /dev/null +++ b/SecuritySystem/SecuritySystemView/Report/FormReportOrders.Designer.cs @@ -0,0 +1,143 @@ +namespace SecuritySystemView.Report +{ + partial class FormReportOrders + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + groupBox = new GroupBox(); + buttonToPDF = new Button(); + buttonMake = new Button(); + label2 = new Label(); + dateTimePickerTo = new DateTimePicker(); + dateTimePickerFrom = new DateTimePicker(); + label1 = new Label(); + reportViewer1 = new Microsoft.Reporting.WinForms.ReportViewer(); + groupBox.SuspendLayout(); + SuspendLayout(); + // + // groupBox + // + groupBox.Controls.Add(buttonToPDF); + groupBox.Controls.Add(buttonMake); + groupBox.Controls.Add(label2); + groupBox.Controls.Add(dateTimePickerTo); + groupBox.Controls.Add(dateTimePickerFrom); + groupBox.Controls.Add(label1); + groupBox.Dock = DockStyle.Top; + groupBox.Location = new Point(0, 0); + groupBox.Name = "groupBox"; + groupBox.Size = new Size(1049, 54); + groupBox.TabIndex = 0; + groupBox.TabStop = false; + // + // buttonToPDF + // + buttonToPDF.Location = new Point(720, 18); + buttonToPDF.Name = "buttonToPDF"; + buttonToPDF.Size = new Size(200, 30); + buttonToPDF.TabIndex = 5; + buttonToPDF.Text = "Выгрузить в PDF"; + buttonToPDF.UseVisualStyleBackColor = true; + buttonToPDF.Click += ButtonToPDF_Click; + // + // buttonMake + // + buttonMake.Location = new Point(498, 18); + buttonMake.Name = "buttonMake"; + buttonMake.Size = new Size(200, 30); + buttonMake.TabIndex = 4; + buttonMake.Text = "Сформировать"; + buttonMake.UseVisualStyleBackColor = true; + buttonMake.Click += ButtonMake_Click; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(236, 23); + label2.Name = "label2"; + label2.Size = new Size(27, 20); + label2.TabIndex = 3; + label2.Text = "по"; + // + // dateTimePickerTo + // + dateTimePickerTo.Location = new Point(269, 18); + dateTimePickerTo.Name = "dateTimePickerTo"; + dateTimePickerTo.Size = new Size(200, 27); + dateTimePickerTo.TabIndex = 2; + dateTimePickerTo.Value = DateTime.Today; + // + // dateTimePickerFrom + // + dateTimePickerFrom.Location = new Point(30, 18); + dateTimePickerFrom.Name = "dateTimePickerFrom"; + dateTimePickerFrom.Size = new Size(200, 27); + dateTimePickerFrom.TabIndex = 1; + dateTimePickerFrom.Value = DateTime.Today.AddMonths(-1); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(6, 23); + label1.Name = "label1"; + label1.Size = new Size(18, 20); + label1.TabIndex = 0; + label1.Text = "C"; + // + // reportViewer1 + // + reportViewer1.Location = new Point(0, 0); + reportViewer1.Name = "ReportViewer"; + reportViewer1.ServerReport.BearerToken = null; + reportViewer1.Size = new Size(396, 246); + reportViewer1.TabIndex = 0; + // + // FormReportOrders + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1049, 450); + Controls.Add(groupBox); + Name = "FormReportOrders"; + Text = "Заказы"; + groupBox.ResumeLayout(false); + groupBox.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBox; + private Button buttonToPDF; + private Button buttonMake; + private Label label2; + private DateTimePicker dateTimePickerTo; + private DateTimePicker dateTimePickerFrom; + private Label label1; + private Microsoft.Reporting.WinForms.ReportViewer reportViewer1; + } +} \ No newline at end of file diff --git a/SecuritySystem/SecuritySystemView/Report/FormReportOrders.cs b/SecuritySystem/SecuritySystemView/Report/FormReportOrders.cs new file mode 100644 index 0000000..a87ee34 --- /dev/null +++ b/SecuritySystem/SecuritySystemView/Report/FormReportOrders.cs @@ -0,0 +1,95 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.BusinessLogicsContracts; + +namespace SecuritySystemView.Report +{ + public partial class FormReportOrders : Form + { + private readonly ReportViewer reportViewer; + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportOrders(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("Report\\ReportOrders.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(groupBox); + } + private void ButtonMake_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + DateTime dateFrom = dateTimePickerFrom.Value; + DateTime dateTo = dateTimePickerTo.Value; + dateFrom = new DateTime(dateFrom.Year, dateFrom.Month, dateFrom.Day, 0, 0, 0); + dateTo = new DateTime(dateTo.Year, dateTo.Month, dateTo.Day, 23, 59, 59); + var dataSource = _logic.GetOrders(new ReportBindingModel + { + DateFrom = dateFrom, + DateTo = dateTo + }); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") }; reportViewer.LocalReport.SetParameters(parameters); reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonToPDF_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + using var dialog = new SaveFileDialog + { + Filter = "pdf|*.pdf" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + DateTime dateFrom = dateTimePickerFrom.Value; + DateTime dateTo = dateTimePickerTo.Value; + dateFrom = new DateTime(dateFrom.Year, dateFrom.Month, dateFrom.Day, 0, 0, 0); + dateTo = new DateTime(dateTo.Year, dateTo.Month, dateTo.Day, 23, 59, 59); + _logic.SaveOrdersToPdfFile(new ReportBindingModel + { + FileName = dialog.FileName, + DateFrom = dateFrom, + DateTo = dateTo + }); + _logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + +} diff --git a/SecuritySystem/SecuritySystemView/Report/FormReportOrders.resx b/SecuritySystem/SecuritySystemView/Report/FormReportOrders.resx new file mode 100644 index 0000000..fbd1d64 --- /dev/null +++ b/SecuritySystem/SecuritySystemView/Report/FormReportOrders.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.Designer.cs b/SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.Designer.cs new file mode 100644 index 0000000..a35c42e --- /dev/null +++ b/SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.Designer.cs @@ -0,0 +1,106 @@ +namespace SecuritySystemView.Report +{ + partial class FormReportSecureComponents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonSaveToExcel = new Button(); + dataGridView = new DataGridView(); + ColumnSecure = new DataGridViewTextBoxColumn(); + ColumnComponent = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(12, 12); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(181, 29); + buttonSaveToExcel.TabIndex = 0; + buttonSaveToExcel.Text = "Сохранить в Excel"; + buttonSaveToExcel.UseVisualStyleBackColor = true; + buttonSaveToExcel.Click += ButtonSaveToExcel_Click; + // + // dataGridView + // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnSecure, ColumnComponent, ColumnCount }); + dataGridView.Location = new Point(0, 47); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(845, 403); + dataGridView.TabIndex = 1; + // + // ColumnSecure + // + ColumnSecure.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + ColumnSecure.HeaderText = "Изделие"; + ColumnSecure.MinimumWidth = 6; + ColumnSecure.Name = "ColumnSecure"; + // + // ColumnComponent + // + ColumnComponent.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + ColumnComponent.HeaderText = "Компонент"; + ColumnComponent.MinimumWidth = 6; + ColumnComponent.Name = "ColumnComponent"; + // + // ColumnCount + // + ColumnCount.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader; + ColumnCount.HeaderText = "Количество"; + ColumnCount.MinimumWidth = 6; + ColumnCount.Name = "ColumnCount"; + ColumnCount.Width = 119; + // + // FormReportSecureComponents + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(845, 450); + Controls.Add(dataGridView); + Controls.Add(buttonSaveToExcel); + Name = "FormReportSecureComponents"; + Text = "Компоненты по изделиям"; + Load += FormReportSecureComponents_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Button buttonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ColumnSecure; + private DataGridViewTextBoxColumn ColumnComponent; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.cs b/SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.cs new file mode 100644 index 0000000..352dd22 --- /dev/null +++ b/SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.cs @@ -0,0 +1,70 @@ +using Microsoft.Extensions.Logging; +using SecuritySystemContracts.BindingModels; +using SecuritySystemContracts.BusinessLogicsContracts; + +namespace SecuritySystemView.Report +{ + public partial class FormReportSecureComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportSecureComponents(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormReportSecureComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetSecureComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.SecureName, "", "" }); + foreach (var listElem in elem.Components) + { + dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); + } + dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount }); + dataGridView.Rows.Add(Array.Empty()); + } + } + _logger.LogInformation("Загрузка списка изделий по компонентам"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonSaveToExcel_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "xlsx|*.xlsx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveSecureComponentToExcelFile(new + ReportBindingModel + { + FileName = dialog.FileName + }); + _logger.LogInformation("Сохранение списка изделий по компонентам"); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.resx b/SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.resx new file mode 100644 index 0000000..04e7ead --- /dev/null +++ b/SecuritySystem/SecuritySystemView/Report/FormReportSecureComponents.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/SecuritySystem/SecuritySystemView/Report/ReportOrders.rdlc b/SecuritySystem/SecuritySystemView/Report/ReportOrders.rdlc new file mode 100644 index 0000000..802d95d --- /dev/null +++ b/SecuritySystem/SecuritySystemView/Report/ReportOrders.rdlc @@ -0,0 +1,607 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + SecuritySystemContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + SecureName + System.String + + + Status + System.String + + + Sum + System.Decimal + + + + SecuritySystemContracts.ViewModels + ReportOrdersViewModel + SecuritySystemContracts.ViewModels.ReportOrdersViewModel, SecuritySystemContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 1cm + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Заказы + + + + + + + 1cm + 21cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 1.39933cm + + + 3.21438cm + + + 9.18567cm + + + 2.64817cm + + + 3.47367cm + + + + + 0.6cm + + + + + true + true + + + + + Номер + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Дата создания + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Изделие + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Статус + + + + + + + Textbox2 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + + Textbox7 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Id.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!DateCreate.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!SecureName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Status.Value + + + + Status + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + + Sum + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 19.92122cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 14.5cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 17cm + 0.6cm + 3.47367cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +