4ая лаба
This commit is contained in:
parent
b87b2493c8
commit
a9cace146f
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,6 +4,8 @@
|
|||||||
##
|
##
|
||||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
|
||||||
|
*.dll
|
||||||
|
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
*.suo
|
*.suo
|
||||||
|
28
COP/AppByPlugins/AppByPlugins.csproj
Normal file
28
COP/AppByPlugins/AppByPlugins.csproj
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.20">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
|
||||||
|
<PackageReference Include="System.Text.Encodings.Web" Version="7.0.0" />
|
||||||
|
<PackageReference Include="System.Text.Json" Version="7.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ClientsDatabaseImplement\ClientsDatabaseImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
</Project>
|
173
COP/AppByPlugins/FormMain.Designer.cs
generated
Normal file
173
COP/AppByPlugins/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
namespace AppByPlugins
|
||||||
|
{
|
||||||
|
partial class FormMain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
menuStrip = new MenuStrip();
|
||||||
|
ControlsStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ActionsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ThesaurusToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
AddElementToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
UpdElementToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
DelElementToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
DocsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
SimpleDocToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
TableDocToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ChartDocToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
panelControl = new Panel();
|
||||||
|
menuStrip.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
menuStrip.Items.AddRange(new ToolStripItem[] { ControlsStripMenuItem, ActionsToolStripMenuItem, DocsToolStripMenuItem });
|
||||||
|
menuStrip.Location = new Point(0, 0);
|
||||||
|
menuStrip.Name = "menuStrip";
|
||||||
|
menuStrip.Size = new Size(800, 24);
|
||||||
|
menuStrip.TabIndex = 0;
|
||||||
|
menuStrip.Text = "Меню";
|
||||||
|
//
|
||||||
|
// ControlsStripMenuItem
|
||||||
|
//
|
||||||
|
ControlsStripMenuItem.Name = "ControlsStripMenuItem";
|
||||||
|
ControlsStripMenuItem.Size = new Size(90, 20);
|
||||||
|
ControlsStripMenuItem.Text = "Компоненты";
|
||||||
|
//
|
||||||
|
// ActionsToolStripMenuItem
|
||||||
|
//
|
||||||
|
ActionsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ThesaurusToolStripMenuItem, AddElementToolStripMenuItem, UpdElementToolStripMenuItem, DelElementToolStripMenuItem });
|
||||||
|
ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
|
||||||
|
ActionsToolStripMenuItem.Size = new Size(70, 20);
|
||||||
|
ActionsToolStripMenuItem.Text = "Действия";
|
||||||
|
//
|
||||||
|
// ThesaurusToolStripMenuItem
|
||||||
|
//
|
||||||
|
ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
|
||||||
|
ThesaurusToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.I;
|
||||||
|
ThesaurusToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
ThesaurusToolStripMenuItem.Text = "Справочник";
|
||||||
|
ThesaurusToolStripMenuItem.Click += ThesaurusToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// AddElementToolStripMenuItem
|
||||||
|
//
|
||||||
|
AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
|
||||||
|
AddElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
|
||||||
|
AddElementToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
AddElementToolStripMenuItem.Text = "Добавить";
|
||||||
|
AddElementToolStripMenuItem.Click += AddElementToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// UpdElementToolStripMenuItem
|
||||||
|
//
|
||||||
|
UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
|
||||||
|
UpdElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
|
||||||
|
UpdElementToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
UpdElementToolStripMenuItem.Text = "Изменить";
|
||||||
|
UpdElementToolStripMenuItem.Click += UpdElementToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// DelElementToolStripMenuItem
|
||||||
|
//
|
||||||
|
DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
|
||||||
|
DelElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
|
||||||
|
DelElementToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
DelElementToolStripMenuItem.Text = "Удалить";
|
||||||
|
DelElementToolStripMenuItem.Click += DelElementToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// DocsToolStripMenuItem
|
||||||
|
//
|
||||||
|
DocsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SimpleDocToolStripMenuItem, TableDocToolStripMenuItem, ChartDocToolStripMenuItem });
|
||||||
|
DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
|
||||||
|
DocsToolStripMenuItem.Size = new Size(82, 20);
|
||||||
|
DocsToolStripMenuItem.Text = "Документы";
|
||||||
|
//
|
||||||
|
// SimpleDocToolStripMenuItem
|
||||||
|
//
|
||||||
|
SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
|
||||||
|
SimpleDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||||
|
SimpleDocToolStripMenuItem.Size = new Size(233, 22);
|
||||||
|
SimpleDocToolStripMenuItem.Text = "Простой документ";
|
||||||
|
SimpleDocToolStripMenuItem.Click += SimpleDocToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// TableDocToolStripMenuItem
|
||||||
|
//
|
||||||
|
TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
|
||||||
|
TableDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
|
||||||
|
TableDocToolStripMenuItem.Size = new Size(233, 22);
|
||||||
|
TableDocToolStripMenuItem.Text = "Документ с таблицой";
|
||||||
|
TableDocToolStripMenuItem.Click += TableDocToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// ChartDocToolStripMenuItem
|
||||||
|
//
|
||||||
|
ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
|
||||||
|
ChartDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
|
||||||
|
ChartDocToolStripMenuItem.Size = new Size(233, 22);
|
||||||
|
ChartDocToolStripMenuItem.Text = "Документ с диаграммой";
|
||||||
|
ChartDocToolStripMenuItem.Click += ChartDocToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// panelControl
|
||||||
|
//
|
||||||
|
panelControl.Dock = DockStyle.Fill;
|
||||||
|
panelControl.Location = new Point(0, 24);
|
||||||
|
panelControl.Name = "panelControl";
|
||||||
|
panelControl.Size = new Size(800, 426);
|
||||||
|
panelControl.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(panelControl);
|
||||||
|
Controls.Add(menuStrip);
|
||||||
|
MainMenuStrip = menuStrip;
|
||||||
|
Name = "FormMain";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
Text = "Главная форма";
|
||||||
|
WindowState = FormWindowState.Maximized;
|
||||||
|
KeyDown += FormMain_KeyDown;
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.MenuStrip menuStrip;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ControlsStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem DocsToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem SimpleDocToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem TableDocToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ChartDocToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.Panel panelControl;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ActionsToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem ThesaurusToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem AddElementToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem UpdElementToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem DelElementToolStripMenuItem;
|
||||||
|
}
|
||||||
|
}
|
225
COP/AppByPlugins/FormMain.cs
Normal file
225
COP/AppByPlugins/FormMain.cs
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
using PluginsConventionLibrary;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace AppByPlugins
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
private readonly Dictionary<string, IPluginsConvention> _plugins;
|
||||||
|
private string _selectedPlugin;
|
||||||
|
|
||||||
|
public FormMain()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_plugins = LoadPlugins();
|
||||||
|
_selectedPlugin = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, IPluginsConvention> LoadPlugins()
|
||||||
|
{
|
||||||
|
var plugins = new Dictionary<string, IPluginsConvention>();
|
||||||
|
|
||||||
|
string pluginsDir = Directory.GetParent(Directory.GetCurrentDirectory())!.Parent!.Parent!.Parent!.FullName + "\\Plugins";
|
||||||
|
|
||||||
|
string[] dllFiles = Directory.GetFiles(pluginsDir, "*.dll", SearchOption.AllDirectories);
|
||||||
|
|
||||||
|
foreach (string dllFile in dllFiles)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
Assembly assembly = Assembly.LoadFrom(dllFile);
|
||||||
|
Type[] types = assembly.GetTypes();
|
||||||
|
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
|
||||||
|
{
|
||||||
|
var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
|
||||||
|
plugins.Add(plugin.PluginName, plugin);
|
||||||
|
CreateMenuItem(plugin.PluginName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Ошибка при загрузке сборки {dllFile}: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return plugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void CreateMenuItem(string pluginName)
|
||||||
|
{
|
||||||
|
ToolStripMenuItem menuItem = new(pluginName);
|
||||||
|
menuItem.Click += (object? sender, EventArgs e) =>
|
||||||
|
{
|
||||||
|
UserControl userControl = _plugins[pluginName].GetControl;
|
||||||
|
if (userControl != null)
|
||||||
|
{
|
||||||
|
panelControl.Controls.Clear();
|
||||||
|
userControl.Dock = DockStyle.Fill;
|
||||||
|
_plugins[pluginName].ReloadData();
|
||||||
|
_selectedPlugin = pluginName;
|
||||||
|
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:
|
||||||
|
CreateSimpleDoc();
|
||||||
|
break;
|
||||||
|
case Keys.T:
|
||||||
|
CreateTableDoc();
|
||||||
|
break;
|
||||||
|
case Keys.C:
|
||||||
|
CreateChartDoc();
|
||||||
|
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 CreateSimpleDoc()
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new()
|
||||||
|
{
|
||||||
|
Filter = "Word Files|*.docx"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreateTableDoc()
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new()
|
||||||
|
{
|
||||||
|
Filter = "PDF Files|*.pdf"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreateChartDoc()
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new()
|
||||||
|
{
|
||||||
|
Filter = "Excel Files|*.xlsx"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 SimpleDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateSimpleDoc();
|
||||||
|
private void TableDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateTableDoc();
|
||||||
|
private void ChartDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateChartDoc();
|
||||||
|
}
|
||||||
|
}
|
120
COP/AppByPlugins/FormMain.resx
Normal file
120
COP/AppByPlugins/FormMain.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
17
COP/AppByPlugins/Program.cs
Normal file
17
COP/AppByPlugins/Program.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace AppByPlugins
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[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 FormMain());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
COP/COP.sln
16
COP/COP.sln
@ -13,9 +13,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientsContracts", "Clients
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientsDatabaseImplement", "ClientsDatabaseImplement\ClientsDatabaseImplement.csproj", "{725F3378-1474-4195-9F76-B9C98690CC76}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientsDatabaseImplement", "ClientsDatabaseImplement\ClientsDatabaseImplement.csproj", "{725F3378-1474-4195-9F76-B9C98690CC76}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BulatovaComponents", "BulatovaComponents\BulatovaComponents.csproj", "{A8DDA2DE-1B0C-4870-BA0B-BDE84B705B3E}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BulatovaComponents", "BulatovaComponents\BulatovaComponents.csproj", "{A8DDA2DE-1B0C-4870-BA0B-BDE84B705B3E}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientsDataModels", "ClientsDataModels\ClientsDataModels.csproj", "{83105892-317C-4442-B064-E489D2CFE39D}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientsDataModels", "ClientsDataModels\ClientsDataModels.csproj", "{83105892-317C-4442-B064-E489D2CFE39D}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibrary", "PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{21F2683A-8624-4C9B-A765-2E7CCA8D8BBD}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppByPlugins", "AppByPlugins\AppByPlugins.csproj", "{586FCB30-AC9A-4229-B7F7-3FB2ADF581B6}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -51,6 +55,14 @@ Global
|
|||||||
{83105892-317C-4442-B064-E489D2CFE39D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{83105892-317C-4442-B064-E489D2CFE39D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{83105892-317C-4442-B064-E489D2CFE39D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{83105892-317C-4442-B064-E489D2CFE39D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{83105892-317C-4442-B064-E489D2CFE39D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{83105892-317C-4442-B064-E489D2CFE39D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{21F2683A-8624-4C9B-A765-2E7CCA8D8BBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{21F2683A-8624-4C9B-A765-2E7CCA8D8BBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{21F2683A-8624-4C9B-A765-2E7CCA8D8BBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{21F2683A-8624-4C9B-A765-2E7CCA8D8BBD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{586FCB30-AC9A-4229-B7F7-3FB2ADF581B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{586FCB30-AC9A-4229-B7F7-3FB2ADF581B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{586FCB30-AC9A-4229-B7F7-3FB2ADF581B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{586FCB30-AC9A-4229-B7F7-3FB2ADF581B6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
64
COP/PluginsConventionLibrary/IPluginsConvention.cs
Normal file
64
COP/PluginsConventionLibrary/IPluginsConvention.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PluginsConventionLibrary
|
||||||
|
{
|
||||||
|
public interface IPluginsConvention
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Название плагина
|
||||||
|
/// </summary>
|
||||||
|
string PluginName { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Получение контрола для вывода набора данных
|
||||||
|
/// </summary>
|
||||||
|
UserControl GetControl { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Получение элемента, выбранного в контроле
|
||||||
|
/// </summary>
|
||||||
|
PluginsConventionElement GetElement { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Получение формы для создания/редактирования объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="element"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Form GetForm(PluginsConventionElement element);
|
||||||
|
/// <summary>
|
||||||
|
/// Получение формы для работы со справочником
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Form GetThesaurus();
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление элемента
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="element"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool DeleteElement(PluginsConventionElement element);
|
||||||
|
/// <summary>
|
||||||
|
/// Обновление набора данных в контроле
|
||||||
|
/// </summary>
|
||||||
|
void ReloadData();
|
||||||
|
/// <summary>
|
||||||
|
/// Создание простого документа
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="saveDocument"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool CreateSimpleDocument(PluginsConventionSaveDocument
|
||||||
|
saveDocument);
|
||||||
|
/// <summary>
|
||||||
|
/// Создание простого документа
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="saveDocument"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
|
||||||
|
/// <summary>
|
||||||
|
/// Создание документа с диаграммой
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="saveDocument"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
|
||||||
|
}
|
||||||
|
}
|
13
COP/PluginsConventionLibrary/PluginsConventionElement.cs
Normal file
13
COP/PluginsConventionLibrary/PluginsConventionElement.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PluginsConventionLibrary
|
||||||
|
{
|
||||||
|
public class PluginsConventionElement
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
10
COP/PluginsConventionLibrary/PluginsConventionLibrary.csproj
Normal file
10
COP/PluginsConventionLibrary/PluginsConventionLibrary.csproj
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PluginsConventionLibrary
|
||||||
|
{
|
||||||
|
public class PluginsConventionSaveDocument
|
||||||
|
{
|
||||||
|
public string FileName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
200
COP/WinForms/PluginsConvention.cs
Normal file
200
COP/WinForms/PluginsConvention.cs
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
using ChubykinaComponents.Components;
|
||||||
|
using ChubykinaComponents.LogicalComponents;
|
||||||
|
using BulatovaComponents.NonVisualComponents;
|
||||||
|
using ComponentsLibraryNet60.DocumentWithChart;
|
||||||
|
using ComponentsLibraryNet60.DocumentWithTable;
|
||||||
|
using ComponentsLibraryNet60.Models;
|
||||||
|
using ControlsLibraryNet60.Data;
|
||||||
|
using ControlsLibraryNet60.Models;
|
||||||
|
using PluginsConventionLibrary;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using ClientsContracts.BusinessLogicContracts;
|
||||||
|
using ClientsContracts.ViewModels;
|
||||||
|
using ClientBusinessLogic.BusinessLogics;
|
||||||
|
using ClientsDatabaseImplement.Implements;
|
||||||
|
|
||||||
|
namespace WinForms
|
||||||
|
{
|
||||||
|
public class PluginsConvention : IPluginsConvention
|
||||||
|
{
|
||||||
|
private readonly IClientLogic _clientLogic;
|
||||||
|
private readonly IStatusLogic _statusLogic;
|
||||||
|
private readonly UserTreeView _myTreeView;
|
||||||
|
private readonly WordLongTextComponent wordLongTextComponent;
|
||||||
|
private readonly ExcelDiagramComponent excelDiagramComponent;
|
||||||
|
private readonly ComponentDocumentWithTableMultiHeaderPdf componentDocumentWithTableMultiHeaderPdf;
|
||||||
|
public string PluginName { get; set; } = "LabWork_03_plugin";
|
||||||
|
|
||||||
|
public UserControl GetControl
|
||||||
|
{
|
||||||
|
get { return _myTreeView; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public PluginsConvention()
|
||||||
|
{
|
||||||
|
_clientLogic = new ClientLogic(new ClientStorage());
|
||||||
|
_statusLogic = new StatusLogic(new StatusStorage());
|
||||||
|
wordLongTextComponent = new();
|
||||||
|
excelDiagramComponent = new();
|
||||||
|
componentDocumentWithTableMultiHeaderPdf = new();
|
||||||
|
_myTreeView = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PluginsConventionElement GetElement
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int Id = _myTreeView.getSelecetedNodeValue<ClientViewModel>()!.Id;
|
||||||
|
byte[] bytes = new byte[16];
|
||||||
|
BitConverter.GetBytes(Id).CopyTo(bytes, 0);
|
||||||
|
Guid guid = new Guid(bytes);
|
||||||
|
return new PluginsConventionElement() { Id = guid };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Form GetForm(PluginsConventionElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return new FormClient(_clientLogic, _statusLogic);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FormClient form = new FormClient(_clientLogic, _statusLogic);
|
||||||
|
form.Id = element.Id.GetHashCode();
|
||||||
|
return form;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Form GetThesaurus()
|
||||||
|
{
|
||||||
|
return new FormStatus(_statusLogic);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeleteElement(PluginsConventionElement element)
|
||||||
|
{
|
||||||
|
_clientLogic.Delete(
|
||||||
|
new ClientsContracts.BindingModels.ClientBindingModel { Id = element.Id.GetHashCode() }
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReloadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var clients = _clientLogic.ReadList(null);
|
||||||
|
if (clients != null)
|
||||||
|
{
|
||||||
|
_myTreeView.clear();
|
||||||
|
|
||||||
|
_myTreeView.setHierarchy(new List<(string, bool)> { ("StatusName", false), ("ViewAmount", false), ("Id", true), ("Name", true) });
|
||||||
|
|
||||||
|
foreach (var client in clients)
|
||||||
|
{
|
||||||
|
if (!client.Amount.HasValue)
|
||||||
|
{
|
||||||
|
client.ViewAmount = "нет покупок";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.ViewAmount = client.Amount.Value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_myTreeView.addItems(clients);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
ex.Message,
|
||||||
|
"Ошибка",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
|
||||||
|
{
|
||||||
|
List<string> paragraphs = new List<string>();
|
||||||
|
foreach (var client in _clientLogic.ReadList(null))
|
||||||
|
{
|
||||||
|
if (client.Amount == null)
|
||||||
|
{
|
||||||
|
paragraphs.Add(client.Name + ": " + client.Reviews);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string path = saveDocument.FileName;
|
||||||
|
wordLongTextComponent.createWithLongText(new WordLongTextInfo(path, "Аккаунты без суммы покупок", paragraphs.ToArray()));
|
||||||
|
MessageBox.Show("Документ создан");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
|
||||||
|
{
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
List<string> paragraphs = new List<string>();
|
||||||
|
string path = saveDocument.FileName;
|
||||||
|
var clients = _clientLogic.ReadList(null);
|
||||||
|
foreach (var client in clients)
|
||||||
|
{
|
||||||
|
if (!client.Amount.HasValue)
|
||||||
|
{
|
||||||
|
client.DocAmount = "нет";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.DocAmount = client.Amount.Value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ComponentDocumentWithTableHeaderDataConfig<ClientViewModel> config = new ComponentsLibraryNet60.Models.ComponentDocumentWithTableHeaderDataConfig<ClientViewModel>
|
||||||
|
{
|
||||||
|
Data = clients,
|
||||||
|
UseUnion = false,
|
||||||
|
Header = "Аккаунты",
|
||||||
|
ColumnsRowsDataCount = (4, 1),
|
||||||
|
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
||||||
|
{
|
||||||
|
(0, 0, "Id", "Id"),
|
||||||
|
(1, 0, "ФИО", "Name"),
|
||||||
|
(2, 0, "Статус", "StatusName"),
|
||||||
|
(3, 0, "Сумма покупок", "DocAmount")
|
||||||
|
},
|
||||||
|
ColumnsRowsWidth = new List<(int Column, int Row)>
|
||||||
|
{
|
||||||
|
(10, 10),
|
||||||
|
(10, 10),
|
||||||
|
(10, 10),
|
||||||
|
(10, 10)
|
||||||
|
},
|
||||||
|
ColumnUnion = new List<(int StartIndex, int Count)>(),
|
||||||
|
FilePath = path
|
||||||
|
};
|
||||||
|
componentDocumentWithTableMultiHeaderPdf.CreateDoc(config);
|
||||||
|
MessageBox.Show("Документ создан");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
|
||||||
|
{
|
||||||
|
List<string> paragraphs = new List<string>();
|
||||||
|
string path = saveDocument.FileName;
|
||||||
|
var data = _clientLogic.ReadList(null).Where(x => x.Amount == null).GroupBy(x => x.StatusName).Select(x => new
|
||||||
|
{
|
||||||
|
StatusName = x.Key,
|
||||||
|
StatusCount = x.Count(),
|
||||||
|
}).ToList();
|
||||||
|
excelDiagramComponent.createWithDiagram(path, "Статус без суммы покупок", "Статус без суммы покупок", ChubykinaComponents.LogicalComponents.DiagramLegendEnum.BottomRight,
|
||||||
|
data, "StatusName", "StatusCount");
|
||||||
|
MessageBox.Show("Документ создан");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,10 +19,19 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="CreatePluginsFolder" BeforeTargets="PreBuildEvent" Condition="!Exists('$(SolutionDir)Plugins')">
|
||||||
|
<MakeDir Directories="$(SolutionDir)Plugins" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="CopyPlugins" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)Plugins\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\BulatovaComponents\BulatovaComponents.csproj" />
|
<ProjectReference Include="..\BulatovaComponents\BulatovaComponents.csproj" />
|
||||||
<ProjectReference Include="..\ClientBusinessLogic\ClientBusinessLogic.csproj" />
|
<ProjectReference Include="..\ClientBusinessLogic\ClientBusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\ClientsDatabaseImplement\ClientsDatabaseImplement.csproj" />
|
<ProjectReference Include="..\ClientsDatabaseImplement\ClientsDatabaseImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user