Mochalov D.V. LabWork08_Hard #16

Closed
b0n3l3sS wants to merge 15 commits from LabWork08_Hard into LabWork07_Hard
61 changed files with 1553 additions and 744 deletions

3
.gitignore vendored
View File

@ -14,6 +14,9 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# dll files
*.dll
# Mono auto generated files
mono_crash.*

View File

@ -0,0 +1,51 @@
using LawFirmContracts.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmView
{
public static class DataGridViewExtension
{
public static void FillAndConfigGrid<T>(this DataGridView grid, List<T>? data)
{
if (data == null)
{
return;
}
grid.DataSource = data;
var type = typeof(T);
var properties = type.GetProperties();
foreach (DataGridViewColumn column in grid.Columns)
{
var property = properties.FirstOrDefault(x => x.Name == column.Name);
if (property == null)
{
throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем { column.Name }");
}
var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault();
if (attribute == null)
{
throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства { property.Name }");
}
// ищем нужный нам атрибут
if (attribute is ColumnAttribute columnAttr)
{
column.DefaultCellStyle.Format = columnAttr.Format;
column.HeaderText = columnAttr.Title;
column.Visible = columnAttr.Visible;
if (columnAttr.IsUseAutoSize)
{
column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString());
}
else
{
column.Width = columnAttr.Width;
}
}
}
}
}
}

View File

@ -1,6 +1,8 @@
using LawFirm;
using LawFirmBusinessLogic.BusinessLogics;
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.DI;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@ -34,13 +36,7 @@ namespace LawFirmView
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["BlankName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка бланков");
}
catch (Exception ex)
@ -52,8 +48,8 @@ namespace LawFirmView
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormBlank));
if (service is FormBlank form)
var form = DependencyManager.Instance.Resolve<FormBlank>();
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ShowDialog() == DialogResult.OK)
{
@ -65,14 +61,12 @@ namespace LawFirmView
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormBlank));
if (service is FormBlank form)
var form = DependencyManager.Instance.Resolve<FormBlank>();
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}

View File

@ -33,13 +33,7 @@ namespace LawFirmView
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка клиентов");
}
catch (Exception ex)

View File

@ -1,6 +1,7 @@
using LawFirm;
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.DI;
using LawFirmContracts.SearchModels;
using LawFirmDataModels.Models;
using Microsoft.Extensions.Logging;
@ -99,26 +100,23 @@ namespace LawFirmView
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDocumentBlank));
if (service is FormDocumentBlank form)
var form = DependencyManager.Instance.Resolve<FormDocumentBlank>();
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ShowDialog() == DialogResult.OK)
if (form.BlankModel == null)
{
if (form.BlankModel == null)
{
return;
}
_logger.LogInformation("Добавление нового бланка:{ BlankName}- { Count}", form.BlankModel.BlankName, form.Count);
if (_documentBlanks.ContainsKey(form.Id))
{
_documentBlanks[form.Id] = (form.BlankModel,form.Count);
}
else
{
_documentBlanks.Add(form.Id, (form.BlankModel,form.Count));
}
LoadData();
return;
}
_logger.LogInformation("Добавление нового бланка: { BlankName}-{Count}", form.BlankModel.BlankName, form.Count);
if (_documentBlanks.ContainsKey(form.Id))
{
_documentBlanks[form.Id] = (form.BlankModel, form.Count);
}
else
{
_documentBlanks.Add(form.Id, (form.BlankModel, form.Count));
}
LoadData();
}
}
@ -126,22 +124,21 @@ namespace LawFirmView
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDocumentBlank));
if (service is FormDocumentBlank form)
var form = DependencyManager.Instance.Resolve<FormDocumentBlank>();
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id;
form.Count = _documentBlanks[id].Item2;
if (form.ShowDialog() == DialogResult.OK)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id;
form.Count = _documentBlanks[id].Item2;
if (form.ShowDialog() == DialogResult.OK)
if (form.BlankModel == null)
{
if (form.BlankModel == null)
{
return;
}
_logger.LogInformation("Изменение бланка:{ BlankName}- { Count}", form.BlankModel.BlankName, form.Count);
_documentBlanks[form.Id] = (form.BlankModel,form.Count);
LoadData();
return;
}
_logger.LogInformation("Изменение бланка:{ BlankName}- { Count}", form.BlankModel.BlankName, form.Count);
_documentBlanks[form.Id] = (form.BlankModel,form.Count);
LoadData();
}
}
}

View File

@ -1,6 +1,7 @@
using LawFirm;
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.DI;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@ -33,14 +34,7 @@ namespace LawFirmView
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["DocumentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["DocumentBlanks"].Visible = false;
}
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка документов");
}
catch (Exception ex)
@ -52,13 +46,10 @@ namespace LawFirmView
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDocument));
if (service is FormDocument form)
var form = DependencyManager.Instance.Resolve<FormDocument>();
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
LoadData();
}
}
@ -66,14 +57,11 @@ namespace LawFirmView
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDocument));
if (service is FormDocument form)
var form = DependencyManager.Instance.Resolve<FormDocument>();
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
LoadData();
}
}
}

View File

@ -1,6 +1,7 @@
using LawFirm;
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.DI;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@ -33,32 +34,22 @@ namespace LawFirmView
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка исполнителей");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки исполнителей");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCreate_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (service is FormImplementer form)
var form = DependencyManager.Instance.Resolve<FormImplementer>();
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
LoadData();
}
}
@ -66,14 +57,11 @@ namespace LawFirmView
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (service is FormImplementer form)
var form = DependencyManager.Instance.Resolve<FormImplementer>();
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
LoadData();
}
}
}

View File

@ -1,5 +1,6 @@
using LawFirm;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.DI;
using LawFirmContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
@ -38,18 +39,13 @@ namespace LawFirmView
{
try
{
var list = _logic.ReadList(new()
dataGridView.FillAndConfigGrid(_logic.ReadList(new()
{
Page = currentPage,
PageSize = pageSize,
});
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["MessageId"].Visible = false;
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}));
_logger.LogInformation("Загрузка писем");
_logger.LogInformation("Загрузка писем");
labelPage.Text = $"Страница: {currentPage}";
return true;
@ -99,13 +95,10 @@ namespace LawFirmView
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormMail));
if (service is FormMail form)
{
form.MessageId = (string)(dataGridView.SelectedRows[0].Cells["MessageId"].Value);
form.ShowDialog();
LoadMail();
}
var form = DependencyManager.Instance.Resolve<FormMail>();
form.MessageId = (string)(dataGridView.SelectedRows[0].Cells["MessageId"].Value);
form.ShowDialog();
LoadMail();
}
}
}

View File

