diff --git a/Contracts/ReportModels/ProductReportModel.cs b/Contracts/ReportModels/ProductReportModel.cs
index 8105863..96f7e76 100644
--- a/Contracts/ReportModels/ProductReportModel.cs
+++ b/Contracts/ReportModels/ProductReportModel.cs
@@ -12,6 +12,6 @@ namespace Contracts.ReportModels
public string Name { get; set; }
public string Image { get; set; }
public string Manufacturers { get; set; }
- public string DeliveryDate { get; set; }
+ public DateTime DeliveryDate { get; set; }
}
}
diff --git a/Lab4/Form1.Designer.cs b/Lab4/Form1.Designer.cs
new file mode 100644
index 0000000..76fe65f
--- /dev/null
+++ b/Lab4/Form1.Designer.cs
@@ -0,0 +1,170 @@
+namespace Lab4
+{
+ partial class Form1
+ {
+ ///
+ /// 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()
+ {
+ menuStrip1 = new MenuStrip();
+ ControlsStripMenuItem = new ToolStripMenuItem();
+ действияToolStripMenuItem = new ToolStripMenuItem();
+ справочникToolStripMenuItem = new ToolStripMenuItem();
+ добавитьToolStripMenuItem = new ToolStripMenuItem();
+ изменитьToolStripMenuItem = new ToolStripMenuItem();
+ удалитьToolStripMenuItem = new ToolStripMenuItem();
+ документыToolStripMenuItem = new ToolStripMenuItem();
+ вордToolStripMenuItem = new ToolStripMenuItem();
+ эксельToolStripMenuItem = new ToolStripMenuItem();
+ пдфToolStripMenuItem = new ToolStripMenuItem();
+ panelControl = new Panel();
+ menuStrip1.SuspendLayout();
+ SuspendLayout();
+ //
+ // menuStrip1
+ //
+ menuStrip1.ImageScalingSize = new Size(20, 20);
+ menuStrip1.Items.AddRange(new ToolStripItem[] { ControlsStripMenuItem, действияToolStripMenuItem, документыToolStripMenuItem });
+ menuStrip1.Location = new Point(0, 0);
+ menuStrip1.Name = "menuStrip1";
+ menuStrip1.Size = new Size(800, 28);
+ menuStrip1.TabIndex = 0;
+ menuStrip1.Text = "menuStrip1";
+ //
+ // ControlsStripMenuItem
+ //
+ ControlsStripMenuItem.Name = "ControlsStripMenuItem";
+ ControlsStripMenuItem.Size = new Size(113, 24);
+ ControlsStripMenuItem.Text = "Компоненты";
+ //
+ // действияToolStripMenuItem
+ //
+ действияToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, добавитьToolStripMenuItem, изменитьToolStripMenuItem, удалитьToolStripMenuItem });
+ действияToolStripMenuItem.Name = "действияToolStripMenuItem";
+ действияToolStripMenuItem.Size = new Size(88, 24);
+ действияToolStripMenuItem.Text = "Действия";
+ //
+ // справочникToolStripMenuItem
+ //
+ справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
+ справочникToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.I;
+ справочникToolStripMenuItem.Size = new Size(223, 26);
+ справочникToolStripMenuItem.Text = "Справочник";
+ справочникToolStripMenuItem.Click += ThesaurusToolStripMenuItem_Click;
+ //
+ // добавитьToolStripMenuItem
+ //
+ добавитьToolStripMenuItem.Name = "добавитьToolStripMenuItem";
+ добавитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
+ добавитьToolStripMenuItem.Size = new Size(223, 26);
+ добавитьToolStripMenuItem.Text = "Добавить";
+ добавитьToolStripMenuItem.Click += AddElementToolStripMenuItem_Click;
+ //
+ // изменитьToolStripMenuItem
+ //
+ изменитьToolStripMenuItem.Name = "изменитьToolStripMenuItem";
+ изменитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
+ изменитьToolStripMenuItem.Size = new Size(223, 26);
+ изменитьToolStripMenuItem.Text = "Изменить";
+ изменитьToolStripMenuItem.Click += UpdElementToolStripMenuItem_Click;
+ //
+ // удалитьToolStripMenuItem
+ //
+ удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
+ удалитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
+ удалитьToolStripMenuItem.Size = new Size(223, 26);
+ удалитьToolStripMenuItem.Text = "Удалить";
+ удалитьToolStripMenuItem.Click += DelElementToolStripMenuItem_Click;
+ //
+ // документыToolStripMenuItem
+ //
+ документыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { вордToolStripMenuItem, эксельToolStripMenuItem, пдфToolStripMenuItem });
+ документыToolStripMenuItem.Name = "документыToolStripMenuItem";
+ документыToolStripMenuItem.Size = new Size(101, 24);
+ документыToolStripMenuItem.Text = "Документы";
+ //
+ // вордToolStripMenuItem
+ //
+ вордToolStripMenuItem.Name = "вордToolStripMenuItem";
+ вордToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
+ вордToolStripMenuItem.Size = new Size(224, 26);
+ вордToolStripMenuItem.Text = "Ворд";
+ вордToolStripMenuItem.Click += WordDocToolStripMenuItem_Click;
+ //
+ // эксельToolStripMenuItem
+ //
+ эксельToolStripMenuItem.Name = "эксельToolStripMenuItem";
+ эксельToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
+ эксельToolStripMenuItem.Size = new Size(224, 26);
+ эксельToolStripMenuItem.Text = "Эксель";
+ эксельToolStripMenuItem.Click += ExcelDocToolStripMenuItem_Click;
+ //
+ // пдфToolStripMenuItem
+ //
+ пдфToolStripMenuItem.Name = "пдфToolStripMenuItem";
+ пдфToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
+ пдфToolStripMenuItem.Size = new Size(224, 26);
+ пдфToolStripMenuItem.Text = "Пдф";
+ пдфToolStripMenuItem.Click += PdfDocToolStripMenuItem_Click;
+ //
+ // panelControl
+ //
+ panelControl.Location = new Point(0, 31);
+ panelControl.Name = "panelControl";
+ panelControl.Size = new Size(800, 417);
+ panelControl.TabIndex = 1;
+ //
+ // Form1
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(panelControl);
+ Controls.Add(menuStrip1);
+ MainMenuStrip = menuStrip1;
+ Name = "Form1";
+ Text = "Form1";
+ menuStrip1.ResumeLayout(false);
+ menuStrip1.PerformLayout();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem ControlsStripMenuItem;
+ private ToolStripMenuItem действияToolStripMenuItem;
+ private ToolStripMenuItem справочникToolStripMenuItem;
+ private ToolStripMenuItem добавитьToolStripMenuItem;
+ private ToolStripMenuItem изменитьToolStripMenuItem;
+ private ToolStripMenuItem удалитьToolStripMenuItem;
+ private ToolStripMenuItem документыToolStripMenuItem;
+ private ToolStripMenuItem вордToolStripMenuItem;
+ private ToolStripMenuItem эксельToolStripMenuItem;
+ private ToolStripMenuItem пдфToolStripMenuItem;
+ private Panel panelControl;
+ }
+}
diff --git a/Lab4/Form1.cs b/Lab4/Form1.cs
new file mode 100644
index 0000000..bdac933
--- /dev/null
+++ b/Lab4/Form1.cs
@@ -0,0 +1,234 @@
+using Plugins;
+using System.Reflection;
+
+namespace Lab4
+{
+ public partial class Form1 : Form
+ {
+ private readonly Dictionary _plugins;
+ private string _selectedPlugin;
+ public Form1()
+ {
+
+ InitializeComponent();
+ _plugins = LoadPlugins();
+ _selectedPlugin = string.Empty;
+ }
+
+ private Dictionary LoadPlugins()
+ {
+ Dictionary plugins = new();
+ string currentDirectory = Directory.GetParent(Environment.CurrentDirectory)!.Parent!.Parent!.Parent!.FullName + "\\plugin";
+ string[] dllFiles = Directory.GetFiles(currentDirectory, "*.dll", SearchOption.AllDirectories);
+ foreach (string dllFile in dllFiles)
+ {
+ try
+ {
+ Assembly assembly = Assembly.LoadFrom(dllFile);
+
+ Type[] types = assembly.GetTypes();
+
+ foreach (Type type in types)
+ {
+ if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
+ {
+ var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
+
+ plugins.Add(plugin.PluginName, plugin);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($" {dllFile}: {ex.Message}");
+ }
+ }
+
+ foreach (var plugin in plugins)
+ {
+ CreateMenuItem(plugin.Value.PluginName);
+ }
+
+ return plugins;
+ }
+ private void CreateMenuItem(string pluginName)
+ {
+ ToolStripMenuItem menuItem = new ToolStripMenuItem(pluginName);
+ menuItem.Click += (object? sender, EventArgs a) =>
+ {
+ _selectedPlugin = pluginName;
+ IPluginsConvention plugin = _plugins[pluginName];
+ UserControl userControl = plugin.GetControl;
+ if (userControl != null)
+ {
+ panelControl.Controls.Clear();
+ plugin.ReloadData();
+ userControl.Dock = DockStyle.Fill;
+ panelControl.Controls.Add(userControl);
+ }
+ };
+ ControlsStripMenuItem.DropDownItems.Add(menuItem);
+ }
+ private void FormMain_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (string.IsNullOrEmpty(_selectedPlugin) ||
+ !_plugins.ContainsKey(_selectedPlugin))
+ {
+ return;
+ }
+ if (!e.Control)
+ {
+ return;
+ }
+ switch (e.KeyCode)
+ {
+ case Keys.I:
+ ShowThesaurus();
+ break;
+ case Keys.A:
+ AddNewElement();
+ break;
+ case Keys.U:
+ UpdateElement();
+ break;
+ case Keys.D:
+ DeleteElement();
+ break;
+ case Keys.S:
+ CreateWordDoc();
+ break;
+ case Keys.T:
+ CreatePdfDoc();
+ break;
+ case Keys.C:
+ CreateExcelDoc();
+ break;
+ }
+ }
+ private void ShowThesaurus()
+ {
+ _plugins[_selectedPlugin].GetThesaurus()?.Show();
+ }
+ private void AddNewElement()
+ {
+ var form = _plugins[_selectedPlugin].GetForm(null);
+ if (form != null && form.ShowDialog() == DialogResult.OK)
+ {
+ _plugins[_selectedPlugin].ReloadData();
+ }
+ }
+ private void UpdateElement()
+ {
+ var element = _plugins[_selectedPlugin].GetElement;
+ if (element == null)
+ {
+ MessageBox.Show(" ", "",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ var form = _plugins[_selectedPlugin].GetForm(element);
+ if (form != null && form.ShowDialog() == DialogResult.OK)
+ {
+ _plugins[_selectedPlugin].ReloadData();
+ }
+ }
+ private void DeleteElement()
+ {
+ if (MessageBox.Show(" ", "",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
+ {
+ return;
+ }
+ var element = _plugins[_selectedPlugin].GetElement;
+ if (element == null)
+ {
+ MessageBox.Show(" ", "",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (_plugins[_selectedPlugin].DeleteElement(element))
+ {
+ _plugins[_selectedPlugin].ReloadData();
+ }
+ }
+ private void CreateWordDoc()
+ {
+ SaveFileDialog saveFileDialog = new SaveFileDialog();
+ saveFileDialog.Filter = "Word Documents (*.docx)|*.docx";
+ saveFileDialog.Title = " ";
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_plugins[_selectedPlugin].CreateWordDocument(new
+ PluginsConventionSaveDocument()
+ { FileName = saveFileDialog.FileName }))
+ {
+ MessageBox.Show(" ", "" +
+ " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show(" ",
+ "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ }
+ }
+ private void CreatePdfDoc()
+ {
+ SaveFileDialog saveFileDialog = new SaveFileDialog();
+ saveFileDialog.Filter = "PDF Files (*.pdf)|*.pdf";
+ saveFileDialog.Title = " ";
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_plugins[_selectedPlugin].CreatePdfDocument(new
+ PluginsConventionSaveDocument()
+ { FileName = saveFileDialog.FileName }))
+ {
+ MessageBox.Show(" ", "" +
+ " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show(" ",
+ "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void CreateExcelDoc()
+ {
+ SaveFileDialog saveFileDialog = new SaveFileDialog();
+ saveFileDialog.Filter = "Excel Files (*.xlsx)|*.xlsx";
+ saveFileDialog.Title = " ";
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_plugins[_selectedPlugin].CreateExcelDocument(new
+ PluginsConventionSaveDocument()
+ { FileName = saveFileDialog.FileName }))
+ {
+ MessageBox.Show(" ", "" +
+ " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show(" ",
+ "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ }
+ }
+ private void ThesaurusToolStripMenuItem_Click(object sender,
+ EventArgs e) => ShowThesaurus();
+ private void AddElementToolStripMenuItem_Click(object sender,
+ EventArgs e) => AddNewElement();
+ private void UpdElementToolStripMenuItem_Click(object sender,
+ EventArgs e) => UpdateElement();
+ private void DelElementToolStripMenuItem_Click(object sender,
+ EventArgs e) => DeleteElement();
+ private void WordDocToolStripMenuItem_Click(object sender,
+ EventArgs e) => CreateWordDoc();
+ private void ExcelDocToolStripMenuItem_Click(object sender, EventArgs
+ e) => CreateExcelDoc();
+ private void PdfDocToolStripMenuItem_Click(object sender, EventArgs
+ e) => CreatePdfDoc();
+ }
+}
diff --git a/Lab4/Form1.resx b/Lab4/Form1.resx
new file mode 100644
index 0000000..a0623c8
--- /dev/null
+++ b/Lab4/Form1.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/Lab4/Lab4.csproj b/Lab4/Lab4.csproj
new file mode 100644
index 0000000..f0792ee
--- /dev/null
+++ b/Lab4/Lab4.csproj
@@ -0,0 +1,16 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Lab4/Program.cs b/Lab4/Program.cs
new file mode 100644
index 0000000..10f9355
--- /dev/null
+++ b/Lab4/Program.cs
@@ -0,0 +1,17 @@
+namespace Lab4
+{
+ internal static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ ApplicationConfiguration.Initialize();
+ Application.Run(new Form1());
+ }
+ }
+}
\ No newline at end of file
diff --git a/Plugins/IPluginsConvention.cs b/Plugins/IPluginsConvention.cs
new file mode 100644
index 0000000..206f5e3
--- /dev/null
+++ b/Plugins/IPluginsConvention.cs
@@ -0,0 +1,16 @@
+namespace Plugins
+{
+ public interface IPluginsConvention
+ {
+ string PluginName { get; }
+ UserControl GetControl { get; }
+ PluginsConventionElement GetElement { get; }
+ Form GetForm(PluginsConventionElement element);
+ Form GetThesaurus();
+ bool DeleteElement(PluginsConventionElement element);
+ void ReloadData();
+ bool CreateWordDocument(PluginsConventionSaveDocument saveDocument);
+ bool CreatePdfDocument(PluginsConventionSaveDocument saveDocument);
+ bool CreateExcelDocument(PluginsConventionSaveDocument saveDocument);
+ }
+}
diff --git a/Plugins/Plugins.csproj b/Plugins/Plugins.csproj
new file mode 100644
index 0000000..060aa1c
--- /dev/null
+++ b/Plugins/Plugins.csproj
@@ -0,0 +1,10 @@
+
+
+
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
diff --git a/Plugins/PluginsConventionElement.cs b/Plugins/PluginsConventionElement.cs
new file mode 100644
index 0000000..3dcb4a6
--- /dev/null
+++ b/Plugins/PluginsConventionElement.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Plugins
+{
+ public class PluginsConventionElement
+ {
+ public Guid Id { get; set; }
+ }
+}
diff --git a/Plugins/PluginsConventionSaveDocument.cs b/Plugins/PluginsConventionSaveDocument.cs
new file mode 100644
index 0000000..05cffac
--- /dev/null
+++ b/Plugins/PluginsConventionSaveDocument.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Plugins
+{
+ public class PluginsConventionSaveDocument
+ {
+ public string FileName { get; set; }
+ }
+}
diff --git a/ShopProducts.sln b/ShopProducts.sln
index 3600486..4050ac3 100644
--- a/ShopProducts.sln
+++ b/ShopProducts.sln
@@ -5,11 +5,15 @@ VisualStudioVersion = 17.8.34408.163
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShopProducts", "ShopProducts\ShopProducts.csproj", "{E8F82DF1-6741-454A-B96D-C1F2FB29134D}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{F2440E2E-293A-4107-980B-EC0020529692}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{F2440E2E-293A-4107-980B-EC0020529692}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BusinessLogic", "BusinessLogic\BusinessLogic.csproj", "{344C1681-67A5-485B-8E99-89F7D5866078}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BusinessLogic", "BusinessLogic\BusinessLogic.csproj", "{344C1681-67A5-485B-8E99-89F7D5866078}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{80BABD36-989A-4181-9159-23A0BD3CF04A}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{80BABD36-989A-4181-9159-23A0BD3CF04A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plugins", "Plugins\Plugins.csproj", "{93670F3B-6242-4043-9F04-55D1D09F13F2}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4", "Lab4\Lab4.csproj", "{8A6B55B8-934D-42BE-9C39-834FDA71A474}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -33,6 +37,14 @@ Global
{80BABD36-989A-4181-9159-23A0BD3CF04A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80BABD36-989A-4181-9159-23A0BD3CF04A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80BABD36-989A-4181-9159-23A0BD3CF04A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {93670F3B-6242-4043-9F04-55D1D09F13F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {93670F3B-6242-4043-9F04-55D1D09F13F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {93670F3B-6242-4043-9F04-55D1D09F13F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {93670F3B-6242-4043-9F04-55D1D09F13F2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8A6B55B8-934D-42BE-9C39-834FDA71A474}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8A6B55B8-934D-42BE-9C39-834FDA71A474}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8A6B55B8-934D-42BE-9C39-834FDA71A474}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8A6B55B8-934D-42BE-9C39-834FDA71A474}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/ShopProducts/FormProducts.cs b/ShopProducts/FormProducts.cs
index 9903a12..31debe8 100644
--- a/ShopProducts/FormProducts.cs
+++ b/ShopProducts/FormProducts.cs
@@ -142,9 +142,9 @@ namespace ShopProducts
ChartTitle = "- ",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Data = new Dictionary>
- {
- { "TTT", data }
- }
+ {
+ { "TTT", data }
+ }
});
MessageBox.Show("Word !", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
diff --git a/ShopProducts/PluginConvention.cs b/ShopProducts/PluginConvention.cs
new file mode 100644
index 0000000..6d535f8
--- /dev/null
+++ b/ShopProducts/PluginConvention.cs
@@ -0,0 +1,291 @@
+using BusinessLogic;
+using Contracts.BusinessLogicContracts;
+using Contracts.ReportModels;
+using ControlsLibraryNet60.Data;
+using DatabaseImplement.Implements;
+using DocumentFormat.OpenXml.Drawing.Charts;
+using Plugins;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using WinFormsLibrary1.Configs.Image;
+using WinFormsLibrary1;
+using ComponentsLibraryNet60.DocumentWithChart;
+using ComponentsLibraryNet60.Models;
+using ComponentsLibraryNet60.DocumentWithTable;
+using Contracts.ViewModels;
+using ControlsLibraryNet60.Models;
+using Contracts.BindingModels;
+
+namespace ShopProducts
+{
+ public class PluginsConvention : IPluginsConvention
+ {
+ private readonly ProductLogic _ProductLogic = new ProductLogic(new ProductStorage());
+ private readonly ManufacturerLogic _ManufacturerLogic = new ManufacturerLogic(new ManufacturerStorage());
+ /*private UserTreeView userTreeView1 = new UserTreeView();*/
+ private ControlDataTableRow controlDataTableRow1 = new ControlDataTableRow();
+ public string PluginName { get; set; } = "Лаба 4";
+
+ public UserControl GetControl
+ {
+ get
+ {
+ Load();
+ /*return userTreeView1;*/
+ return controlDataTableRow1;
+ }
+ }
+
+ public PluginsConventionElement GetElement
+ {
+ get
+ {
+ /*var selectedProduct = userTreeView1.GetSelectedObject();*/
+ var selectedProduct = controlDataTableRow1.GetSelectedObject();
+
+ int? id = null;
+ if (selectedProduct != null)
+ {
+ id = Convert.ToInt32(selectedProduct.Id);
+ }
+ byte[] bytes = new byte[16];
+ if (!id.HasValue)
+ {
+ id = -1;
+ }
+ BitConverter.GetBytes(id.Value).CopyTo(bytes, 0);
+ return new()
+ {
+ Id = new Guid(bytes)
+ };
+ }
+ }
+
+ public bool CreateExcelDocument(PluginsConventionSaveDocument saveDocument)
+ {
+ try
+ {
+ string fileName = saveDocument.FileName;
+
+ var list = _ProductLogic.Read(null);
+ ComponentDocumentWithTableHeaderRowExcel table = new ComponentDocumentWithTableHeaderRowExcel();
+ table.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig
+ {
+ FilePath = fileName,
+ Header = "Продукты",
+ UseUnion = true,
+ ColumnsRowsWidth = new List<(int, int)> { (5, 0), (10, 0), (10, 0), (10, 0) },
+ ColumnUnion = new List<(int StartIndex, int Count)> { (1, 2) },
+ Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
+ {
+ (0, 0, "ID", "Id"),
+ (1, 0, "Продукт", ""),
+ (1, 1, "Название", "Name"),
+ (2, 1, "Производитель", "Manufacturers"),
+ (3, 0, "Дата поставки", "DeliveryDate"),
+ },
+ Data = list
+ });
+
+ return true;
+
+ /*COP.PieChart pieChart1 = new COP.PieChart();
+ string fileName = saveDocument.FileName;
+ var dates = _ProductLogic.GetExcelInfo();
+ var chartData = dates.Select(x => new DataItem { Name = x.Item1, Value = x.Item2 }).ToList();
+ pieChart1.GenerateDocument(new ExcelChartInfo(fileName, "Сколько клиентов какого статуса совершали покупки",
+ "Круговая диаграмма", COP.Enums.LegendPosition.Bottom, chartData));
+ return true;*/
+
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ }
+
+ public bool CreateWordDocument(PluginsConventionSaveDocument saveDocument)
+ {
+ try
+ {
+ ComponentDocumentWithChartBarWord chart = new ComponentDocumentWithChartBarWord();
+
+ var data = _ProductLogic.GetWordInfo();
+ chart.CreateDoc(new ComponentDocumentWithChartConfig
+ {
+ FilePath = saveDocument.FileName,
+ Header = "Гистограмма продуктов",
+ ChartTitle = "Кол-во продукции по производителю",
+ LegendLocation = Location.Bottom,
+ Data = new Dictionary>
+ {
+ { "TTT", data }
+ }
+ });
+
+ /*string fileName = saveDocument.FileName;
+ List textList = new List();
+ var list = _ProductLogic.Read(new ProductBindingModel { PurchaseSum = 0 });
+ var rs = list.Select(item => string.Concat("ФИО: ", item.Name, " Отзывы: ", item.Reviews, '\n')).ToArray();
+ if (list != null)
+ {
+ BigTextDocument.CreateDocument(new BigTextDocumentInfo
+ (fileName, "Документ по клиентам, совершавшим покупки (ФИО клиента и его отзывы)", rs)
+ );
+ }*/
+ return true;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ }
+
+ public bool CreatePdfDocument(PluginsConventionSaveDocument saveDocument)
+ {
+ try
+ {
+ PdfWithImages pdf = new PdfWithImages();
+ var productImages = _ProductLogic.Read(null).Select(p => p.Image).ToList();
+ var config = new PdfWithImageConfig
+ {
+ FilePath = saveDocument.FileName,
+ Header = "Документ с изображениями",
+ Images = productImages
+ };
+ pdf.CreatePdf(config);
+
+ /*string fileName = saveDocument.FileName;
+ KOP.PDFComponents.PdfTableComponent pdfTableComponent1 = new();
+ var Products = _ProductLogic.Read(null);
+ for (int i = 0; i < Products.Count; i++)
+ {
+ if (Products[i].PurchaseSum == null || Products[i].PurchaseSum == "") { Products[i].PurchaseSum = "нет"; }
+ }
+ pdfTableComponent1.CreateDocument(fileName, "Отчёт по всем клиентам",
+ new List { 2.0, 6.0, 4.0, 4.0 }, new List { 5.0, 3.0 },
+ new List<(string, string)> { ("Id", "Id"), ("ФИО", "Name"), ("Статус", "Manufacturer"), ("Сумма покупок", "PurchaseSum") },
+ Products
+ );*/
+ return true;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ }
+
+
+ private void Load()
+ {
+ /*List stringToHierachy = new List() { "Manufacturer", "PurchaseSum", "Id", "Name" };
+ userTreeView1.Hierarchy = stringToHierachy;*/
+
+ var tableConfig = new List
+ {
+ new DataTableColumnConfig
+ {
+ ColumnHeader = "Id",
+ PropertyName = "Id",
+ Visible = false
+ },
+ new DataTableColumnConfig
+ {
+ ColumnHeader = "Name",
+ PropertyName = "Name",
+ Visible = true
+ },
+ new DataTableColumnConfig
+ {
+ ColumnHeader = "Manufacturers",
+ PropertyName = "Manufacturers",
+ Visible = true
+ },
+ new DataTableColumnConfig
+ {
+ ColumnHeader = "Delivery date",
+ PropertyName = "DeliveryDate",
+ Visible = true
+ }
+ };
+
+ controlDataTableRow1.LoadColumns(tableConfig);
+
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ /*var list = _ProductLogic.Read(null);
+ for (int i = 0; i < list.Count; i++)
+ {
+ if (list[i].PurchaseSum == null || list[i].PurchaseSum == "") { list[i].PurchaseSum = "нет"; }
+ }
+ userTreeView1.PopulateTree(list);*/
+
+ controlDataTableRow1.Clear();
+
+ var list = _ProductLogic.Read(null);
+ for (int i = 0; i < list.Count; i++)
+ {
+ controlDataTableRow1.AddRow(list[i]);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ public bool DeleteElement(PluginsConventionElement element)
+ {
+ var selectedProduct = controlDataTableRow1.GetSelectedObject();
+ int id = Convert.ToInt32(selectedProduct.Id);
+ try
+ {
+
+ _ProductLogic.Delete(new ProductBindingModel { Id = id });
+ LoadData();
+ return true;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+ }
+
+ public Form GetForm(PluginsConventionElement element)
+ {
+ if (element == null)
+ {
+ return new FormProduct(_ProductLogic, _ManufacturerLogic);
+ }
+ if (element.Id.GetHashCode() >= 0)
+ {
+ FormProduct form = new FormProduct(_ProductLogic, _ManufacturerLogic);
+ form.Id = element.Id.GetHashCode();
+ return form;
+ }
+ return null;
+ }
+
+ public Form GetThesaurus()
+ {
+ return new FormManufacturers(_ManufacturerLogic);
+ }
+
+ public void ReloadData()
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/ShopProducts/ShopProducts.csproj b/ShopProducts/ShopProducts.csproj
index e8f47d1..94ec3f2 100644
--- a/ShopProducts/ShopProducts.csproj
+++ b/ShopProducts/ShopProducts.csproj
@@ -22,6 +22,7 @@
+
\ No newline at end of file
diff --git a/plugin/BusinessLogic.dll b/plugin/BusinessLogic.dll
new file mode 100644
index 0000000..6db84ce
Binary files /dev/null and b/plugin/BusinessLogic.dll differ
diff --git a/plugin/ComponentsLibraryNet60.dll b/plugin/ComponentsLibraryNet60.dll
new file mode 100644
index 0000000..9807306
Binary files /dev/null and b/plugin/ComponentsLibraryNet60.dll differ
diff --git a/plugin/Contracts.dll b/plugin/Contracts.dll
new file mode 100644
index 0000000..888f400
Binary files /dev/null and b/plugin/Contracts.dll differ
diff --git a/plugin/ControlsLibraryNet60.dll b/plugin/ControlsLibraryNet60.dll
new file mode 100644
index 0000000..3d14013
Binary files /dev/null and b/plugin/ControlsLibraryNet60.dll differ
diff --git a/plugin/DatabaseImplement.dll b/plugin/DatabaseImplement.dll
new file mode 100644
index 0000000..1adffdc
Binary files /dev/null and b/plugin/DatabaseImplement.dll differ
diff --git a/plugin/DocumentFormat.OpenXml.dll b/plugin/DocumentFormat.OpenXml.dll
new file mode 100644
index 0000000..846973a
Binary files /dev/null and b/plugin/DocumentFormat.OpenXml.dll differ
diff --git a/plugin/Humanizer.dll b/plugin/Humanizer.dll
new file mode 100644
index 0000000..df62d3f
Binary files /dev/null and b/plugin/Humanizer.dll differ
diff --git a/plugin/Microsoft.Data.SqlClient.SNI.dll b/plugin/Microsoft.Data.SqlClient.SNI.dll
new file mode 100644
index 0000000..0add8c2
Binary files /dev/null and b/plugin/Microsoft.Data.SqlClient.SNI.dll differ
diff --git a/plugin/Microsoft.Data.SqlClient.dll b/plugin/Microsoft.Data.SqlClient.dll
new file mode 100644
index 0000000..0cfc4b0
Binary files /dev/null and b/plugin/Microsoft.Data.SqlClient.dll differ
diff --git a/plugin/Microsoft.EntityFrameworkCore.Abstractions.dll b/plugin/Microsoft.EntityFrameworkCore.Abstractions.dll
new file mode 100644
index 0000000..5a063d8
Binary files /dev/null and b/plugin/Microsoft.EntityFrameworkCore.Abstractions.dll differ
diff --git a/plugin/Microsoft.EntityFrameworkCore.Design.dll b/plugin/Microsoft.EntityFrameworkCore.Design.dll
new file mode 100644
index 0000000..92778e5
Binary files /dev/null and b/plugin/Microsoft.EntityFrameworkCore.Design.dll differ
diff --git a/plugin/Microsoft.EntityFrameworkCore.Relational.dll b/plugin/Microsoft.EntityFrameworkCore.Relational.dll
new file mode 100644
index 0000000..c659517
Binary files /dev/null and b/plugin/Microsoft.EntityFrameworkCore.Relational.dll differ
diff --git a/plugin/Microsoft.EntityFrameworkCore.SqlServer.dll b/plugin/Microsoft.EntityFrameworkCore.SqlServer.dll
new file mode 100644
index 0000000..a5af08b
Binary files /dev/null and b/plugin/Microsoft.EntityFrameworkCore.SqlServer.dll differ
diff --git a/plugin/Microsoft.EntityFrameworkCore.dll b/plugin/Microsoft.EntityFrameworkCore.dll
new file mode 100644
index 0000000..c31e545
Binary files /dev/null and b/plugin/Microsoft.EntityFrameworkCore.dll differ
diff --git a/plugin/Microsoft.Extensions.Caching.Abstractions.dll b/plugin/Microsoft.Extensions.Caching.Abstractions.dll
new file mode 100644
index 0000000..94eedf1
Binary files /dev/null and b/plugin/Microsoft.Extensions.Caching.Abstractions.dll differ
diff --git a/plugin/Microsoft.Extensions.Caching.Memory.dll b/plugin/Microsoft.Extensions.Caching.Memory.dll
new file mode 100644
index 0000000..42eb85f
Binary files /dev/null and b/plugin/Microsoft.Extensions.Caching.Memory.dll differ
diff --git a/plugin/Microsoft.Extensions.Configuration.Abstractions.dll b/plugin/Microsoft.Extensions.Configuration.Abstractions.dll
new file mode 100644
index 0000000..9a24516
Binary files /dev/null and b/plugin/Microsoft.Extensions.Configuration.Abstractions.dll differ
diff --git a/plugin/Microsoft.Extensions.DependencyInjection.Abstractions.dll b/plugin/Microsoft.Extensions.DependencyInjection.Abstractions.dll
new file mode 100644
index 0000000..b4ee93d
Binary files /dev/null and b/plugin/Microsoft.Extensions.DependencyInjection.Abstractions.dll differ
diff --git a/plugin/Microsoft.Extensions.DependencyInjection.dll b/plugin/Microsoft.Extensions.DependencyInjection.dll
new file mode 100644
index 0000000..6fe031c
Binary files /dev/null and b/plugin/Microsoft.Extensions.DependencyInjection.dll differ
diff --git a/plugin/Microsoft.Extensions.Logging.Abstractions.dll b/plugin/Microsoft.Extensions.Logging.Abstractions.dll
new file mode 100644
index 0000000..bb27a2f
Binary files /dev/null and b/plugin/Microsoft.Extensions.Logging.Abstractions.dll differ
diff --git a/plugin/Microsoft.Extensions.Logging.dll b/plugin/Microsoft.Extensions.Logging.dll
new file mode 100644
index 0000000..9e2d7f9
Binary files /dev/null and b/plugin/Microsoft.Extensions.Logging.dll differ
diff --git a/plugin/Microsoft.Extensions.Options.dll b/plugin/Microsoft.Extensions.Options.dll
new file mode 100644
index 0000000..604b602
Binary files /dev/null and b/plugin/Microsoft.Extensions.Options.dll differ
diff --git a/plugin/Microsoft.Extensions.Primitives.dll b/plugin/Microsoft.Extensions.Primitives.dll
new file mode 100644
index 0000000..1b2c43a
Binary files /dev/null and b/plugin/Microsoft.Extensions.Primitives.dll differ
diff --git a/plugin/Microsoft.Identity.Client.dll b/plugin/Microsoft.Identity.Client.dll
new file mode 100644
index 0000000..c01fcbf
Binary files /dev/null and b/plugin/Microsoft.Identity.Client.dll differ
diff --git a/plugin/Microsoft.IdentityModel.JsonWebTokens.dll b/plugin/Microsoft.IdentityModel.JsonWebTokens.dll
new file mode 100644
index 0000000..70b84f2
Binary files /dev/null and b/plugin/Microsoft.IdentityModel.JsonWebTokens.dll differ
diff --git a/plugin/Microsoft.IdentityModel.Logging.dll b/plugin/Microsoft.IdentityModel.Logging.dll
new file mode 100644
index 0000000..7ecc3be
Binary files /dev/null and b/plugin/Microsoft.IdentityModel.Logging.dll differ
diff --git a/plugin/Microsoft.IdentityModel.Protocols.OpenIdConnect.dll b/plugin/Microsoft.IdentityModel.Protocols.OpenIdConnect.dll
new file mode 100644
index 0000000..d925b5b
Binary files /dev/null and b/plugin/Microsoft.IdentityModel.Protocols.OpenIdConnect.dll differ
diff --git a/plugin/Microsoft.IdentityModel.Protocols.dll b/plugin/Microsoft.IdentityModel.Protocols.dll
new file mode 100644
index 0000000..17423cc
Binary files /dev/null and b/plugin/Microsoft.IdentityModel.Protocols.dll differ
diff --git a/plugin/Microsoft.IdentityModel.Tokens.dll b/plugin/Microsoft.IdentityModel.Tokens.dll
new file mode 100644
index 0000000..dd66624
Binary files /dev/null and b/plugin/Microsoft.IdentityModel.Tokens.dll differ
diff --git a/plugin/MigraDoc.DocumentObjectModel.dll b/plugin/MigraDoc.DocumentObjectModel.dll
new file mode 100644
index 0000000..2bf457c
Binary files /dev/null and b/plugin/MigraDoc.DocumentObjectModel.dll differ
diff --git a/plugin/MigraDoc.DocumentObjectModel.resources.dll b/plugin/MigraDoc.DocumentObjectModel.resources.dll
new file mode 100644
index 0000000..4331e4a
Binary files /dev/null and b/plugin/MigraDoc.DocumentObjectModel.resources.dll differ
diff --git a/plugin/MigraDoc.Rendering.dll b/plugin/MigraDoc.Rendering.dll
new file mode 100644
index 0000000..9c14fbe
Binary files /dev/null and b/plugin/MigraDoc.Rendering.dll differ
diff --git a/plugin/MigraDoc.Rendering.resources.dll b/plugin/MigraDoc.Rendering.resources.dll
new file mode 100644
index 0000000..cde2390
Binary files /dev/null and b/plugin/MigraDoc.Rendering.resources.dll differ
diff --git a/plugin/PdfSharp.Charting.dll b/plugin/PdfSharp.Charting.dll
new file mode 100644
index 0000000..384a0f0
Binary files /dev/null and b/plugin/PdfSharp.Charting.dll differ
diff --git a/plugin/PdfSharp.Charting.resources.dll b/plugin/PdfSharp.Charting.resources.dll
new file mode 100644
index 0000000..4a0c247
Binary files /dev/null and b/plugin/PdfSharp.Charting.resources.dll differ
diff --git a/plugin/PdfSharp.dll b/plugin/PdfSharp.dll
new file mode 100644
index 0000000..aa564e1
Binary files /dev/null and b/plugin/PdfSharp.dll differ
diff --git a/plugin/PdfSharp.resources.dll b/plugin/PdfSharp.resources.dll
new file mode 100644
index 0000000..da5b607
Binary files /dev/null and b/plugin/PdfSharp.resources.dll differ
diff --git a/plugin/Plugins.dll b/plugin/Plugins.dll
new file mode 100644
index 0000000..ed2c59d
Binary files /dev/null and b/plugin/Plugins.dll differ
diff --git a/plugin/ShopProducts.dll b/plugin/ShopProducts.dll
new file mode 100644
index 0000000..8fd8f30
Binary files /dev/null and b/plugin/ShopProducts.dll differ
diff --git a/plugin/System.Diagnostics.DiagnosticSource.dll b/plugin/System.Diagnostics.DiagnosticSource.dll
new file mode 100644
index 0000000..1e58f62
Binary files /dev/null and b/plugin/System.Diagnostics.DiagnosticSource.dll differ
diff --git a/plugin/System.IdentityModel.Tokens.Jwt.dll b/plugin/System.IdentityModel.Tokens.Jwt.dll
new file mode 100644
index 0000000..efd3c61
Binary files /dev/null and b/plugin/System.IdentityModel.Tokens.Jwt.dll differ
diff --git a/plugin/System.Runtime.Caching.dll b/plugin/System.Runtime.Caching.dll
new file mode 100644
index 0000000..6fedfab
Binary files /dev/null and b/plugin/System.Runtime.Caching.dll differ
diff --git a/plugin/WinFormsLibrary1.dll b/plugin/WinFormsLibrary1.dll
new file mode 100644
index 0000000..e73a47a
Binary files /dev/null and b/plugin/WinFormsLibrary1.dll differ