Small commit.

This commit is contained in:
ElEgEv 2023-11-02 17:27:46 +04:00
parent b9162ffb1a
commit 695eca91b9
5 changed files with 257 additions and 0 deletions

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -55,7 +55,9 @@ namespace PluginsConventionLibraryNet60
public List<IPluginsConvention> LoadPl() public List<IPluginsConvention> LoadPl()
{ {
string currentDir = Environment.CurrentDirectory; string currentDir = Environment.CurrentDirectory;
string pluginsDir = Directory.GetParent(currentDir).Parent.Parent.Parent.FullName + "\\Plugins"; string pluginsDir = Directory.GetParent(currentDir).Parent.Parent.Parent.FullName + "\\Plugins";
string[] dllFiles = Directory.GetFiles( string[] dllFiles = Directory.GetFiles(
pluginsDir, pluginsDir,
"*.dll", "*.dll",
@ -134,6 +136,7 @@ namespace PluginsConventionLibraryNet60
{ {
_plugins[_selectedPlugin].GetThesaurus()?.Show(); _plugins[_selectedPlugin].GetThesaurus()?.Show();
} }
private void AddNewElement() private void AddNewElement()
{ {
var form = _plugins[_selectedPlugin].GetForm(null); var form = _plugins[_selectedPlugin].GetForm(null);

View File

@ -20,6 +20,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginsLib", "PluginsLib\Pl
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibraryNet60", "PluginsConventionLibraryNet60\PluginsConventionLibraryNet60.csproj", "{F6851562-4D46-4348-9FFF-8618390C91BC}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibraryNet60", "PluginsConventionLibraryNet60\PluginsConventionLibraryNet60.csproj", "{F6851562-4D46-4348-9FFF-8618390C91BC}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugins", "Plugins\Plugins.csproj", "{F2FCBB98-CFEC-4CBD-B063-6A3E8409E0F2}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{F6851562-4D46-4348-9FFF-8618390C91BC}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -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<OrderViewModel>()!.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<string>() {
"Идентификатор",
"ФИО заказчика",
"Статус заказа",
"Сумма"
};
var listData = new List<OrderTableViewModel>();
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<string>() { "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<OrderTableViewModel>
{
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);
}
}
}
}

View File

@ -25,6 +25,7 @@
<ProjectReference Include="..\Contracts\Contracts.csproj" /> <ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" /> <ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
<ProjectReference Include="..\DataModels\DataModels.csproj" /> <ProjectReference Include="..\DataModels\DataModels.csproj" />
<ProjectReference Include="..\PluginsLib\PluginsLib.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>