lab8
This commit is contained in:
parent
9679a01937
commit
aecb2bdf42
@ -15,11 +15,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairListImplement
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairFileImplement", "PlumpingRepairFileImplement\PlumbingRepairFileImplement.csproj", "{BA7E2CE6-7797-42C7-931C-40C48EA521C7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairDatabaseImplement", "PlumbingRepairDatabaseImplement\PlumbingRepairDatabaseImplement.csproj", "{1E4DDF78-14D2-498B-9A17-473F156DBE11}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairRestApi", "PlumbingRepairRestApi\PlumbingRepairRestApi.csproj", "{96133F01-9E2F-4767-8CD8-811D8806E930}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlumbingRepairRestApi", "PlumbingRepairRestApi\PlumbingRepairRestApi.csproj", "{96133F01-9E2F-4767-8CD8-811D8806E930}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairClientApp", "PlumbingRepairClientApp\PlumbingRepairClientApp.csproj", "{C8A5024D-9529-452F-AAF3-9EDEEFED6758}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlumbingRepairClientApp", "PlumbingRepairClientApp\PlumbingRepairClientApp.csproj", "{C8A5024D-9529-452F-AAF3-9EDEEFED6758}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlumbingRepairDatabaseImplement", "PlumbingRepairDatabaseImplement\PlumbingRepairDatabaseImplement.csproj", "{A7874FFC-162B-4B6E-92CD-EA265B9E35F1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -51,10 +51,6 @@ Global
|
||||
{BA7E2CE6-7797-42C7-931C-40C48EA521C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BA7E2CE6-7797-42C7-931C-40C48EA521C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BA7E2CE6-7797-42C7-931C-40C48EA521C7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1E4DDF78-14D2-498B-9A17-473F156DBE11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1E4DDF78-14D2-498B-9A17-473F156DBE11}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1E4DDF78-14D2-498B-9A17-473F156DBE11}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1E4DDF78-14D2-498B-9A17-473F156DBE11}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{96133F01-9E2F-4767-8CD8-811D8806E930}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{96133F01-9E2F-4767-8CD8-811D8806E930}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{96133F01-9E2F-4767-8CD8-811D8806E930}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -63,6 +59,10 @@ Global
|
||||
{C8A5024D-9529-452F-AAF3-9EDEEFED6758}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C8A5024D-9529-452F-AAF3-9EDEEFED6758}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C8A5024D-9529-452F-AAF3-9EDEEFED6758}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A7874FFC-162B-4B6E-92CD-EA265B9E35F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A7874FFC-162B-4B6E-92CD-EA265B9E35F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A7874FFC-162B-4B6E-92CD-EA265B9E35F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A7874FFC-162B-4B6E-92CD-EA265B9E35F1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -5,7 +5,7 @@
|
||||
<add key="SmtpClientPort" value="587" />
|
||||
<add key="PopHost" value="pop.gmail.com" />
|
||||
<add key="PopPort" value="995" />
|
||||
<add key="MailLogin" value="sevenknee5073@gmail.com" />
|
||||
<add key="MailPassword" value="tkhr rren pidn eyqa" />
|
||||
<add key="MailLogin" value="labwork7turner@gmail.com" />
|
||||
<add key="MailPassword" value="daxm gvdc qdza sfza" />
|
||||
</appSettings>
|
||||
</configuration>
|
53
PlumbingRepair/DataGridViewExtension.cs
Normal file
53
PlumbingRepair/DataGridViewExtension.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using PlumbingRepairContracts.Attributes;
|
||||
|
||||
namespace PlumbingRepair
|
||||
{
|
||||
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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -22,14 +22,8 @@ namespace PlumbingRepair
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||
using PlumbingRepairContracts.DI;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PlumbingRepair
|
||||
{
|
||||
@ -23,18 +25,10 @@ namespace PlumbingRepair
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
DataGridView.DataSource = list;
|
||||
DataGridView.Columns["Id"].Visible = false;
|
||||
DataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
DataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -46,31 +40,24 @@ namespace PlumbingRepair
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
|
||||
if (service is FormComponent form)
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private void ChangeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||
|
||||
if (service is FormComponent form)
|
||||
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
|
67
PlumbingRepair/FormCreateOrder.Designer.cs
generated
67
PlumbingRepair/FormCreateOrder.Designer.cs
generated
@ -36,66 +36,68 @@
|
||||
this.SumTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SaveButton = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.comboBoxClient = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// WorkNameLabel
|
||||
//
|
||||
this.WorkNameLabel.AutoSize = true;
|
||||
this.WorkNameLabel.Location = new System.Drawing.Point(12, 9);
|
||||
this.WorkNameLabel.Location = new System.Drawing.Point(14, 12);
|
||||
this.WorkNameLabel.Name = "WorkNameLabel";
|
||||
this.WorkNameLabel.Size = new System.Drawing.Size(51, 15);
|
||||
this.WorkNameLabel.Size = new System.Drawing.Size(75, 20);
|
||||
this.WorkNameLabel.TabIndex = 0;
|
||||
this.WorkNameLabel.Text = "Работа: ";
|
||||
this.WorkNameLabel.Text = "Изделие: ";
|
||||
//
|
||||
// CountLabel
|
||||
//
|
||||
this.CountLabel.AutoSize = true;
|
||||
this.CountLabel.Location = new System.Drawing.Point(12, 40);
|
||||
this.CountLabel.Location = new System.Drawing.Point(14, 53);
|
||||
this.CountLabel.Name = "CountLabel";
|
||||
this.CountLabel.Size = new System.Drawing.Size(78, 15);
|
||||
this.CountLabel.Size = new System.Drawing.Size(97, 20);
|
||||
this.CountLabel.TabIndex = 1;
|
||||
this.CountLabel.Text = "Количество: ";
|
||||
//
|
||||
// SumLabel
|
||||
//
|
||||
this.SumLabel.AutoSize = true;
|
||||
this.SumLabel.Location = new System.Drawing.Point(12, 72);
|
||||
this.SumLabel.Location = new System.Drawing.Point(14, 96);
|
||||
this.SumLabel.Name = "SumLabel";
|
||||
this.SumLabel.Size = new System.Drawing.Size(51, 15);
|
||||
this.SumLabel.Size = new System.Drawing.Size(62, 20);
|
||||
this.SumLabel.TabIndex = 2;
|
||||
this.SumLabel.Text = "Сумма: ";
|
||||
//
|
||||
// WorkComboBox
|
||||
//
|
||||
this.WorkComboBox.FormattingEnabled = true;
|
||||
this.WorkComboBox.Location = new System.Drawing.Point(93, 6);
|
||||
this.WorkComboBox.Location = new System.Drawing.Point(106, 8);
|
||||
this.WorkComboBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.WorkComboBox.Name = "WorkComboBox";
|
||||
this.WorkComboBox.Size = new System.Drawing.Size(201, 23);
|
||||
this.WorkComboBox.Size = new System.Drawing.Size(229, 28);
|
||||
this.WorkComboBox.TabIndex = 3;
|
||||
this.WorkComboBox.SelectedIndexChanged += new System.EventHandler(this.WorkComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// CountTextBox
|
||||
//
|
||||
this.CountTextBox.Location = new System.Drawing.Point(93, 37);
|
||||
this.CountTextBox.Location = new System.Drawing.Point(106, 49);
|
||||
this.CountTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.CountTextBox.Name = "CountTextBox";
|
||||
this.CountTextBox.Size = new System.Drawing.Size(201, 23);
|
||||
this.CountTextBox.Size = new System.Drawing.Size(229, 27);
|
||||
this.CountTextBox.TabIndex = 4;
|
||||
this.CountTextBox.TextChanged += new System.EventHandler(this.CountTextBox_TextChanged);
|
||||
//
|
||||
// SumTextBox
|
||||
//
|
||||
this.SumTextBox.Location = new System.Drawing.Point(93, 69);
|
||||
this.SumTextBox.Location = new System.Drawing.Point(106, 92);
|
||||
this.SumTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.SumTextBox.Name = "SumTextBox";
|
||||
this.SumTextBox.Size = new System.Drawing.Size(201, 23);
|
||||
this.SumTextBox.Size = new System.Drawing.Size(229, 27);
|
||||
this.SumTextBox.TabIndex = 5;
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(222, 191);
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(250, 151);
|
||||
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(86, 31);
|
||||
this.ButtonCancel.TabIndex = 6;
|
||||
this.ButtonCancel.Text = "Отменить";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
@ -103,38 +105,20 @@
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
this.SaveButton.Location = new System.Drawing.Point(130, 191);
|
||||
this.SaveButton.Location = new System.Drawing.Point(147, 151);
|
||||
this.SaveButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.SaveButton.Name = "SaveButton";
|
||||
this.SaveButton.Size = new System.Drawing.Size(85, 23);
|
||||
this.SaveButton.Size = new System.Drawing.Size(97, 31);
|
||||
this.SaveButton.TabIndex = 7;
|
||||
this.SaveButton.Text = "Сохранить";
|
||||
this.SaveButton.UseVisualStyleBackColor = true;
|
||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 106);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(49, 15);
|
||||
this.label1.TabIndex = 8;
|
||||
this.label1.Text = "Клиент:";
|
||||
//
|
||||
// comboBoxClient
|
||||
//
|
||||
this.comboBoxClient.FormattingEnabled = true;
|
||||
this.comboBoxClient.Location = new System.Drawing.Point(93, 106);
|
||||
this.comboBoxClient.Name = "comboBoxClient";
|
||||
this.comboBoxClient.Size = new System.Drawing.Size(201, 23);
|
||||
this.comboBoxClient.TabIndex = 9;
|
||||
//
|
||||
// FormCreateOrder
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(309, 226);
|
||||
this.Controls.Add(this.comboBoxClient);
|
||||
this.Controls.Add(this.label1);
|
||||
this.ClientSize = new System.Drawing.Size(353, 204);
|
||||
this.Controls.Add(this.SaveButton);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.SumTextBox);
|
||||
@ -143,6 +127,7 @@
|
||||
this.Controls.Add(this.SumLabel);
|
||||
this.Controls.Add(this.CountLabel);
|
||||
this.Controls.Add(this.WorkNameLabel);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormCreateOrder";
|
||||
this.Text = "Заказ";
|
||||
this.ResumeLayout(false);
|
||||
@ -160,7 +145,5 @@
|
||||
private TextBox SumTextBox;
|
||||
private Button ButtonCancel;
|
||||
private Button SaveButton;
|
||||
private Label label1;
|
||||
private ComboBox comboBoxClient;
|
||||
}
|
||||
}
|
@ -10,26 +10,23 @@ namespace PlumbingRepair
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkLogic _logicW;
|
||||
private readonly IOrderLogic _logicO;
|
||||
private readonly IClientLogic _logicC;
|
||||
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IWorkLogic logicW, IOrderLogic logicO, IClientLogic logicC)
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IWorkLogic logicW, IOrderLogic logicO)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicW = logicW;
|
||||
_logicO = logicO;
|
||||
_logicC = logicC;
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка Работ для заказа");
|
||||
_logger.LogInformation("Загрузка изделий для заказа");
|
||||
|
||||
try
|
||||
{
|
||||
var list = _logicW.ReadList(null);
|
||||
var listClients = _logicC.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
WorkComboBox.DisplayMember = "WorkName";
|
||||
@ -37,18 +34,11 @@ namespace PlumbingRepair
|
||||
WorkComboBox.DataSource = list;
|
||||
WorkComboBox.SelectedItem = null;
|
||||
}
|
||||
if(listClients != null)
|
||||
{
|
||||
comboBoxClient.DisplayMember = "ClientFIO";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
comboBoxClient.DataSource = listClients;
|
||||
comboBoxClient.SelectedItem = null;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка Работ");
|
||||
_logger.LogError(ex, "Ошибка загрузки списка изделий");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
@ -103,12 +93,7 @@ namespace PlumbingRepair
|
||||
|
||||
if (WorkComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите Работа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxClient.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите заказчика", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -121,8 +106,7 @@ namespace PlumbingRepair
|
||||
WorkId = Convert.ToInt32(WorkComboBox.SelectedValue),
|
||||
WorkName = WorkComboBox.Text,
|
||||
Count = Convert.ToInt32(CountTextBox.Text),
|
||||
Sum = Convert.ToDouble(SumTextBox.Text),
|
||||
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue)
|
||||
Sum = Convert.ToDouble(SumTextBox.Text)
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||
using PlumbingRepairContracts.DI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -26,14 +27,10 @@ namespace PlumbingRepair
|
||||
|
||||
private void AddButton_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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,14 +38,11 @@ namespace PlumbingRepair
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -98,14 +92,7 @@ namespace PlumbingRepair
|
||||
{
|
||||
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("Загрузка исполнителей");
|
||||
}
|
||||
|
@ -20,14 +20,7 @@ namespace PlumbingRepair
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
DataGridView.DataSource = list;
|
||||
DataGridView.Columns["ClientId"].Visible = false;
|
||||
DataGridView.Columns["MessageId"].Visible = false;
|
||||
DataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
DataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка писем");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
95
PlumbingRepair/FormMain.Designer.cs
generated
95
PlumbingRepair/FormMain.Designer.cs
generated
@ -30,7 +30,7 @@
|
||||
{
|
||||
MenuStrip = new MenuStrip();
|
||||
СправочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
РаботыToolStripMenuItem = new ToolStripMenuItem();
|
||||
ИзделияToolStripMenuItem = new ToolStripMenuItem();
|
||||
КомпонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
КлиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
исполнителиToolStripMenuItem = new ToolStripMenuItem();
|
||||
@ -39,11 +39,12 @@
|
||||
WorkComponentToolStripMenuItem = new ToolStripMenuItem();
|
||||
OrdersToolStripMenuItem = new ToolStripMenuItem();
|
||||
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
||||
письмаToolStripMenuItem = new ToolStripMenuItem();
|
||||
создатьБэкапToolStripMenuItem = new ToolStripMenuItem();
|
||||
CreateOrderButton = new Button();
|
||||
IssuedOrderButton = new Button();
|
||||
UpdateListButton = new Button();
|
||||
DataGridView = new DataGridView();
|
||||
почтаToolStripMenuItem = new ToolStripMenuItem();
|
||||
MenuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -51,45 +52,46 @@
|
||||
// MenuStrip
|
||||
//
|
||||
MenuStrip.ImageScalingSize = new Size(20, 20);
|
||||
MenuStrip.Items.AddRange(new ToolStripItem[] { СправочникиToolStripMenuItem, отчетыToolStripMenuItem, запускРаботToolStripMenuItem, почтаToolStripMenuItem });
|
||||
MenuStrip.Items.AddRange(new ToolStripItem[] { СправочникиToolStripMenuItem, отчетыToolStripMenuItem, запускРаботToolStripMenuItem, письмаToolStripMenuItem, создатьБэкапToolStripMenuItem });
|
||||
MenuStrip.Location = new Point(0, 0);
|
||||
MenuStrip.Name = "MenuStrip";
|
||||
MenuStrip.Size = new Size(865, 24);
|
||||
MenuStrip.Padding = new Padding(7, 3, 0, 3);
|
||||
MenuStrip.Size = new Size(989, 30);
|
||||
MenuStrip.TabIndex = 0;
|
||||
MenuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// СправочникиToolStripMenuItem
|
||||
//
|
||||
СправочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { РаботыToolStripMenuItem, КомпонентыToolStripMenuItem, КлиентыToolStripMenuItem, исполнителиToolStripMenuItem });
|
||||
СправочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ИзделияToolStripMenuItem, КомпонентыToolStripMenuItem, КлиентыToolStripMenuItem, исполнителиToolStripMenuItem });
|
||||
СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
|
||||
СправочникиToolStripMenuItem.Size = new Size(94, 20);
|
||||
СправочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
СправочникиToolStripMenuItem.Text = "Cправочники";
|
||||
//
|
||||
// РаботыToolStripMenuItem
|
||||
// ИзделияToolStripMenuItem
|
||||
//
|
||||
РаботыToolStripMenuItem.Name = "РаботыToolStripMenuItem";
|
||||
РаботыToolStripMenuItem.Size = new Size(149, 22);
|
||||
РаботыToolStripMenuItem.Text = "Работы";
|
||||
РаботыToolStripMenuItem.Click += РаботыToolStripMenuItem_Click;
|
||||
ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
||||
ИзделияToolStripMenuItem.Size = new Size(185, 26);
|
||||
ИзделияToolStripMenuItem.Text = "Изделия";
|
||||
ИзделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
|
||||
//
|
||||
// КомпонентыToolStripMenuItem
|
||||
//
|
||||
КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
||||
КомпонентыToolStripMenuItem.Size = new Size(149, 22);
|
||||
КомпонентыToolStripMenuItem.Size = new Size(185, 26);
|
||||
КомпонентыToolStripMenuItem.Text = "Компоненты";
|
||||
КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
||||
//
|
||||
// КлиентыToolStripMenuItem
|
||||
//
|
||||
КлиентыToolStripMenuItem.Name = "КлиентыToolStripMenuItem";
|
||||
КлиентыToolStripMenuItem.Size = new Size(149, 22);
|
||||
КлиентыToolStripMenuItem.Size = new Size(185, 26);
|
||||
КлиентыToolStripMenuItem.Text = "Клиенты";
|
||||
КлиентыToolStripMenuItem.Click += КлиентыToolStripMenuItem_Click;
|
||||
//
|
||||
// исполнителиToolStripMenuItem
|
||||
//
|
||||
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||
исполнителиToolStripMenuItem.Size = new Size(149, 22);
|
||||
исполнителиToolStripMenuItem.Size = new Size(185, 26);
|
||||
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
|
||||
//
|
||||
@ -97,42 +99,57 @@
|
||||
//
|
||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { WorksToolStripMenuItem, WorkComponentToolStripMenuItem, OrdersToolStripMenuItem });
|
||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
//
|
||||
// WorksToolStripMenuItem
|
||||
//
|
||||
WorksToolStripMenuItem.Name = "WorksToolStripMenuItem";
|
||||
WorksToolStripMenuItem.Size = new Size(211, 22);
|
||||
WorksToolStripMenuItem.Text = "Список Работ";
|
||||
WorksToolStripMenuItem.Size = new Size(273, 26);
|
||||
WorksToolStripMenuItem.Text = "Список изделий";
|
||||
WorksToolStripMenuItem.Click += WorksToolStripMenuItem_Click;
|
||||
//
|
||||
// WorkComponentToolStripMenuItem
|
||||
//
|
||||
WorkComponentToolStripMenuItem.Name = "WorkComponentToolStripMenuItem";
|
||||
WorkComponentToolStripMenuItem.Size = new Size(211, 22);
|
||||
WorkComponentToolStripMenuItem.Text = "Работы по компонентам";
|
||||
WorkComponentToolStripMenuItem.Size = new Size(273, 26);
|
||||
WorkComponentToolStripMenuItem.Text = "Изделия по компонентам";
|
||||
WorkComponentToolStripMenuItem.Click += WorkComponentToolStripMenuItem_Click;
|
||||
//
|
||||
// OrdersToolStripMenuItem
|
||||
//
|
||||
OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
|
||||
OrdersToolStripMenuItem.Size = new Size(211, 22);
|
||||
OrdersToolStripMenuItem.Size = new Size(273, 26);
|
||||
OrdersToolStripMenuItem.Text = "Список заказов";
|
||||
OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
||||
//
|
||||
// запускРаботToolStripMenuItem
|
||||
//
|
||||
запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
|
||||
запускРаботToolStripMenuItem.Size = new Size(92, 20);
|
||||
запускРаботToolStripMenuItem.Size = new Size(114, 24);
|
||||
запускРаботToolStripMenuItem.Text = "Запуск работ";
|
||||
запускРаботToolStripMenuItem.Click += запускРаботToolStripMenuItem_Click;
|
||||
//
|
||||
// письмаToolStripMenuItem
|
||||
//
|
||||
письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
|
||||
письмаToolStripMenuItem.Size = new Size(77, 24);
|
||||
письмаToolStripMenuItem.Text = "Письма";
|
||||
письмаToolStripMenuItem.Click += письмаToolStripMenuItem_Click;
|
||||
//
|
||||
// создатьБэкапToolStripMenuItem
|
||||
//
|
||||
создатьБэкапToolStripMenuItem.Name = "создатьБэкапToolStripMenuItem";
|
||||
создатьБэкапToolStripMenuItem.Size = new Size(122, 24);
|
||||
создатьБэкапToolStripMenuItem.Text = "Создать бэкап";
|
||||
создатьБэкапToolStripMenuItem.Click += создатьБэкапToolStripMenuItem_Click;
|
||||
//
|
||||
// CreateOrderButton
|
||||
//
|
||||
CreateOrderButton.Location = new Point(728, 28);
|
||||
CreateOrderButton.Location = new Point(832, 37);
|
||||
CreateOrderButton.Margin = new Padding(3, 4, 3, 4);
|
||||
CreateOrderButton.Name = "CreateOrderButton";
|
||||
CreateOrderButton.Size = new Size(125, 33);
|
||||
CreateOrderButton.Size = new Size(143, 44);
|
||||
CreateOrderButton.TabIndex = 2;
|
||||
CreateOrderButton.Text = "Создать заказ";
|
||||
CreateOrderButton.UseVisualStyleBackColor = true;
|
||||
@ -140,9 +157,10 @@
|
||||
//
|
||||
// IssuedOrderButton
|
||||
//
|
||||
IssuedOrderButton.Location = new Point(727, 112);
|
||||
IssuedOrderButton.Location = new Point(831, 149);
|
||||
IssuedOrderButton.Margin = new Padding(3, 4, 3, 4);
|
||||
IssuedOrderButton.Name = "IssuedOrderButton";
|
||||
IssuedOrderButton.Size = new Size(125, 33);
|
||||
IssuedOrderButton.Size = new Size(143, 44);
|
||||
IssuedOrderButton.TabIndex = 5;
|
||||
IssuedOrderButton.Text = "Заказ выдан";
|
||||
IssuedOrderButton.UseVisualStyleBackColor = true;
|
||||
@ -150,9 +168,10 @@
|
||||
//
|
||||
// UpdateListButton
|
||||
//
|
||||
UpdateListButton.Location = new Point(727, 202);
|
||||
UpdateListButton.Location = new Point(831, 269);
|
||||
UpdateListButton.Margin = new Padding(3, 4, 3, 4);
|
||||
UpdateListButton.Name = "UpdateListButton";
|
||||
UpdateListButton.Size = new Size(125, 33);
|
||||
UpdateListButton.Size = new Size(143, 44);
|
||||
UpdateListButton.TabIndex = 6;
|
||||
UpdateListButton.Text = "Обновить список";
|
||||
UpdateListButton.UseVisualStyleBackColor = true;
|
||||
@ -161,31 +180,26 @@
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(0, 27);
|
||||
DataGridView.Location = new Point(0, 36);
|
||||
DataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.RowTemplate.Height = 25;
|
||||
DataGridView.Size = new Size(722, 421);
|
||||
DataGridView.Size = new Size(825, 561);
|
||||
DataGridView.TabIndex = 1;
|
||||
//
|
||||
// почтаToolStripMenuItem
|
||||
//
|
||||
почтаToolStripMenuItem.Name = "почтаToolStripMenuItem";
|
||||
почтаToolStripMenuItem.Size = new Size(53, 20);
|
||||
почтаToolStripMenuItem.Text = "Почта";
|
||||
почтаToolStripMenuItem.Click += почтаToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(865, 450);
|
||||
ClientSize = new Size(989, 600);
|
||||
Controls.Add(UpdateListButton);
|
||||
Controls.Add(IssuedOrderButton);
|
||||
Controls.Add(CreateOrderButton);
|
||||
Controls.Add(DataGridView);
|
||||
Controls.Add(MenuStrip);
|
||||
MainMenuStrip = MenuStrip;
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormMain";
|
||||
Text = "Ремонт сантехники";
|
||||
Load += FormMain_Load;
|
||||
@ -200,7 +214,7 @@
|
||||
|
||||
private MenuStrip MenuStrip;
|
||||
private ToolStripMenuItem СправочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem РаботыToolStripMenuItem;
|
||||
private ToolStripMenuItem ИзделияToolStripMenuItem;
|
||||
private ToolStripMenuItem КомпонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem КлиентыToolStripMenuItem;
|
||||
private Button CreateOrderButton;
|
||||
@ -213,6 +227,7 @@
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||
private DataGridView DataGridView;
|
||||
private ToolStripMenuItem почтаToolStripMenuItem;
|
||||
private ToolStripMenuItem письмаToolStripMenuItem;
|
||||
private ToolStripMenuItem создатьБэкапToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PlumbingRepairBusinessLogic.BusinessLogic;
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||
using PlumbingRepairDataModels.Enums;
|
||||
using System.Windows.Forms;
|
||||
using PlumbingRepairContracts.DI;
|
||||
|
||||
namespace PlumbingRepair
|
||||
{
|
||||
@ -14,13 +12,15 @@ namespace PlumbingRepair
|
||||
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly IWorkProcess _workProcess;
|
||||
public FormMain(ILogger<FormMain> logger, IWorkProcess workProcess, IOrderLogic orderLogic, IReportLogic reportLogic)
|
||||
private readonly IBackUpLogic _backUpLogic;
|
||||
public FormMain(ILogger<FormMain> logger, IBackUpLogic backUpLogic, IWorkProcess workProcess, IOrderLogic orderLogic, IReportLogic reportLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
_backUpLogic = backUpLogic;
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
@ -34,16 +34,7 @@ namespace PlumbingRepair
|
||||
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
DataGridView.DataSource = list;
|
||||
DataGridView.Columns["WorkId"].Visible = false;
|
||||
DataGridView.Columns["ClientId"].Visible = false;
|
||||
DataGridView.Columns["ImplementerId"].Visible = false;
|
||||
}
|
||||
|
||||
DataGridView.FillandConfigGrid(_orderLogic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -55,41 +46,26 @@ namespace PlumbingRepair
|
||||
|
||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormComponents>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void РаботыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorks));
|
||||
|
||||
if (service is FormWorks form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormWorks>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void КлиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormClients>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void IssuedOrderButton_Click(object sender, EventArgs e)
|
||||
@ -142,44 +118,55 @@ namespace PlumbingRepair
|
||||
|
||||
private void WorkComponentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportWorkComponents));
|
||||
if (service is FormReportWorkComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormReportWorkComponents>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||
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(FormImplementers));
|
||||
|
||||
if (service is FormImplementers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void почтаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void письмаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMails));
|
||||
if (service is FormMails form)
|
||||
var form = DependencyManager.Instance.Resolve<FormMails>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void создатьБэкапToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
form.ShowDialog();
|
||||
if (_backUpLogic != null)
|
||||
{
|
||||
var fbd = new FolderBrowserDialog();
|
||||
if (fbd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_backUpLogic.CreateBackUp(new BackUpSaveBindingModel
|
||||
{
|
||||
FolderName = fbd.SelectedPath
|
||||
});
|
||||
MessageBox.Show("Бекап создан", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,64 +1,4 @@
|
||||
<?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.
|
||||
-->
|
||||
<root>
|
||||
<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">
|
||||
|
@ -62,7 +62,7 @@
|
||||
// work
|
||||
//
|
||||
this.work.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.work.HeaderText = "Работа";
|
||||
this.work.HeaderText = "Изделие";
|
||||
this.work.Name = "work";
|
||||
//
|
||||
// component
|
||||
@ -83,7 +83,7 @@
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Name = "FormReportWorkComponents";
|
||||
this.Text = "Работы по компонентам";
|
||||
this.Text = "Изделия по компонентам";
|
||||
this.Load += new System.EventHandler(this.FormReportWorkComponents_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -32,13 +32,13 @@ namespace PlumbingRepair
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
_logger.LogInformation("Сохранение списка Работ по компонентам");
|
||||
_logger.LogInformation("Сохранение списка изделий по компонентам");
|
||||
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка Работ по компонентам");
|
||||
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
@ -65,11 +65,11 @@ namespace PlumbingRepair
|
||||
dataGridView.Rows.Add(Array.Empty<object>());
|
||||
}
|
||||
}
|
||||
_logger.LogInformation("Загрузки списка Работ по компонентам");
|
||||
_logger.LogInformation("Загрузки списка изделий по компонентам");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка Работ по компонентам");
|
||||
_logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
2
PlumbingRepair/FormWork.Designer.cs
generated
2
PlumbingRepair/FormWork.Designer.cs
generated
@ -223,7 +223,7 @@
|
||||
this.Controls.Add(this.PriceLabel);
|
||||
this.Controls.Add(this.WorkNameLabel);
|
||||
this.Name = "FormWork";
|
||||
this.Text = "Работа";
|
||||
this.Text = "Изделие";
|
||||
this.ComponentsGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -4,6 +4,7 @@ using PlumbingRepairContracts.SearchModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Windows.Forms;
|
||||
using PlumbingRepairContracts.DI;
|
||||
|
||||
namespace PlumbingRepair
|
||||
{
|
||||
@ -29,7 +30,7 @@ namespace PlumbingRepair
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка Работы");
|
||||
_logger.LogInformation("Загрузка изделия");
|
||||
|
||||
try
|
||||
{
|
||||
@ -48,14 +49,14 @@ namespace PlumbingRepair
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки Работы");
|
||||
_logger.LogError(ex, "Ошибка загрузки изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка компонент Работы");
|
||||
_logger.LogInformation("Загрузка компонент изделия");
|
||||
|
||||
try
|
||||
{
|
||||
@ -71,37 +72,33 @@ namespace PlumbingRepair
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонент Работы");
|
||||
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorkComponent));
|
||||
|
||||
if (service is FormWorkComponent form)
|
||||
{
|
||||
var form = DependencyManager.Instance.Resolve<FormWorkComponent>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
|
||||
if (_workComponents.ContainsKey(form.Id))
|
||||
{
|
||||
_workComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
_workComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
||||
}
|
||||
|
||||
LoadData();
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
|
||||
if (_workComponents.ContainsKey(form.Id))
|
||||
{
|
||||
_workComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
_workComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,25 +106,21 @@ namespace PlumbingRepair
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorkComponent));
|
||||
var form = DependencyManager.Instance.Resolve<FormWorkComponent>();
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _workComponents[id].Item2;
|
||||
|
||||
if (service is FormWorkComponent form)
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _workComponents[id].Item2;
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
_workComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
LoadData();
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
_workComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,7 +171,7 @@ namespace PlumbingRepair
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Сохранение Работы");
|
||||
_logger.LogInformation("Сохранение изделия");
|
||||
|
||||
try
|
||||
{
|
||||
@ -203,7 +196,7 @@ namespace PlumbingRepair
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения Работы");
|
||||
_logger.LogError(ex, "Ошибка сохранения изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
2
PlumbingRepair/FormWorkComponent.Designer.cs
generated
2
PlumbingRepair/FormWorkComponent.Designer.cs
generated
@ -106,7 +106,7 @@
|
||||
this.Controls.Add(this.ComponentSelectLabel);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormWorkComponent";
|
||||
this.Text = "Компонент Работы";
|
||||
this.Text = "Компонент изделия";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
2
PlumbingRepair/FormWorks.Designer.cs
generated
2
PlumbingRepair/FormWorks.Designer.cs
generated
@ -103,7 +103,7 @@
|
||||
this.Controls.Add(this.DataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormWorks";
|
||||
this.Text = "Работы";
|
||||
this.Text = "Изделия";
|
||||
this.Load += new System.EventHandler(this.FormComponents_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||
using PlumbingRepairContracts.DI;
|
||||
|
||||
namespace PlumbingRepair
|
||||
{
|
||||
@ -25,52 +26,34 @@ namespace PlumbingRepair
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
DataGridView.DataSource = list;
|
||||
DataGridView.Columns["Id"].Visible = false;
|
||||
DataGridView.Columns["WorkName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["WorkComponents"].Visible = false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка Работ");
|
||||
DataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка изделий");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки Работ");
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWork));
|
||||
|
||||
if (service is FormWork form)
|
||||
var form = DependencyManager.Instance.Resolve<FormWork>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private void ChangeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWork));
|
||||
|
||||
if (service is FormWork form)
|
||||
var form = DependencyManager.Instance.Resolve<FormWork>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -81,7 +64,7 @@ namespace PlumbingRepair
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление Работы");
|
||||
_logger.LogInformation("Удаление изделия");
|
||||
|
||||
try
|
||||
{
|
||||
@ -97,7 +80,7 @@ namespace PlumbingRepair
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления Работы");
|
||||
_logger.LogError(ex, "Ошибка удаления изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PlumbingRepairBusinessLogic\PlumbingRepairBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\PlumbingRepairContracts\PlumbingRepairContracts.csproj" />
|
||||
<ProjectReference Include="..\PlumbingRepairDatabaseImplement\PlumbingRepairDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\PlumbingRepairListImplement\PlumbingRepairListImplement.csproj" />
|
||||
<ProjectReference Include="..\PlumpingRepairFileImplement\PlumbingRepairFileImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -1,7 +1,4 @@
|
||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||
using PlumbingRepairContracts.StoragesContracts;
|
||||
using PlumbingRepairDatabaseImplement.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using PlumbingRepairBusinessLogic.BusinessLogic;
|
||||
@ -9,28 +6,23 @@ using PlumbingRepairBusinessLogic.OfficePackage;
|
||||
using PlumbingRepairBusinessLogic.OfficePackage.Implements;
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairBusinessLogic.MailWorker;
|
||||
using PlumbingRepairContracts.DI;
|
||||
|
||||
namespace PlumbingRepair
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <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();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
InitDependency();
|
||||
|
||||
try
|
||||
{
|
||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
||||
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||
@ -45,51 +37,51 @@ namespace PlumbingRepair
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var logger = _serviceProvider.GetService<ILogger>();
|
||||
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||
logger?.LogError(ex, "Error");
|
||||
}
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
private static void InitDependency()
|
||||
{
|
||||
DependencyManager.InitDependency();
|
||||
DependencyManager.Instance.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IWorkStorage, WorkStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IWorkLogic, WorkLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
services.AddTransient<FormComponents>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormWork>();
|
||||
services.AddTransient<FormWorkComponent>();
|
||||
services.AddTransient<FormWorks>();
|
||||
services.AddTransient<FormReportWorkComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormClients>();
|
||||
services.AddTransient<FormImplementer>();
|
||||
services.AddTransient<FormImplementers>();
|
||||
services.AddTransient<FormMails>();
|
||||
|
||||
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||
DependencyManager.Instance.RegisterType<IWorkLogic, WorkLogic>();
|
||||
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||
|
||||
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
||||
DependencyManager.Instance.RegisterType<FormMain>();
|
||||
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||
DependencyManager.Instance.RegisterType<FormWork>();
|
||||
DependencyManager.Instance.RegisterType<FormWorkComponent>();
|
||||
DependencyManager.Instance.RegisterType<FormWorks>();
|
||||
DependencyManager.Instance.RegisterType<FormReportWorkComponents>();
|
||||
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||
DependencyManager.Instance.RegisterType<FormClients>();
|
||||
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||
DependencyManager.Instance.RegisterType<FormMails>();
|
||||
}
|
||||
|
||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||
}
|
||||
}
|
@ -212,7 +212,7 @@
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Работа</Value>
|
||||
<Value>Изделие</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
|
112
PlumbingRepairBusinessLogic/BusinessLogic/BackUpLogic.cs
Normal file
112
PlumbingRepairBusinessLogic/BusinessLogic/BackUpLogic.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||
using PlumbingRepairContracts.StoragesContracts;
|
||||
using PlumbingRepairDataModels;
|
||||
using System.IO.Compression;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Json;
|
||||
|
||||
namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
{
|
||||
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(BackUpSaveBindingModel 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,45 +9,45 @@ using PlumbingRepairBusinessLogic.MailWorker;
|
||||
|
||||
namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
private readonly IClientLogic _clientLogic;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, AbstractMailWorker mailWorker, IClientLogic clientLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_mailWorker = mailWorker;
|
||||
_clientLogic = clientLogic;
|
||||
}
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (model.Status != OrderStatus.Неизвестен)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed. Order status incorrect.");
|
||||
return false;
|
||||
}
|
||||
if (model.Status != OrderStatus.Неизвестен)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed. Order status incorrect.");
|
||||
return false;
|
||||
}
|
||||
|
||||
model.Status = OrderStatus.Принят;
|
||||
model.Status = OrderStatus.Принят;
|
||||
var result = _orderStorage.Insert(model);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
model.Status = OrderStatus.Неизвестен;
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
{
|
||||
model.Status = OrderStatus.Неизвестен;
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
SendOrderMessage(result.ClientId, $"Ремонт сантехники, Заказ №{result.Id}", $"Заказ №{result.Id} от {result.DateCreate} на сумму {result.Sum:0.00} принят");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
|
||||
{
|
||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
@ -108,65 +108,65 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||
}
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||
}
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Выдан);
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, OrderStatus.Готов);
|
||||
}
|
||||
}
|
||||
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("Order. OrderId:{Id}", model?.Id);
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("Order. OrderId:{Id}", model?.Id);
|
||||
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (model.WorkId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.WorkId));
|
||||
}
|
||||
if (model.WorkId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.WorkId));
|
||||
}
|
||||
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
|
||||
}
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
|
||||
}
|
||||
|
||||
if (model.Sum <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
||||
}
|
||||
if (model.Sum <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. WorkId: { WorkId}", model.Id, model.Sum, model.WorkId);
|
||||
}
|
||||
_logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. WorkId: { WorkId}", model.Id, model.Sum, model.WorkId);
|
||||
}
|
||||
|
||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||
{
|
||||
@ -185,4 +185,4 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
_saveToWord.CreateDoc(new WordInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список Работ",
|
||||
Title = "Список изделий",
|
||||
Works = _workStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
@ -85,7 +85,7 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
_saveToExcel.CreateReport(new ExcelInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список Работ",
|
||||
Title = "Список изделий",
|
||||
Works = GetWork()
|
||||
});
|
||||
}
|
||||
|
@ -113,12 +113,12 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
|
||||
if (string.IsNullOrEmpty(model.WorkName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия Работы", nameof(model.WorkName));
|
||||
throw new ArgumentNullException("Нет названия изделия", nameof(model.WorkName));
|
||||
}
|
||||
|
||||
if (model.Price <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена Работы должна быть больше 0", nameof(model.Price));
|
||||
throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Work. WorkName:{WorkName}.Price:{ Cost}. Id: { Id}", model.WorkName, model.Price, model.Id);
|
||||
@ -130,7 +130,7 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Работа с таким названием уже есть");
|
||||
throw new InvalidOperationException("Изделие с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace PlumbingRepairBusinessLogic.OfficePackage
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "2cm", "3cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер", "Дата создания", "Работа", "Статус", "Стоимость" },
|
||||
Texts = new List<string> { "Номер", "Дата создания", "Изделие", "Статус", "Стоимость" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
@ -10,6 +10,7 @@
|
||||
<None Include="Views\Home\Create.cshtml" />
|
||||
<None Include="Views\Home\Enter.cshtml" />
|
||||
<None Include="Views\Home\Index.cshtml" />
|
||||
<None Include="Views\Home\Mails.cshtml" />
|
||||
<None Include="Views\Home\Privacy.cshtml" />
|
||||
<None Include="Views\Home\Register.cshtml" />
|
||||
<None Include="Views\Shared\Error.cshtml" />
|
||||
|
20
PlumbingRepairContracts/Attributes/ColumnAttribute.cs
Normal file
20
PlumbingRepairContracts/Attributes/ColumnAttribute.cs
Normal file
@ -0,0 +1,20 @@
|
||||
namespace PlumbingRepairContracts.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)
|
||||
{
|
||||
Title = title;
|
||||
Visible = visible;
|
||||
Width = width;
|
||||
GridViewAutoSize = gridViewAutoSize;
|
||||
IsUseAutoSize = isUseAutoSize;
|
||||
}
|
||||
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; }
|
||||
}
|
||||
}
|
14
PlumbingRepairContracts/Attributes/GridViewAutoSize.cs
Normal file
14
PlumbingRepairContracts/Attributes/GridViewAutoSize.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace PlumbingRepairContracts.Attributes
|
||||
{
|
||||
public enum GridViewAutoSize
|
||||
{
|
||||
NotSet = 0,
|
||||
None = 1,
|
||||
ColumnHeader = 2,
|
||||
AllCellsExceptHeader = 4,
|
||||
AllCells = 6,
|
||||
DisplayedCellsExceptHeader = 8,
|
||||
DisplayedCells = 10,
|
||||
Fill = 16
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
namespace PlumbingRepairContracts.BindingModels
|
||||
{
|
||||
public class BackUpSaveBindingModel
|
||||
{
|
||||
public string FolderName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -10,5 +10,7 @@ namespace PlumbingRepairContracts.BindingModels
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
public string Body { get; set; } = string.Empty;
|
||||
public DateTime DateDelivery { get; set; }
|
||||
|
||||
public int Id => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
|
||||
namespace PlumbingRepairContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IBackUpLogic
|
||||
{
|
||||
void CreateBackUp(BackUpSaveBindingModel model);
|
||||
}
|
||||
}
|
38
PlumbingRepairContracts/DI/DependencyManager.cs
Normal file
38
PlumbingRepairContracts/DI/DependencyManager.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace PlumbingRepairContracts.DI
|
||||
{
|
||||
public class DependencyManager
|
||||
{
|
||||
private readonly IDependencyContainer _dependencyManager;
|
||||
private static DependencyManager? _manager;
|
||||
private static readonly object _locjObject = new();
|
||||
|
||||
private DependencyManager()
|
||||
{
|
||||
_dependencyManager = new ServiceDependencyContainer();
|
||||
}
|
||||
|
||||
public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } }
|
||||
|
||||
public static void InitDependency()
|
||||
{
|
||||
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
||||
if (ext == null)
|
||||
{
|
||||
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
|
||||
}
|
||||
|
||||
// регистрируем зависимости
|
||||
ext.RegisterServices();
|
||||
}
|
||||
|
||||
public void AddLogging(Action<ILoggingBuilder> configure) => _dependencyManager.AddLogging(configure);
|
||||
|
||||
public void RegisterType<T, U>(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType<T, U>(isSingle);
|
||||
|
||||
public void RegisterType<T>(bool isSingle = false) where T : class => _dependencyManager.RegisterType<T>(isSingle);
|
||||
|
||||
public T Resolve<T>() => _dependencyManager.Resolve<T>();
|
||||
}
|
||||
}
|
12
PlumbingRepairContracts/DI/IDependencyContainer.cs
Normal file
12
PlumbingRepairContracts/DI/IDependencyContainer.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace PlumbingRepairContracts.DI
|
||||
{
|
||||
public interface IDependencyContainer
|
||||
{
|
||||
void AddLogging(Action<ILoggingBuilder> configure);
|
||||
void RegisterType<T, U>(bool isSingle) where U : class, T where T : class;
|
||||
void RegisterType<T>(bool isSingle) where T : class;
|
||||
T Resolve<T>();
|
||||
}
|
||||
}
|
8
PlumbingRepairContracts/DI/IImplementationExtension.cs
Normal file
8
PlumbingRepairContracts/DI/IImplementationExtension.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace PlumbingRepairContracts.DI
|
||||
{
|
||||
public interface IImplementationExtension
|
||||
{
|
||||
public int Priority { get; }
|
||||
public void RegisterServices();
|
||||
}
|
||||
}
|
59
PlumbingRepairContracts/DI/ServiceDependencyContainer.cs
Normal file
59
PlumbingRepairContracts/DI/ServiceDependencyContainer.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace PlumbingRepairContracts.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>()!;
|
||||
}
|
||||
}
|
||||
}
|
52
PlumbingRepairContracts/DI/ServiceProviderLoader.cs
Normal file
52
PlumbingRepairContracts/DI/ServiceProviderLoader.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace PlumbingRepairContracts.DI
|
||||
{
|
||||
public class ServiceProviderLoader
|
||||
{
|
||||
public static IImplementationExtension? GetImplementationExtensions()
|
||||
{
|
||||
IImplementationExtension? source = null;
|
||||
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())
|
||||
{
|
||||
if (t.IsClass && typeof(IImplementationExtension).IsAssignableFrom(t))
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
source = (IImplementationExtension)Activator.CreateInstance(t)!;
|
||||
}
|
||||
else
|
||||
{
|
||||
var newSource = (IImplementationExtension)Activator.CreateInstance(t)!;
|
||||
|
||||
if (newSource.Priority > source.Priority)
|
||||
{
|
||||
source = newSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
38
PlumbingRepairContracts/DI/UnityDependencyContainer.cs
Normal file
38
PlumbingRepairContracts/DI/UnityDependencyContainer.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Unity.Microsoft.Logging;
|
||||
using Unity;
|
||||
|
||||
namespace PlumbingRepairContracts.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);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,12 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PlumbingRepairDataModels\PlumbingRepairDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
8
PlumbingRepairContracts/StoragesContracts/IBackUpInfo.cs
Normal file
8
PlumbingRepairContracts/StoragesContracts/IBackUpInfo.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace PlumbingRepairContracts.StoragesContracts
|
||||
{
|
||||
public interface IBackUpInfo
|
||||
{
|
||||
List<T>? GetList<T>() where T : class, new();
|
||||
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||
}
|
||||
}
|
@ -1,16 +1,18 @@
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using PlumbingRepairContracts.Attributes;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace PlumbingRepairContracts.ViewModels
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("ФИО клиента")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Логин (эл. почта)")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
[Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[Column("Логин (эл. почта)", width: 150)]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Column("Пароль", width: 150)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using PlumbingRepairContracts.Attributes;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace PlumbingRepairContracts.ViewModels
|
||||
{
|
||||
public class ComponentViewModel : IComponentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название компонента")]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Cost { get; set; }
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
[Column("Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
[Column("Цена", width: 80)]
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,24 @@
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using PlumbingRepairContracts.Attributes;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace PlumbingRepairContracts.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: 150)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Стаж работы")]
|
||||
[Column("Стаж работы", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[DisplayName("Квалификация")]
|
||||
[Column("Квалификация", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,28 @@
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using PlumbingRepairContracts.Attributes;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace PlumbingRepairContracts.ViewModels
|
||||
{
|
||||
public class MessageInfoViewModel : IMessageInfoModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
|
||||
[Column(visible: false)]
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
[DisplayName("Имя отправителя")]
|
||||
[Column("Имя отправителя", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата отправления")]
|
||||
[Column("Дата отправления", width: 100)]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
|
||||
[DisplayName("Тема")]
|
||||
[Column("Тема", width: 150)]
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Содержание")]
|
||||
[Column("Содержание", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
[Column(visible: false)]
|
||||
public int Id => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using PlumbingRepairDataModels.Enums;
|
||||
using PlumbingRepairContracts.Attributes;
|
||||
using PlumbingRepairDataModels.Enums;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
@ -6,26 +7,29 @@ namespace PlumbingRepairContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
public int WorkId { get; set; }
|
||||
[DisplayName("Название изделия")]
|
||||
public string WorkName { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Клиент")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[Column("Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int Id { get; set; }
|
||||
[Column(visible: false)]
|
||||
public int WorkId { get; set; }
|
||||
[Column("Название изделия", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public string WorkName { get; set; } = string.Empty;
|
||||
[Column(visible: false)]
|
||||
public int ClientId { get; set; }
|
||||
[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("Количество")]
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Дата выполнения")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
[Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int Count { get; set; }
|
||||
[Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public double Sum { get; set; }
|
||||
[Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[Column("Дата создания", width: 130)]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[Column("Дата выполнения", width: 130)]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,18 @@
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using PlumbingRepairContracts.Attributes;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace PlumbingRepairContracts.ViewModels
|
||||
{
|
||||
public class WorkViewModel : IWorkModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название изделия")]
|
||||
public string WorkName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IComponentModel, int)> WorkComponents { get; set; } = new();
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
[Column("Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string WorkName { get; set; } = string.Empty;
|
||||
[Column("Цена", width: 100)]
|
||||
public double Price { get; set; }
|
||||
[Column(visible: false)]
|
||||
public Dictionary<int, (IComponentModel, int)> WorkComponents { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PlumbingRepairBusinessLogic\PlumbingRepairBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\PlumbingRepairDatabaseImplement\PlumbingRepairDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -12,12 +12,14 @@ namespace PlumbingRepairFileImplement
|
||||
private readonly string WorkFileName = "Work.xml";
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
private readonly string ImplementerFileName = "Implementer.xml";
|
||||
private readonly string MessageFileName = "Message.xml";
|
||||
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Work> Works { get; private set; }
|
||||
public List<Client> Clients { get; private set; }
|
||||
public List<Implementer> Implementers { get; private set; }
|
||||
public List<Message> Messages { get; private set; }
|
||||
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
@ -33,6 +35,7 @@ namespace PlumbingRepairFileImplement
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement);
|
||||
public void SaveMessages() => SaveData(Messages, MessageFileName, "Messages", x => x.GetXElement);
|
||||
|
||||
private DataFileSingleton()
|
||||
{
|
||||
@ -41,6 +44,7 @@ namespace PlumbingRepairFileImplement
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
|
||||
Messages = LoadData(MessageFileName, "Message", x => Message.Create(x)!)!;
|
||||
}
|
||||
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||
|
22
PlumpingRepairFileImplement/FileImplementationExtension.cs
Normal file
22
PlumpingRepairFileImplement/FileImplementationExtension.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using PlumbingRepairContracts.DI;
|
||||
using PlumbingRepairContracts.StoragesContracts;
|
||||
using PlumbingRepairFileImplement.Implements;
|
||||
|
||||
namespace PlumbingRepairFileImplement
|
||||
{
|
||||
public class FileImplementationExtension : IImplementationExtension
|
||||
{
|
||||
public int Priority => 1;
|
||||
|
||||
public void RegisterServices()
|
||||
{
|
||||
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||
DependencyManager.Instance.RegisterType<IWorkStorage, WorkStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
||||
}
|
32
PlumpingRepairFileImplement/Implements/BackUpInfo.cs
Normal file
32
PlumpingRepairFileImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using PlumbingRepairContracts.StoragesContracts;
|
||||
|
||||
namespace PlumbingRepairFileImplement.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;
|
||||
}
|
||||
}
|
||||
}
|
52
PlumpingRepairFileImplement/Implements/MessageInfoStorage.cs
Normal file
52
PlumpingRepairFileImplement/Implements/MessageInfoStorage.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.SearchModels;
|
||||
using PlumbingRepairContracts.StoragesContracts;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairFileImplement.Models;
|
||||
|
||||
namespace PlumbingRepairFileImplement.Implements
|
||||
{
|
||||
public class MessageInfoStorage : IMessageInfoStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public MessageInfoStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||
{
|
||||
if (model.MessageId == null)
|
||||
return null;
|
||||
return source.Messages.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||
{
|
||||
if (!model.ClientId.HasValue)
|
||||
return new();
|
||||
return source.Messages
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<MessageInfoViewModel> GetFullList()
|
||||
{
|
||||
return source.Messages
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||
{
|
||||
var newMessage = Message.Create(model);
|
||||
if (newMessage == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Messages.Add(newMessage);
|
||||
source.SaveMessages();
|
||||
return newMessage.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,22 @@
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PlumbingRepairFileImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ClientFIO { get; private set; } = string.Empty;
|
||||
public string Email { get; private set; } = string.Empty;
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
[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)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -1,15 +1,20 @@
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PlumbingRepairFileImplement.Models
|
||||
{
|
||||
public class Component : IComponentModel
|
||||
[DataContract]
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public double Cost { get; set; }
|
||||
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
{
|
||||
|
@ -1,20 +1,23 @@
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PlumbingRepairFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
[DataMember]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public int Qualification { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
|
||||
public static Implementer? Create(ImplementerBindingModel? model)
|
||||
|
80
PlumpingRepairFileImplement/Models/Message.cs
Normal file
80
PlumpingRepairFileImplement/Models/Message.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PlumbingRepairFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Message : IMessageInfoModel
|
||||
{
|
||||
[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 static Message? Create(MessageInfoBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Body = model.Body,
|
||||
Subject = model.Subject,
|
||||
DateDelivery = model.DateDelivery,
|
||||
SenderName = model.SenderName,
|
||||
ClientId = model.ClientId,
|
||||
MessageId = model.MessageId
|
||||
};
|
||||
}
|
||||
|
||||
public static Message? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Body = element.Attribute("Body")!.Value,
|
||||
Subject = element.Attribute("Subject")!.Value,
|
||||
DateDelivery = Convert.ToDateTime(element.Attribute("DateDelivery")!.Value),
|
||||
SenderName = element.Attribute("SenderName")!.Value,
|
||||
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
|
||||
MessageId = element.Attribute("MessageId")!.Value,
|
||||
};
|
||||
}
|
||||
|
||||
public MessageInfoViewModel GetViewModel => new()
|
||||
{
|
||||
Body = Body,
|
||||
Subject = Subject,
|
||||
DateDelivery = DateDelivery,
|
||||
SenderName = SenderName,
|
||||
ClientId = ClientId,
|
||||
MessageId = MessageId
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("MessageInfo",
|
||||
new XAttribute("Subject", Subject),
|
||||
new XAttribute("Body", Body),
|
||||
new XAttribute("ClientId", ClientId.ToString()),
|
||||
new XAttribute("MessageId", MessageId),
|
||||
new XAttribute("SenderName", SenderName),
|
||||
new XAttribute("DateDelivery", DateDelivery.ToString())
|
||||
);
|
||||
|
||||
public int Id => throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -2,22 +2,34 @@
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Enums;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PlumbingRepairFileImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
[DataContract]
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int WorkId { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public int WorkId { get; private set; }
|
||||
[DataMember]
|
||||
public int ClientId { get; private set; }
|
||||
[DataMember]
|
||||
public int? ImplementerId { get; private set; }
|
||||
[DataMember]
|
||||
public string WorkName { get; private set; } = string.Empty;
|
||||
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 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)
|
||||
{
|
||||
@ -47,7 +59,9 @@ namespace PlumbingRepairFileImplement.Models
|
||||
return null;
|
||||
}
|
||||
|
||||
var order = new Order()
|
||||
DateTime.TryParse(element.Element("DateImplement")!.Value, out DateTime dateImpl);
|
||||
|
||||
var order = new Order()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
WorkId = Convert.ToInt32(element.Element("WorkId")!.Value),
|
||||
@ -56,12 +70,10 @@ namespace PlumbingRepairFileImplement.Models
|
||||
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null)
|
||||
};
|
||||
|
||||
DateTime.TryParse(element.Element("DateImplement")!.Value, out DateTime dateImpl);
|
||||
order.DateImplement = dateImpl;
|
||||
Status = (OrderStatus)Convert.ToInt32(element.Element("Status")!.Value),
|
||||
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null),
|
||||
DateImplement = dateImpl
|
||||
};
|
||||
|
||||
return order;
|
||||
}
|
||||
|
@ -1,21 +1,26 @@
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.ViewModels;
|
||||
using PlumbingRepairDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PlumbingRepairFileImplement.Models
|
||||
{
|
||||
public class Work : IWorkModel
|
||||
[DataContract]
|
||||
public class Work : IWorkModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string WorkName { get; private set; } = string.Empty;
|
||||
public double Price { get; private set; }
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public string WorkName { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public double Price { get; private set; }
|
||||
|
||||
public Dictionary<int, int> Components { get; private set; } = new();
|
||||
|
||||
public Dictionary<int, (IComponentModel, int)> _workComponents = null;
|
||||
|
||||
public Dictionary<int, (IComponentModel, int)> WorkComponents
|
||||
[DataMember]
|
||||
public Dictionary<int, (IComponentModel, int)> WorkComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -11,4 +11,8 @@
|
||||
<ProjectReference Include="..\PlumbingRepairDataModels\PlumbingRepairDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user