diff --git a/.gitignore b/.gitignore index ca1c7a3..0fe264c 100644 --- a/.gitignore +++ b/.gitignore @@ -398,3 +398,8 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml + + +# dll файлы +*.dll + diff --git a/JewelryStore/FormClients.Designer.cs b/JewelryStore/FormClients.Designer.cs index c3bb02d..0238873 100644 --- a/JewelryStore/FormClients.Designer.cs +++ b/JewelryStore/FormClients.Designer.cs @@ -28,19 +28,19 @@ /// private void InitializeComponent() { - this.dataGridView = new System.Windows.Forms.DataGridView(); + this.DataGridView = new System.Windows.Forms.DataGridView(); this.ButtonDel = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit(); this.SuspendLayout(); // // dataGridView // - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(12, 85); - this.dataGridView.Name = "dataGridView"; - this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(559, 453); - this.dataGridView.TabIndex = 6; + this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.DataGridView.Location = new System.Drawing.Point(12, 85); + this.DataGridView.Name = "dataGridView"; + this.DataGridView.RowTemplate.Height = 25; + this.DataGridView.Size = new System.Drawing.Size(559, 453); + this.DataGridView.TabIndex = 6; // // ButtonDel // @@ -58,18 +58,18 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(588, 549); this.Controls.Add(this.ButtonDel); - this.Controls.Add(this.dataGridView); + this.Controls.Add(this.DataGridView); this.Name = "FormClients"; this.Text = "Клиенты"; this.Load += new System.EventHandler(this.FormClients_Load); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit(); this.ResumeLayout(false); } #endregion - private DataGridView dataGridView; + private DataGridView DataGridView; private Button ButtonDel; } } \ No newline at end of file diff --git a/JewelryStore/FormClients.cs b/JewelryStore/FormClients.cs index a034728..963d960 100644 --- a/JewelryStore/FormClients.cs +++ b/JewelryStore/FormClients.cs @@ -1,6 +1,4 @@ -using JewelryStoreContracts.BindingModels; -using JewelryStoreContracts.BusinessLogicsContracts; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,6 +8,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using JewelryStore; +using JewelryStoreContracts.BindingModels; +using JewelryStoreContracts.BusinessLogicsContracts; +using JewelryStoreContracts.DI; namespace JewelryStore { @@ -45,13 +47,13 @@ namespace JewelryStore private void ButtonDel_Click(object sender, EventArgs e) { - if (dataGridView.SelectedRows.Count == 1) + if (DataGridView.SelectedRows.Count == 1) { if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Удаление клиента"); try { diff --git a/JewelryStore/FormComponents.Designer.cs b/JewelryStore/FormComponents.Designer.cs index 7156e1f..4999362 100644 --- a/JewelryStore/FormComponents.Designer.cs +++ b/JewelryStore/FormComponents.Designer.cs @@ -28,24 +28,24 @@ /// private void InitializeComponent() { - this.dataGridView = new System.Windows.Forms.DataGridView(); + this.DataGridView = new System.Windows.Forms.DataGridView(); this.buttonAdd = new System.Windows.Forms.Button(); this.buttonChange = new System.Windows.Forms.Button(); this.buttonDelete = new System.Windows.Forms.Button(); this.buttonUpdate = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit(); this.SuspendLayout(); // // dataGridView // - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; - this.dataGridView.Location = new System.Drawing.Point(0, 0); - this.dataGridView.Name = "dataGridView"; - this.dataGridView.RowHeadersWidth = 62; - this.dataGridView.RowTemplate.Height = 33; - this.dataGridView.Size = new System.Drawing.Size(459, 488); - this.dataGridView.TabIndex = 0; + this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.DataGridView.Dock = System.Windows.Forms.DockStyle.Left; + this.DataGridView.Location = new System.Drawing.Point(0, 0); + this.DataGridView.Name = "dataGridView"; + this.DataGridView.RowHeadersWidth = 62; + this.DataGridView.RowTemplate.Height = 33; + this.DataGridView.Size = new System.Drawing.Size(459, 488); + this.DataGridView.TabIndex = 0; // // buttonAdd // @@ -96,18 +96,18 @@ this.Controls.Add(this.buttonDelete); this.Controls.Add(this.buttonChange); this.Controls.Add(this.buttonAdd); - this.Controls.Add(this.dataGridView); + this.Controls.Add(this.DataGridView); this.Name = "FormComponents"; this.Text = "Компоненты"; this.Load += new System.EventHandler(this.FormComponents_Load); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit(); this.ResumeLayout(false); } #endregion - private DataGridView dataGridView; + private DataGridView DataGridView; private Button buttonAdd; private Button buttonChange; private Button buttonDelete; diff --git a/JewelryStore/FormComponents.cs b/JewelryStore/FormComponents.cs index c7b9479..b78684d 100644 --- a/JewelryStore/FormComponents.cs +++ b/JewelryStore/FormComponents.cs @@ -35,7 +35,7 @@ namespace JewelryStore { try { - DataGridView.FillandConfigGrid(_logic.ReadList(null)); + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка компонентов"); } @@ -62,13 +62,13 @@ namespace JewelryStore private void buttonDelete_Click(object sender, EventArgs e) { - if (dataGridView.SelectedRows.Count == 1) + if (DataGridView.SelectedRows.Count == 1) { if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Удаление компонента"); try { @@ -94,7 +94,7 @@ namespace JewelryStore private void buttonChange_Click(object sender, EventArgs e) { - if (dataGridView.SelectedRows.Count == 1) + if (DataGridView.SelectedRows.Count == 1) { var form = DependencyManager.Instance.Resolve(); if (form.ShowDialog() == DialogResult.OK) diff --git a/JewelryStore/Program.cs b/JewelryStore/Program.cs index 1856df7..ab30205 100644 --- a/JewelryStore/Program.cs +++ b/JewelryStore/Program.cs @@ -1,7 +1,6 @@ using JewelryStoreContracts.BusinessLogicsContracts; using JewelryStoreContracts.StoragesContracts; using JewelryStoreBusinessLogic.BusinessLogics; -using JewelryStoreDatabaseImplement.Implements; using Microsoft.Extensions.DependencyInjection; using System.Drawing; diff --git a/JewelryStoreContracts/BindingModels/MessageInfoBindingModel.cs b/JewelryStoreContracts/BindingModels/MessageInfoBindingModel.cs index defcf64..494198a 100644 --- a/JewelryStoreContracts/BindingModels/MessageInfoBindingModel.cs +++ b/JewelryStoreContracts/BindingModels/MessageInfoBindingModel.cs @@ -15,5 +15,7 @@ namespace JewelryStoreContracts.BindingModels public string Subject { get; set; } = string.Empty; public string Body { get; set; } = string.Empty; public DateTime DateDelivery { get; set; } + + public int Id => throw new NotImplementedException(); } } diff --git a/JewelryStoreContracts/DI/ServiceProviderLoader.cs b/JewelryStoreContracts/DI/ServiceProviderLoader.cs index 8acd2d3..c692882 100644 --- a/JewelryStoreContracts/DI/ServiceProviderLoader.cs +++ b/JewelryStoreContracts/DI/ServiceProviderLoader.cs @@ -20,9 +20,11 @@ namespace JewelryStoreContracts.DI { 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)) @@ -34,6 +36,7 @@ namespace JewelryStoreContracts.DI else { var newSource = (IImplementationExtension)Activator.CreateInstance(t)!; + if (newSource.Priority > source.Priority) { source = newSource; @@ -42,15 +45,19 @@ namespace JewelryStoreContracts.DI } } } + 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/JewelryStoreContracts/ViewModels/MessageInfoViewModel.cs b/JewelryStoreContracts/ViewModels/MessageInfoViewModel.cs index 766c416..16277df 100644 --- a/JewelryStoreContracts/ViewModels/MessageInfoViewModel.cs +++ b/JewelryStoreContracts/ViewModels/MessageInfoViewModel.cs @@ -23,5 +23,7 @@ namespace JewelryStoreContracts.ViewModels public string Subject { get; set; } = string.Empty; [Column("Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Body { get; set; } = string.Empty; + + public int Id => throw new NotImplementedException(); } } diff --git a/JewelryStoreDataModels/Models/IMessageInfoModel.cs b/JewelryStoreDataModels/Models/IMessageInfoModel.cs index 120de88..738ae14 100644 --- a/JewelryStoreDataModels/Models/IMessageInfoModel.cs +++ b/JewelryStoreDataModels/Models/IMessageInfoModel.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace JewelryStoreDataModels.Models { - public interface IMessageInfoModel + public interface IMessageInfoModel : IId { string MessageId { get; } int? ClientId { get; } diff --git a/JewelryStoreDatabaseImplement/JewelryStoreDatabaseImplement.csproj b/JewelryStoreDatabaseImplement/JewelryStoreDatabaseImplement.csproj index f41d15e..a60091c 100644 --- a/JewelryStoreDatabaseImplement/JewelryStoreDatabaseImplement.csproj +++ b/JewelryStoreDatabaseImplement/JewelryStoreDatabaseImplement.csproj @@ -4,6 +4,7 @@ net6.0 enable enable + OnBuildSuccess @@ -21,4 +22,8 @@ + + diff --git a/JewelryStoreDatabaseImplement/Models/Message.cs b/JewelryStoreDatabaseImplement/Models/Message.cs index e3ba8d4..45af43e 100644 --- a/JewelryStoreDatabaseImplement/Models/Message.cs +++ b/JewelryStoreDatabaseImplement/Models/Message.cs @@ -56,5 +56,7 @@ namespace JewelryStoreDatabaseImplement.Models SenderName = SenderName, DateDelivery = DateDelivery, }; + + public int Id => throw new NotImplementedException(); } } diff --git a/JewelryStoreFileImplement/JewelryStoreFileImplement.csproj b/JewelryStoreFileImplement/JewelryStoreFileImplement.csproj index e899402..c6146ac 100644 --- a/JewelryStoreFileImplement/JewelryStoreFileImplement.csproj +++ b/JewelryStoreFileImplement/JewelryStoreFileImplement.csproj @@ -1,9 +1,10 @@ - + net6.0 enable enable + OnBuildSuccess @@ -15,4 +16,8 @@ + + diff --git a/JewelryStoreFileImplement/Models/Message.cs b/JewelryStoreFileImplement/Models/Message.cs index f9d46e7..2d9efb4 100644 --- a/JewelryStoreFileImplement/Models/Message.cs +++ b/JewelryStoreFileImplement/Models/Message.cs @@ -78,5 +78,7 @@ namespace JewelryStoreFileImplement.Models new XAttribute("SenderName", SenderName), new XAttribute("DateDelivery", DateDelivery) ); + + public int Id => throw new NotImplementedException(); } } diff --git a/JewelryStoreListImplement/JewelryStoreListImplement.csproj b/JewelryStoreListImplement/JewelryStoreListImplement.csproj index e899402..2818ea3 100644 --- a/JewelryStoreListImplement/JewelryStoreListImplement.csproj +++ b/JewelryStoreListImplement/JewelryStoreListImplement.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -15,4 +15,8 @@ + + diff --git a/JewelryStoreListImplement/Models/Message.cs b/JewelryStoreListImplement/Models/Message.cs index 48376a6..7ae55ac 100644 --- a/JewelryStoreListImplement/Models/Message.cs +++ b/JewelryStoreListImplement/Models/Message.cs @@ -49,5 +49,7 @@ namespace JewelryStoreListImplement.Models ClientId = ClientId, MessageId = MessageId }; + + public int Id => throw new NotImplementedException(); } }