From 695eca91b91d5be7caeab3c0bcc25e9b328d8064 Mon Sep 17 00:00:00 2001
From: ElEgEv <112943269+ElEgEv@users.noreply.github.com>
Date: Thu, 2 Nov 2023 17:27:46 +0400
Subject: [PATCH] Small commit.
---
VisualComponentsForm/Plugins/Plugins.csproj | 9 +
.../PluginsConventionLibraryNet60/FormMain.cs | 3 +
VisualComponentsForm/VisualComponentsForm.sln | 6 +
.../VisualComponentsForm/PluginsConvention.cs | 238 ++++++++++++++++++
.../VisualComponentsForm.csproj | 1 +
5 files changed, 257 insertions(+)
create mode 100644 VisualComponentsForm/Plugins/Plugins.csproj
create mode 100644 VisualComponentsForm/VisualComponentsForm/PluginsConvention.cs
diff --git a/VisualComponentsForm/Plugins/Plugins.csproj b/VisualComponentsForm/Plugins/Plugins.csproj
new file mode 100644
index 0000000..cfadb03
--- /dev/null
+++ b/VisualComponentsForm/Plugins/Plugins.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net7.0
+ enable
+ enable
+
+
+
diff --git a/VisualComponentsForm/PluginsConventionLibraryNet60/FormMain.cs b/VisualComponentsForm/PluginsConventionLibraryNet60/FormMain.cs
index ad11ee4..fe49cad 100644
--- a/VisualComponentsForm/PluginsConventionLibraryNet60/FormMain.cs
+++ b/VisualComponentsForm/PluginsConventionLibraryNet60/FormMain.cs
@@ -55,7 +55,9 @@ namespace PluginsConventionLibraryNet60
public List LoadPl()
{
string currentDir = Environment.CurrentDirectory;
+
string pluginsDir = Directory.GetParent(currentDir).Parent.Parent.Parent.FullName + "\\Plugins";
+
string[] dllFiles = Directory.GetFiles(
pluginsDir,
"*.dll",
@@ -134,6 +136,7 @@ namespace PluginsConventionLibraryNet60
{
_plugins[_selectedPlugin].GetThesaurus()?.Show();
}
+
private void AddNewElement()
{
var form = _plugins[_selectedPlugin].GetForm(null);
diff --git a/VisualComponentsForm/VisualComponentsForm.sln b/VisualComponentsForm/VisualComponentsForm.sln
index 6c18f86..18c8dce 100644
--- a/VisualComponentsForm/VisualComponentsForm.sln
+++ b/VisualComponentsForm/VisualComponentsForm.sln
@@ -20,6 +20,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginsLib", "PluginsLib\Pl
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibraryNet60", "PluginsConventionLibraryNet60\PluginsConventionLibraryNet60.csproj", "{F6851562-4D46-4348-9FFF-8618390C91BC}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugins", "Plugins\Plugins.csproj", "{F2FCBB98-CFEC-4CBD-B063-6A3E8409E0F2}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -54,6 +56,10 @@ Global
{F6851562-4D46-4348-9FFF-8618390C91BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6851562-4D46-4348-9FFF-8618390C91BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6851562-4D46-4348-9FFF-8618390C91BC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F2FCBB98-CFEC-4CBD-B063-6A3E8409E0F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F2FCBB98-CFEC-4CBD-B063-6A3E8409E0F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F2FCBB98-CFEC-4CBD-B063-6A3E8409E0F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F2FCBB98-CFEC-4CBD-B063-6A3E8409E0F2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/VisualComponentsForm/VisualComponentsForm/PluginsConvention.cs b/VisualComponentsForm/VisualComponentsForm/PluginsConvention.cs
new file mode 100644
index 0000000..6598dce
--- /dev/null
+++ b/VisualComponentsForm/VisualComponentsForm/PluginsConvention.cs
@@ -0,0 +1,238 @@
+using DatabaseImplement.Implements;
+using DataModels.Models;
+using NonVisualComponents.Classes;
+using PluginsLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using VisualComponentsLib.CustomListBox;
+
+namespace VisualComponentsForm
+{
+ public class PluginsConvention : IPluginsConvention
+ {
+ private readonly LabWorkStorage _labWorkStorage;
+ private readonly IDiscipline _discipline;
+ private readonly ValueTree valTree;
+ private readonly ComponentTextWord componentTextWord;
+ private readonly ConfigurableTable configurableTable;
+ private readonly PieChartDocument pieChartDocument;
+
+ public string PluginName { get; set; } = "Список объектов";
+
+ public PluginsConvention()
+ {
+ _labWorkStorage = new LabWorkStorage();
+ _discipline = new DisciplineStorage();
+ componentTextWord = new ComponentTextWord();
+ configurableTable = new ConfigurableTable();
+ pieChartDocument = new PieChartDocument();
+ valTree = new ValueTree();
+ }
+
+ public UserControl GetControl
+ {
+ get { return valTree; }
+ }
+
+ public PluginsConventionElement GetElement
+ {
+ get
+ {
+ int Id = valTree.GetSelectedRecord()!.Id;
+ byte[] bytes = new byte[16];
+
+ BitConverter.GetBytes(Id).CopyTo(bytes, 0);
+
+ Guid curId = new Guid(bytes);
+
+ return new PluginsConventionElement() { Id = curId };
+ }
+ }
+
+ public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
+ {
+ try
+ {
+ string[] strings = _labWorkStorage.getUniqueStatusNames();
+ double[] doubles = _labWorkStorage.getCountByStatus(strings);
+
+ pieChartDocument.Gen(new PieChartDocumentConfig()
+ {
+ FilePath = saveDocument.FileName,
+ Title = System.IO.Path.GetFileName(saveDocument.FileName),
+ ChartTitle = "Сколько оплаченных заказов в каких статусах находятся",
+ Data = doubles,
+ Labels = strings,
+ LegendPosition = ChartLegendPosition.Top,
+ });
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+
+ return false;
+ }
+ }
+
+ public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
+ {
+ try
+ {
+ var view = new OrderSearchModel
+ {
+ TotalPrice = null
+ };
+
+ var list = _labWorkStorage.GetFilteredList(view);
+
+ string[] data = new string[list.Count];
+ string curStr = "";
+
+ for (int i = 0; i < list.Count; i++)
+ {
+ curStr = "ФИО Заказчика: " + list[i].UserInfo + ". Информация о товарах: " + list[i].ProductsInfo;
+ data[i] = curStr;
+ }
+
+ WordData wd = new WordData
+ {
+ filePath = saveDocument.FileName,
+ title = System.IO.Path.GetFileName(saveDocument.FileName),
+ data = data
+ };
+
+ componentTextWord.CreateFileWithBigText(wd);
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+
+ return false;
+ }
+ }
+
+ public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
+ {
+ try
+ {
+ var list = _labWorkStorage.GetFullList();
+
+ var ColumnHeaders = new List() {
+ "Идентификатор",
+ "ФИО заказчика",
+ "Статус заказа",
+ "Сумма"
+ };
+
+ var listData = new List();
+
+ int id = 0;
+ string UserInfo = "";
+ string TotalPrice = "";
+ string Status = "";
+
+ for (int i = 0; i < list.Count; i++)
+ {
+ id = list[i].Id;
+ UserInfo = list[i].UserInfo;
+
+ if (list[i].TotalPrice == null)
+ {
+ TotalPrice = "Оплачено скидками";
+ }
+ else
+ {
+ TotalPrice = list[i].TotalPrice.ToString()!;
+ }
+
+ Status = list[i].Status;
+
+ var data = new OrderTableViewModel()
+ {
+ Id = id,
+ UserInfo = UserInfo,
+ TotalPrice = TotalPrice,
+ Status = Status
+ };
+
+ listData.Add(data);
+ }
+
+ var props = new List() { "Id", "UserInfo", "Status", "TotalPrice" };
+
+ int[] rowHeight = new int[listData.Count + 1];
+
+ for (int i = 0; i < rowHeight.Length; i++)
+ {
+ rowHeight[i] = 20;
+ }
+
+ configurableTable.SaveToPdfFile(new PdfTableInfo
+ {
+ FilePath = saveDocument.FileName,
+ DocumentTitle = "Заголовок",
+ TableData = listData,
+ ColumnWidths = new int[] { 10, 10, 10, 30 },
+ RowHeight = rowHeight,
+ ColumnHeaders = ColumnHeaders,
+ Properties = props
+ });
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+
+ return false;
+ }
+ }
+
+ public bool DeleteElement(PluginsConventionElement element)
+ {
+ _labWorkStorage.Delete(new(element.Id.GetHashCode()));
+
+ return true;
+ }
+
+ public Form GetForm(PluginsConventionElement element)
+ {
+ if (element == null)
+ {
+ return new FormMain(_labWorkStorage, _discipline);
+ }
+ else
+ {
+ FormMain form = new FormMain(_labWorkStorage, _discipline);
+
+ return form;
+ }
+
+ }
+
+ public Form GetThesaurus()
+ {
+ return new FormStatusDirectory(_discipline);
+ }
+
+ public void ReloadData()
+ {
+ var labWorks = _labWorkStorage.GetFullList();
+
+ myListBox.ClearAll();
+
+ foreach (var labWork in labWorks)
+ {
+ myListBox.AddItem(labWork.Discipline + " | " + labWork.Id.ToString() + " | "
+ + labWork.Theme + " | " + labWork.Questions);
+ }
+ }
+ }
+}
diff --git a/VisualComponentsForm/VisualComponentsForm/VisualComponentsForm.csproj b/VisualComponentsForm/VisualComponentsForm/VisualComponentsForm.csproj
index 6e4eaca..5146250 100644
--- a/VisualComponentsForm/VisualComponentsForm/VisualComponentsForm.csproj
+++ b/VisualComponentsForm/VisualComponentsForm/VisualComponentsForm.csproj
@@ -25,6 +25,7 @@
+
\ No newline at end of file