diff --git a/.gitignore b/.gitignore index ca1c7a3..a743e0a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +ImplementationExtensions + # Mono auto generated files mono_crash.* diff --git a/Shipyard/Shipyard/DataGridViewExtension.cs b/Shipyard/Shipyard/DataGridViewExtension.cs new file mode 100644 index 0000000..00fdab4 --- /dev/null +++ b/Shipyard/Shipyard/DataGridViewExtension.cs @@ -0,0 +1,51 @@ +using ShipyardContracts.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardView +{ + internal static class DataGridViewExtension + { + public static void FillAndConfigGrid(this DataGridView grid, List? 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; + } + } + } + } + } +} diff --git a/Shipyard/Shipyard/FormClients.cs b/Shipyard/Shipyard/FormClients.cs index 46f8a93..99e19d9 100644 --- a/Shipyard/Shipyard/FormClients.cs +++ b/Shipyard/Shipyard/FormClients.cs @@ -35,13 +35,7 @@ namespace ShipyardView { try { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } + dataGridView.FillAndConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка клиентов"); } catch (Exception ex) diff --git a/Shipyard/Shipyard/FormDetails.cs b/Shipyard/Shipyard/FormDetails.cs index 63faa96..0bd81ab 100644 --- a/Shipyard/Shipyard/FormDetails.cs +++ b/Shipyard/Shipyard/FormDetails.cs @@ -2,6 +2,7 @@ using Microsoft.VisualBasic.Logging; using ShipyardContracts.BindingModels; using ShipyardContracts.BusinessLogicsContracts; +using ShipyardContracts.DI; using System; using System.Collections.Generic; using System.ComponentModel; @@ -33,13 +34,7 @@ namespace ShipyardView { try { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["DetailName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } + dataGridView.FillAndConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка деталей"); } catch (Exception ex) @@ -51,13 +46,10 @@ namespace ShipyardView private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormDetail)); - if (service is FormDetail form) + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) { - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } + LoadData(); } } @@ -65,14 +57,11 @@ namespace ShipyardView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormDetail)); - if (service is FormDetail form) + var form = DependencyManager.Instance.Resolve(); + 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(); } } } diff --git a/Shipyard/Shipyard/FormImplementers.cs b/Shipyard/Shipyard/FormImplementers.cs index 83903a1..074621a 100644 --- a/Shipyard/Shipyard/FormImplementers.cs +++ b/Shipyard/Shipyard/FormImplementers.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using ShipyardContracts.BindingModels; using ShipyardContracts.BusinessLogicsContracts; +using ShipyardContracts.DI; using System; using System.Collections.Generic; using System.ComponentModel; @@ -32,16 +33,7 @@ namespace ShipyardView { try { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["Password"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["WorkExperience"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["Qualification"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } + dataGridView.FillAndConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка исполнителей"); } catch (Exception ex) @@ -53,13 +45,10 @@ namespace ShipyardView private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); - if (service is FormImplementer form) + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) { - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } + LoadData(); } } @@ -67,14 +56,11 @@ namespace ShipyardView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); - if (service is FormImplementer form) + var form = DependencyManager.Instance.Resolve(); + 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(); } } } diff --git a/Shipyard/Shipyard/FormMails.cs b/Shipyard/Shipyard/FormMails.cs index 2010045..2d08854 100644 --- a/Shipyard/Shipyard/FormMails.cs +++ b/Shipyard/Shipyard/FormMails.cs @@ -28,14 +28,7 @@ namespace ShipyardView { 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) diff --git a/Shipyard/Shipyard/FormMain.Designer.cs b/Shipyard/Shipyard/FormMain.Designer.cs index 594c98a..8ac15d4 100644 --- a/Shipyard/Shipyard/FormMain.Designer.cs +++ b/Shipyard/Shipyard/FormMain.Designer.cs @@ -42,8 +42,9 @@ this.shipsDetailsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.запускаРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.dataGridView = new System.Windows.Forms.DataGridView(); this.письмаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.создатьБекапToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -88,7 +89,8 @@ this.ToolStripMenuItem, this.отчетыToolStripMenuItem, this.запускаРаботToolStripMenuItem, - this.письмаToolStripMenuItem}); + this.письмаToolStripMenuItem, + this.создатьБекапToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(1160, 28); @@ -109,28 +111,28 @@ // ДеталиToolStripMenuItem // this.ДеталиToolStripMenuItem.Name = "ДеталиToolStripMenuItem"; - this.ДеталиToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.ДеталиToolStripMenuItem.Size = new System.Drawing.Size(185, 26); this.ДеталиToolStripMenuItem.Text = "Детали"; this.ДеталиToolStripMenuItem.Click += new System.EventHandler(this.ДеталиToolStripMenuItem_Click); // // КораблиToolStripMenuItem // this.КораблиToolStripMenuItem.Name = "КораблиToolStripMenuItem"; - this.КораблиToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.КораблиToolStripMenuItem.Size = new System.Drawing.Size(185, 26); this.КораблиToolStripMenuItem.Text = "Корабли"; this.КораблиToolStripMenuItem.Click += new System.EventHandler(this.КораблиToolStripMenuItem_Click); // // клиентыToolStripMenuItem // this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; - this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(185, 26); this.клиентыToolStripMenuItem.Text = "Клиенты"; this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.КлиентыToolStripMenuItem_Click); // // исполнителиToolStripMenuItem // this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem"; - this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(185, 26); this.исполнителиToolStripMenuItem.Text = "Исполнители"; this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.ИсполнителиToolStripMenuItem_Click); // @@ -172,6 +174,13 @@ this.запускаРаботToolStripMenuItem.Text = "Запуск работ"; this.запускаРаботToolStripMenuItem.Click += new System.EventHandler(this.ЗапускРаботToolStripMenuItem_Click); // + // письмаToolStripMenuItem + // + this.письмаToolStripMenuItem.Name = "письмаToolStripMenuItem"; + this.письмаToolStripMenuItem.Size = new System.Drawing.Size(77, 24); + this.письмаToolStripMenuItem.Text = "Письма"; + this.письмаToolStripMenuItem.Click += new System.EventHandler(this.письмаToolStripMenuItem_Click); + // // dataGridView // this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; @@ -183,12 +192,12 @@ this.dataGridView.Size = new System.Drawing.Size(933, 446); this.dataGridView.TabIndex = 6; // - // письмаToolStripMenuItem + // создатьБекапToolStripMenuItem // - this.письмаToolStripMenuItem.Name = "письмаToolStripMenuItem"; - this.письмаToolStripMenuItem.Size = new System.Drawing.Size(77, 24); - this.письмаToolStripMenuItem.Text = "Письма"; - this.письмаToolStripMenuItem.Click += new System.EventHandler(this.письмаToolStripMenuItem_Click); + this.создатьБекапToolStripMenuItem.Name = "создатьБекапToolStripMenuItem"; + this.создатьБекапToolStripMenuItem.Size = new System.Drawing.Size(123, 24); + this.создатьБекапToolStripMenuItem.Text = "Создать бекап"; + this.создатьБекапToolStripMenuItem.Click += new System.EventHandler(this.создатьБекапToolStripMenuItem_Click); // // FormMain // @@ -230,5 +239,6 @@ private ToolStripMenuItem исполнителиToolStripMenuItem; private ToolStripMenuItem запускаРаботToolStripMenuItem; private ToolStripMenuItem письмаToolStripMenuItem; + private ToolStripMenuItem создатьБекапToolStripMenuItem; } } \ No newline at end of file diff --git a/Shipyard/Shipyard/FormMain.cs b/Shipyard/Shipyard/FormMain.cs index 40e39df..c53b499 100644 --- a/Shipyard/Shipyard/FormMain.cs +++ b/Shipyard/Shipyard/FormMain.cs @@ -1,6 +1,8 @@ using Microsoft.Extensions.Logging; +using ShipyardBusinessLogic; using ShipyardContracts.BindingModels; using ShipyardContracts.BusinessLogicsContracts; +using ShipyardContracts.DI; using ShipyardDataModels.Enums; using System; using System.Collections.Generic; @@ -20,13 +22,15 @@ namespace ShipyardView private readonly IOrderLogic _orderLogic; private readonly IReportLogic _reportLogic; private readonly IWorkProcess _workProcess; - public FormMain(ILogger logger, IOrderLogic orderLogic,IReportLogic reportlogic, IWorkProcess workProcess) + private readonly IBackUpLogic _backUpLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic,IReportLogic reportlogic, IWorkProcess workProcess, IBackUpLogic backUpLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; _reportLogic = reportlogic; _workProcess = workProcess; + _backUpLogic = backUpLogic; } private void FormMain_Load(object sender, EventArgs e) @@ -38,14 +42,7 @@ namespace ShipyardView _logger.LogInformation("Загрузка заказов"); try { - var list = _orderLogic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["ShipId"].Visible = false; - dataGridView.Columns["ClientId"].Visible = false; - dataGridView.Columns["ImplementerId"].Visible = false; - } + dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null)); _logger.LogInformation("Загрузка заказов"); } catch (Exception ex) @@ -57,30 +54,21 @@ namespace ShipyardView private void ДеталиToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormDetails)); - if (service is FormDetails form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void КораблиToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormShips)); - if (service is FormShips form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void ButtonCreateOrder_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(); + form.ShowDialog(); + LoadData(); } private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) @@ -172,44 +160,32 @@ namespace ShipyardView private void shipDetailsToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormReportShipDetails)); - if (service is FormReportShipDetails form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + 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(); + 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(); + form.ShowDialog(); } 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(); + form.ShowDialog(); } private void ЗапускРаботToolStripMenuItem_Click(object sender, EventArgs e) { _workProcess.DoWork(( - Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, + DependencyManager.Instance.Resolve())!, _orderLogic); MessageBox.Show("Передано на работу","произведен запуск", MessageBoxButtons.OK, MessageBoxIcon.Information); @@ -217,11 +193,34 @@ namespace ShipyardView 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(); + 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 BackUpSaveBinidngModel + { + FolderName = fbd.SelectedPath + }); + MessageBox.Show("Бекап создан", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } } } diff --git a/Shipyard/Shipyard/FormShip.cs b/Shipyard/Shipyard/FormShip.cs index 0bf1f1f..52c5e68 100644 --- a/Shipyard/Shipyard/FormShip.cs +++ b/Shipyard/Shipyard/FormShip.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using ShipyardContracts.BindingModels; using ShipyardContracts.BusinessLogicsContracts; +using ShipyardContracts.DI; using ShipyardContracts.SearchModels; using ShipyardDataModels.Models; using System; @@ -81,26 +82,23 @@ namespace ShipyardView private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormShipDetail)); - if (service is FormShipDetail form) + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) { - if (form.ShowDialog() == DialogResult.OK) + if (form.DetailModel == null) { - if (form.DetailModel == null) - { - return; - } - _logger.LogInformation("Добавление нового детали:{ DetailName} - { Count}", form.DetailModel.DetailName, form.Count); - if (_shipDetails.ContainsKey(form.Id)) - { - _shipDetails[form.Id] = (form.DetailModel,form.Count); - } - else - { - _shipDetails.Add(form.Id, (form.DetailModel,form.Count)); - } - LoadData(); + return; } + _logger.LogInformation("Добавление нового детали:{ DetailName} - { Count}", form.DetailModel.DetailName, form.Count); + if (_shipDetails.ContainsKey(form.Id)) + { + _shipDetails[form.Id] = (form.DetailModel,form.Count); + } + else + { + _shipDetails.Add(form.Id, (form.DetailModel,form.Count)); + } + LoadData(); } } @@ -108,22 +106,19 @@ namespace ShipyardView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormShipDetail)); - if (service is FormShipDetail form) + var form = DependencyManager.Instance.Resolve(); + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _shipDetails[id].Item2; + if (form.ShowDialog() == DialogResult.OK) { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); - form.Id = id; - form.Count = _shipDetails[id].Item2; - if (form.ShowDialog() == DialogResult.OK) + if (form.DetailModel == null) { - if (form.DetailModel == null) - { - return; - } - _logger.LogInformation("Изменение детали: { DetailName} - { Count}", form.DetailModel.DetailName, form.Count); - _shipDetails[form.Id] = (form.DetailModel,form.Count); - LoadData(); + return; } + _logger.LogInformation("Изменение детали: { DetailName} - { Count}", form.DetailModel.DetailName, form.Count); + _shipDetails[form.Id] = (form.DetailModel,form.Count); + LoadData(); } } } diff --git a/Shipyard/Shipyard/FormShips.cs b/Shipyard/Shipyard/FormShips.cs index 4b04caf..d774bb1 100644 --- a/Shipyard/Shipyard/FormShips.cs +++ b/Shipyard/Shipyard/FormShips.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using ShipyardContracts.BindingModels; using ShipyardContracts.BusinessLogicsContracts; +using ShipyardContracts.DI; using System; using System.Collections.Generic; using System.ComponentModel; @@ -32,14 +33,7 @@ namespace ShipyardView { try { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ShipName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["ShipDetails"].Visible = false; - } + dataGridView.FillAndConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка кораблей"); } catch (Exception ex) @@ -51,13 +45,10 @@ namespace ShipyardView private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormShip)); - if (service is FormShip form) + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) { - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } + LoadData(); } } @@ -65,14 +56,11 @@ namespace ShipyardView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormShip)); - if (service is FormShip form) + var form = DependencyManager.Instance.Resolve(); + 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(); } } } diff --git a/Shipyard/Shipyard/Program.cs b/Shipyard/Shipyard/Program.cs index bc00fda..3f4e070 100644 --- a/Shipyard/Shipyard/Program.cs +++ b/Shipyard/Shipyard/Program.cs @@ -5,17 +5,15 @@ using ShipyardBusinessLogic.BusinessLogics; using ShipyardBusinessLogic.OfficePackage.Implements; using ShipyardBusinessLogic.OfficePackage; using ShipyardContracts.BusinessLogicsContracts; -using ShipyardContracts.StoragesContracts; -using ShipyardDataBaseImplement.Implements; using ShipyardBusinessLogic.MailWorker; using ShipyardContracts.BindingModels; +using ShipyardBusinessLogic; +using ShipyardContracts.DI; namespace ShipyardView { internal static class Program { - private static ServiceProvider? _serviceProvider; - public static ServiceProvider? ServiceProvider => _serviceProvider; /// /// The main entry point for the application. /// @@ -26,12 +24,10 @@ namespace ShipyardView // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - var services = new ServiceCollection(); - ConfigureServices(services); - _serviceProvider = services.BuildServiceProvider(); + InitDependency(); try { - var mailSender = _serviceProvider.GetService(); + var mailSender = DependencyManager.Instance.Resolve(); mailSender?.MailConfig(new MailConfigBindingModel { MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty, @@ -46,56 +42,52 @@ namespace ShipyardView } catch (Exception ex) { - var logger = _serviceProvider.GetService(); + var logger = DependencyManager.Instance.Resolve(); logger?.LogError(ex, " "); } - Application.Run(_serviceProvider.GetRequiredService()); + Application.Run(DependencyManager.Instance.Resolve()); } - private static void ConfigureServices(ServiceCollection services) + private static void InitDependency() { - services.AddLogging(option => + DependencyManager.InitDependency(); + + DependencyManager.Instance.AddLogging(option => { option.SetMinimumLevel(LogLevel.Information); option.AddNLog("nlog.config"); }); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(true); + DependencyManager.Instance.RegisterType(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddSingleton(); - - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); } - private static void MailCheck(object obj) => ServiceProvider?.GetService()?.MailCheck(); + private static void MailCheck(object obj) => DependencyManager.Instance?.Resolve()?.MailCheck(); } diff --git a/Shipyard/ShipyardBusinessLogic/BackUpLogic.cs b/Shipyard/ShipyardBusinessLogic/BackUpLogic.cs new file mode 100644 index 0000000..fec2360 --- /dev/null +++ b/Shipyard/ShipyardBusinessLogic/BackUpLogic.cs @@ -0,0 +1,103 @@ +using Microsoft.Extensions.Logging; +using ShipyardContracts.BindingModels; +using ShipyardContracts.BusinessLogicsContracts; +using ShipyardContracts.StoragesContracts; +using ShipyardDataModels; +using System; +using System.Collections.Generic; +using System.IO.Compression; +using System.Linq; +using System.Reflection; +using System.Runtime.Serialization.Json; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardBusinessLogic +{ + public class BackUpLogic : IBackUpLogic + { + private readonly ILogger _logger; + + private readonly IBackUpInfo _backUpInfo; + + public BackUpLogic(ILogger 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(string folderName) where T : class, new() + { + var records = _backUpInfo.GetList(); + if (records == null) + { + _logger.LogWarning("{type} type get null list", typeof(T).Name); + return; + } + var jsonFormatter = new DataContractJsonSerializer(typeof(List)); + using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate); + jsonFormatter.WriteObject(fs, records); + } + } +} diff --git a/Shipyard/ShipyardContracts/Attributes/ColumnAttribute.cs b/Shipyard/ShipyardContracts/Attributes/ColumnAttribute.cs new file mode 100644 index 0000000..b799c0f --- /dev/null +++ b/Shipyard/ShipyardContracts/Attributes/ColumnAttribute.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardContracts.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; + } + } +} diff --git a/Shipyard/ShipyardContracts/Attributes/GridViewAutoSize.cs b/Shipyard/ShipyardContracts/Attributes/GridViewAutoSize.cs new file mode 100644 index 0000000..e27b49e --- /dev/null +++ b/Shipyard/ShipyardContracts/Attributes/GridViewAutoSize.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardContracts.Attributes +{ + public enum GridViewAutoSize + { + NotSet = 0, + + None = 1, + + ColumnHeader = 2, + + AllCellsExceptHeader = 4, + + AllCells = 6, + + DisplayedCellsExceptHeader = 8, + + DisplayedCells = 10, + + Fill = 16 + } +} diff --git a/Shipyard/ShipyardContracts/BindingModels/BackUpSaveBinidngModel.cs b/Shipyard/ShipyardContracts/BindingModels/BackUpSaveBinidngModel.cs new file mode 100644 index 0000000..e8b0b8d --- /dev/null +++ b/Shipyard/ShipyardContracts/BindingModels/BackUpSaveBinidngModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardContracts.BindingModels +{ + public class BackUpSaveBinidngModel + { + public string FolderName { get; set; } = string.Empty; + } +} diff --git a/Shipyard/ShipyardContracts/BindingModels/MessageInfoBindingModel.cs b/Shipyard/ShipyardContracts/BindingModels/MessageInfoBindingModel.cs index 8a0e5f1..ce103c7 100644 --- a/Shipyard/ShipyardContracts/BindingModels/MessageInfoBindingModel.cs +++ b/Shipyard/ShipyardContracts/BindingModels/MessageInfoBindingModel.cs @@ -20,5 +20,6 @@ namespace ShipyardContracts.BindingModels public string Body { get; set; } = string.Empty; public DateTime DateDelivery { get; set; } + public int Id => throw new NotImplementedException(); } } diff --git a/Shipyard/ShipyardContracts/BusinessLogicsContracts/IBackUpLogic.cs b/Shipyard/ShipyardContracts/BusinessLogicsContracts/IBackUpLogic.cs new file mode 100644 index 0000000..26bd2a2 --- /dev/null +++ b/Shipyard/ShipyardContracts/BusinessLogicsContracts/IBackUpLogic.cs @@ -0,0 +1,14 @@ +using ShipyardContracts.BindingModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardContracts.BusinessLogicsContracts +{ + public interface IBackUpLogic + { + void CreateBackUp(BackUpSaveBinidngModel model); + } +} diff --git a/Shipyard/ShipyardContracts/DI/DependencyManager.cs b/Shipyard/ShipyardContracts/DI/DependencyManager.cs new file mode 100644 index 0000000..daec9d0 --- /dev/null +++ b/Shipyard/ShipyardContracts/DI/DependencyManager.cs @@ -0,0 +1,66 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardContracts.DI +{ + public class DependencyManager + { + private readonly IDependencyContainer _dependencyManager; + + private static DependencyManager? _manager; + + private static readonly object _locjObject = new(); + + private DependencyManager() + { + _dependencyManager = new UnityDependencyContainer(); + } + + public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } } + + /// + /// Иницализация библиотек, в которых идут установки зависомстей + /// + public static void InitDependency() + { + var ext = ServiceProviderLoader.GetImplementationExtensions(); + if (ext == null) + { + throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям"); + } + // регистрируем зависимости + ext.RegisterServices(); + } + + /// + /// Регистрация логгера + /// + /// + public void AddLogging(Action configure) => _dependencyManager.AddLogging(configure); + + /// + /// Добавление зависимости + /// + /// + /// + public void RegisterType(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType(isSingle); + + /// + /// Добавление зависимости + /// + /// + /// + public void RegisterType(bool isSingle = false) where T : class => _dependencyManager.RegisterType(isSingle); + + /// + /// Получение класса со всеми зависмостями + /// + /// + /// + public T Resolve() => _dependencyManager.Resolve(); + } +} diff --git a/Shipyard/ShipyardContracts/DI/IDependencyContainer.cs b/Shipyard/ShipyardContracts/DI/IDependencyContainer.cs new file mode 100644 index 0000000..9b98d42 --- /dev/null +++ b/Shipyard/ShipyardContracts/DI/IDependencyContainer.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardContracts.DI +{ + public interface IDependencyContainer + { + /// + /// Регистрация логгера + /// + /// + void AddLogging(Action configure); + + /// + /// Добавление зависимости + /// + /// + /// + /// + void RegisterType(bool isSingle) where U : class, T where T : class; + + /// + /// Добавление зависимости + /// + /// + /// + void RegisterType(bool isSingle) where T : class; + + /// + /// Получение класса со всеми зависмостями + /// + /// + /// + T Resolve(); + } +} diff --git a/Shipyard/ShipyardContracts/DI/IImplementationExtension.cs b/Shipyard/ShipyardContracts/DI/IImplementationExtension.cs new file mode 100644 index 0000000..cedf2a4 --- /dev/null +++ b/Shipyard/ShipyardContracts/DI/IImplementationExtension.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardContracts.DI +{ + public interface IImplementationExtension + { + public int Priority { get; } + /// + /// Регистрация сервисов + /// + public void RegisterServices(); + } +} diff --git a/Shipyard/ShipyardContracts/DI/ServiceDependencyContainer.cs b/Shipyard/ShipyardContracts/DI/ServiceDependencyContainer.cs new file mode 100644 index 0000000..f910fc8 --- /dev/null +++ b/Shipyard/ShipyardContracts/DI/ServiceDependencyContainer.cs @@ -0,0 +1,62 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardContracts.DI +{ + public class ServiceDependencyContainer : IDependencyContainer + { + private ServiceProvider? _serviceProvider; + + private readonly ServiceCollection _serviceCollection; + + public ServiceDependencyContainer() + { + _serviceCollection = new ServiceCollection(); + } + + public void AddLogging(Action configure) + { + _serviceCollection.AddLogging(configure); + } + + public void RegisterType(bool isSingle) where U : class, T where T : class + { + if (isSingle) + { + _serviceCollection.AddSingleton(); + } + else + { + _serviceCollection.AddTransient(); + } + _serviceProvider = null; + } + + public void RegisterType(bool isSingle) where T : class + { + if (isSingle) + { + _serviceCollection.AddSingleton(); + } + else + { + _serviceCollection.AddTransient(); + } + _serviceProvider = null; + } + + public T Resolve() + { + if (_serviceProvider == null) + { + _serviceProvider = _serviceCollection.BuildServiceProvider(); + } + return _serviceProvider.GetService()!; + } + } +} diff --git a/Shipyard/ShipyardContracts/DI/ServiceProviderLoader.cs b/Shipyard/ShipyardContracts/DI/ServiceProviderLoader.cs new file mode 100644 index 0000000..3b57b4a --- /dev/null +++ b/Shipyard/ShipyardContracts/DI/ServiceProviderLoader.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardContracts.DI +{ + public class ServiceProviderLoader + { + /// + /// Загрузка всех классов-реализаций IImplementationExtension + /// + /// + 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"; + } + } +} diff --git a/Shipyard/ShipyardContracts/DI/UnityDependencyContainer.cs b/Shipyard/ShipyardContracts/DI/UnityDependencyContainer.cs new file mode 100644 index 0000000..b9213f7 --- /dev/null +++ b/Shipyard/ShipyardContracts/DI/UnityDependencyContainer.cs @@ -0,0 +1,38 @@ +using Microsoft.Extensions.Logging; +using Unity.Microsoft.Logging; +using Unity; + +namespace ShipyardContracts.DI +{ + public class UnityDependencyContainer : IDependencyContainer + { + private readonly IUnityContainer _container; + + public UnityDependencyContainer() + { + _container = new UnityContainer(); + } + + public void AddLogging(Action configure) + { + var factory = LoggerFactory.Create(configure); + _container.AddExtension(new LoggingExtension(factory)); + } + + public void RegisterType(bool isSingle) where T : class + { + _container.RegisterType(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient); + + } + + public T Resolve() + { + return _container.Resolve(); + } + + void IDependencyContainer.RegisterType(bool isSingle) + { + _container.RegisterType(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient); + } + } +} diff --git a/Shipyard/ShipyardContracts/ShipyardContracts.csproj b/Shipyard/ShipyardContracts/ShipyardContracts.csproj index 45e1102..3acdfe9 100644 --- a/Shipyard/ShipyardContracts/ShipyardContracts.csproj +++ b/Shipyard/ShipyardContracts/ShipyardContracts.csproj @@ -16,6 +16,8 @@ + + diff --git a/Shipyard/ShipyardContracts/StoragesContracts/IBackUpInfo.cs b/Shipyard/ShipyardContracts/StoragesContracts/IBackUpInfo.cs new file mode 100644 index 0000000..2083567 --- /dev/null +++ b/Shipyard/ShipyardContracts/StoragesContracts/IBackUpInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardContracts.StoragesContracts +{ + public interface IBackUpInfo + { + List? GetList() where T : class, new(); + + Type? GetTypeByModelInterface(string modelInterfaceName); + } +} diff --git a/Shipyard/ShipyardContracts/ViewModels/ClientViewModel.cs b/Shipyard/ShipyardContracts/ViewModels/ClientViewModel.cs index ba52890..2e45bd6 100644 --- a/Shipyard/ShipyardContracts/ViewModels/ClientViewModel.cs +++ b/Shipyard/ShipyardContracts/ViewModels/ClientViewModel.cs @@ -1,4 +1,5 @@ -using ShipyardDataModels.Models; +using ShipyardContracts.Attributes; +using ShipyardDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,15 +11,16 @@ namespace ShipyardContracts.ViewModels { public class ClientViewModel:IClientModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("ФИО клиента")] + [Column(title: "ФИО клиента", width: 150)] public string ClientFIO { get; set; } = string.Empty; - [DisplayName("Логин (эл. почта)")] + [Column(title: "Логин (эл. почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Email { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column(title: "Пароль", width: 150)] public string Password { get; set; } = string.Empty; } } diff --git a/Shipyard/ShipyardContracts/ViewModels/DetailViewModel.cs b/Shipyard/ShipyardContracts/ViewModels/DetailViewModel.cs index 3017778..ab2010c 100644 --- a/Shipyard/ShipyardContracts/ViewModels/DetailViewModel.cs +++ b/Shipyard/ShipyardContracts/ViewModels/DetailViewModel.cs @@ -1,4 +1,5 @@ -using ShipyardDataModels.Models; +using ShipyardContracts.Attributes; +using ShipyardDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -11,10 +12,11 @@ namespace ShipyardContracts.ViewModels { public class DetailViewModel:IDetailModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название детали")] + [Column(title: "Название детали", width: 150)] public string DetailName { get; set; } = string.Empty; - [DisplayName("Цена")] + [Column(title: "Цена", width: 150)] public double Cost { get; set; } } diff --git a/Shipyard/ShipyardContracts/ViewModels/ImplementerViewModel.cs b/Shipyard/ShipyardContracts/ViewModels/ImplementerViewModel.cs index dac2447..5d28187 100644 --- a/Shipyard/ShipyardContracts/ViewModels/ImplementerViewModel.cs +++ b/Shipyard/ShipyardContracts/ViewModels/ImplementerViewModel.cs @@ -1,4 +1,5 @@ -using ShipyardDataModels.Models; +using ShipyardContracts.Attributes; +using ShipyardDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,18 +11,19 @@ namespace ShipyardContracts.ViewModels { public class ImplementerViewModel : IImplementerModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("ФИО исполнителя")] + [Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column(title: "Пароль", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Password { get; set; } = string.Empty; - [DisplayName("Стаж работы")] + [Column(title: "Стаж работы", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public int WorkExperience { get; set; } - [DisplayName("Квалификация")] + [Column(title: "Квалификация", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public int Qualification { get; set; } } } diff --git a/Shipyard/ShipyardContracts/ViewModels/MessageInfoViewModel.cs b/Shipyard/ShipyardContracts/ViewModels/MessageInfoViewModel.cs index 416f0d9..52fb5d5 100644 --- a/Shipyard/ShipyardContracts/ViewModels/MessageInfoViewModel.cs +++ b/Shipyard/ShipyardContracts/ViewModels/MessageInfoViewModel.cs @@ -1,4 +1,5 @@ -using ShipyardDataModels.Models; +using ShipyardContracts.Attributes; +using ShipyardDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,20 +11,25 @@ namespace ShipyardContracts.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(title: "Отправитель", width: 150)] public string SenderName { get; set; } = string.Empty; - [DisplayName("Дата письма")] + [Column(title: "Дата письма", width: 150)] public DateTime DateDelivery { get; set; } - [DisplayName("Заголовок")] + [Column(title: "Заголовок", width: 150)] public string Subject { get; set; } = string.Empty; - [DisplayName("Текст")] + [Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Body { get; set; } = string.Empty; + + [Column(visible: false)] + public int Id => throw new NotImplementedException(); } } diff --git a/Shipyard/ShipyardContracts/ViewModels/OrderViewModel.cs b/Shipyard/ShipyardContracts/ViewModels/OrderViewModel.cs index 5cc48f0..7385717 100644 --- a/Shipyard/ShipyardContracts/ViewModels/OrderViewModel.cs +++ b/Shipyard/ShipyardContracts/ViewModels/OrderViewModel.cs @@ -1,4 +1,5 @@ -using ShipyardDataModels.Enums; +using ShipyardContracts.Attributes; +using ShipyardDataModels.Enums; using ShipyardDataModels.Models; using System; using System.Collections.Generic; @@ -11,26 +12,40 @@ namespace ShipyardContracts.ViewModels { public class OrderViewModel:IOrderModel { - [DisplayName("Номер")] + [Column(title: "Номер", width: 150)] public int Id { get; set; } + + [Column(visible: false)] public int ShipId { get; set; } - [DisplayName("Корабль")] + + [Column(title: "Корабль", width: 150)] public string ShipName { get; set; } = string.Empty; + + [Column(visible: false)] public int ClientId { get; set; } - [DisplayName("Клиент")] + + [Column(title: "Клиент", width: 150)] public string ClientFIO { get; set; } = string.Empty; + + [Column(visible: false)] public int? ImplementerId { get; set; } - [DisplayName("Исполнитель")] + + [Column(title: "Исполнитель", width: 150)] public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Количество")] + + [Column(title: "Количество", width: 150)] public int Count { get; set; } - [DisplayName("Сумма")] + + [Column(title: "Сумма", width: 150)] public double Sum { get; set; } - [DisplayName("Статус")] + + [Column(title: "Статус", width: 150)] public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; - [DisplayName("Дата создания")] + + [Column(title: "Дата создания", width: 150)] public DateTime DateCreate { get; set; } = DateTime.Now; - [DisplayName("Дата выполнения")] + + [Column(title: "Дата выполнения", width: 150)] public DateTime? DateImplement { get; set; } } } diff --git a/Shipyard/ShipyardContracts/ViewModels/ShipViewModel.cs b/Shipyard/ShipyardContracts/ViewModels/ShipViewModel.cs index 07b135f..b95d28b 100644 --- a/Shipyard/ShipyardContracts/ViewModels/ShipViewModel.cs +++ b/Shipyard/ShipyardContracts/ViewModels/ShipViewModel.cs @@ -1,4 +1,5 @@ -using ShipyardDataModels.Models; +using ShipyardContracts.Attributes; +using ShipyardDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,11 +11,16 @@ namespace ShipyardContracts.ViewModels { public class ShipViewModel:IShipModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название корабля")] + + [Column(title: "Название корабля", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ShipName { get; set; } = string.Empty; - [DisplayName("Цена")] + + [Column(title: "Цена", width: 150)] public double Price { get; set; } + + [Column(visible: false)] public Dictionary ShipDetails { get; set; } = new(); } } diff --git a/Shipyard/ShipyardDataBaseImplement/DataBaseImplementationExtension.cs b/Shipyard/ShipyardDataBaseImplement/DataBaseImplementationExtension.cs new file mode 100644 index 0000000..deb264a --- /dev/null +++ b/Shipyard/ShipyardDataBaseImplement/DataBaseImplementationExtension.cs @@ -0,0 +1,27 @@ +using ShipyardContracts.DI; +using ShipyardContracts.StoragesContracts; +using ShipyardDataBaseImplement.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardDataBaseImplement +{ + public class DataBaseImplementationExtension : IImplementationExtension + { + public int Priority => 2; + + public void RegisterServices() + { + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + } + } +} diff --git a/Shipyard/ShipyardDataBaseImplement/Implements/BackUpInfo.cs b/Shipyard/ShipyardDataBaseImplement/Implements/BackUpInfo.cs new file mode 100644 index 0000000..9a6b4e0 --- /dev/null +++ b/Shipyard/ShipyardDataBaseImplement/Implements/BackUpInfo.cs @@ -0,0 +1,32 @@ +using ShipyardContracts.StoragesContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardDataBaseImplement.Implements +{ + public class BackUpInfo : IBackUpInfo + { + public List? GetList() where T : class, new() + { + using var context = new ShipyardDataBase(); + return context.Set().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; + } + } +} diff --git a/Shipyard/ShipyardDataBaseImplement/Models/Client.cs b/Shipyard/ShipyardDataBaseImplement/Models/Client.cs index 302cc40..ce7130a 100644 --- a/Shipyard/ShipyardDataBaseImplement/Models/Client.cs +++ b/Shipyard/ShipyardDataBaseImplement/Models/Client.cs @@ -1,24 +1,25 @@ using ShipyardContracts.BindingModels; using ShipyardContracts.ViewModels; using ShipyardDataModels.Models; -using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Runtime.Serialization; namespace ShipyardDataBaseImplement.Models { + [DataContract] public class Client:IClientModel { + [DataMember] public int Id { get; set; } [Required] + [DataMember] public string ClientFIO { get; set; }= string.Empty; [Required] + [DataMember] public string Email { get; set; }= string.Empty; [Required] + [DataMember] public string Password { get; set; }= string.Empty; [ForeignKey("ClientId")] public virtual List Orders { get; set; } = new(); diff --git a/Shipyard/ShipyardDataBaseImplement/Models/Detail.cs b/Shipyard/ShipyardDataBaseImplement/Models/Detail.cs index d662338..52a9a38 100644 --- a/Shipyard/ShipyardDataBaseImplement/Models/Detail.cs +++ b/Shipyard/ShipyardDataBaseImplement/Models/Detail.cs @@ -9,15 +9,20 @@ using System.Text; using System.Threading.Tasks; using ShipyardContracts.BindingModels; using ShipyardContracts.ViewModels; +using System.Runtime.Serialization; namespace ShipyardDataBaseImplement.Models { + [DataContract] public class Detail:IDetailModel { + [DataMember] public int Id { get; private set; } [Required] + [DataMember] public string DetailName { get; private set; } = string.Empty; [Required] + [DataMember] public double Cost { get; set; } [ForeignKey("DetailId")] public virtual List ShipDetails { get; set; } = new(); diff --git a/Shipyard/ShipyardDataBaseImplement/Models/Implementer.cs b/Shipyard/ShipyardDataBaseImplement/Models/Implementer.cs index 75e0517..3383dcb 100644 --- a/Shipyard/ShipyardDataBaseImplement/Models/Implementer.cs +++ b/Shipyard/ShipyardDataBaseImplement/Models/Implementer.cs @@ -6,25 +6,32 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; namespace ShipyardDataBaseImplement.Models { + [DataContract] public class Implementer : IImplementerModel { + [DataMember] public int Id { get; set; } [Required] + [DataMember] public string ImplementerFIO { get; set; } = String.Empty; [Required] + [DataMember] public string Password { get; set; } = String.Empty; [Required] + [DataMember] public int WorkExperience { get; set; } [Required] + [DataMember] public int Qualification { get; set; } [ForeignKey("ImplementerId")] diff --git a/Shipyard/ShipyardDataBaseImplement/Models/Message.cs b/Shipyard/ShipyardDataBaseImplement/Models/Message.cs index f0748e7..37a3d7d 100644 --- a/Shipyard/ShipyardDataBaseImplement/Models/Message.cs +++ b/Shipyard/ShipyardDataBaseImplement/Models/Message.cs @@ -5,14 +5,17 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; namespace ShipyardDataBaseImplement.Models { + [DataContract] public class Message:IMessageInfoModel { [Key] + [DataMember] public string MessageId { get; private set; } = string.Empty; public int? ClientId { get; private set; } @@ -24,7 +27,7 @@ namespace ShipyardDataBaseImplement.Models public string Subject { get; private set; } = string.Empty; public string Body { get; private set; } = string.Empty; - + public int Id => throw new NotImplementedException(); public Client? Client { get; private set; } public static Message? Create(MessageInfoBindingModel model) { diff --git a/Shipyard/ShipyardDataBaseImplement/Models/Order.cs b/Shipyard/ShipyardDataBaseImplement/Models/Order.cs index 5d535eb..8ef9936 100644 --- a/Shipyard/ShipyardDataBaseImplement/Models/Order.cs +++ b/Shipyard/ShipyardDataBaseImplement/Models/Order.cs @@ -6,29 +6,46 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; namespace ShipyardDataBaseImplement.Models { + [DataContract] public class Order:IOrderModel { [Required] + [DataMember] public int ShipId { get; set; } + [Required] + [DataMember] public int ClientId { get; set; } + + [DataMember] public int? ImplementerId { get; set; } + [Required] + [DataMember] public int Count { get; set; } + [Required] + [DataMember] public double Sum { get; set; } + [Required] + [DataMember] public OrderStatus Status { get; set; } + [Required] + [DataMember] public DateTime DateCreate { get; set; } + [DataMember] public DateTime? DateImplement { get; set; } + [DataMember] public int Id { get; set; } public virtual Ship Ship { get; set; } public virtual Client Client { get; set; } diff --git a/Shipyard/ShipyardDataBaseImplement/Models/Ship.cs b/Shipyard/ShipyardDataBaseImplement/Models/Ship.cs index aaa5cdc..790190a 100644 --- a/Shipyard/ShipyardDataBaseImplement/Models/Ship.cs +++ b/Shipyard/ShipyardDataBaseImplement/Models/Ship.cs @@ -8,18 +8,28 @@ using System.Text; using System.Threading.Tasks; using ShipyardContracts.BindingModels; using ShipyardContracts.ViewModels; +using System.Runtime.Serialization; namespace ShipyardDataBaseImplement.Models { + [DataContract] public class Ship:IShipModel { + [DataMember] public int Id { get; set; } + [Required] + [DataMember] public string ShipName { get; set; } = string.Empty; + [Required] + [DataMember] public double Price { get; set; } + private Dictionary? _shipDetails = null; + [NotMapped] + [DataMember] public Dictionary ShipDetails { get diff --git a/Shipyard/ShipyardDataBaseImplement/ShipyardDataBaseImplement.csproj b/Shipyard/ShipyardDataBaseImplement/ShipyardDataBaseImplement.csproj index 39bebaf..64cd830 100644 --- a/Shipyard/ShipyardDataBaseImplement/ShipyardDataBaseImplement.csproj +++ b/Shipyard/ShipyardDataBaseImplement/ShipyardDataBaseImplement.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -19,4 +19,8 @@ + + + + diff --git a/Shipyard/ShipyardDataModels/Models/IMessageInfoModel.cs b/Shipyard/ShipyardDataModels/Models/IMessageInfoModel.cs index 02063dd..2e61010 100644 --- a/Shipyard/ShipyardDataModels/Models/IMessageInfoModel.cs +++ b/Shipyard/ShipyardDataModels/Models/IMessageInfoModel.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace ShipyardDataModels.Models { - public interface IMessageInfoModel + public interface IMessageInfoModel : IId { string MessageId { get; } diff --git a/Shipyard/ShipyardFileImplement/FileImplementationExtension.cs b/Shipyard/ShipyardFileImplement/FileImplementationExtension.cs new file mode 100644 index 0000000..13e7db2 --- /dev/null +++ b/Shipyard/ShipyardFileImplement/FileImplementationExtension.cs @@ -0,0 +1,27 @@ +using ShipyardContracts.DI; +using ShipyardContracts.StoragesContracts; +using ShipyardFileImplement.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardFileImplement +{ + public class FileImplementationExtension : IImplementationExtension + { + public int Priority => 1; + + public void RegisterServices() + { + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + } + } +} diff --git a/Shipyard/ShipyardFileImplement/Implements/BackUpInfo.cs b/Shipyard/ShipyardFileImplement/Implements/BackUpInfo.cs new file mode 100644 index 0000000..297c95c --- /dev/null +++ b/Shipyard/ShipyardFileImplement/Implements/BackUpInfo.cs @@ -0,0 +1,34 @@ +using ShipyardContracts.StoragesContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardFileImplement.Implements +{ + public class BackUpInfo : IBackUpInfo + { + public List? GetList() where T : class, new() + { + var source = DataFileSingleton.GetInstance(); + return (List?)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; + } + } +} diff --git a/Shipyard/ShipyardFileImplement/Models/Client.cs b/Shipyard/ShipyardFileImplement/Models/Client.cs index b07f11d..bfb3cae 100644 --- a/Shipyard/ShipyardFileImplement/Models/Client.cs +++ b/Shipyard/ShipyardFileImplement/Models/Client.cs @@ -4,17 +4,26 @@ using ShipyardDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace ShipyardFileImplement.Models { + [DataContract] public class Client:IClientModel { + [DataMember] public int Id { get; set; } + + [DataMember] public string ClientFIO { get; set; }= string.Empty; + + [DataMember] public string Email { get; set; }= string.Empty; + + [DataMember] public string Password { get; set; }= string.Empty; public static Client? Create(ClientBindingModel model) { diff --git a/Shipyard/ShipyardFileImplement/Models/Detail.cs b/Shipyard/ShipyardFileImplement/Models/Detail.cs index 9ee4aaf..696894b 100644 --- a/Shipyard/ShipyardFileImplement/Models/Detail.cs +++ b/Shipyard/ShipyardFileImplement/Models/Detail.cs @@ -5,16 +5,23 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace ShipyardFileImplement.Models { + [DataContract] public class Detail:IDetailModel { + [DataMember] public int Id { get; private set; } + + [DataMember] public string DetailName { get; private set; } = string.Empty; + + [DataMember] public double Cost { get; set; } public static Detail? Create(DetailBindingModel model) { diff --git a/Shipyard/ShipyardFileImplement/Models/Implementer.cs b/Shipyard/ShipyardFileImplement/Models/Implementer.cs index a21a45a..a85b7b9 100644 --- a/Shipyard/ShipyardFileImplement/Models/Implementer.cs +++ b/Shipyard/ShipyardFileImplement/Models/Implementer.cs @@ -4,22 +4,29 @@ using ShipyardDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace ShipyardFileImplement.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) diff --git a/Shipyard/ShipyardFileImplement/Models/Message.cs b/Shipyard/ShipyardFileImplement/Models/Message.cs index 6804164..b155015 100644 --- a/Shipyard/ShipyardFileImplement/Models/Message.cs +++ b/Shipyard/ShipyardFileImplement/Models/Message.cs @@ -4,25 +4,34 @@ using ShipyardDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace ShipyardFileImplement.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 int Id => throw new NotImplementedException(); public static Message? Create(MessageInfoBindingModel model) { if (model == null) diff --git a/Shipyard/ShipyardFileImplement/Models/Order.cs b/Shipyard/ShipyardFileImplement/Models/Order.cs index a780a0e..388c335 100644 --- a/Shipyard/ShipyardFileImplement/Models/Order.cs +++ b/Shipyard/ShipyardFileImplement/Models/Order.cs @@ -2,20 +2,39 @@ using ShipyardContracts.ViewModels; using ShipyardDataModels.Enums; using ShipyardDataModels.Models; +using System.Runtime.Serialization; using System.Xml.Linq; namespace ShipyardFileImplement.Models { + [DataContract] public class Order : IOrderModel { + [DataMember] public int Id { get; private set; } + + [DataMember] public int ShipId { get; private set; } + + [DataMember] public int ClientId { get; private set; } + + [DataMember] public int? ImplementerId { 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) { diff --git a/Shipyard/ShipyardFileImplement/Models/Ship.cs b/Shipyard/ShipyardFileImplement/Models/Ship.cs index 091e4b3..38e635b 100644 --- a/Shipyard/ShipyardFileImplement/Models/Ship.cs +++ b/Shipyard/ShipyardFileImplement/Models/Ship.cs @@ -4,19 +4,28 @@ using ShipyardDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace ShipyardFileImplement.Models { + [DataContract] public class Ship : IShipModel { + [DataMember] public int Id { get; private set; } + + [DataMember] public string ShipName { get; private set; } = string.Empty; + + [DataMember] public double Price { get; private set; } public Dictionary Details { get; private set; } = new(); private Dictionary? _shipDetails = null; + + [DataMember] public Dictionary ShipDetails { get diff --git a/Shipyard/ShipyardFileImplement/ShipyardFileImplement.csproj b/Shipyard/ShipyardFileImplement/ShipyardFileImplement.csproj index 79514f7..78a9e82 100644 --- a/Shipyard/ShipyardFileImplement/ShipyardFileImplement.csproj +++ b/Shipyard/ShipyardFileImplement/ShipyardFileImplement.csproj @@ -20,4 +20,8 @@ + + + + diff --git a/Shipyard/ShipyardListImplement»/Implements/BackUpInfo.cs b/Shipyard/ShipyardListImplement»/Implements/BackUpInfo.cs new file mode 100644 index 0000000..1886374 --- /dev/null +++ b/Shipyard/ShipyardListImplement»/Implements/BackUpInfo.cs @@ -0,0 +1,22 @@ +using ShipyardContracts.StoragesContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardListImplement_.Implements +{ + public class BackUpInfo : IBackUpInfo + { + public List? GetList() where T : class, new() + { + throw new NotImplementedException(); + } + + public Type? GetTypeByModelInterface(string modelInterfaceName) + { + throw new NotImplementedException(); + } + } +} diff --git a/Shipyard/ShipyardListImplement»/ListImplementationExtension.cs b/Shipyard/ShipyardListImplement»/ListImplementationExtension.cs new file mode 100644 index 0000000..2a2697f --- /dev/null +++ b/Shipyard/ShipyardListImplement»/ListImplementationExtension.cs @@ -0,0 +1,28 @@ +using ShipyardContracts.DI; +using ShipyardContracts.StoragesContracts; +using ShipyardListImplement.Implements; +using ShipyardListImplement_.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShipyardListImplement_ +{ + public class ListImplementationExtension : IImplementationExtension + { + public int Priority => 0; + + public void RegisterServices() + { + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + } + } +} diff --git a/Shipyard/ShipyardListImplement»/Models/Client.cs b/Shipyard/ShipyardListImplement»/Models/Client.cs index 3ff0f37..8f231d5 100644 --- a/Shipyard/ShipyardListImplement»/Models/Client.cs +++ b/Shipyard/ShipyardListImplement»/Models/Client.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; @@ -14,8 +15,11 @@ namespace ShipyardListImplement.Models public class Client :IClientModel { public int Id { get; set; } + public string ClientFIO { get; set; }= string.Empty; + public string Email { get; set; }= string.Empty; + public string Password { get; set; }= string.Empty; public static Client? Create(ClientBindingModel? model) { diff --git a/Shipyard/ShipyardListImplement»/Models/Detail.cs b/Shipyard/ShipyardListImplement»/Models/Detail.cs index 2e7bc87..63a85cb 100644 --- a/Shipyard/ShipyardListImplement»/Models/Detail.cs +++ b/Shipyard/ShipyardListImplement»/Models/Detail.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; @@ -13,7 +14,9 @@ namespace ShipyardListImplement.Models public class Detail:IDetailModel { public int Id { get; private set; } + public string DetailName { get; private set; } = string.Empty; + public double Cost { get; set; } public static Detail? Create(DetailBindingModel? model) { diff --git a/Shipyard/ShipyardListImplement»/Models/Implementer.cs b/Shipyard/ShipyardListImplement»/Models/Implementer.cs index 1f51406..4496d33 100644 --- a/Shipyard/ShipyardListImplement»/Models/Implementer.cs +++ b/Shipyard/ShipyardListImplement»/Models/Implementer.cs @@ -5,6 +5,7 @@ using ShipyardListImplement.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; diff --git a/Shipyard/ShipyardListImplement»/Models/Message.cs b/Shipyard/ShipyardListImplement»/Models/Message.cs index 99d8e1c..1b0f6e8 100644 --- a/Shipyard/ShipyardListImplement»/Models/Message.cs +++ b/Shipyard/ShipyardListImplement»/Models/Message.cs @@ -4,6 +4,7 @@ using ShipyardDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; @@ -22,6 +23,7 @@ namespace ShipyardListImplement_.Models public string Subject { get; private set; } = string.Empty; public string Body { get; private set; } = string.Empty; + public int Id => throw new NotImplementedException(); public static Message? Create(MessageInfoBindingModel model) { diff --git a/Shipyard/ShipyardListImplement»/Models/Order.cs b/Shipyard/ShipyardListImplement»/Models/Order.cs index 69bb7a5..a6d1e42 100644 --- a/Shipyard/ShipyardListImplement»/Models/Order.cs +++ b/Shipyard/ShipyardListImplement»/Models/Order.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; @@ -15,13 +16,21 @@ namespace ShipyardListImplement.Models public class Order: IOrderModel { public int Id { get; private set; } + public int ShipId { get; private set; } + public int ClientId {get; private set; } + public int? ImplementerId { get; private set; } + public int Count { get; private set; } + public double Sum { get; private set; } + public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; private set; }= DateTime.Now; + public DateTime? DateImplement { get; private set; } public static Order? Create(OrderBindingModel? model) diff --git a/Shipyard/ShipyardListImplement»/Models/Ship.cs b/Shipyard/ShipyardListImplement»/Models/Ship.cs index 4c526b3..4962741 100644 --- a/Shipyard/ShipyardListImplement»/Models/Ship.cs +++ b/Shipyard/ShipyardListImplement»/Models/Ship.cs @@ -4,6 +4,7 @@ using ShipyardDataModels.Models; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; @@ -12,7 +13,9 @@ namespace ShipyardListImplement.Models public class Ship:IShipModel { public int Id { get; private set; } + public string ShipName { get; private set; } = string.Empty; + public double Price { get; private set; } public Dictionary ShipDetails { get; private set; } = new Dictionary(); public static Ship? Create(ShipBindingModel? model) diff --git a/Shipyard/ShipyardListImplement»/ShipyardListImplement.csproj b/Shipyard/ShipyardListImplement»/ShipyardListImplement.csproj index 22ef310..2a2ea2e 100644 --- a/Shipyard/ShipyardListImplement»/ShipyardListImplement.csproj +++ b/Shipyard/ShipyardListImplement»/ShipyardListImplement.csproj @@ -24,4 +24,8 @@ + + + +