@ -1,279 +1,297 @@
namespace LawFirmView
{
partial class FormMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
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);
}
/// <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
#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();
справочники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();
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
письмаToolStripMenuItem = new ToolStripMenuItem();
списокМагазиновToolStripMenuItem = new ToolStripMenuItem();
документыВМагазинахToolStripMenuItem = new ToolStripMenuItem();
списокЗаказовПоДатеToolStripMenuItem = new ToolStripMenuItem();
запускРаботыToolStripMenuItem = new ToolStripMenuItem();
dataGridView = new DataGridView();
buttonCreateOrder = new Button();
buttonSetToFinish = new Button();
buttonUpdate = new Button();
письмаToolStripMenuItem = new ToolStripMenuItem();
buttonSupplyShop = new Button();
buttonSellDocuments = new Button();
menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem, запускРаботыToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(1139, 28);
menuStrip.TabIndex = 0;
menuStrip.Text = "Справочники";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { бланкиToolStripMenuItem, документыToolStripMenuItem, клиентыToolStripMenuItem, магазиныToolStripMenuItem, исполнителиToolStripMenuItem, письмаToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
//
// бланкиToolStripMenuItem
//
бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem";
бланкиToolStripMenuItem.Size = new Size(224, 26);
бланкиToolStripMenuItem.Text = "Бланки";
бланкиToolStripMenuItem.Click += бланкиToolStripMenuItem_Click;
//
// документыToolStripMenuItem
//
документыToolStripMenuItem.Name = окументыToolStripMenuItem";
документыToolStripMenuItem.Size = new Size(224, 26);
документыToolStripMenuItem.Text = "Документы";
документыToolStripMenuItem.Click += документыToolStripMenuItem_Click;
//
// клиентыToolStripMenuItem
//
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
клиентыToolStripMenuItem.Size = new Size(224, 26);
клиентыToolStripMenuItem.Text = "Клиенты";
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
//
// магазиныToolStripMenuItem
//
магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem";
магазиныToolStripMenuItem.Size = new Size(224, 26);
магазиныToolStripMenuItem.Text = "Магазины";
магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click;
//
// исполнителиToolStripMenuItem
//
исполнителиToolStripMenuItem.Name = сполнителиToolStripMenuItem";
исполнителиToolStripMenuItem.Size = new Size(224, 26);
исполнителиToolStripMenuItem.Text = "Исполнители";
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокДокументовToolStripMenuItem, бланкиПоДокументамToolStripMenuItem, списокЗаказовToolStripMenuItem, списокМагазиновToolStripMenuItem, документыВМагазинахToolStripMenuItem, списокЗаказовПоДатеToolStripMenuItem });
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(73, 24);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// списокДокументовToolStripMenuItem
//
списокДокументовToolStripMenuItem.Name = "списокДокументовToolStripMenuItem";
списокДокументовToolStripMenuItem.Size = new Size(259, 26);
списокДокументовToolStripMenuItem.Text = "Список документов";
списокДокументовToolStripMenuItem.Click += списокДокументовToolStripMenuItem_Click;
//
// бланкиПоДокументамToolStripMenuItem
//
бланкиПоДокументамToolStripMenuItem.Name = "бланкиПоДокументамToolStripMenuItem";
бланкиПоДокументамToolStripMenuItem.Size = new Size(259, 26);
бланкиПоДокументамToolStripMenuItem.Text = "Бланки по документам";
бланкиПоДокументамToolStripMenuItem.Click += бланкиПоДокументамToolStripMenuItem_Click;
//
// списокЗаказовToolStripMenuItem
//
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
списокЗаказовToolStripMenuItem.Size = new Size(259, 26);
списокЗаказовToolStripMenuItem.Text = "Список заказов";
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
//
// списокМагазиновToolStripMenuItem
//
списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
списокМагазиновToolStripMenuItem.Size = new Size(259, 26);
списокМагазиновToolStripMenuItem.Text = "Список магазинов";
списокМагазиновToolStripMenuItem.Click += списокМагазиновToolStripMenuItem_Click;
//
// документыВМагазинахToolStripMenuItem
//
документыВМагазинахToolStripMenuItem.Name = окументыВМагазинахToolStripMenuItem";
документыВМагазинахToolStripMenuItem.Size = new Size(259, 26);
документыВМагазинахToolStripMenuItem.Text = "Документы в магазинах";
документыВМагазинахToolStripMenuItem.Click += документыВМагазинахToolStripMenuItem_Click;
//
// списокЗаказовПоДатеToolStripMenuItem
//
списокЗаказовПоДатеToolStripMenuItem.Name = "списокЗаказовПоДатеToolStripMenuItem";
списокЗаказовПоДатеToolStripMenuItem.Size = new Size(259, 26);
списокЗаказовПоДатеToolStripMenuItem.Text = "Список заказов по дате";
списокЗаказовПоДатеToolStripMenuItem.Click += списокЗаказовПоДатеToolStripMenuItem_Click;
//
// запускРаботыToolStripMenuItem
//
запускРаботыToolStripMenuItem.Name = апускРаботыToolStripMenuItem";
запускРаботыToolStripMenuItem.Size = new Size(125, 24);
запускРаботыToolStripMenuItem.Text = "Запуск работы";
запускРаботыToolStripMenuItem.Click += запускРаботыToolStripMenuItem_Click;
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 31);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(915, 407);
dataGridView.TabIndex = 1;
//
// buttonCreateOrder
//
buttonCreateOrder.Location = new Point(933, 45);
buttonCreateOrder.Name = "buttonCreateOrder";
buttonCreateOrder.Size = new Size(194, 29);
buttonCreateOrder.TabIndex = 2;
buttonCreateOrder.Text = "Создать заказ";
buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.Click += buttonCreateOrder_Click;
//
// buttonSetToFinish
//
buttonSetToFinish.Location = new Point(933, 80);
buttonSetToFinish.Name = "buttonSetToFinish";
buttonSetToFinish.Size = new Size(194, 29);
buttonSetToFinish.TabIndex = 5;
buttonSetToFinish.Text = "Заказ выдан";
buttonSetToFinish.UseVisualStyleBackColor = true;
buttonSetToFinish.Click += buttonSetToFinish_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(933, 410);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(194, 29);
buttonUpdate.TabIndex = 6;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += buttonUpdate_Click;
//
// письмаToolStripMenuItem
//
письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
письмаToolStripMenuItem.Size = new Size(224, 26);
письмаToolStripMenuItem.Text = "Письма";
письмаToolStripMenuItem.Click += письмаToolStripMenuItem_Click;
//
buttonSupplyShop.Location = new Point(933, 115);
buttonSupplyShop.Name = "buttonSupplyShop";
buttonSupplyShop.Size = new Size(194, 29);
buttonSupplyShop.TabIndex = 7;
buttonSupplyShop.Text = "Пополнение магазина";
buttonSupplyShop.UseVisualStyleBackColor = true;
buttonSupplyShop.Click += buttonSupplyShop_Click;
//
// buttonSellDocuments
//
buttonSellDocuments.Location = new Point(933, 150);
buttonSellDocuments.Name = "buttonSellDocuments";
buttonSellDocuments.Size = new Size(194, 29);
buttonSellDocuments.TabIndex = 8;
buttonSellDocuments.Text = "Продажа документов";
buttonSellDocuments.UseVisualStyleBackColor = true;
buttonSellDocuments.Click += buttonSellDocuments_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1139, 450);
Controls.Add(buttonSellDocuments);
Controls.Add(buttonSupplyShop);
Controls.Add(buttonUpdate);
Controls.Add(buttonSetToFinish);
Controls.Add(buttonCreateOrder);
Controls.Add(dataGridView);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormMain";
Text = "Юридическая компания";
Load += FormMain_Load;
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
}
/// <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();
справочники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();
бланкиПоДокументамToolStripMenuItem = new ToolStripMenuItem();
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
#endregion
списокМагазиновToolStripMenuItem = new ToolStripMenuItem();
документыВМагазинахToolStripMenuItem = new ToolStripMenuItem();
списокЗаказовПоДатеToolStripMenuItem = new ToolStripMenuItem();
запускРаботыToolStripMenuItem = new ToolStripMenuItem();
private MenuStrip menuStrip;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem бланкиToolStripMenuItem;
private ToolStripMenuItem документыToolStripMenuItem;
private DataGridView dataGridView;
private Button buttonCreateOrder;
private Button buttonSetToFinish;
private Button buttonUpdate;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem списокДокументовToolStripMenuItem;
private ToolStripMenuItem бланкиПоДокументамToolStripMenuItem;
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
private ToolStripMenuItem магазиныToolStripMenuItem;
private Button buttonSupplyShop;
private Button buttonSellDocuments;
private ToolStripMenuItem списокМагазиновToolStripMenuItem;
private ToolStripMenuItem документыВМагазинахToolStripMenuItem;
private ToolStripMenuItem списокЗаказовПоДатеToolStripMenuItem;
private ToolStripMenuItem клиентыToolStripMenuItem;
private ToolStripMenuItem исполнителиToolStripMenuItem;
private ToolStripMenuItem запускРаботыToolStripMenuItem;
private ToolStripMenuItem письмаToolStripMenuItem;
}
dataGridView = new DataGridView();
buttonCreateOrder = new Button();
buttonSetToFinish = new Button();
buttonUpdate = new Button();
buttonSupplyShop = new Button();
buttonSellDocuments = new Button();
создатьБэкапToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem, запускРаботыToolStripMenuItem, создатьБэкапToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(1139, 28);
menuStrip.TabIndex = 0;
menuStrip.Text = "Справочники";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { бланкиToolStripMenuItem, документыToolStripMenuItem, клиентыToolStripMenuItem, исполнителиToolStripMenuItem, письмаToolStripMenuItem, магазиныToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
//
// бланкиToolStripMenuItem
//
бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem";
бланкиToolStripMenuItem.Size = new Size(185, 26);
бланкиToolStripMenuItem.Text = "Бланки";
бланкиToolStripMenuItem.Click += бланкиToolStripMenuItem_Click;
//
// документыToolStripMenuItem
//
документыToolStripMenuItem.Name = окументыToolStripMenuItem";
документыToolStripMenuItem.Size = new Size(185, 26);
документыToolStripMenuItem.Text = "Документы";
документыToolStripMenuItem.Click += документыToolStripMenuItem_Click;
//
// клиентыToolStripMenuItem
//
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
клиентыToolStripMenuItem.Size = new Size(185, 26);
клиентыToolStripMenuItem.Text = "Клиенты";
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
//
// магазиныToolStripMenuItem
//
магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem";
магазиныToolStripMenuItem.Size = new Size(224, 26);
магазиныToolStripMenuItem.Text = "Магазины";
магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click;
//
// исполнителиToolStripMenuItem
//
исполнителиToolStripMenuItem.Name = сполнителиToolStripMenuItem";
исполнителиToolStripMenuItem.Size = new Size(185, 26);
исполнителиToolStripMenuItem.Text = "Исполнители";
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
//
// письмаToolStripMenuItem
//
письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
письмаToolStripMenuItem.Size = new Size(185, 26);
письмаToolStripMenuItem.Text = "Письма";
письмаToolStripMenuItem.Click += письмаToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокДокументовToolStripMenuItem, бланкиПоДокументамToolStripMenuItem, списокЗаказовToolStripMenuItem, списокМагазиновToolStripMenuItem, списокЗаказовПоДатеToolStripMenuItem, документыВМагазинахToolStripMenuItem });
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(73, 24);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// списокДокументовToolStripMenuItem
//
списокДокументовToolStripMenuItem.Name = "списокДокументовToolStripMenuItem";
списокДокументовToolStripMenuItem.Size = new Size(252, 26);
списокДокументовToolStripMenuItem.Text = "Список документов";
списокДокументовToolStripMenuItem.Click += списокДокументовToolStripMenuItem_Click;
//
// бланкиПоДокументамToolStripMenuItem
//
бланкиПоДокументамToolStripMenuItem.Name = "бланкиПоДокументамToolStripMenuItem";
бланкиПоДокументамToolStripMenuItem.Size = new Size(252, 26);
бланкиПоДокументамToolStripMenuItem.Text = "Бланки по документам";
бланкиПоДокументамToolStripMenuItem.Click += бланкиПоДокументамToolStripMenuItem_Click;
//
// списокЗаказовToolStripMenuItem
//
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
списокЗаказовToolStripMenuItem.Size = new Size(252, 26);
списокЗаказовToolStripMenuItem.Text = "Список заказов";
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;// списокМагазиновToolStripMenuItem
//
списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
списокМагазиновToolStripMenuItem.Size = new Size(259, 26);
списокМагазиновToolStripMenuItem.Text = "Список магазинов";
списокМагазиновToolStripMenuItem.Click += списокМагазиновToolStripMenuItem_Click;
//
// документыВМагазинахToolStripMenuItem
//
документыВМагазинахToolStripMenuItem.Name = окументыВМагазинахToolStripMenuItem";
документыВМагазинахToolStripMenuItem.Size = new Size(259, 26);
документыВМагазинахToolStripMenuItem.Text = "Документы в магазинах";
документыВМагазинахToolStripMenuItem.Click += документыВМагазинахToolStripMenuItem_Click;
//
// списокЗаказовПоДатеToolStripMenuItem
//
списокЗаказовПоДатеToolStripMenuItem.Name = "списокЗаказовПоДатеToolStripMenuItem";
списокЗаказовПоДатеToolStripMenuItem.Size = new Size(259, 26);
списокЗаказовПоДатеToolStripMenuItem.Text = "Список заказов по дате";
списокЗаказовПоДатеToolStripMenuItem.Click += списокЗаказовПоДатеToolStripMenuItem_Click;
//
// запускРаботыToolStripMenuItem
//
запускРаботыToolStripMenuItem.Name = апускРаботыToolStripMenuItem";
запускРаботыToolStripMenuItem.Size = new Size(125, 24);
запускРаботыToolStripMenuItem.Text = "Запуск работы";
запускРаботыToolStripMenuItem.Click += запускРаботыToolStripMenuItem_Click;
//
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 31);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(915, 407);
dataGridView.TabIndex = 1;
//
// buttonCreateOrder
//
buttonCreateOrder.Location = new Point(933, 45);
buttonCreateOrder.Name = "buttonCreateOrder";
buttonCreateOrder.Size = new Size(194, 29);
buttonCreateOrder.TabIndex = 2;
buttonCreateOrder.Text = "Создать заказ";
buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.Click += buttonCreateOrder_Click;
//
// buttonSetToFinish
//
buttonSetToFinish.Location = new Point(933, 80);
buttonSetToFinish.Name = "buttonSetToFinish";
buttonSetToFinish.Size = new Size(194, 29);
buttonSetToFinish.TabIndex = 5;
buttonSetToFinish.Text = "Заказ выдан";
buttonSetToFinish.UseVisualStyleBackColor = true;
buttonSetToFinish.Click += buttonSetToFinish_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(933, 410);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(194, 29);
buttonUpdate.TabIndex = 6;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += buttonUpdate_Click;
//
// создатьБэкапToolStripMenuItem
//
создатьБэкапToolStripMenuItem.Name = "создатьБэкапToolStripMenuItem";
создатьБэкапToolStripMenuItem.Size = new Size(122, 24);
создатьБэкапToolStripMenuItem.Text = "Создать бэкап";
создатьБэкапToolStripMenuItem.Click += создатьБэкапToolStripMenuItem_Click;
buttonSupplyShop.Location = new Point(933, 115);
buttonSupplyShop.Name = "buttonSupplyShop";
buttonSupplyShop.Size = new Size(194, 29);
buttonSupplyShop.TabIndex = 7;
buttonSupplyShop.Text = "Пополнение магазина";
buttonSupplyShop.UseVisualStyleBackColor = true;
buttonSupplyShop.Click += buttonSupplyShop_Click;
//
// buttonSellDocuments
//
buttonSellDocuments.Location = new Point(933, 150);
buttonSellDocuments.Name = "buttonSellDocuments";
buttonSellDocuments.Size = new Size(194, 29);
buttonSellDocuments.TabIndex = 8;
buttonSellDocuments.Text = "Продажа документов";
buttonSellDocuments.UseVisualStyleBackColor = true;
buttonSellDocuments.Click += buttonSellDocuments_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1139, 450);
Controls.Add(buttonUpdate);
Controls.Add(buttonSetToFinish);
Controls.Add(buttonCreateOrder);
Controls.Add(buttonSellDocuments);
Controls.Add(buttonSupplyShop);
Controls.Add(dataGridView);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormMain";
Text = "Юридическая компания";
Load += FormMain_Load;
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem бланкиToolStripMenuItem;
private ToolStripMenuItem документыToolStripMenuItem;
private DataGridView dataGridView;
private Button buttonCreateOrder;
private Button buttonSetToFinish;
private Button buttonUpdate;
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 ToolStripMenuItem магазиныToolStripMenuItem;
private Button buttonSupplyShop;
private Button buttonSellDocuments;
private ToolStripMenuItem списокМагазиновToolStripMenuItem;
private ToolStripMenuItem документыВМагазинахToolStripMenuItem;
private ToolStripMenuItem списокЗаказовПоДатеToolStripMenuItem;
}
}

