From ebed3c5c1df40ea4b310b83f41ec6e7dc0a3f45b Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sun, 30 Apr 2023 01:01:54 +0400 Subject: [PATCH] =?UTF-8?q?LabWork08=20=D0=BF=D0=BE=20=D0=B2=D0=B8=D0=B4?= =?UTF-8?q?=D0=B5=D0=BE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ BlacksmithWorkshop/BlacksmithWorkshop.sln | 4 ++-- .../BlacksmithWorkshop/DataGridViewExtension.cs | 2 ++ .../BusinessLogic/BackUpLogic.cs | 4 ++++ .../Attributes/ColumnAttribute.cs | 1 + .../BindingModels/MessageInfoBindingModel.cs | 6 ++++-- .../DI/IImplementationExtension.cs | 1 + .../ViewModels/ClientViewModel.cs | 7 ++++++- .../ViewModels/MessageInfoViewModel.cs | 4 +++- .../Models/IMessageInfoModel.cs | 2 +- .../BlacksmithWorkshopDatabaseImplement.csproj | 4 ++++ .../Models/MessageInfo.cs | 4 +++- .../BlacksmithWorkshopFileImplement.csproj | 4 ++++ .../BlacksmithWorkshopFileImplement/Models/MessageInfo.cs | 6 ++++-- .../BlacksmithWorkshopListImplement.csproj | 4 ++++ .../BlacksmithWorkshopListImplement/Models/MessageInfo.cs | 6 ++++-- 16 files changed, 49 insertions(+), 12 deletions(-) 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/BlacksmithWorkshop/BlacksmithWorkshop.sln b/BlacksmithWorkshop/BlacksmithWorkshop.sln index d66652b..96a37bb 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop.sln +++ b/BlacksmithWorkshop/BlacksmithWorkshop.sln @@ -17,9 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopFileImple EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopDatabaseImplement", "BlacksmithWorkshopDatabaseImplement\BlacksmithWorkshopDatabaseImplement.csproj", "{EE03BAE3-52EE-4E3B-8992-382D89E61E1A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopRestApi", "BlackmithWorkshopRestApi\BlacksmithWorkshopRestApi.csproj", "{23DBD9A3-2107-44AB-8B87-6982BFD2E69A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopRestApi", "BlackmithWorkshopRestApi\BlacksmithWorkshopRestApi.csproj", "{23DBD9A3-2107-44AB-8B87-6982BFD2E69A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopClientApp", "BlacksmithWorkshopClientApp\BlacksmithWorkshopClientApp.csproj", "{FCA95914-11AF-494A-8116-BB7B3253D925}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopClientApp", "BlacksmithWorkshopClientApp\BlacksmithWorkshopClientApp.csproj", "{FCA95914-11AF-494A-8116-BB7B3253D925}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/DataGridViewExtension.cs b/BlacksmithWorkshop/BlacksmithWorkshop/DataGridViewExtension.cs index 5f555c7..fd6b156 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/DataGridViewExtension.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/DataGridViewExtension.cs @@ -18,8 +18,10 @@ namespace BlacksmithWorkshop grid.DataSource = data; + //получаем тип var type = typeof(T); + //получаем свойства var properties = type.GetProperties(); foreach (DataGridViewColumn column in grid.Columns) diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/BackUpLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/BackUpLogic.cs index c59648b..6169c15 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/BackUpLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/BackUpLogic.cs @@ -19,6 +19,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic private readonly ILogger _logger; private readonly IBackUpInfo _backUpInfo; + public BackUpLogic(ILogger logger, IBackUpInfo backUpInfo) { _logger = logger; @@ -40,6 +41,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic if (dirInfo.Exists) { + //НЕ ВЫБИРАЕМ РАБОЧИЙ СТОЛ, ИНАЧЕ ВСЁ С НЕГО УДАЛИТСЯ foreach (var file in dirInfo.GetFiles()) { file.Delete(); @@ -73,6 +75,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic foreach (var type in types) { + //проверка на то, является ли тип интерфейсом и унаследован ли он от IId if (type.IsInterface && type.GetInterface(typeIId.Name) != null) { var modelType = _backUpInfo.GetTypeByModelInterface(type.Name); @@ -114,6 +117,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic return; } + //три строчки ниже - сериализация файлов в json var jsonFormatter = new DataContractJsonSerializer(typeof(List)); using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/Attributes/ColumnAttribute.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/Attributes/ColumnAttribute.cs index c34a5fe..aec5b3a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/Attributes/ColumnAttribute.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/Attributes/ColumnAttribute.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; namespace BlacksmithWorkshopContracts.Attributes { + //указываем, что данный атрибут можно прописать только в Property [AttributeUsage(AttributeTargets.Property)] public class ColumnAttribute : Attribute { diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/MessageInfoBindingModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/MessageInfoBindingModel.cs index 7d7d454..23b9a70 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/MessageInfoBindingModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/MessageInfoBindingModel.cs @@ -9,7 +9,9 @@ namespace BlacksmithWorkshopContracts.BindingModels { public class MessageInfoBindingModel : IMessageInfoModel { - public string MessageId { get; set; } = string.Empty; + public int Id { get; set; } + + public string MessageId { get; set; } = string.Empty; public int? ClientId { get; set; } @@ -20,5 +22,5 @@ namespace BlacksmithWorkshopContracts.BindingModels public string Subject { get; set; } = string.Empty; public string Body { get; set; } = string.Empty; - } + } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/DI/IImplementationExtension.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/DI/IImplementationExtension.cs index 7a7c24e..12b6fd0 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/DI/IImplementationExtension.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/DI/IImplementationExtension.cs @@ -10,6 +10,7 @@ namespace BlacksmithWorkshopContracts.DI //Интерфейс для регистрации зависимостей в модулях public interface IImplementationExtension { + //для установления приоритета public int Priority { get; } //Регистрация сервисов diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ClientViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ClientViewModel.cs index ca7e87a..f222404 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ClientViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ClientViewModel.cs @@ -1,4 +1,5 @@ -using BlacksmithWorkshopDataModels.Models; +using BlacksmithWorkshopContracts.Attributes; +using BlacksmithWorkshopDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,12 +11,16 @@ namespace BlacksmithWorkshopContracts.ViewModels { public class ClientViewModel : IClientModel { + [Column(visible: false)] public int Id { get; set; } + [Column(title: "ФИО клиента", width: 150)] public string ClientFIO { get; set; } = string.Empty; + [Column(title: "Логие (эл. почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Email { get; set; } = string.Empty; + [Column(title: "Пароль", width: 150)] public string Password { get; set; } = string.Empty; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs index 5933def..8a9a2a1 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs @@ -10,7 +10,9 @@ namespace BlacksmithWorkshopContracts.ViewModels { public class MessageInfoViewModel : IMessageInfoModel { - public string MessageId { get; set; } = string.Empty; + public int Id { get; set; } + + public string MessageId { get; set; } = string.Empty; public int? ClientId { get; set; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IMessageInfoModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IMessageInfoModel.cs index a7ac56e..b91d51d 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IMessageInfoModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IMessageInfoModel.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace BlacksmithWorkshopDataModels.Models { - public interface IMessageInfoModel + public interface IMessageInfoModel : IId { string MessageId { get; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDatabaseImplement.csproj b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDatabaseImplement.csproj index bdecbbd..15df830 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDatabaseImplement.csproj +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDatabaseImplement.csproj @@ -20,4 +20,8 @@ + + + + diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/MessageInfo.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/MessageInfo.cs index a42d009..d0f0af4 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/MessageInfo.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/MessageInfo.cs @@ -12,7 +12,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Models { public class MessageInfo : IMessageInfoModel { - [Key] + public int Id { get; set; } + + [Key] public string MessageId { get; set; } = string.Empty; public int? ClientId { get; set; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/BlacksmithWorkshopFileImplement.csproj b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/BlacksmithWorkshopFileImplement.csproj index b65badc..d1597ab 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/BlacksmithWorkshopFileImplement.csproj +++ b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/BlacksmithWorkshopFileImplement.csproj @@ -11,4 +11,8 @@ + + + + diff --git a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/MessageInfo.cs b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/MessageInfo.cs index 4884680..5d36e6a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/MessageInfo.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/MessageInfo.cs @@ -14,7 +14,9 @@ namespace BlacksmithWorkshopFileImplement.Models { public class MessageInfo : IMessageInfoModel { - public string MessageId { get; private set; } = string.Empty; + public int Id { get; private set; } + + public string MessageId { get; private set; } = string.Empty; public int? ClientId { get; private set; } @@ -94,5 +96,5 @@ namespace BlacksmithWorkshopFileImplement.Models new XElement("Body", Body), new XElement("Subject", Subject), new XElement("DateDelivery", DateDelivery.ToString())); - } + } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj index b65badc..d1597ab 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/BlacksmithWorkshopListImplement.csproj @@ -11,4 +11,8 @@ + + + + diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/MessageInfo.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/MessageInfo.cs index cfcc629..e116e76 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/MessageInfo.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Models/MessageInfo.cs @@ -12,7 +12,9 @@ namespace BlacksmithWorkshopListImplement.Models { public class MessageInfo : IMessageInfoModel { - public string MessageId { get; private set; } = string.Empty; + public int Id { get; private set; } + + public string MessageId { get; private set; } = string.Empty; public int? ClientId { get; private set; } @@ -69,5 +71,5 @@ namespace BlacksmithWorkshopListImplement.Models Subject = Subject, Body = Body }; - } + } }