начал делать
This commit is contained in:
parent
72147f6d7f
commit
53824dd988
46
TravelCompany/TravelCompany/DataGridViewExtension.cs
Normal file
46
TravelCompany/TravelCompany/DataGridViewExtension.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using TravelCompanyContracts.Attributes;
|
||||||
|
|
||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
internal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
31
TravelCompany/TravelCompany/FormMain.Designer.cs
generated
31
TravelCompany/TravelCompany/FormMain.Designer.cs
generated
@ -40,13 +40,14 @@
|
|||||||
компонентыПоПутёвкамToolStripMenuItem = new ToolStripMenuItem();
|
компонентыПоПутёвкамToolStripMenuItem = new ToolStripMenuItem();
|
||||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||||
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
почтаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
buttonTakeOrderInWork = new Button();
|
buttonTakeOrderInWork = new Button();
|
||||||
buttonOrderReady = new Button();
|
buttonOrderReady = new Button();
|
||||||
buttonIssuedOrder = new Button();
|
buttonIssuedOrder = new Button();
|
||||||
buttonRef = new Button();
|
buttonRef = new Button();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
почтаToolStripMenuItem = new ToolStripMenuItem();
|
создатьБекапToolStripMenuItem = new ToolStripMenuItem();
|
||||||
toolStrip1.SuspendLayout();
|
toolStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -54,7 +55,7 @@
|
|||||||
// toolStrip1
|
// toolStrip1
|
||||||
//
|
//
|
||||||
toolStrip1.ImageScalingSize = new Size(20, 20);
|
toolStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, отчетыToolStripMenuItem, запускРаботToolStripMenuItem, почтаToolStripMenuItem });
|
toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, отчетыToolStripMenuItem, запускРаботToolStripMenuItem, почтаToolStripMenuItem, создатьБекапToolStripMenuItem });
|
||||||
toolStrip1.Location = new Point(0, 0);
|
toolStrip1.Location = new Point(0, 0);
|
||||||
toolStrip1.Name = "toolStrip1";
|
toolStrip1.Name = "toolStrip1";
|
||||||
toolStrip1.Size = new Size(969, 25);
|
toolStrip1.Size = new Size(969, 25);
|
||||||
@ -74,28 +75,28 @@
|
|||||||
// компонентыToolStripMenuItem
|
// компонентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||||
компонентыToolStripMenuItem.Size = new Size(180, 22);
|
компонентыToolStripMenuItem.Size = new Size(174, 22);
|
||||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||||
компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
|
компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// ПутёвкиToolStripMenuItem
|
// ПутёвкиToolStripMenuItem
|
||||||
//
|
//
|
||||||
ПутёвкиToolStripMenuItem.Name = "ПутёвкиToolStripMenuItem";
|
ПутёвкиToolStripMenuItem.Name = "ПутёвкиToolStripMenuItem";
|
||||||
ПутёвкиToolStripMenuItem.Size = new Size(180, 22);
|
ПутёвкиToolStripMenuItem.Size = new Size(174, 22);
|
||||||
ПутёвкиToolStripMenuItem.Text = "Туристич. путёвки";
|
ПутёвкиToolStripMenuItem.Text = "Туристич. путёвки";
|
||||||
ПутёвкиToolStripMenuItem.Click += консервыToolStripMenuItem_Click;
|
ПутёвкиToolStripMenuItem.Click += консервыToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// клиентыToolStripMenuItem
|
// клиентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||||
клиентыToolStripMenuItem.Size = new Size(180, 22);
|
клиентыToolStripMenuItem.Size = new Size(174, 22);
|
||||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// исполнителиToolStripMenuItem
|
// исполнителиToolStripMenuItem
|
||||||
//
|
//
|
||||||
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||||
исполнителиToolStripMenuItem.Size = new Size(180, 22);
|
исполнителиToolStripMenuItem.Size = new Size(174, 22);
|
||||||
исполнителиToolStripMenuItem.Text = "Исполнители";
|
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||||
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
|
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
@ -134,6 +135,13 @@
|
|||||||
запускРаботToolStripMenuItem.Text = "Запуск работ";
|
запускРаботToolStripMenuItem.Text = "Запуск работ";
|
||||||
запускРаботToolStripMenuItem.Click += запускРаботToolStripMenuItem_Click;
|
запускРаботToolStripMenuItem.Click += запускРаботToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// почтаToolStripMenuItem
|
||||||
|
//
|
||||||
|
почтаToolStripMenuItem.Name = "почтаToolStripMenuItem";
|
||||||
|
почтаToolStripMenuItem.Size = new Size(53, 25);
|
||||||
|
почтаToolStripMenuItem.Text = "Почта";
|
||||||
|
почтаToolStripMenuItem.Click += почтаToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// buttonCreateOrder
|
// buttonCreateOrder
|
||||||
//
|
//
|
||||||
buttonCreateOrder.Location = new Point(800, 56);
|
buttonCreateOrder.Location = new Point(800, 56);
|
||||||
@ -196,12 +204,12 @@
|
|||||||
dataGridView.Size = new Size(763, 435);
|
dataGridView.Size = new Size(763, 435);
|
||||||
dataGridView.TabIndex = 6;
|
dataGridView.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// почтаToolStripMenuItem
|
// создатьБекапToolStripMenuItem
|
||||||
//
|
//
|
||||||
почтаToolStripMenuItem.Name = "почтаToolStripMenuItem";
|
создатьБекапToolStripMenuItem.Name = "создатьБекапToolStripMenuItem";
|
||||||
почтаToolStripMenuItem.Size = new Size(53, 25);
|
создатьБекапToolStripMenuItem.Size = new Size(97, 25);
|
||||||
почтаToolStripMenuItem.Text = "Почта";
|
создатьБекапToolStripMenuItem.Text = "Создать Бекап";
|
||||||
почтаToolStripMenuItem.Click += почтаToolStripMenuItem_Click;
|
создатьБекапToolStripMenuItem.Click += createBackUpToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
@ -245,5 +253,6 @@
|
|||||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
private ToolStripMenuItem почтаToolStripMenuItem;
|
private ToolStripMenuItem почтаToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem создатьБекапToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using TravelCompanyBusinessLogic.BusinessLogic;
|
using TravelCompanyBusinessLogic.BusinessLogic;
|
||||||
|
using TravelCompanyContracts.DI;
|
||||||
|
|
||||||
namespace TravelCompany.Forms
|
namespace TravelCompany.Forms
|
||||||
{
|
{
|
||||||
@ -20,13 +21,17 @@ namespace TravelCompany.Forms
|
|||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
private readonly IWorkProcess _workProcess;
|
private readonly IWorkProcess _workProcess;
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
private readonly IBackUpLogic _backUpLogic;
|
||||||
|
|
||||||
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
_workProcess = workProcess;
|
_workProcess = workProcess;
|
||||||
|
_backUpLogic = backUpLogic;
|
||||||
|
|
||||||
}
|
}
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -34,53 +39,33 @@ namespace TravelCompany.Forms
|
|||||||
}
|
}
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Загрузка заказов");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _orderLogic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["TravelId"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
|
||||||
dataGridView.Columns["TravelName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
var form = DependencyManager.Instance.Resolve<FormComponents>();
|
||||||
if (service is FormComponents form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
private void консервыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void консервыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormTravels));
|
var form = DependencyManager.Instance.Resolve<FormTravels>();
|
||||||
|
|
||||||
if (service is FormTravels form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||||
if (service is FormCreateOrder form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
|
private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
@ -164,72 +149,71 @@ namespace TravelCompany.Forms
|
|||||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
_reportLogic.SaveTravelsToWordFile(new ReportBindingModel
|
_reportLogic.SaveTravelsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||||
{
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
FileName = dialog.FileName
|
|
||||||
});
|
|
||||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Information);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void компонентыПоПутёвкамToolStripMenuItem_Click(object sender, EventArgs e)
|
private void компонентыПоПутёвкамToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var form = DependencyManager.Instance.Resolve<FormReportTravelComponents>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormReportTravelComponents));
|
|
||||||
if (service is FormReportTravelComponents form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
|
||||||
if (service is FormReportOrders form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var form = DependencyManager.Instance.Resolve<FormClients>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormClients));
|
|
||||||
if (service is FormClients form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic
|
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
|
||||||
)) as IImplementerLogic)!, _orderLogic);
|
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var form = DependencyManager.Instance.Resolve<ImplementersForm>();
|
||||||
Program.ServiceProvider?.GetService(typeof(ImplementersForm));
|
|
||||||
if (service is ImplementersForm form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void почтаToolStripMenuItem_Click(object sender, EventArgs e)
|
private void почтаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var form = DependencyManager.Instance.Resolve<FormViewMail>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormViewMail));
|
|
||||||
if (service is FormViewMail form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createBackUpToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_backUpLogic != null)
|
||||||
|
{
|
||||||
|
var fbd = new FolderBrowserDialog();
|
||||||
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_backUpLogic.CreateBackUp(new BackUpSaveBinidngModel
|
||||||
|
{
|
||||||
|
FolderName = fbd.SelectedPath
|
||||||
|
});
|
||||||
|
MessageBox.Show("Бекап создан", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка создания бэкапа", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,8 @@ using TravelCompanyBusinessLogic.OfficePackage.Implements;
|
|||||||
using TravelCompanyBusinessLogic.OfficePackage;
|
using TravelCompanyBusinessLogic.OfficePackage;
|
||||||
using TravelCompanyBusinessLogic.MailWorker;
|
using TravelCompanyBusinessLogic.MailWorker;
|
||||||
using TravelCompanyContracts.BindingModels;
|
using TravelCompanyContracts.BindingModels;
|
||||||
using IceCreamBusinessLogic.BusinessLogic;
|
using TravelCompanyContracts.DI;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace TravelCompany.Forms
|
namespace TravelCompany.Forms
|
||||||
@ -27,86 +28,69 @@ namespace TravelCompany.Forms
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
var services = new ServiceCollection();
|
InitDependency();
|
||||||
ConfigureServices(services);
|
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mailSender =
|
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
||||||
_serviceProvider.GetService<AbstractMailWorker>();
|
|
||||||
mailSender?.MailConfig(new MailConfigBindingModel
|
mailSender?.MailConfig(new MailConfigBindingModel
|
||||||
{
|
{
|
||||||
MailLogin =
|
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||||
System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ??
|
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
|
||||||
string.Empty,
|
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
|
||||||
MailPassword =
|
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
|
||||||
System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ??
|
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
|
||||||
string.Empty,
|
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
|
||||||
SmtpClientHost =
|
|
||||||
System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ??
|
|
||||||
string.Empty,
|
|
||||||
SmtpClientPort =
|
|
||||||
Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
|
|
||||||
PopHost =
|
|
||||||
System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
|
|
||||||
PopPort =
|
|
||||||
Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
|
|
||||||
});
|
});
|
||||||
// ñîçäàåì òàéìåð
|
|
||||||
var timer = new System.Threading.Timer(new
|
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
||||||
TimerCallback(MailCheck!), null, 0, 100000);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var logger = _serviceProvider.GetService<ILogger>();
|
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||||
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
logger?.LogError(ex, "Mails Problem");
|
||||||
}
|
}
|
||||||
|
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
|
||||||
}
|
}
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void InitDependency()
|
||||||
{
|
{
|
||||||
services.AddLogging(option =>
|
DependencyManager.InitDependency();
|
||||||
|
|
||||||
|
DependencyManager.Instance.AddLogging(option =>
|
||||||
{
|
{
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
|
||||||
services.AddTransient<ITravelStorage, TravelStorage>();
|
|
||||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
|
||||||
|
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<ITravelLogic, TravelLogic>();
|
DependencyManager.Instance.RegisterType<ITravelLogic, TravelLogic>();
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
|
||||||
|
|
||||||
services.AddTransient<FormMain>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<FormComponent>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<FormComponents>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
services.AddTransient<FormCreateOrder>();
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>();
|
||||||
services.AddTransient<FormTravel>();
|
|
||||||
services.AddTransient<FormTravelComponent>();
|
DependencyManager.Instance.RegisterType<FormMain>();
|
||||||
services.AddTransient<FormTravels>();
|
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||||
services.AddTransient<FormReportTravelComponents>();
|
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||||
services.AddTransient<FormReportOrders>();
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
DependencyManager.Instance.RegisterType<FormTravel>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
DependencyManager.Instance.RegisterType<FormTravelComponent>();
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
DependencyManager.Instance.RegisterType<FormTravels>();
|
||||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
DependencyManager.Instance.RegisterType<FormReportTravelComponents>();
|
||||||
services.AddTransient<FormClients>();
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||||
services.AddTransient<ImplementersForm>();
|
DependencyManager.Instance.RegisterType<FormClients>();
|
||||||
services.AddTransient<ImplementerForm>();
|
DependencyManager.Instance.RegisterType<ImplementersForm>();
|
||||||
services.AddTransient<FormViewMail>();
|
DependencyManager.Instance.RegisterType<ImplementerForm>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormViewMail>();
|
||||||
|
|
||||||
}
|
}
|
||||||
private static void MailCheck(object obj) =>
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||||
ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.BusinessLogicsContracts;
|
||||||
|
using TravelCompanyContracts.StoragesContracts;
|
||||||
|
using TravelCompanyDataModels;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization.Json;
|
||||||
|
|
||||||
|
namespace TravelCompanyBusinessLogic.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(BackUpSaveBinidngModel model)
|
||||||
|
{
|
||||||
|
if (_backUpInfo == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Clear folder");
|
||||||
|
var dirInfo = new DirectoryInfo(model.FolderName);
|
||||||
|
if (dirInfo.Exists)
|
||||||
|
{
|
||||||
|
foreach (var file in dirInfo.GetFiles())
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Delete archive");
|
||||||
|
string fileName = $"{model.FolderName}.zip";
|
||||||
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
File.Delete(fileName);
|
||||||
|
}
|
||||||
|
// берем метод для сохранения
|
||||||
|
_logger.LogDebug("Get assembly");
|
||||||
|
var typeIId = typeof(IId);
|
||||||
|
var assembly = typeIId.Assembly;
|
||||||
|
if (assembly == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
||||||
|
}
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
_logger.LogDebug("Find {count} types", types.Length);
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
||||||
|
{
|
||||||
|
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
||||||
|
if (modelType == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
||||||
|
// вызываем метод на выполнение
|
||||||
|
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Create zip and remove folder");
|
||||||
|
// архивируем
|
||||||
|
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
||||||
|
// удаляем папку
|
||||||
|
dirInfo.Delete(true);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveToFile<T>(string folderName) where T : class, new()
|
||||||
|
{
|
||||||
|
var records = _backUpInfo.GetList<T>();
|
||||||
|
if (records == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
||||||
|
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
||||||
|
jsonFormatter.WriteObject(fs, records);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ using TravelCompanyContracts.StoragesContracts;
|
|||||||
using TravelCompanyContracts.ViewModels;
|
using TravelCompanyContracts.ViewModels;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace IceCreamBusinessLogic.BusinessLogic
|
namespace TravelCompanyBusinessLogic.BusinessLogic
|
||||||
{
|
{
|
||||||
public class MessageInfoLogic : IMessageInfoLogic
|
public class MessageInfoLogic : IMessageInfoLogic
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
namespace TravelCompanyContracts.Attributes
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class ColumnAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string Title { get; private set; }
|
||||||
|
|
||||||
|
public bool Visible { get; private set; }
|
||||||
|
|
||||||
|
public int Width { get; private set; }
|
||||||
|
|
||||||
|
public GridViewAutoSize GridViewAutoSize { get; private set; }
|
||||||
|
|
||||||
|
public bool IsUseAutoSize { get; private set; }
|
||||||
|
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
namespace TravelCompanyContracts.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 TravelCompanyContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class BackUpSaveBinidngModel
|
||||||
|
{
|
||||||
|
public string FolderName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -20,5 +20,7 @@ namespace TravelCompanyContracts.BindingModels
|
|||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpLogic
|
||||||
|
{
|
||||||
|
void CreateBackUp(BackUpSaveBinidngModel model);
|
||||||
|
}
|
||||||
|
}
|
61
TravelCompany/TravelCompanyContracts/DI/DependencyManager.cs
Normal file
61
TravelCompany/TravelCompanyContracts/DI/DependencyManager.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.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; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Иницализация библиотек, в которых идут установки зависомстей
|
||||||
|
/// </summary>
|
||||||
|
public static void InitDependency()
|
||||||
|
{
|
||||||
|
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
||||||
|
if (ext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
|
||||||
|
}
|
||||||
|
// регистрируем зависимости
|
||||||
|
ext.RegisterServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация логгера
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configure"></param>
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure) => _dependencyManager.AddLogging(configure);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="U"></typeparam>
|
||||||
|
public void RegisterType<T, U>(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType<T, U>(isSingle);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="U"></typeparam>
|
||||||
|
public void RegisterType<T>(bool isSingle = false) where T : class => _dependencyManager.RegisterType<T>(isSingle);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение класса со всеми зависмостями
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T Resolve<T>() => _dependencyManager.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.DI
|
||||||
|
{
|
||||||
|
public interface IDependencyContainer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация логгера
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configure"></param>
|
||||||
|
void AddLogging(Action<ILoggingBuilder> configure);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="U"></typeparam>
|
||||||
|
/// <param name="isSingle"></param>
|
||||||
|
void RegisterType<T, U>(bool isSingle) where U : class, T where T : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="isSingle"></param>
|
||||||
|
void RegisterType<T>(bool isSingle) where T : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение класса со всеми зависмостями
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
T Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.DI
|
||||||
|
{
|
||||||
|
public interface IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация сервисов
|
||||||
|
/// </summary>
|
||||||
|
public void RegisterServices();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.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>()!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.DI
|
||||||
|
{
|
||||||
|
public class ServiceProviderLoader
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Загрузка всех классов-реализаций IImplementationExtension
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
namespace TravelCompanyContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpInfo
|
||||||
|
{
|
||||||
|
List<T>? GetList<T>() where T : class, new();
|
||||||
|
|
||||||
|
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,19 @@
|
|||||||
using TravelCompanyDataModels.Models;
|
using TravelCompanyDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using TravelCompanyContracts.Attributes;
|
||||||
|
|
||||||
|
|
||||||
namespace TravelCompanyContracts.ViewModels
|
namespace TravelCompanyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ClientViewModel : IClientModel
|
public class ClientViewModel : IClientModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("ФИО клиента")]
|
[Column(title: "ФИО клиента", width: 150)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Логин (эл. почта)")]
|
[Column(title: "Логин (эл. почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,18 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using TravelCompanyContracts.Attributes;
|
||||||
|
|
||||||
|
|
||||||
namespace TravelCompanyContracts.ViewModels
|
namespace TravelCompanyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ComponentViewModel : IComponentModel
|
public class ComponentViewModel : IComponentModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название компонента")]
|
[Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 150)]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,19 +5,22 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using TravelCompanyContracts.Attributes;
|
||||||
|
|
||||||
|
|
||||||
namespace TravelCompanyContracts.ViewModels
|
namespace TravelCompanyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Стаж работы")]
|
[Column(title: "Стаж работы", width: 60)]
|
||||||
public int WorkExperience { get; set; } = 0;
|
public int WorkExperience { get; set; } = 0;
|
||||||
[DisplayName("Квалификация")]
|
[Column(title: "Квалификация", width: 60)]
|
||||||
public int Qualification { get; set; } = 0;
|
public int Qualification { get; set; } = 0;
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 100)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
using TravelCompanyDataModels.Models;
|
using TravelCompanyDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using TravelCompanyContracts.Attributes;
|
||||||
|
|
||||||
|
|
||||||
namespace TravelCompanyContracts.ViewModels
|
namespace TravelCompanyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class MessageInfoViewModel : IMessageInfoModel
|
public class MessageInfoViewModel : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public string MessageId { get; set; } = string.Empty;
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
[Column(title: "Отправитель", width: 150)]
|
||||||
[DisplayName("Отправитель")]
|
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
[Column(title: "Дата письма", width: 120)]
|
||||||
[DisplayName("Дата письма")]
|
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
[Column(title: "Заголовок", width: 120)]
|
||||||
[DisplayName("Заголовок")]
|
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
[DisplayName("Текст")]
|
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,39 +1,36 @@
|
|||||||
using TravelCompanyDataModels;
|
using TravelCompanyDataModels.Enums;
|
||||||
using TravelCompanyDataModels.Enums;
|
|
||||||
using TravelCompanyDataModels.Models;
|
using TravelCompanyDataModels.Models;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using TravelCompanyContracts.Attributes;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TravelCompanyDataModels.Enums;
|
|
||||||
using TravelCompanyDataModels.Models;
|
|
||||||
|
|
||||||
namespace TravelCompanyContracts.ViewModels
|
namespace TravelCompanyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
[DisplayName("Номер")]
|
[Column(title: "Номер", width: 90)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public int TravelId { get; set; }
|
public int TravelId { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ImplementerId { get; set; } = null;
|
public int? ImplementerId { get; set; } = null;
|
||||||
[DisplayName("Клиент")]
|
[Column(title: "Клиент", width: 190)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Путёвка")]
|
[Column(title: "Путёвка", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string TravelName { get; set; } = string.Empty;
|
public string TravelName { get; set; } = string.Empty;
|
||||||
[DisplayName("Исполнитель")]
|
[Column(title: "Исполнитель", width: 150)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Количество")]
|
[Column(title: "Количество", width: 100)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[DisplayName("Сумма")]
|
[Column(title: "Сумма", width: 120)]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
[DisplayName("Статус")]
|
[Column(title: "Статус", width: 70)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
[DisplayName("Дата создания")]
|
[Column(title: "Дата создания", width: 120)]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
[DisplayName("Дата выполнения")]
|
[Column(title: "Дата выполнения", width: 120)]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace TravelCompanyContracts.ViewModels
|
namespace TravelCompanyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ReportOrdersViewModel
|
public class ReportOrdersViewModel
|
||||||
|
@ -5,16 +5,20 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using TravelCompanyContracts.Attributes;
|
||||||
|
|
||||||
|
|
||||||
namespace TravelCompanyContracts.ViewModels
|
namespace TravelCompanyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class TravelViewModel : ITravelModel
|
public class TravelViewModel : ITravelModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название изделия")]
|
[Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string TravelName { get; set; }
|
public string TravelName { get; set; }
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 70)]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public Dictionary<int, (IComponentModel, int)> TravelComponents { get; set; } = new();
|
public Dictionary<int, (IComponentModel, int)> TravelComponents { get; set; } = new();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace TravelCompanyDataModels
|
namespace TravelCompanyDataModels
|
||||||
{
|
{
|
||||||
public interface IImplementerModel
|
public interface IImplementerModel : IId
|
||||||
{
|
{
|
||||||
string ImplementerFIO { get; }
|
string ImplementerFIO { get; }
|
||||||
string Password { get; }
|
string Password { get; }
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace TravelCompanyDataModels.Models
|
namespace TravelCompanyDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IMessageInfoModel
|
public interface IMessageInfoModel : IId
|
||||||
{
|
{
|
||||||
string MessageId { get; }
|
string MessageId { get; }
|
||||||
int? ClientId { get; }
|
int? ClientId { get; }
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
using TravelCompanyContracts.DI;
|
||||||
|
using TravelCompanyContracts.StoragesContracts;
|
||||||
|
using TravelCompanyDatabaseImplement.Implements;
|
||||||
|
|
||||||
|
namespace TravelCompanyDatabaseImplement
|
||||||
|
{
|
||||||
|
public class ImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 3;
|
||||||
|
|
||||||
|
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<ITravelStorage, TravelStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
using TravelCompanyContracts.StoragesContracts;
|
||||||
|
|
||||||
|
namespace TravelCompanyDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
using var context = new TravelCompanyDataBase();
|
||||||
|
return context.Set<T>().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
var assembly = typeof(BackUpInfo).Assembly;
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,20 +5,27 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace TravelCompanyDatabaseImplement.Models
|
namespace TravelCompanyDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
|
|
||||||
public class Client : IClientModel
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
@ -8,16 +8,24 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace TravelCompanyDatabaseImplement.Models
|
namespace TravelCompanyDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Component : IComponentModel
|
public class Component : IComponentModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
[ForeignKey("ComponentId")]
|
[ForeignKey("ComponentId")]
|
||||||
public virtual List<TravelComponent> TravelComponents { get; set; } =
|
public virtual List<TravelComponent> TravelComponents { get; set; } =
|
||||||
new();
|
new();
|
||||||
|
@ -8,18 +8,29 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace TravelCompanyDatabaseImplement.Models
|
namespace TravelCompanyDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int Qualification { get; set; } = 0;
|
public int Qualification { get; set; } = 0;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int WorkExperience { get; set; } = 0;
|
public int WorkExperience { get; set; } = 0;
|
||||||
[ForeignKey("ImplementerId")]
|
[ForeignKey("ImplementerId")]
|
||||||
|
@ -2,22 +2,38 @@
|
|||||||
using TravelCompanyContracts.ViewModels;
|
using TravelCompanyContracts.ViewModels;
|
||||||
using TravelCompanyDataModels.Models;
|
using TravelCompanyDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace TravelCompanyDatabaseImplement.Models
|
namespace TravelCompanyDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
public class MessageInfo : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[NotMapped]
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Key]
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||||
public string MessageId { get; private set; } = string.Empty;
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int? ClientId { get; private set; }
|
public int? ClientId { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public string SenderName { get; private set; } = string.Empty;
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public string Subject { get; private set; } = string.Empty;
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public Client? Client { get; private set; }
|
public Client? Client { get; private set; }
|
||||||
|
@ -5,27 +5,46 @@ using TravelCompanyDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace TravelCompanyDatabaseImplement.Models
|
namespace TravelCompanyDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public OrderStatus Status { get; private set; }
|
public OrderStatus Status { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime DateCreate { get; private set; }
|
public DateTime DateCreate { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int TravelId { get; private set; }
|
public int TravelId { get; private set; }
|
||||||
public virtual Travel Travel { get; private set; }
|
public virtual Travel Travel { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
public virtual Client Client { get; private set; }
|
public virtual Client Client { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerId { get; private set; } = null;
|
public int? ImplementerId { get; private set; } = null;
|
||||||
public virtual Implementer? Implementer { get; private set; }
|
public virtual Implementer? Implementer { get; private set; }
|
||||||
public static Order? Create(TravelCompanyDataBase context, OrderBindingModel model)
|
public static Order? Create(TravelCompanyDataBase context, OrderBindingModel model)
|
||||||
|
@ -8,18 +8,28 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace TravelCompanyDatabaseImplement.Models
|
namespace TravelCompanyDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Travel : ITravelModel
|
public class Travel : ITravelModel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string TravelName { get; set; } = string.Empty;
|
public string TravelName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
private Dictionary<int, (IComponentModel, int)>? _TravelComponents =
|
|
||||||
null;
|
private Dictionary<int, (IComponentModel, int)>? _TravelComponents = null;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Dictionary<int, (IComponentModel, int)> TravelComponents
|
public Dictionary<int, (IComponentModel, int)> TravelComponents
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user