View File

@ -2,6 +2,7 @@
using LawFirmBusinessLogic.BusinessLogics;
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.DI;
using LawFirmDataModels.Enums;
using Microsoft.Extensions.Logging;
using System;
@ -17,114 +18,91 @@ using System.Windows.Forms;
namespace LawFirmView
{
public partial class FormMain : Form
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic;
private readonly IWorkProcess _workProcess;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
_reportLogic = reportLogic;
_workProcess = workProcess;
}
public partial class FormMain : Form
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic;
private readonly IWorkProcess _workProcess;
private readonly IBackUpLogic _backUpLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
_reportLogic = reportLogic;
_workProcess = workProcess;
_backUpLogic = backUpLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
_logger.LogInformation("Загрузка заказов");
try
{
var list = _orderLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["DocumentId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["ImplementerId"].Visible = false;
}
_logger.LogInformation("Загрузка заказов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
_logger.LogInformation("Загрузка заказов");
try
{
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
_logger.LogInformation("Загрузка заказов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void бланкиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormBlanks));
if (service is FormBlanks form)
{
form.ShowDialog();
}
}
private void бланкиToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormBlanks>();
form.ShowDialog();
}
private void документыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDocuments));
if (service is FormDocuments form)
{
form.ShowDialog();
}
}
private void документыToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormDocuments>();
form.ShowDialog();
}
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
}
}
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormClients>();
form.ShowDialog();
}
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
if (service is FormImplementers form)
{
form.ShowDialog();
}
}
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormImplementers>();
form.ShowDialog();
}
private void бланкиПоДокументамToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks));
if (service is FormReportDocumentBlanks form)
{
form.ShowDialog();
}
}
private void бланкиПоДокументамToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormReportDocumentBlanks>();
form.ShowDialog();
}
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrder));
if (service is FormReportOrder form)
{
form.ShowDialog();
}
}
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormReportOrder>();
form.ShowDialog();
}
private void списокДокументовToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SaveDocumentsToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void списокДокументовToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SaveDocumentsToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void списокМагазиновToolStripMenuItem_Click(object sender, EventArgs e)
{
@ -141,104 +119,105 @@ namespace LawFirmView
private void документыВМагазинахToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportShopDocuments));
if (service is FormReportShopDocuments form)
{
form.ShowDialog();
}
}
var form = DependencyManager.Instance.Resolve<FormReportShopDocuments>();
form.ShowDialog();
}
private void списокЗаказовПоДатеToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportDateOrders));
if (service is FormReportDateOrders form)
{
form.ShowDialog();
}
}
var form = DependencyManager.Instance.Resolve<FormReportDateOrders>();
form.ShowDialog();
}
private void магазиныToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
if (service is FormShops form)
{
form.ShowDialog();
}
}
var form = DependencyManager.Instance.Resolve<FormShops>();
form.ShowDialog();
}
private void buttonCreateOrder_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
form.ShowDialog();
LoadData();
}
private void buttonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form)
{
form.ShowDialog();
LoadData();
}
}
private void buttonSetToFinish_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try
{
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
{
Id = id,
});
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
_logger.LogInformation("Заказ №{id} выдан", id);
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonSetToFinish_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try
{
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
{
Id = id
});
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
_logger.LogInformation("Заказ №{id} выдан", id);
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void buttonSupplyShop_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShopSupply));
if (service is FormShopSupply form)
{
form.ShowDialog();
}
}
var form = DependencyManager.Instance.Resolve<FormShopSupply>();
form.ShowDialog();
}
private void buttonSellDocuments_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShopSell));
if (service is FormShopSell form)
{
form.ShowDialog();
}
}
var form = DependencyManager.Instance.Resolve<FormShopSell>();
form.ShowDialog();
}
private void запускРаботыToolStripMenuItem_Click(object sender, EventArgs e)
{
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void письмаToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormMails));
if (service is FormMails form)
{
form.ShowDialog();
}
}
}
private void письмаToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormMails>();
form.ShowDialog();
}
private void создатьБэкапToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
if (_backUpLogic != null)
{
var fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
_backUpLogic.CreateBackUp(new BackUpSaveBinidngModel
{
FolderName = fbd.SelectedPath
});
MessageBox.Show("Бекап создан", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -1,6 +1,7 @@
using LawFirm;
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.DI;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@ -35,16 +36,7 @@ namespace LawFirmView
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ShopDocuments"].Visible = false;
}
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка магазинов");
}
@ -62,22 +54,19 @@ namespace LawFirmView
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
if (service is FormShop form)
var form = DependencyManager.Instance.Resolve<FormShop>();
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
LoadData();
}
}
private void buttonEdit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
var service = DependencyManager.Instance.Resolve<FormShop>();
if (service is FormShop form)
{

View File

@ -4,6 +4,7 @@ using LawFirmBusinessLogic.OfficePackage;
using LawFirmBusinessLogic.OfficePackage.Implements;
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.DI;
using LawFirmContracts.StorageContracts;
using LawFirmDatabaseImplement.Implements;
using LawFirmView;
@ -16,8 +17,6 @@ namespace LawFirm
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
@ -28,14 +27,12 @@ namespace LawFirm
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
InitDependency();
try
try
{
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
mailSender?.MailConfig(new MailConfigBindingModel
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
mailSender?.MailConfig(new MailConfigBindingModel
{
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
@ -49,67 +46,46 @@ namespace LawFirm
}
catch (Exception ex)
{
var logger = _serviceProvider.GetService<ILogger>();
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
var logger = DependencyManager.Instance.Resolve<ILogger>();
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
}
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
}
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
private static void ConfigureServices(ServiceCollection services)
private static void InitDependency()
{
services.AddLogging(option =>
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IBlankStorage, BlankStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IDocumentStorage, DocumentStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IImplementerStorage, ImplementerStorage>();
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
services.AddTransient<IShopStorage, ShopStorage>();
services.AddTransient<IBlankLogic, BlankLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IDocumentLogic, DocumentLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IImplementerLogic, ImplementerLogic>();
services.AddTransient<IWorkProcess, WorkModeling>();
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormBlank>();
DependencyManager.Instance.RegisterType<FormBlanks>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormDocument>();
DependencyManager.Instance.RegisterType<FormDocumentBlank>();
DependencyManager.Instance.RegisterType<FormDocuments>();
DependencyManager.Instance.RegisterType<FormReportDocumentBlanks>();
DependencyManager.Instance.RegisterType<FormReportOrder>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMails>();
services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
services.AddTransient<FormMain>();
services.AddTransient<FormBlank>();
services.AddTransient<FormBlanks>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormDocument>();
services.AddTransient<FormDocumentBlank>();
services.AddTransient<FormDocuments>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
services.AddTransient<FormShopSupply>();
services.AddTransient<FormShopSell>();
services.AddTransient<FormReportDocumentBlanks>();
services.AddTransient<FormReportOrder>();
services.AddTransient<FormReportShopDocuments>();
services.AddTransient<FormReportDateOrders>();
services.AddTransient<FormClients>();
services.AddTransient<FormImplementers>();
services.AddTransient<FormImplementer>();
services.AddTransient<FormMails>();
services.AddTransient<FormMail>();
DependencyManager.Instance.RegisterType<FormMail>();
DependencyManager.Instance.RegisterType<FormReportShopDocuments>();
DependencyManager.Instance.RegisterType<FormReportDateOrders>();
DependencyManager.Instance.RegisterType<FormShop>();
DependencyManager.Instance.RegisterType<FormShops>();
DependencyManager.Instance.RegisterType<FormShopSupply>();
DependencyManager.Instance.RegisterType<FormShopSell>();
}
}

View File

@ -0,0 +1,101 @@
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.StorageContracts;
using LawFirmDataModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmBusinessLogic.BusinessLogics
{
public class BackUpLogic : IBackUpLogic
{
private readonly ILogger _logger;
private readonly IBackUpInfo _backUpInfo;
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
{
_logger = logger;
_backUpInfo = backUpInfo;
}
public void CreateBackUp(BackUpSaveBinidngModel model)
{
if (_backUpInfo == null)
{
return;
}
try
{
_logger.LogDebug("Clear folder");
// зачистка папки и удаление старого архива
var dirInfo = new DirectoryInfo(model.FolderName);
if (dirInfo.Exists)
{
foreach (var file in dirInfo.GetFiles())
{
file.Delete();
}
}
_logger.LogDebug("Delete archive");
string fileName = $"{model.FolderName}.zip";
if (File.Exists(fileName))
{
File.Delete(fileName);
}
// берем метод для сохранения
_logger.LogDebug("Get assembly");
var typeIId = typeof(IId);
var assembly = typeIId.Assembly;
if (assembly == null)
{
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
}
var types = assembly.GetTypes();
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
_logger.LogDebug("Find {count} types", types.Length);
foreach (var type in types)
{
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
{
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
if (modelType == null)
{
throw new InvalidOperationException($"Не найденкласс - модель для { type.Name }");
}
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
// вызываем метод на выполнение
method?.MakeGenericMethod(modelType).Invoke(this, new
object[] { model.FolderName });
}
}
_logger.LogDebug("Create zip and remove folder");
// архивируем
ZipFile.CreateFromDirectory(model.FolderName, fileName);
// удаляем папку
dirInfo.Delete(true);
}
catch (Exception)
{
throw;
}
}
private void SaveToFile<T>(string folderName) where T : class, new()
{
var records = _backUpInfo.GetList<T>();
if (records == null)
{
_logger.LogWarning("{type} type get null list", typeof(T).Name);
return;
}
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
jsonFormatter.WriteObject(fs, records);
}
}
}

View File

@ -18,4 +18,8 @@
<ProjectReference Include="..\LawFirmContracts\LawFirmContracts.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -0,0 +1,39 @@
using LawFirmBusinessLogic.BusinessLogics;
using LawFirmBusinessLogic.MailWorker;
using LawFirmBusinessLogic.OfficePackage.Implements;
using LawFirmBusinessLogic.OfficePackage;
using LawFirmContracts.BusinessLogicContracts;
using LawFirmContracts.DI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmBusinessLogic
{
public class LogicImplementationExtension : ILogicImplementationExtension
{
public int Priority => 0;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IBlankLogic, BlankLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<IDocumentLogic, DocumentLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
DependencyManager.Instance.RegisterType<IShopLogic, ShopLogic>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(isSingle: true);
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.Attributes
{
[AttributeUsage(AttributeTargets.Property)]
public class ColumnAttribute : Attribute
{
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false, string format = "")
{
Title = title;
Visible = visible;
Width = width;
GridViewAutoSize = gridViewAutoSize;
IsUseAutoSize = isUseAutoSize;
Format = format;
}
public string Title { get; private set; }
public bool Visible { get; private set; }
public int Width { get; private set; }
public GridViewAutoSize GridViewAutoSize { get; private set; }
public bool IsUseAutoSize { get; private set; }
public string Format { get; private set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.Attributes
{
public enum GridViewAutoSize
{
NotSet = 0,
None = 1,
ColumnHeader = 2,
AllCellsExceptHeader = 4,
AllCells = 6,
DisplayedCellsExceptHeader = 8,
DisplayedCells = 10,
Fill = 16
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.BindingModels
{
public class BackUpSaveBinidngModel
{
public string FolderName { get; set; } = string.Empty;
}
}

View File

@ -19,8 +19,12 @@ namespace LawFirmContracts.BindingModels
public string Subject { get; set; } = string.Empty;
public string Body { get; set; } = string.Empty;
public bool IsReaded { get; set; }
public string Body { get; set; } = string.Empty;
public bool IsReaded { get; set; }
public string? Reply { get; set; }
public int Id => throw new NotImplementedException();
}
}

View File

@ -0,0 +1,15 @@
using LawFirmContracts.BindingModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.BusinessLogicContracts
{
public interface IBackUpLogic
{
void CreateBackUp(BackUpSaveBinidngModel model);
}
}

View File

@ -0,0 +1,69 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.DI
{
public class DependencyManager
{
private readonly IDependencyContainer _dependencyManager;
private static DependencyManager? _manager;
private static readonly object _locjObject = new();
private DependencyManager()
{
_dependencyManager = new UnityDependencyContainer();
}
public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } }
/// <summary>
/// Иницализация библиотек, в которых идут установки зависомстей
/// </summary>
public static void InitDependency()
{
// берем все расширения и проходимся по ним, регистрируя сервисы в каждом
var extensions = ServiceProviderLoader.GetImplementationExtensions();
foreach (var extension in extensions)
{
if (extension == null)
{
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
}
extension.RegisterServices();
}
}
/// <summary>
/// Регистрация логгера
/// </summary>
/// <param name="configure"></param>
public void AddLogging(Action<ILoggingBuilder> configure) => _dependencyManager.AddLogging(configure);
/// <summary>
/// Добавление зависимости
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="U"></typeparam>
public void RegisterType<T, U>(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType<T, U>(isSingle);
/// <summary>
/// Добавление зависимости
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="U"></typeparam>
public void RegisterType<T>(bool isSingle = false) where T : class => _dependencyManager.RegisterType<T>(isSingle);
/// <summary>
/// Получение класса со всеми зависмостями
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public T Resolve<T>() => _dependencyManager.Resolve<T>();
}
}

View File

@ -0,0 +1,40 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.DI
{
public interface IDependencyContainer
{
/// <summary>
/// Регистрация логгера
/// </summary>
/// <param name="configure"></param>
void AddLogging(Action<ILoggingBuilder> configure);
/// <summary>
/// Добавление зависимости
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="U"></typeparam>
/// <param name="isSingle"></param>
void RegisterType<T, U>(bool isSingle) where U : class, T where T : class;
/// <summary>
/// Добавление зависимости
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="isSingle"></param>
void RegisterType<T>(bool isSingle) where T : class;
/// <summary>
/// Получение класса со всеми зависмостями
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
T Resolve<T>();
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.DI
{
public interface IImplementationExtension
{
public int Priority { get; }
/// <summary>
/// Регистрация сервисов
/// </summary>
public void RegisterServices();
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.DI
{
public interface ILogicImplementationExtension : IImplementationExtension
{
}
}

View File

@ -0,0 +1,62 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.DI
{
public class ServiceDependencyContainer : IDependencyContainer
{
private ServiceProvider? _serviceProvider;
private readonly ServiceCollection _serviceCollection;
public ServiceDependencyContainer()
{
_serviceCollection = new ServiceCollection();
}
public void AddLogging(Action<ILoggingBuilder> configure)
{
_serviceCollection.AddLogging(configure);
}
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
{
if (isSingle)
{
_serviceCollection.AddSingleton<T, U>();
}
else
{
_serviceCollection.AddTransient<T, U>();
}
_serviceProvider = null;
}
public void RegisterType<T>(bool isSingle) where T : class
{
if (isSingle)
{
_serviceCollection.AddSingleton<T>();
}
else
{
_serviceCollection.AddTransient<T>();
}
_serviceProvider = null;
}
public T Resolve<T>()
{
if (_serviceProvider == null)
{
_serviceProvider = _serviceCollection.BuildServiceProvider();
}
return _serviceProvider.GetService<T>()!;
}
}
}

View File

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.DI
{
public class ServiceProviderLoader
{
/// Загрузка всех классов-реализаций IImplementationExtension
public static List<IImplementationExtension?> GetImplementationExtensions()
{
Type[] types =
{
typeof(ILogicImplementationExtension),
typeof(IImplementationExtension)
};
var endTypes = new IImplementationExtension?[types.Length];
var files = Directory.GetFiles(TryGetImplementationExtensionsFolder(), "*.dll", SearchOption.AllDirectories);
foreach (var file in files.Distinct())
{
Assembly asm = Assembly.LoadFrom(file);
foreach (var t in asm.GetExportedTypes())
{
for (var i = 0; i < types.Length; i++)
{
if (t.IsClass && types[i].IsAssignableFrom(t))
{
if (endTypes[i] == null)
{
endTypes[i] = (IImplementationExtension)Activator.CreateInstance(t)!;
}
else
{
var newSource = (IImplementationExtension)Activator.CreateInstance(t)!;
if (newSource.Priority > endTypes[i].Priority)
{
endTypes[i] = newSource;
}
}
}
}
}
}
return endTypes.ToList();
}
private static string TryGetImplementationExtensionsFolder()
{
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
while (directory != null && !directory.GetDirectories("ImplementationExtensions", SearchOption.AllDirectories).Any(x => x.Name == "ImplementationExtensions"))
{
directory = directory.Parent;
}
return $"{directory?.FullName}\\ImplementationExtensions";
}
}
}

View File

@ -0,0 +1,44 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
using Unity.Lifetime;
using Unity.Microsoft.Logging;
namespace LawFirmContracts.DI
{
public class UnityDependencyContainer : IDependencyContainer
{
private readonly IUnityContainer _container;
public UnityDependencyContainer()
{
_container = new UnityContainer();
}
public void AddLogging(Action<ILoggingBuilder> configure)
{
var factory = LoggerFactory.Create(configure);
_container.AddExtension(new LoggingExtension(factory));
}
public void RegisterType<T>(bool isSingle) where T : class
{
_container.RegisterType<T>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
}
public T Resolve<T>()
{
return _container.Resolve<T>();
}
void IDependencyContainer.RegisterType<T, U>(bool isSingle)
{
_container.RegisterType<T, U>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
}
}
}

View File

@ -8,6 +8,8 @@
<ItemGroup>
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.StorageContracts
{
public interface IBackUpInfo
{
List<T>? GetList<T>() where T : class, new();
Type? GetTypeByModelInterface(string modelInterfaceName);
}
}

View File

@ -1,4 +1,5 @@
using LawFirmDataModels.Models;
using LawFirmContracts.Attributes;
using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -10,12 +11,13 @@ namespace LawFirmContracts.ViewModels
{
public class BlankViewModel : IBlankModel
{
[DisplayName("Название бланка")]
[Column("Название бланка", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string BlankName { get; set; } = string.Empty;
[DisplayName("Цена")]
[Column("Цена", width: 100, format: "0.00")]
public double Cost { get; set; }
[Column(visible: false)]
public int Id { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using LawFirmDataModels.Models;
using LawFirmContracts.Attributes;
using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -10,12 +11,16 @@ namespace LawFirmContracts.ViewModels
{
public class ClientViewModel : IClientModel
{
[Column(visible:false)]
public int Id { get; set; }
[DisplayName("ФИО клиента")]
[Column(title:"ФИО клиента", width: 150 )]
public string ClientFIO { get; set; } = string.Empty;
[DisplayName("Логин (почта)")]
[Column(title:"Логин (эл.почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string Email { get; set; } = string.Empty;
[DisplayName("Пароль")]
[Column(title: "Пароль", width: 150)]
public string Password { get; set; } = string.Empty;
}
}

View File

@ -1,4 +1,5 @@
using LawFirmDataModels.Models;
using LawFirmContracts.Attributes;
using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -10,14 +11,16 @@ namespace LawFirmContracts.ViewModels
{
public class DocumentViewModel : IDocumentModel
{
[DisplayName("Название документа")]
[Column("Название документа", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string DocumentName {get; set;} = string.Empty;
[DisplayName("Цена")]
[Column("Цена", width: 100, format:"0.00")]
public double Price { get; set; }
[Column(visible: false)]
public Dictionary<int, (IBlankModel, int)> DocumentBlanks { get; set; } = new();
[Column(visible: false)]
public int Id { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using LawFirmDataModels.Models;
using LawFirmContracts.Attributes;
using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -10,18 +11,19 @@ namespace LawFirmContracts.ViewModels
{
public class ImplementerViewModel : IImplementerModel
{
[Column(visible: false)]
public int Id { get; set; }
[DisplayName("ФИО")]
[Column("ФИО", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Пароль")]
[Column("Пароль", width: 200)]
public string Password { get; set; } = string.Empty;
[DisplayName("Трудовой стаж")]
[Column("Трудовой стаж", width: 200)]
public int WorkExperience { get; set; }
[DisplayName("Квалификация")]
[Column("Квалификация", width: 200)]
public int Qualification { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using LawFirmDataModels.Models;
using LawFirmContracts.Attributes;
using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -10,20 +11,31 @@ namespace LawFirmContracts.ViewModels
{
public class MessageInfoViewModel : IMessageInfoModel
{
public string MessageId { get; set; } = string.Empty;
[Column(visible: false)]
public string MessageId { get; set; } = string.Empty;
public int? ClientId { get; set; }
[DisplayName("Отправитель")]
public string SenderName { get; set; } = string.Empty;
[DisplayName("Дата письма")]
public DateTime DateDelivery { get; set; }
[DisplayName("Заголовок")]
public string Subject { get; set; } = string.Empty;
[DisplayName("Текст")]
public string Body { get; set; } = string.Empty;
[DisplayName("Прочитано")]
[Column(visible: false)]
public int? ClientId { get; set; }
[Column("Отправитель", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
public string SenderName { get; set; } = string.Empty;
[Column("Дата письма", width: 100, format:"D")]
public DateTime DateDelivery { get; set; }
[Column("Заголовок", width: 150)]
public string Subject { get; set; } = string.Empty;
[Column("Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string Body { get; set; } = string.Empty;
[Column("Прочитано", width: 50)]
public bool IsReaded { get; set; }
[DisplayName("Ответ")]
[Column("Ответ", width: 150)]
public string? Reply { get; set; }
[Column(visible: false)]
public int Id => throw new NotImplementedException();
}
}

View File

@ -1,4 +1,5 @@
using LawFirmDataModels.Enums;
using LawFirmContracts.Attributes;
using LawFirmDataModels.Enums;
using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
@ -11,33 +12,40 @@ namespace LawFirmContracts.ViewModels
{
public class OrderViewModel : IOrderModel
{
[DisplayName("Номер")]
[Column("Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int Id { get; set; }
[Column(visible: false)]
public int DocumentId { get; set; }
[DisplayName("Документ")]
[Column("Документ", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public string DocumentName { get; set; } = string.Empty;
[Column(visible: false)]
public int ClientId { get; set; }
[DisplayName("ФИО клиента")]
[Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public string ClientFIO { get; set; } = string.Empty;
[Column(visible: false)]
public int? ImplementerId { get; set; }
[DisplayName("ФИО исполнителя")]
[Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Количество")]
[Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int Count { get; set; }
[DisplayName("Сумма")]
[Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true, format:"0.00")]
public double Sum { get; set; }
[DisplayName("Статус")]
[Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DisplayName("Дата создания")]
[Column("Дата создания", width: 100, format:"D")]
public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Дата выполнения")]
[Column("Дата выполнения", width: 100, format:"D")]
public DateTime? DateImplement { get; set; }

View File

@ -1,4 +1,5 @@
using LawFirmDataModels.Models;
using LawFirmContracts.Attributes;
using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -10,19 +11,25 @@ namespace LawFirmContracts.ViewModels
{
public class ShopViewModel : IShopModel
{
[DisplayName("Название магазина")]
[Column("Название магазина", gridViewAutoSize:GridViewAutoSize.Fill, isUseAutoSize: true)]
public string Name { get; set; } = string.Empty;
[DisplayName("Адрес")]
[Column("Адрес", width: 150)]
public string Adress { get; set; } = string.Empty;
[DisplayName("Дата открытия")]
[Column("Дата открытия", format:"D", isUseAutoSize:true, gridViewAutoSize:GridViewAutoSize.AllCells)]
public DateTime OpeningDate { get; set; }
[Column(visible: false)]
public Dictionary<int, (IDocumentModel, int)> ShopDocuments { get; set; } = new();
[Column(visible: false)]
public List<Tuple<string, int>>? DocumentCount { get; set; } = new();
[Column(visible: false)]
public int Id { get; set; }
[DisplayName("Макс. документов в магазине")]
[Column("Макс. документов в магазине", width:100)]
public int MaxCountDocuments { get; set; }
}
}

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace LawFirmDataModels.Models
{
public interface IMessageInfoModel
public interface IMessageInfoModel : IId
{
string MessageId { get; }
int? ClientId { get; }

View File

@ -0,0 +1,28 @@
using LawFirmContracts.DI;
using LawFirmContracts.StorageContracts;
using LawFirmDatabaseImplement.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmDatabaseImplement
{
public class DatabaseImplementationExtension : IImplementationExtension
{
public int Priority => 2;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IBlankStorage, BlankStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IDocumentStorage, DocumentStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
DependencyManager.Instance.RegisterType<IShopStorage, ShopStorage>();
}
}
}

View File

@ -0,0 +1,32 @@
using LawFirmContracts.StorageContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmDatabaseImplement.Implements
{
public class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
using var context = new LawFirmDatabase();
return context.Set<T>().ToList();
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
var assembly = typeof(BackUpInfo).Assembly;
var types = assembly.GetTypes();
foreach (var type in types)
{
if (type.IsClass &&
type.GetInterface(modelInterfaceName) != null)
{
return type;
}
}
return null;
}
}
}

View File

@ -20,4 +20,8 @@
<ProjectReference Include="..\LawFirmDataModels\LawFirmDataModels.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -6,18 +6,23 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmDatabaseImplement.Models
{
[DataContract]
public class Blank : IBlankModel
{
[DataMember]
public int Id { get; private set; }
[Required]
[DataMember]
public string BlankName { get; private set; } = String.Empty;
[Required]
[DataMember]
public double Cost { get; set; }
[ForeignKey("BlankId")]

View File

@ -8,20 +8,26 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace LawFirmDatabaseImplement.Models
{
[DataContract]
public class Client : IClientModel
{
[DataMember]
public int Id { get; private set; }
[Required]
[DataMember]
public string ClientFIO { get; private set; } = string.Empty;
[Required]
[DataMember]
public string Email { get; private set; } = string.Empty;
[Required]
[DataMember]
public string Password { get; private set; } = string.Empty;
[ForeignKey("ClientId")]

View File

@ -6,22 +6,28 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmDatabaseImplement.Models
{
[DataContract]
public class Document : IDocumentModel
{
[DataMember]
public int Id { get; private set; }
[Required]
[DataMember]
public string DocumentName { get; private set; } = string.Empty;
[Required]
[DataMember]
public double Price { get; private set; }
private Dictionary<int, (IBlankModel, int)>? _documentBlanks = null;
[NotMapped]
[DataMember]
public Dictionary<int, (IBlankModel, int)> DocumentBlanks
{
get

View File

@ -5,21 +5,24 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmDatabaseImplement.Models
{
[DataContract]
public class Implementer : IImplementerModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ImplementerFIO { get; private set; } = string.Empty;
[DataMember]
public string Password { get; private set; } = string.Empty;
[DataMember]
public int WorkExperience { get; private set; }
[DataMember]
public int Qualification { get; private set; }
[ForeignKey("ImplementerId")]

View File

@ -5,25 +5,28 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmDatabaseImplement.Models
{
public class MessageInfo : IMessageInfoModel
[DataContract]
public class MessageInfo : IMessageInfoModel
{
[Key]
public string MessageId { get; private set; } = string.Empty;
public int? ClientId { get; private set; }
public string SenderName { get; private set; } = string.Empty;
public DateTime DateDelivery { get; private set; } = DateTime.Now;
public string Subject { get; private set; } = string.Empty;
public string Body { get; private set; } = string.Empty;
[DataMember]
public string MessageId { get; private set; } = string.Empty;
[DataMember]
public int? ClientId { get; private set; }
[DataMember]
public string SenderName { get; private set; } = string.Empty;
[DataMember]
public DateTime DateDelivery { get; private set; } = DateTime.Now;
[DataMember]
public string Subject { get; private set; } = string.Empty;
[DataMember]
public string Body { get; private set; } = string.Empty;
public virtual Client? Client { get; private set; }
public bool IsReaded { get; private set; }
@ -70,5 +73,6 @@ namespace LawFirmDatabaseImplement.Models
IsReaded = IsReaded,
};
}
public int Id => throw new NotImplementedException();
}
}

View File

@ -6,28 +6,38 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmDatabaseImplement.Models
{
[DataContract]
public class Order : IOrderModel
{
[DataMember]
public int Id { get; private set; }
[Required]
[DataMember]
public int DocumentId { get; private set; }
[Required]
[DataMember]
public int ClientId { get; private set; }
[DataMember]
public int? ImplementerId { get; private set; }
[Required]
[DataMember]
public int Count { get; private set; }
[Required]
[DataMember]
public double Sum { get; private set; }
[Required]
[DataMember]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
[Required]
[DataMember]
public DateTime DateCreate { get; private set; } = DateTime.Now;
[DataMember]
public DateTime? DateImplement { get; private set; }
public virtual Document Document { get; set; }
public virtual Client Client { get; set; }

View File

@ -8,19 +8,25 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace LawFirmDatabaseImplement.Models
{
[DataContract]
public class Shop : IShopModel
{
[DataMember]
public int Id { get; set; }
[Required]
[DataMember]
public string Name { get; set; } = string.Empty;
[Required]
[DataMember]
public string Adress { get; set; } = string.Empty;
[Required]
[DataMember]
public DateTime OpeningDate { get; set; }
[ForeignKey("ShopId")]
@ -29,6 +35,7 @@ namespace LawFirmDatabaseImplement.Models
private Dictionary<int, (IDocumentModel, int)>? _shopDocuments = null;
[NotMapped]
[DataMember]
public Dictionary<int, (IDocumentModel, int)> ShopDocuments
{
get

View File

@ -0,0 +1,28 @@
using LawFirmContracts.DI;
using LawFirmContracts.StorageContracts;
using LawFirmFileImplement.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmFileImplement
{
public class FileImplementationExtension : IImplementationExtension
{
public int Priority => 1;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IBlankStorage, BlankStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IDocumentStorage, DocumentStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
DependencyManager.Instance.RegisterType<IShopStorage, ShopStorage>();
}
}
}

View File

@ -0,0 +1,33 @@
using LawFirmContracts.StorageContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmFileImplement.Implements
{
public class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
var source = DataFileSingleton.GetInstance();
return (List<T>?)source.GetType().GetProperties()
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))
?.GetValue(source);
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
var assembly = typeof(BackUpInfo).Assembly;
var types = assembly.GetTypes();
foreach (var type in types)
{
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
{
return type;
}
}
return null;
}
}
}

View File

@ -11,4 +11,8 @@
<ProjectReference Include="..\LawFirmDataModels\LawFirmDataModels.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -5,18 +5,21 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace LawFirmFileImplement.Models
{
[DataContract]
public class Blank : IBlankModel
{
[DataMember]
public string BlankName { get; private set; } = String.Empty;
[DataMember]
public double Cost { get; set; }
[DataMember]
public int Id { get; private set; }
public static Blank? Create(BlankBindingModel? model)

View File

@ -4,20 +4,23 @@ using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace LawFirmFileImplement.Models
{
[DataContract]
public class Client : IClientModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ClientFIO { get; private set; } = string.Empty;
[DataMember]
public string Email { get; private set; } = string.Empty;
[DataMember]
public string Password { get; private set; } = string.Empty;
public static Client? Create(ClientBindingModel model)

View File

@ -4,23 +4,27 @@ using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace LawFirmFileImplement.Models
{
[DataContract]
public class Document : IDocumentModel
{
[DataMember]
public string DocumentName { get; private set; } = string.Empty;
[DataMember]
public double Price { get; private set; }
[DataMember]
public int Id { get; private set; }
public Dictionary<int, int> Blanks { get; private set; } = new();
private Dictionary<int, (IBlankModel, int)>? _documentBlanks = null;
[DataMember]
public Dictionary<int, (IBlankModel, int)> DocumentBlanks
{
get

View File

@ -4,22 +4,25 @@ using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace LawFirmFileImplement.Models
{
[DataContract]
public class Implementer : IImplementerModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ImplementerFIO { get; private set; } = string.Empty;
[DataMember]
public string Password { get; private set; } = string.Empty;
[DataMember]
public int WorkExperience { get; private set; }
[DataMember]
public int Qualification { get; private set; }
public static Implementer? Create(XElement element)

View File

@ -4,26 +4,31 @@ using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace LawFirmFileImplement.Models
{
public class MessageInfo : IMessageInfoModel
[DataContract]
public class MessageInfo : IMessageInfoModel
{
public string MessageId { get; private set; } = string.Empty;
public int? ClientId { get; private set; }
public string SenderName { get; private set; } = string.Empty;
public DateTime DateDelivery { get; private set; } = DateTime.Now;
public string Subject { get; private set; } = string.Empty;
public string Body { get; private set; } = string.Empty;
[DataMember]
public string MessageId { get; private set; } = string.Empty;
[DataMember]
public int? ClientId { get; private set; }
[DataMember]
public string SenderName { get; private set; } = string.Empty;
[DataMember]
public DateTime DateDelivery { get; private set; } = DateTime.Now;
[DataMember]
public string Subject { get; private set; } = string.Empty;
[DataMember]
public string Body { get; private set; } = string.Empty;
[DataMember]
public bool IsReaded { get; private set; }
[DataMember]
public string? Reply { get; private set; }
public static MessageInfo? Create(MessageInfoBindingModel model)
@ -96,5 +101,7 @@ namespace LawFirmFileImplement.Models
new XAttribute("Reply", Reply),
new XAttribute("HasRead", IsReaded)
);
}
public int Id => throw new NotImplementedException();
}
}

View File

@ -5,29 +5,35 @@ using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace LawFirmFileImplement.Models
{
[DataContract]
public class Order : IOrderModel
{
public int DocumentId { get; private set; }
public int ClientId { get; set; }
public int? ImplementerId { get; set; }
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; private set; } = DateTime.Now;
public DateTime? DateImplement { get; private set; }
[DataMember]
public int Id { get; private set; }
[DataMember]
public int DocumentId { get; private set; }
[DataMember]
public int ClientId { get; set; }
[DataMember]
public int? ImplementerId { get; set; }
[DataMember]
public int Count { get; private set; }
[DataMember]
public double Sum { get; private set; }
[DataMember]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
[DataMember]
public DateTime DateCreate { get; private set; } = DateTime.Now;
[DataMember]
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model)
{

View File

@ -5,28 +5,31 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace LawFirmFileImplement.Models
{
[DataContract]
public class Shop : IShopModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string Name { get; private set; } = string.Empty;
[DataMember]
public string Adress { get; private set; } = string.Empty;
[DataMember]
public int MaxCountDocuments { get; private set; }
[DataMember]
public DateTime OpeningDate { get; private set; }
public Dictionary<int, int> Documents { get; private set; } = new();
private Dictionary<int, (IDocumentModel, int)>? _shopDocuments = null;
[DataMember]
public Dictionary<int, (IDocumentModel, int)> ShopDocuments
{
get

View File

@ -0,0 +1,22 @@
using LawFirmContracts.StorageContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmListImplements.Implements
{
public class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
throw new NotImplementedException();
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
throw new NotImplementedException();
}
}
}

View File

@ -15,4 +15,8 @@
<ProjectReference Include="..\LawFirmDataModels\LawFirmDataModels.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)ImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -0,0 +1,28 @@
using LawFirmContracts.DI;
using LawFirmContracts.StorageContracts;
using LawFirmListImplements.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmListImplements
{
public class ListImplementationExtension : IImplementationExtension
{
public int Priority => 0;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IBlankStorage, BlankStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IDocumentStorage, DocumentStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
DependencyManager.Instance.RegisterType<IShopStorage, ShopStorage>();
}
}
}

View File

@ -66,5 +66,6 @@ namespace LawFirmListImplements.Models
IsReaded = IsReaded,
};
}
public int Id => throw new NotImplementedException();
}
}