From 9f89c838526ba5e70084c723114c911d665150ee Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Tue, 21 May 2024 20:02:14 +0400 Subject: [PATCH 1/3] =?UTF-8?q?=D0=9E=D1=88=D0=B8=D0=B1=D0=BA=D0=B8.=20?= =?UTF-8?q?=D0=9C=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE?= =?UTF-8?q?=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlumbingRepair/DataGridViewExtension.cs | 54 ++++++++ PlumbingRepair/PlumbingRepair/FormClients.cs | 13 +- .../PlumbingRepair/FormComponent.cs | 117 ++++++++++-------- .../PlumbingRepair/FormImplementer.cs | 117 +++++++++--------- PlumbingRepair/PlumbingRepair/Program.cs | 85 ++++++------- .../BusinessLogics/BackUpLogic.cs | 112 +++++++++++++++++ .../Attributes/ColumnAttribute.cs | 29 +++++ .../Attributes/GridViewAutoSize.cs | 20 +++ .../BindingModels/BackUpSaveBindingModel.cs | 13 ++ .../BindingModels/MessageInfoBindingModel.cs | 1 + .../BusinessLogicsContracts/IBackUpLogic.cs | 14 +++ .../DI/DependencyManager.cs | 43 +++++++ .../DI/IDependencyContainer.cs | 17 +++ .../DI/IImplementationExtension.cs | 14 +++ .../DI/ServiceDependencyContainer.cs | 64 ++++++++++ .../DI/ServiceProviderLoader.cs | 57 +++++++++ .../DI/UnityDependencyContainer.cs | 44 +++++++ .../PlumbingRepairContracts.csproj | 6 + .../StoragesContracts/IBackUpInfo.cs | 14 +++ .../ViewModels/ClientViewModel.cs | 10 +- .../ViewModels/ComponentViewModel.cs | 6 +- .../ViewModels/ImplementerViewModel.cs | 11 +- .../ViewModels/MessageInfoViewModel.cs | 15 ++- .../ViewModels/OrderViewModel.cs | 25 ++-- .../ViewModels/WorkViewModel.cs | 9 +- .../DatabaseImplementationExtension.cs | 27 ++++ .../Implements/BackUpInfo.cs | 33 +++++ .../Models/Client.cs | 9 +- .../Models/Component.cs | 5 + .../Models/Implementer.cs | 7 ++ .../Models/Message.cs | 9 ++ .../Models/Order.cs | 20 +-- .../Models/Work.cs | 6 + .../Models/IMessageInfoModel.cs | 2 +- .../FileImplementationExtension.cs | 27 ++++ .../Implements/BackUpInfo.cs | 37 ++++++ .../Models/Client.cs | 6 + .../Models/Component.cs | 5 + .../Models/Implementer.cs | 11 +- .../Models/Message.cs | 14 ++- .../Models/Order.cs | 20 ++- .../Models/Work.cs | 6 + .../Implements/BackUpInfo.cs | 22 ++++ .../ListImplementationExtension.cs | 27 ++++ .../Models/Message.cs | 1 + 45 files changed, 984 insertions(+), 220 deletions(-) create mode 100644 PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs create mode 100644 PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/BackUpLogic.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/Attributes/ColumnAttribute.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/Attributes/GridViewAutoSize.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/BindingModels/BackUpSaveBindingModel.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IBackUpLogic.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/DI/DependencyManager.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/DI/IDependencyContainer.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/DI/IImplementationExtension.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/DI/ServiceDependencyContainer.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/DI/ServiceProviderLoader.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/DI/UnityDependencyContainer.cs create mode 100644 PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IBackUpInfo.cs create mode 100644 PlumbingRepair/PlumbingRepairDataBaseImplement/DatabaseImplementationExtension.cs create mode 100644 PlumbingRepair/PlumbingRepairDataBaseImplement/Implements/BackUpInfo.cs create mode 100644 PlumbingRepair/PlumbingRepairFileImplement/FileImplementationExtension.cs create mode 100644 PlumbingRepair/PlumbingRepairFileImplement/Implements/BackUpInfo.cs create mode 100644 PlumbingRepair/PlumbingRepairListImplement/Implements/BackUpInfo.cs create mode 100644 PlumbingRepair/PlumbingRepairListImplement/ListImplementationExtension.cs diff --git a/PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs b/PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs new file mode 100644 index 0000000..b7db19e --- /dev/null +++ b/PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairContracts.Attributes +{ + public 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/PlumbingRepair/PlumbingRepair/FormClients.cs b/PlumbingRepair/PlumbingRepair/FormClients.cs index 048d006..67613e5 100644 --- a/PlumbingRepair/PlumbingRepair/FormClients.cs +++ b/PlumbingRepair/PlumbingRepair/FormClients.cs @@ -3,6 +3,7 @@ using PlumbingRepairContracts.BusinessLogicsContracts; using PlumbingRepairContracts.SearchModels; using Microsoft.Extensions.Logging; using System.Windows.Forms; +using PlumbingRepairContracts.Attributes; namespace PlumbingRepairView { @@ -28,18 +29,12 @@ namespace PlumbingRepairView { try { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } - _logger.LogInformation("Загрузка компонентов"); + dataGridView.FillandConfigGrid(_logic.ReadList(null)); + _logger.LogInformation("Загрузка клиентов"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки компонентов"); + _logger.LogError(ex, "Ошибка загрузки клиентов"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/PlumbingRepair/PlumbingRepair/FormComponent.cs b/PlumbingRepair/PlumbingRepair/FormComponent.cs index c080e07..0f40ede 100644 --- a/PlumbingRepair/PlumbingRepair/FormComponent.cs +++ b/PlumbingRepair/PlumbingRepair/FormComponent.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Logging; using PlumbingRepairContracts.BusinessLogicsContracts; using PlumbingRepairContracts.BindingModels; -using PlumbingRepairContracts.SearchModels; +using PlumbingRepairContracts.DI; using System.Windows.Forms; namespace PlumbingRepairView @@ -18,70 +18,79 @@ namespace PlumbingRepairView _logger = logger; _logic = logic; } - private void FormComponent_Load(object sender, EventArgs e) + private void FormComponents_Load(object sender, EventArgs e) { - if (_id.HasValue) - { - try - { - _logger.LogInformation(" "); - var view = _logic.ReadElement(new ComponentSearchModel - { - Id = _id.Value - }); - if (view != null) - { - textBoxName.Text = view.ComponentName; - textBoxCost.Text = view.Cost.ToString(); - } - } - catch (Exception ex) - { - _logger.LogError(ex, " "); - MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } + LoadData(); } - private void ButtonSave_Click(object sender, EventArgs e) + + private void LoadData() { - if (string.IsNullOrEmpty(textBoxName.Text)) - { - MessageBox.Show(" ", "", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - _logger.LogInformation(" "); try { - var model = new ComponentBindingModel - { - Id = _id ?? 0, - ComponentName = textBoxName.Text, - Cost = Convert.ToDouble(textBoxCost.Text) - }; - var operationResult = _id.HasValue ? _logic.Update(model) : - _logic.Create(model); - if (!operationResult) - { - throw new Exception(" . ."); - } - MessageBox.Show(" ", "", - MessageBoxButtons.OK, MessageBoxIcon.Information); - DialogResult = DialogResult.OK; - Close(); + DataGridView.FillandConfigGrid(_logic.ReadList(null)); + _logger.LogInformation(" "); + } catch (Exception ex) { - _logger.LogError(ex, " "); - MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, - MessageBoxIcon.Error); + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void ButtonCancel_Click(object sender, EventArgs e) + private void AddButton_Click(object sender, EventArgs e) { - DialogResult = DialogResult.Cancel; - Close(); + var form = DependencyManager.Instance.Resolve(); + + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + private void ChangeButton_Click(object sender, EventArgs e) + { + if (DataGridView.SelectedRows.Count == 1) + { + var form = DependencyManager.Instance.Resolve(); + form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + + } + } + private void DeleteButton_Click(object sender, EventArgs e) + { + if (DataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show(" ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation(" "); + + try + { + if (!_logic.Delete(new ComponentBindingModel + { + Id = id + })) + { + throw new Exception(" . ."); + } + + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void UpdateButton_Click(object sender, EventArgs e) + { + LoadData(); } } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepair/FormImplementer.cs b/PlumbingRepair/PlumbingRepair/FormImplementer.cs index e8e773c..88fadf9 100644 --- a/PlumbingRepair/PlumbingRepair/FormImplementer.cs +++ b/PlumbingRepair/PlumbingRepair/FormImplementer.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.BusinessLogicsContracts; +using PlumbingRepairContracts.DI; using PlumbingRepairContracts.SearchModels; using System; using System.Collections.Generic; @@ -28,78 +29,82 @@ namespace PlumbingRepair _logic = logic; } - private void ButtonSave_Click(object sender, EventArgs e) + private void AddButton_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(PasswordTextBox.Text)) + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) { - MessageBox.Show("Заполните пароль", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return; + LoadData(); } - if (string.IsNullOrEmpty(FIOTextBox.Text)) + } + + private void ChangeButton_Click(object sender, EventArgs e) + { + if (DataGridView.SelectedRows.Count == 1) { - MessageBox.Show("Заполните фио", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - _logger.LogInformation("Сохранение исполнителя"); - try - { - var model = new ImplementerBindingModel + var form = DependencyManager.Instance.Resolve(); + form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) { - Id = _id ?? 0, - ImplementerFIO = FIOTextBox.Text, - Password = PasswordTextBox.Text, - Qualification = (int)QualificationNumericUpDown.Value, - WorkExperience = (int)WorkExpNumericUpDown.Value, - }; - var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + LoadData(); } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", - MessageBoxButtons.OK, MessageBoxIcon.Information); - DialogResult = DialogResult.OK; - Close(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка сохранения исполнителя"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void ButtonCancel_Click(object sender, EventArgs e) + private void DeleteButton_Click(object sender, EventArgs e) { - DialogResult = DialogResult.Cancel; - Close(); - } - - private void FormImplementer_Load(object sender, EventArgs e) - { - if (_id.HasValue) + if (DataGridView.SelectedRows.Count == 1) { - try + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - _logger.LogInformation("Получение исполнителя"); - var view = _logic.ReadElement(new ImplementerSearchModel + int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + + _logger.LogInformation("Удаление исполнителя"); + + try { - Id = _id.Value - }); - if (view != null) + if (!_logic.Delete(new ImplementerBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + + LoadData(); + } + catch (Exception ex) { - FIOTextBox.Text = view.ImplementerFIO; - PasswordTextBox.Text = view.Password; - QualificationNumericUpDown.Value = view.Qualification; - WorkExpNumericUpDown.Value = view.WorkExperience; + _logger.LogError(ex, "Ошибка удаления исполнителя"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения исполнителя"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } + } + } + + private void UpdateButton_Click(object sender, EventArgs e) + { + LoadData(); + } + + private void FormImplementers_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + try + { + DataGridView.FillandConfigGrid(_logic.ReadList(null)); + + _logger.LogInformation("Загрузка исполнителей"); + } + + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки исполнителей"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } diff --git a/PlumbingRepair/PlumbingRepair/Program.cs b/PlumbingRepair/PlumbingRepair/Program.cs index 7966c85..368ab97 100644 --- a/PlumbingRepair/PlumbingRepair/Program.cs +++ b/PlumbingRepair/PlumbingRepair/Program.cs @@ -5,35 +5,29 @@ using PlumbingRepairContracts.StoragesContracts; using PlumbingRepairBusinessLogic.OfficePackage.Implements; using PlumbingRepairBusinessLogic.OfficePackage; using PlumbingRepairDataBaseImplement.Implements; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using PlumbingRepairBusinessLogic.BusinessLogics; -using PlumbingRepair; using PlumbingRepairBusinessLogic.MailWorker; using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.DI; +using PlumbingRepair; namespace PlumbingRepairView { internal static class Program { - private static ServiceProvider? _serviceProvider; - public static ServiceProvider? ServiceProvider => _serviceProvider; - /// - /// The main entry point for the application. - /// [STAThread] static void Main() { // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - var services = new ServiceCollection(); - ConfigureServices(services); - _serviceProvider = services.BuildServiceProvider(); + InitDependency(); + try { - var mailSender = _serviceProvider.GetService(); + var mailSender = DependencyManager.Instance.Resolve(); mailSender?.MailConfig(new MailConfigBindingModel { MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty, @@ -48,53 +42,50 @@ namespace PlumbingRepairView } catch (Exception ex) { - var logger = _serviceProvider.GetService(); + var logger = DependencyManager.Instance.Resolve(); logger?.LogError(ex, "Error"); } - 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(); - services.AddSingleton(); + 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(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + DependencyManager.Instance.RegisterType(true); - 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(); + 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(); } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/BackUpLogic.cs b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/BackUpLogic.cs new file mode 100644 index 0000000..9151008 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairBusinessLogic/BusinessLogics/BackUpLogic.cs @@ -0,0 +1,112 @@ +using Microsoft.Extensions.Logging; +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.BusinessLogicsContracts; +using PlumbingRepairContracts.StoragesContracts; +using PlumbingRepairDataModels; +using System.IO.Compression; +using System.Reflection; +using System.Runtime.Serialization.Json; + +namespace PlumbingRepairBusinessLogic.BusinessLogics +{ + 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(BackUpSaveBindingModel model) + { + if (_backUpInfo == null) + { + return; + } + + try + { + _logger.LogDebug("Clear folder"); + // зачистка папки и удаление старого архива + var dirInfo = new DirectoryInfo(model.FolderName); + + if (dirInfo.Exists) + { + foreach (var file in dirInfo.GetFiles()) + { + file.Delete(); + } + } + + _logger.LogDebug("Delete archive"); + string fileName = $"{model.FolderName}.zip"; + + if (File.Exists(fileName)) + { + File.Delete(fileName); + } + + // берем метод для сохранения + _logger.LogDebug("Get assembly"); + var typeIId = typeof(IId); + var assembly = typeIId.Assembly; + + if (assembly == null) + { + throw new ArgumentNullException("Сборка не найдена", nameof(assembly)); + } + + var types = assembly.GetTypes(); + var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance); + _logger.LogDebug("Find {count} types", types.Length); + + foreach (var type in types) + { + if (type.IsInterface && type.GetInterface(typeIId.Name) != null) + { + var modelType = _backUpInfo.GetTypeByModelInterface(type.Name); + + if (modelType == null) + { + throw new InvalidOperationException($"Не найден класс-модель для {type.Name}"); + } + + _logger.LogDebug("Call SaveToFile method for {name} type", type.Name); + + method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName }); + } + } + + _logger.LogDebug("Create zip and remove folder"); + + ZipFile.CreateFromDirectory(model.FolderName, fileName); + + dirInfo.Delete(true); + } + catch (Exception) + { + throw; + } + } + + private void SaveToFile(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/PlumbingRepair/PlumbingRepairContracts/Attributes/ColumnAttribute.cs b/PlumbingRepair/PlumbingRepairContracts/Attributes/ColumnAttribute.cs new file mode 100644 index 0000000..2021496 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/Attributes/ColumnAttribute.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairContracts.Attributes +{ + [AttributeUsage(AttributeTargets.Property)] + public class ColumnAttribute : Attribute + { + public ColumnAttribute(string title = "", bool visible = true, int width + = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool + isUseAutoSize = false) + { + Title = title; + Visible = visible; + Width = width; + GridViewAutoSize = gridViewAutoSize; + IsUseAutoSize = isUseAutoSize; + } + public string Title { get; private set; } + public bool Visible { get; private set; } + public int Width { get; private set; } + public GridViewAutoSize GridViewAutoSize { get; private set; } + public bool IsUseAutoSize { get; private set; } + } + +} diff --git a/PlumbingRepair/PlumbingRepairContracts/Attributes/GridViewAutoSize.cs b/PlumbingRepair/PlumbingRepairContracts/Attributes/GridViewAutoSize.cs new file mode 100644 index 0000000..9e482bc --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/Attributes/GridViewAutoSize.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairContracts.Attributes +{ + public enum GridViewAutoSize + { + NotSet = 0, + None = 1, + ColumnHeader = 2, + AllCellsExceptHeader = 4, + AllCells = 6, + DisplayedCellsExceptHeader = 8, + DisplayedCells = 10, + Fill = 16 + } +} diff --git a/PlumbingRepair/PlumbingRepairContracts/BindingModels/BackUpSaveBindingModel.cs b/PlumbingRepair/PlumbingRepairContracts/BindingModels/BackUpSaveBindingModel.cs new file mode 100644 index 0000000..0612d47 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/BindingModels/BackUpSaveBindingModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairContracts.BindingModels +{ + public class BackUpSaveBindingModel + { + public string FolderName { get; set; } = string.Empty; + } +} diff --git a/PlumbingRepair/PlumbingRepairContracts/BindingModels/MessageInfoBindingModel.cs b/PlumbingRepair/PlumbingRepairContracts/BindingModels/MessageInfoBindingModel.cs index d29d717..f67c196 100644 --- a/PlumbingRepair/PlumbingRepairContracts/BindingModels/MessageInfoBindingModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/BindingModels/MessageInfoBindingModel.cs @@ -15,5 +15,6 @@ namespace PlumbingRepairContracts.BindingModels public string Subject { get; set; } = string.Empty; public string Body { get; set; } = string.Empty; public DateTime DateDelivery { get; set; } + public int Id => throw new NotImplementedException(); } } diff --git a/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IBackUpLogic.cs b/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IBackUpLogic.cs new file mode 100644 index 0000000..427c705 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/BusinessLogicsContracts/IBackUpLogic.cs @@ -0,0 +1,14 @@ +using PlumbingRepairContracts.BindingModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairContracts.BusinessLogicsContracts +{ + public interface IBackUpLogic + { + void CreateBackUp(BackUpSaveBindingModel model); + } +} diff --git a/PlumbingRepair/PlumbingRepairContracts/DI/DependencyManager.cs b/PlumbingRepair/PlumbingRepairContracts/DI/DependencyManager.cs new file mode 100644 index 0000000..d22b478 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/DI/DependencyManager.cs @@ -0,0 +1,43 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairContracts.DI +{ + public class DependencyManager + { + private readonly IDependencyContainer _dependencyManager; + private static DependencyManager? _manager; + private static readonly object _locjObject = new(); + + private DependencyManager() + { + _dependencyManager = new ServiceDependencyContainer(); + } + + public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } } + + public static void InitDependency() + { + var ext = ServiceProviderLoader.GetImplementationExtensions(); + if (ext == null) + { + throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям"); + } + + // регистрируем зависимости + ext.RegisterServices(); + } + + public void AddLogging(Action 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/PlumbingRepair/PlumbingRepairContracts/DI/IDependencyContainer.cs b/PlumbingRepair/PlumbingRepairContracts/DI/IDependencyContainer.cs new file mode 100644 index 0000000..053b8cb --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/DI/IDependencyContainer.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; + +namespace PlumbingRepairContracts.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/PlumbingRepair/PlumbingRepairContracts/DI/IImplementationExtension.cs b/PlumbingRepair/PlumbingRepairContracts/DI/IImplementationExtension.cs new file mode 100644 index 0000000..31cd718 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/DI/IImplementationExtension.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairContracts.DI +{ + public interface IImplementationExtension + { + public int Priority { get; } + public void RegisterServices(); + } +} diff --git a/PlumbingRepair/PlumbingRepairContracts/DI/ServiceDependencyContainer.cs b/PlumbingRepair/PlumbingRepairContracts/DI/ServiceDependencyContainer.cs new file mode 100644 index 0000000..7ffb67e --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/DI/ServiceDependencyContainer.cs @@ -0,0 +1,64 @@ +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 PlumbingRepairContracts.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/PlumbingRepair/PlumbingRepairContracts/DI/ServiceProviderLoader.cs b/PlumbingRepair/PlumbingRepairContracts/DI/ServiceProviderLoader.cs new file mode 100644 index 0000000..cb37b05 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/DI/ServiceProviderLoader.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairContracts.DI +{ + public class ServiceProviderLoader + { + public static IImplementationExtension? GetImplementationExtensions() + { + IImplementationExtension? source = null; + var files = Directory.GetFiles(TryGetImplementationExtensionsFolder(), "*.dll", SearchOption.AllDirectories); + + foreach (var file in files.Distinct()) + { + Assembly asm = Assembly.LoadFrom(file); + + foreach (var t in asm.GetExportedTypes()) + { + if (t.IsClass && typeof(IImplementationExtension).IsAssignableFrom(t)) + { + if (source == null) + { + source = (IImplementationExtension)Activator.CreateInstance(t)!; + } + else + { + var newSource = (IImplementationExtension)Activator.CreateInstance(t)!; + + if (newSource.Priority > source.Priority) + { + source = newSource; + } + } + } + } + } + + return source; + } + + private static string TryGetImplementationExtensionsFolder() + { + var directory = new DirectoryInfo(Directory.GetCurrentDirectory()); + + while (directory != null && !directory.GetDirectories("ImplementationExtensions", SearchOption.AllDirectories).Any(x => x.Name == "ImplementationExtensions")) + { + directory = directory.Parent; + } + + return $"{directory?.FullName}\\ImplementationExtensions"; + } + } +} diff --git a/PlumbingRepair/PlumbingRepairContracts/DI/UnityDependencyContainer.cs b/PlumbingRepair/PlumbingRepairContracts/DI/UnityDependencyContainer.cs new file mode 100644 index 0000000..48b966e --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/DI/UnityDependencyContainer.cs @@ -0,0 +1,44 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Unity.Microsoft.Logging; +using Unity; + +namespace PlumbingRepairContracts.DI +{ + public class UnityDependencyContainer : IDependencyContainer + { + private readonly IUnityContainer _container; + + public UnityDependencyContainer() + { + _container = new UnityContainer(); + } + + public void AddLogging(Action 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/PlumbingRepair/PlumbingRepairContracts/PlumbingRepairContracts.csproj b/PlumbingRepair/PlumbingRepairContracts/PlumbingRepairContracts.csproj index 667ab73..44d9b13 100644 --- a/PlumbingRepair/PlumbingRepairContracts/PlumbingRepairContracts.csproj +++ b/PlumbingRepair/PlumbingRepairContracts/PlumbingRepairContracts.csproj @@ -6,6 +6,12 @@ enable + + + + + + diff --git a/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IBackUpInfo.cs b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IBackUpInfo.cs new file mode 100644 index 0000000..0315f6d --- /dev/null +++ b/PlumbingRepair/PlumbingRepairContracts/StoragesContracts/IBackUpInfo.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairContracts.StoragesContracts +{ + public interface IBackUpInfo + { + List? GetList() where T : class, new(); + Type? GetTypeByModelInterface(string modelInterfaceName); + } +} diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/ClientViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/ClientViewModel.cs index df00fc4..23ae710 100644 --- a/PlumbingRepair/PlumbingRepairContracts/ViewModels/ClientViewModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/ClientViewModel.cs @@ -1,4 +1,5 @@ -using PlumbingRepairDataModels.Models; +using PlumbingRepairContracts.Attributes; +using PlumbingRepairDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,12 +11,13 @@ namespace PlumbingRepairContracts.ViewModels { public class ClientViewModel : IClientModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("ФИО клиента")] + [Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ClientFIO { get; set; } = string.Empty; - [DisplayName("Логин (эл. почта)")] + [Column("Логин (эл. почта)", width: 150)] public string Email { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column("Пароль", width: 150)] public string Password { get; set; } = string.Empty; } } diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/ComponentViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/ComponentViewModel.cs index 6ffcec2..8ae8294 100644 --- a/PlumbingRepair/PlumbingRepairContracts/ViewModels/ComponentViewModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/ComponentViewModel.cs @@ -4,16 +4,18 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using PlumbingRepairContracts.Attributes; using PlumbingRepairDataModels.Models; namespace PlumbingRepairContracts.ViewModels { public class ComponentViewModel : IComponentModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название компонента")] + [Column("Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ComponentName { get; set; } = string.Empty; - [DisplayName("Цена")] + [Column("Цена", width: 80)] public double Cost { get; set; } } } diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/ImplementerViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/ImplementerViewModel.cs index ce51d72..ed67365 100644 --- a/PlumbingRepair/PlumbingRepairContracts/ViewModels/ImplementerViewModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/ImplementerViewModel.cs @@ -1,4 +1,5 @@ -using PlumbingRepairDataModels.Models; +using PlumbingRepairContracts.Attributes; +using PlumbingRepairDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -12,16 +13,16 @@ namespace PlumbingRepairContracts.ViewModels { public int Id { get; set; } - [DisplayName("ФИО исполнителя")] + [Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column("Пароль", width: 150)] public string Password { get; set; } = string.Empty; - [DisplayName("Стаж работы")] + [Column("Стаж работы", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public int WorkExperience { get; set; } - [DisplayName("Квалификация")] + [Column("Квалификация", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public int Qualification { get; set; } } } diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/MessageInfoViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/MessageInfoViewModel.cs index b1428a3..7bf3a2a 100644 --- a/PlumbingRepair/PlumbingRepairContracts/ViewModels/MessageInfoViewModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/MessageInfoViewModel.cs @@ -1,4 +1,5 @@ -using PlumbingRepairDataModels.Models; +using PlumbingRepairContracts.Attributes; +using PlumbingRepairDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,20 +11,24 @@ namespace PlumbingRepairContracts.ViewModels { public class MessageInfoViewModel : IMessageInfoModel { + [Column(visible: false)] public string MessageId { get; set; } = string.Empty; + [Column(visible: false)] public int? ClientId { get; set; } - [DisplayName("Имя отправителя")] + [Column("Имя отправителя", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)] public string SenderName { get; set; } = string.Empty; - [DisplayName("Дата отправления")] + [Column("Дата отправления", width: 100)] public DateTime DateDelivery { get; set; } - [DisplayName("Тема")] + [Column("Тема", width: 150)] public string Subject { get; set; } = string.Empty; - [DisplayName("Содержание")] + [Column("Содержание", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Body { get; set; } = string.Empty; + [Column(visible: false)] + public int Id => throw new NotImplementedException(); } } diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs index 202feea..e3f7aa2 100644 --- a/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs @@ -1,4 +1,5 @@ -using PlumbingRepairDataModels.Enums; +using PlumbingRepairContracts.Attributes; +using PlumbingRepairDataModels.Enums; using PlumbingRepairDataModels.Models; using System; using System.Collections.Generic; @@ -11,27 +12,29 @@ namespace PlumbingRepairContracts.ViewModels { public class OrderViewModel : IOrderModel { - [DisplayName("Номер")] + [Column("Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public int Id { get; set; } + [Column(visible: false)] public int WorkId { get; set; } - [DisplayName("Работа")] + [Column("Название изделия", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public string WorkName { get; set; } = string.Empty; - [DisplayName("Клиент")] + [Column(visible: false)] public int ClientId { get; set; } - [DisplayName("ФИО клиента")] + [Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public string ClientFIO { get; set; } = string.Empty; + [Column(visible: false)] public int? ImplementerId { get; set; } - [DisplayName("Исполнитель")] + [Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Количество")] + [Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public int Count { get; set; } - [DisplayName("Сумма")] + [Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public double Sum { get; set; } - [DisplayName("Статус")] + [Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; - [DisplayName("Дата создания")] + [Column("Дата создания", width: 130)] public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); - [DisplayName("Дата выполнения")] + [Column("Дата выполнения", width: 130)] public DateTime? DateImplement { get; set; } public string ClientEmail { get; set; } = string.Empty; } diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/WorkViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/WorkViewModel.cs index 68caa32..c9420b4 100644 --- a/PlumbingRepair/PlumbingRepairContracts/ViewModels/WorkViewModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/WorkViewModel.cs @@ -1,4 +1,5 @@ -using PlumbingRepairDataModels.Models; +using PlumbingRepairContracts.Attributes; +using PlumbingRepairDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,11 +11,13 @@ namespace PlumbingRepairContracts.ViewModels { public class WorkViewModel : IWorkModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название работы")] + [Column("Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string WorkName { get; set; } = string.Empty; - [DisplayName("Цена")] + [Column("Цена", width: 100)] public double Price { get; set; } + [Column(visible: false)] public Dictionary WorkComponents { get; set; } = new(); } diff --git a/PlumbingRepair/PlumbingRepairDataBaseImplement/DatabaseImplementationExtension.cs b/PlumbingRepair/PlumbingRepairDataBaseImplement/DatabaseImplementationExtension.cs new file mode 100644 index 0000000..9617c79 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairDataBaseImplement/DatabaseImplementationExtension.cs @@ -0,0 +1,27 @@ +using PlumbingRepairContracts.DI; +using PlumbingRepairContracts.StoragesContracts; +using PlumbingRepairDataBaseImplement.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairDataBaseImplement +{ + 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/PlumbingRepair/PlumbingRepairDataBaseImplement/Implements/BackUpInfo.cs b/PlumbingRepair/PlumbingRepairDataBaseImplement/Implements/BackUpInfo.cs new file mode 100644 index 0000000..f8807f4 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairDataBaseImplement/Implements/BackUpInfo.cs @@ -0,0 +1,33 @@ +using PlumbingRepairContracts.StoragesContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairDataBaseImplement.Implements +{ + public class BackUpInfo : IBackUpInfo + { + public List? GetList() where T : class, new() + { + using var context = new PlumbingRepairDataBase(); + 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/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Client.cs b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Client.cs index ed151c7..3574c85 100644 --- a/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Client.cs +++ b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Client.cs @@ -8,26 +8,29 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Runtime.Serialization; namespace PlumbingRepairDataBaseImplement.Models { + [DataContract] public class Client : IClientModel { + [DataMember] public int Id { get; private set; } [Required] + [DataMember] public string ClientFIO { get; private set; } = string.Empty; [Required] + [DataMember] public string Email { get; private set; } = string.Empty; [Required] + [DataMember] public string Password { get; private set; } = string.Empty; - - [ForeignKey("ClientId")] public virtual List Orders { get; set; } = new(); [ForeignKey("ClientId")] public virtual List Messages { get; set; } = new(); - public static Client? Create(ClientBindingModel? model) { if (model == null) diff --git a/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Component.cs b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Component.cs index a4b22e0..d3a79d4 100644 --- a/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Component.cs +++ b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Component.cs @@ -3,15 +3,20 @@ using System.ComponentModel.DataAnnotations; using PlumbingRepairDataModels.Models; using PlumbingRepairContracts.ViewModels; using PlumbingRepairContracts.BindingModels; +using System.Runtime.Serialization; namespace PlumbingRepairDataBaseImplement.Models { + [DataContract] public class Component : IComponentModel { + [DataMember] public int Id { get; private set; } [Required] + [DataMember] public string ComponentName { get; private set; } = string.Empty; [Required] + [DataMember] public double Cost { get; set; } [ForeignKey("ComponentId")] public virtual List WorkComponents { get; set; } = new(); diff --git a/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Implementer.cs b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Implementer.cs index e08a9db..aec45b7 100644 --- a/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Implementer.cs +++ b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Implementer.cs @@ -8,23 +8,30 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Runtime.Serialization; namespace PlumbingRepairDataBaseImplement.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/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Message.cs b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Message.cs index 79e9300..77fc733 100644 --- a/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Message.cs +++ b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Message.cs @@ -5,19 +5,27 @@ 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 PlumbingRepairDataBaseImplement.Models { + [DataContract] public class Message : IMessageInfoModel { [Key] + [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.SpecifyKind(DateTime.Now, DateTimeKind.Utc); + [DataMember] public string Subject { get; private set; } = string.Empty; + [DataMember] public string Body { get; private set; } = string.Empty; public virtual Client? Client { get; set; } @@ -48,5 +56,6 @@ namespace PlumbingRepairDataBaseImplement.Models SenderName = SenderName, DateDelivery = DateDelivery }; + public int Id => throw new NotImplementedException(); } } diff --git a/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Order.cs b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Order.cs index 192afb8..092513a 100644 --- a/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Order.cs +++ b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Order.cs @@ -6,33 +6,39 @@ 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 PlumbingRepairDataBaseImplement.Models { + [DataContract] public class Order : IOrderModel { + [DataMember] public int Id { get; private set; } - + [DataMember] public int WorkId { get; private set; } + [Required] + [DataMember] public int ClientId { get; private set; } + [DataMember] public int? ImplementerId { get; set; } - + [DataMember] public string WorkName { get; private set; } = string.Empty; - [Required] + [DataMember] public int Count { get; private set; } - [Required] + [DataMember] public double Sum { get; private set; } - [Required] + [DataMember] public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; - [Required] + [DataMember] public DateTime DateCreate { get; private set; } - + [DataMember] public DateTime? DateImplement { get; private set; } public virtual Work Work { get; set; } diff --git a/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Work.cs b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Work.cs index e9d145e..63e46b7 100644 --- a/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Work.cs +++ b/PlumbingRepair/PlumbingRepairDataBaseImplement/Models/Work.cs @@ -8,19 +8,25 @@ using System.Text; using System.Threading.Tasks; using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.ViewModels; +using System.Runtime.Serialization; namespace PlumbingRepairDataBaseImplement.Models { + [DataContract] public class Work : IWorkModel { + [DataMember] public int Id { get; set; } [Required] + [DataMember] public string WorkName { get; set; } = string.Empty; [Required] + [DataMember] public double Price { get; set; } private Dictionary? _workComponents = null; [NotMapped] + [DataMember] public Dictionary WorkComponents { get diff --git a/PlumbingRepair/PlumbingRepairDataModels/Models/IMessageInfoModel.cs b/PlumbingRepair/PlumbingRepairDataModels/Models/IMessageInfoModel.cs index 9224087..546f5ef 100644 --- a/PlumbingRepair/PlumbingRepairDataModels/Models/IMessageInfoModel.cs +++ b/PlumbingRepair/PlumbingRepairDataModels/Models/IMessageInfoModel.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace PlumbingRepairDataModels.Models { - public interface IMessageInfoModel + public interface IMessageInfoModel : IId { string MessageId { get; } int? ClientId { get; } diff --git a/PlumbingRepair/PlumbingRepairFileImplement/FileImplementationExtension.cs b/PlumbingRepair/PlumbingRepairFileImplement/FileImplementationExtension.cs new file mode 100644 index 0000000..91d3702 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairFileImplement/FileImplementationExtension.cs @@ -0,0 +1,27 @@ +using PlumbingRepairContracts.DI; +using PlumbingRepairContracts.StoragesContracts; +using PlumbingRepairFileImplement.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairFileImplement +{ + 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/PlumbingRepair/PlumbingRepairFileImplement/Implements/BackUpInfo.cs b/PlumbingRepair/PlumbingRepairFileImplement/Implements/BackUpInfo.cs new file mode 100644 index 0000000..4bb5333 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairFileImplement/Implements/BackUpInfo.cs @@ -0,0 +1,37 @@ +using PlumbingRepairContracts.StoragesContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairFileImplement.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/PlumbingRepair/PlumbingRepairFileImplement/Models/Client.cs b/PlumbingRepair/PlumbingRepairFileImplement/Models/Client.cs index e910ee0..fe29714 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/Models/Client.cs +++ b/PlumbingRepair/PlumbingRepairFileImplement/Models/Client.cs @@ -4,17 +4,23 @@ using PlumbingRepairDataModels.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 PlumbingRepairFileImplement.Models { + [DataContract] public class Client : IClientModel { + [DataMember] public int Id { get; private set; } + [DataMember] public string ClientFIO { get; private set; } = string.Empty; + [DataMember] public string Email { get; private set; } = string.Empty; + [DataMember] public string Password { get; private set; } = string.Empty; public static Client? Create(ClientBindingModel model) { diff --git a/PlumbingRepair/PlumbingRepairFileImplement/Models/Component.cs b/PlumbingRepair/PlumbingRepairFileImplement/Models/Component.cs index 7206698..949f6a3 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/Models/Component.cs +++ b/PlumbingRepair/PlumbingRepairFileImplement/Models/Component.cs @@ -1,14 +1,19 @@ using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.ViewModels; using PlumbingRepairDataModels.Models; +using System.Runtime.Serialization; using System.Xml.Linq; namespace PlumbingRepairFileImplement.Models { + [DataContract] public class Component : IComponentModel { + [DataMember] public int Id { get; private set; } + [DataMember] public string ComponentName { get; private set; } = string.Empty; + [DataMember] public double Cost { get; set; } public static Component? Create(ComponentBindingModel model) { diff --git a/PlumbingRepair/PlumbingRepairFileImplement/Models/Implementer.cs b/PlumbingRepair/PlumbingRepairFileImplement/Models/Implementer.cs index c47b9be..afb94d0 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/Models/Implementer.cs +++ b/PlumbingRepair/PlumbingRepairFileImplement/Models/Implementer.cs @@ -4,22 +4,25 @@ using PlumbingRepairDataModels.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 PlumbingRepairFileImplement.Models { + [DataContract] public class Implementer : IImplementerModel { + [DataMember] public string ImplementerFIO { get; set; } = string.Empty; - + [DataMember] public string Password { get; set; } = string.Empty; - + [DataMember] public int WorkExperience { get; set; } - + [DataMember] public int Qualification { get; set; } - + [DataMember] public int Id { get; set; } public static Implementer? Create(ImplementerBindingModel? model) diff --git a/PlumbingRepair/PlumbingRepairFileImplement/Models/Message.cs b/PlumbingRepair/PlumbingRepairFileImplement/Models/Message.cs index ce965c0..be4d507 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/Models/Message.cs +++ b/PlumbingRepair/PlumbingRepairFileImplement/Models/Message.cs @@ -4,24 +4,27 @@ using PlumbingRepairDataModels.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 PlumbingRepairFileImplement.Models { + [DataContract] public class Message : IMessageInfoModel { + [DataMember] public string MessageId { get; private set; } = string.Empty; - + [DataMember] public int? ClientId { get; private set; } - + [DataMember] public string SenderName { get; private set; } = string.Empty; - + [DataMember] public DateTime DateDelivery { get; private set; } = DateTime.Now; - + [DataMember] public string Subject { get; private set; } = string.Empty; - + [DataMember] public string Body { get; private set; } = string.Empty; public static Message? Create(MessageInfoBindingModel model) @@ -76,5 +79,6 @@ namespace PlumbingRepairFileImplement.Models new XAttribute("SenderName", SenderName), new XAttribute("DateDelivery", DateDelivery.ToString()) ); + public int Id => throw new NotImplementedException(); } } diff --git a/PlumbingRepair/PlumbingRepairFileImplement/Models/Order.cs b/PlumbingRepair/PlumbingRepairFileImplement/Models/Order.cs index 8182c42..3fc2917 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/Models/Order.cs +++ b/PlumbingRepair/PlumbingRepairFileImplement/Models/Order.cs @@ -5,23 +5,35 @@ using PlumbingRepairDataModels.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 PlumbingRepairFileImplement.Models { + [DataContract] public class Order : IOrderModel { + [DataMember] public int Id { get; private set; } + [DataMember] public int WorkId { get; private set; } + [DataMember] public int ClientId { get; private set; } + [DataMember] public int? ImplementerId { get; private set; } + [DataMember] public String WorkName { get; private set; } = string.Empty; + [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; } + [DataMember] public DateTime? DateImplement { get; private set; } public static Order? Create(OrderBindingModel? model) @@ -50,6 +62,7 @@ namespace PlumbingRepairFileImplement.Models { return null; } + DateTime.TryParse(element.Element("DateImplement")!.Value, out DateTime dateImpl); return new Order() { Id = Convert.ToInt32(element.Attribute("Id")!.Value), @@ -59,10 +72,9 @@ namespace PlumbingRepairFileImplement.Models ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value), - Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value), - DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value), - DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null - : Convert.ToDateTime(element.Element("DateImplement")!.Value) + Status = (OrderStatus)Convert.ToInt32(element.Element("Status")!.Value), + DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null), + DateImplement = dateImpl }; } public void Update(OrderBindingModel? model) diff --git a/PlumbingRepair/PlumbingRepairFileImplement/Models/Work.cs b/PlumbingRepair/PlumbingRepairFileImplement/Models/Work.cs index 54be2d7..257ce6d 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/Models/Work.cs +++ b/PlumbingRepair/PlumbingRepairFileImplement/Models/Work.cs @@ -4,19 +4,25 @@ using PlumbingRepairDataModels.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 PlumbingRepairFileImplement.Models { + [DataContract] public class Work : IWorkModel { + [DataMember] public int Id { get; private set; } + [DataMember] public string WorkName { get; private set; } = string.Empty; + [DataMember] public double Price { get; private set; } public Dictionary Components { get; private set; } = new(); private Dictionary? _workComponents = null; + [DataMember] public Dictionary WorkComponents { get diff --git a/PlumbingRepair/PlumbingRepairListImplement/Implements/BackUpInfo.cs b/PlumbingRepair/PlumbingRepairListImplement/Implements/BackUpInfo.cs new file mode 100644 index 0000000..ca63a5d --- /dev/null +++ b/PlumbingRepair/PlumbingRepairListImplement/Implements/BackUpInfo.cs @@ -0,0 +1,22 @@ +using PlumbingRepairContracts.StoragesContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairListImplement.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/PlumbingRepair/PlumbingRepairListImplement/ListImplementationExtension.cs b/PlumbingRepair/PlumbingRepairListImplement/ListImplementationExtension.cs new file mode 100644 index 0000000..09466c7 --- /dev/null +++ b/PlumbingRepair/PlumbingRepairListImplement/ListImplementationExtension.cs @@ -0,0 +1,27 @@ +using PlumbingRepairContracts.DI; +using PlumbingRepairContracts.StoragesContracts; +using PlumbingRepairListImplement.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PlumbingRepairListImplement +{ + 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/PlumbingRepair/PlumbingRepairListImplement/Models/Message.cs b/PlumbingRepair/PlumbingRepairListImplement/Models/Message.cs index 1fec089..c919f63 100644 --- a/PlumbingRepair/PlumbingRepairListImplement/Models/Message.cs +++ b/PlumbingRepair/PlumbingRepairListImplement/Models/Message.cs @@ -49,5 +49,6 @@ namespace PlumbingRepairListImplement.Models ClientId = ClientId, MessageId = MessageId }; + public int Id => throw new NotImplementedException(); } } -- 2.25.1 From 112833ae6812156abb4b4c2e46dfa26c27aebe32 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Tue, 21 May 2024 21:56:44 +0400 Subject: [PATCH 2/3] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D1=82=D0=B8=20=D0=B2?= =?UTF-8?q?=D1=81=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20=D1=80?= =?UTF-8?q?=D0=B5=D1=88=D0=B5=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlumbingRepair/DataGridViewExtension.cs | 28 +-- PlumbingRepair/PlumbingRepair/FormClients.cs | 3 - .../PlumbingRepair/FormComponent.cs | 117 +++++----- .../PlumbingRepair/FormComponents.Designer.cs | 26 +-- .../PlumbingRepair/FormComponents.cs | 43 ++-- .../PlumbingRepair/FormImplementer.cs | 126 ++++++----- .../PlumbingRepair/FormImplementers.cs | 22 +- PlumbingRepair/PlumbingRepair/FormMails.cs | 10 +- .../PlumbingRepair/FormMain.Designer.cs | 65 ++---- PlumbingRepair/PlumbingRepair/FormMain.cs | 199 +++++------------- .../PlumbingRepair/FormWork.Designer.cs | 28 +-- PlumbingRepair/PlumbingRepair/FormWork.cs | 86 ++++---- .../PlumbingRepair/FormWorks.Designer.cs | 24 +-- PlumbingRepair/PlumbingRepair/FormWorks.cs | 57 ++--- 14 files changed, 324 insertions(+), 510 deletions(-) diff --git a/PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs b/PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs index b7db19e..0dae034 100644 --- a/PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs +++ b/PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs @@ -1,10 +1,11 @@ -using System; +using PlumbingRepairContracts.Attributes; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace PlumbingRepairContracts.Attributes +namespace PlumbingRepairContracts { public static class DataGridViewExtension { @@ -14,33 +15,37 @@ namespace PlumbingRepairContracts.Attributes { 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); + var property = properties.FirstOrDefault(x => x.Name == column.Name); + if (property == null) { - throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем { column.Name }"); + throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем {column.Name}"); } - var attribute = - property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault(); + + var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault(); + if (attribute == null) { - throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства { property.Name }"); + 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()); + column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString()); } else { @@ -49,6 +54,5 @@ namespace PlumbingRepairContracts.Attributes } } } - } } diff --git a/PlumbingRepair/PlumbingRepair/FormClients.cs b/PlumbingRepair/PlumbingRepair/FormClients.cs index 67613e5..174f470 100644 --- a/PlumbingRepair/PlumbingRepair/FormClients.cs +++ b/PlumbingRepair/PlumbingRepair/FormClients.cs @@ -1,9 +1,6 @@ using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.BusinessLogicsContracts; -using PlumbingRepairContracts.SearchModels; using Microsoft.Extensions.Logging; -using System.Windows.Forms; -using PlumbingRepairContracts.Attributes; namespace PlumbingRepairView { diff --git a/PlumbingRepair/PlumbingRepair/FormComponent.cs b/PlumbingRepair/PlumbingRepair/FormComponent.cs index 0f40ede..c080e07 100644 --- a/PlumbingRepair/PlumbingRepair/FormComponent.cs +++ b/PlumbingRepair/PlumbingRepair/FormComponent.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Logging; using PlumbingRepairContracts.BusinessLogicsContracts; using PlumbingRepairContracts.BindingModels; -using PlumbingRepairContracts.DI; +using PlumbingRepairContracts.SearchModels; using System.Windows.Forms; namespace PlumbingRepairView @@ -18,79 +18,70 @@ namespace PlumbingRepairView _logger = logger; _logic = logic; } - private void FormComponents_Load(object sender, EventArgs e) + private void FormComponent_Load(object sender, EventArgs e) { - LoadData(); + if (_id.HasValue) + { + try + { + _logger.LogInformation(" "); + var view = _logic.ReadElement(new ComponentSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ComponentName; + textBoxCost.Text = view.Cost.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } } - - private void LoadData() + private void ButtonSave_Click(object sender, EventArgs e) { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show(" ", "", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation(" "); try { - DataGridView.FillandConfigGrid(_logic.ReadList(null)); - _logger.LogInformation(" "); - + var model = new ComponentBindingModel + { + Id = _id ?? 0, + ComponentName = textBoxName.Text, + Cost = Convert.ToDouble(textBoxCost.Text) + }; + var operationResult = _id.HasValue ? _logic.Update(model) : + _logic.Create(model); + if (!operationResult) + { + throw new Exception(" . ."); + } + MessageBox.Show(" ", "", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); } catch (Exception ex) { - _logger.LogError(ex, " "); - MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } - private void AddButton_Click(object sender, EventArgs e) + private void ButtonCancel_Click(object sender, EventArgs e) { - var form = DependencyManager.Instance.Resolve(); - - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } - private void ChangeButton_Click(object sender, EventArgs e) - { - if (DataGridView.SelectedRows.Count == 1) - { - var form = DependencyManager.Instance.Resolve(); - form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - - } - } - private void DeleteButton_Click(object sender, EventArgs e) - { - if (DataGridView.SelectedRows.Count == 1) - { - if (MessageBox.Show(" ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation(" "); - - try - { - if (!_logic.Delete(new ComponentBindingModel - { - Id = id - })) - { - throw new Exception(" . ."); - } - - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, " "); - MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - } - private void UpdateButton_Click(object sender, EventArgs e) - { - LoadData(); + DialogResult = DialogResult.Cancel; + Close(); } } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepair/FormComponents.Designer.cs b/PlumbingRepair/PlumbingRepair/FormComponents.Designer.cs index 3a2b842..2b10243 100644 --- a/PlumbingRepair/PlumbingRepair/FormComponents.Designer.cs +++ b/PlumbingRepair/PlumbingRepair/FormComponents.Designer.cs @@ -28,24 +28,24 @@ /// private void InitializeComponent() { - dataGridView = new DataGridView(); + DataGridView = new DataGridView(); buttonAdd = new Button(); buttonDel = new Button(); buttonChange = new Button(); buttonRef = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit(); SuspendLayout(); // // dataGridView // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(10, 8); - dataGridView.Margin = new Padding(2); - dataGridView.Name = "dataGridView"; - dataGridView.RowHeadersWidth = 62; - dataGridView.RowTemplate.Height = 33; - dataGridView.Size = new Size(512, 404); - dataGridView.TabIndex = 0; + DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + DataGridView.Location = new Point(10, 8); + DataGridView.Margin = new Padding(2); + DataGridView.Name = "dataGridView"; + DataGridView.RowHeadersWidth = 62; + DataGridView.RowTemplate.Height = 33; + DataGridView.Size = new Size(512, 404); + DataGridView.TabIndex = 0; // // buttonAdd // @@ -100,18 +100,18 @@ Controls.Add(buttonChange); Controls.Add(buttonDel); Controls.Add(buttonAdd); - Controls.Add(dataGridView); + Controls.Add(DataGridView); Margin = new Padding(2); Name = "FormComponents"; Text = "Компоненты"; Load += FormComponents_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); ResumeLayout(false); } #endregion - private DataGridView dataGridView; + private DataGridView DataGridView; private Button buttonAdd; private Button buttonDel; private Button buttonChange; diff --git a/PlumbingRepair/PlumbingRepair/FormComponents.cs b/PlumbingRepair/PlumbingRepair/FormComponents.cs index 3b86239..2db540d 100644 --- a/PlumbingRepair/PlumbingRepair/FormComponents.cs +++ b/PlumbingRepair/PlumbingRepair/FormComponents.cs @@ -1,6 +1,8 @@ using Microsoft.Extensions.Logging; +using PlumbingRepairContracts.Attributes; using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.BusinessLogicsContracts; +using PlumbingRepairContracts.DI; namespace PlumbingRepairView { @@ -22,14 +24,7 @@ namespace PlumbingRepairView { try { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ComponentName"].AutoSizeMode = - DataGridViewAutoSizeColumnMode.Fill; - } + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка компонентов"); } catch (Exception ex) @@ -41,38 +36,32 @@ namespace PlumbingRepairView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); - if (service is FormComponent form) + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) { + LoadData(); + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (DataGridView.SelectedRows.Count == 1) + { + var form = DependencyManager.Instance.Resolve(); + form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) { LoadData(); } } } - private void ButtonUpd_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); - if (service is FormComponent form) - { - form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } - } - } 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); + int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Удаление компонента"); try { diff --git a/PlumbingRepair/PlumbingRepair/FormImplementer.cs b/PlumbingRepair/PlumbingRepair/FormImplementer.cs index 88fadf9..00aecd8 100644 --- a/PlumbingRepair/PlumbingRepair/FormImplementer.cs +++ b/PlumbingRepair/PlumbingRepair/FormImplementer.cs @@ -29,83 +29,79 @@ namespace PlumbingRepair _logic = logic; } - private void AddButton_Click(object sender, EventArgs e) + private void ButtonSave_Click(object sender, EventArgs e) { - var form = DependencyManager.Instance.Resolve(); - if (form.ShowDialog() == DialogResult.OK) + if (string.IsNullOrEmpty(PasswordTextBox.Text)) { - LoadData(); + MessageBox.Show("Заполните пароль", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; } - } - - private void ChangeButton_Click(object sender, EventArgs e) - { - if (DataGridView.SelectedRows.Count == 1) + if (string.IsNullOrEmpty(FIOTextBox.Text)) { - var form = DependencyManager.Instance.Resolve(); - form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } + MessageBox.Show("Заполните фио", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; } - } - - private void DeleteButton_Click(object sender, EventArgs e) - { - if (DataGridView.SelectedRows.Count == 1) - { - if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); - - _logger.LogInformation("Удаление исполнителя"); - - try - { - if (!_logic.Delete(new ImplementerBindingModel - { - Id = id - })) - { - throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); - } - - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка удаления исполнителя"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - } - - private void UpdateButton_Click(object sender, EventArgs e) - { - LoadData(); - } - - private void FormImplementers_Load(object sender, EventArgs e) - { - LoadData(); - } - - private void LoadData() - { + _logger.LogInformation("Сохранение исполнителя"); try { - DataGridView.FillandConfigGrid(_logic.ReadList(null)); - - _logger.LogInformation("Загрузка исполнителей"); + var model = new ImplementerBindingModel + { + Id = _id ?? 0, + ImplementerFIO = FIOTextBox.Text, + Password = PasswordTextBox.Text, + Qualification = (int)QualificationNumericUpDown.Value, + WorkExperience = (int)WorkExpNumericUpDown.Value, + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); } - catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки исполнителей"); + _logger.LogError(ex, "Ошибка сохранения исполнителя"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void FormImplementer_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение исполнителя"); + var view = _logic.ReadElement(new ImplementerSearchModel + { + Id = _id.Value + }); + if (view != null) + { + FIOTextBox.Text = view.ImplementerFIO; + PasswordTextBox.Text = view.Password; + QualificationNumericUpDown.Value = view.Qualification; + WorkExpNumericUpDown.Value = view.WorkExperience; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения исполнителя"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepair/FormImplementers.cs b/PlumbingRepair/PlumbingRepair/FormImplementers.cs index 28f510b..0c5990e 100644 --- a/PlumbingRepair/PlumbingRepair/FormImplementers.cs +++ b/PlumbingRepair/PlumbingRepair/FormImplementers.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.BusinessLogicsContracts; +using PlumbingRepairContracts.DI; using PlumbingRepairView; using System; using System.Collections.Generic; @@ -27,14 +28,10 @@ namespace PlumbingRepair private void AddButton_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); - - if (service is FormImplementer form) + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) { - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } + LoadData(); } } @@ -42,14 +39,11 @@ namespace PlumbingRepair { if (DataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); - if (service is FormImplementer form) + var form = DependencyManager.Instance.Resolve(); + 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/PlumbingRepair/PlumbingRepair/FormMails.cs b/PlumbingRepair/PlumbingRepair/FormMails.cs index 708b2b5..c6cf560 100644 --- a/PlumbingRepair/PlumbingRepair/FormMails.cs +++ b/PlumbingRepair/PlumbingRepair/FormMails.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using PlumbingRepairContracts.Attributes; using PlumbingRepairContracts.BusinessLogicsContracts; using System; using System.Collections.Generic; @@ -29,14 +30,7 @@ namespace PlumbingRepairView { 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/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs b/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs index d73214d..7d69154 100644 --- a/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs +++ b/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs @@ -40,20 +40,19 @@ исполнителиToolStripMenuItem = new ToolStripMenuItem(); запускРаботToolStripMenuItem = new ToolStripMenuItem(); письмаToolStripMenuItem = new ToolStripMenuItem(); - dataGridView = new DataGridView(); + создатьБэкапToolStripMenuItem = new ToolStripMenuItem(); + DataGridView = new DataGridView(); buttonCreateOrder = new Button(); - buttonTakeOrderInWork = new Button(); - buttonOrderReady = new Button(); buttonIssuedOrder = new Button(); buttonUpdateList = new Button(); menuStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit(); SuspendLayout(); // // menuStrip1 // menuStrip1.ImageScalingSize = new Size(20, 20); - menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem, запускРаботToolStripMenuItem, письмаToolStripMenuItem }); + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem, запускРаботToolStripMenuItem, письмаToolStripMenuItem, создатьБэкапToolStripMenuItem }); menuStrip1.Location = new Point(0, 0); menuStrip1.Name = "menuStrip1"; menuStrip1.Padding = new Padding(8, 2, 0, 2); @@ -133,14 +132,14 @@ // // dataGridView // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(0, 39); - dataGridView.Margin = new Padding(4); - dataGridView.Name = "dataGridView"; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(1098, 525); - dataGridView.TabIndex = 1; + DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + DataGridView.Location = new Point(0, 39); + DataGridView.Margin = new Padding(4); + DataGridView.Name = "dataGridView"; + DataGridView.RowHeadersWidth = 51; + DataGridView.RowTemplate.Height = 29; + DataGridView.Size = new Size(1098, 525); + DataGridView.TabIndex = 1; // // buttonCreateOrder // @@ -153,28 +152,6 @@ buttonCreateOrder.UseVisualStyleBackColor = true; buttonCreateOrder.Click += buttonCreateOrder_Click; // - // buttonTakeOrderInWork - // - buttonTakeOrderInWork.Location = new Point(1129, 178); - buttonTakeOrderInWork.Margin = new Padding(4); - buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(212, 62); - buttonTakeOrderInWork.TabIndex = 3; - buttonTakeOrderInWork.Text = "Отдать на выполнение"; - buttonTakeOrderInWork.UseVisualStyleBackColor = true; - buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; - // - // buttonOrderReady - // - buttonOrderReady.Location = new Point(1129, 291); - buttonOrderReady.Margin = new Padding(4); - buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(212, 36); - buttonOrderReady.TabIndex = 4; - buttonOrderReady.Text = "Заказ готов"; - buttonOrderReady.UseVisualStyleBackColor = true; - buttonOrderReady.Click += buttonOrderReady_Click; - // // buttonIssuedOrder // buttonIssuedOrder.Location = new Point(1129, 404); @@ -204,6 +181,13 @@ письмаToolStripMenuItem.Text = "Письма"; письмаToolStripMenuItem.Click += письмаToolStripMenuItem_Click; // + // создатьБэкапToolStripMenuItem + // + создатьБэкапToolStripMenuItem.Name = "создатьБэкапToolStripMenuItem"; + создатьБэкапToolStripMenuItem.Size = new Size(122, 24); + создатьБэкапToolStripMenuItem.Text = "Создать бэкап"; + создатьБэкапToolStripMenuItem.Click += создатьБэкапToolStripMenuItem_Click; + // // FormMain // AutoScaleDimensions = new SizeF(10F, 25F); @@ -211,10 +195,8 @@ ClientSize = new Size(1379, 592); Controls.Add(buttonUpdateList); Controls.Add(buttonIssuedOrder); - Controls.Add(buttonOrderReady); - Controls.Add(buttonTakeOrderInWork); Controls.Add(buttonCreateOrder); - Controls.Add(dataGridView); + Controls.Add(DataGridView); Controls.Add(menuStrip1); MainMenuStrip = menuStrip1; Margin = new Padding(4); @@ -223,7 +205,7 @@ Load += FormMain_Load; menuStrip1.ResumeLayout(false); menuStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -232,10 +214,8 @@ private MenuStrip menuStrip1; private ToolStripMenuItem справочникиToolStripMenuItem; - private DataGridView dataGridView; + private DataGridView DataGridView; private Button buttonCreateOrder; - private Button buttonTakeOrderInWork; - private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonUpdateList; private ToolStripMenuItem компонентыToolStripMenuItem; @@ -248,5 +228,6 @@ private ToolStripMenuItem запускРаботToolStripMenuItem; private ToolStripMenuItem КлиентыToolStripMenuItem; private ToolStripMenuItem письмаToolStripMenuItem; + private ToolStripMenuItem создатьБэкапToolStripMenuItem; } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepair/FormMain.cs b/PlumbingRepair/PlumbingRepair/FormMain.cs index b27b0df..ddee998 100644 --- a/PlumbingRepair/PlumbingRepair/FormMain.cs +++ b/PlumbingRepair/PlumbingRepair/FormMain.cs @@ -1,18 +1,8 @@ using Microsoft.Extensions.Logging; using PlumbingRepair; -using PlumbingRepairBusinessLogic.BusinessLogics; using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.BusinessLogicsContracts; -using PlumbingRepairDataModels.Enums; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; +using PlumbingRepairContracts.DI; namespace PlumbingRepairView { @@ -22,14 +12,15 @@ namespace PlumbingRepairView 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) @@ -42,16 +33,7 @@ namespace PlumbingRepairView try { - var list = _orderLogic.ReadList(null); - - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["WorkId"].Visible = false; - dataGridView.Columns["ClientId"].Visible = false; - dataGridView.Columns["ImplementerId"].Visible = false; - } - + DataGridView.FillandConfigGrid(_orderLogic.ReadList(null)); _logger.LogInformation("Загрузка заказов"); } catch (Exception ex) @@ -63,124 +45,34 @@ namespace PlumbingRepairView private void компонентыToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - - if (service is FormComponents form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void работыToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormWorks)); - - if (service is FormWorks form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + 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) + private void buttonIssuedOrder_Click(object sender, EventArgs e) { - if (dataGridView.SelectedRows.Count == 1) + if (DataGridView.SelectedRows.Count == 1) { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - - try - { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel - { - Id = id, - WorkId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["WorkId"].Value), - WorkName = dataGridView.SelectedRows[0].Cells["WorkName"].Value.ToString(), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), - }); - - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - - private void buttonOrderReady_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); try { var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { - Id = id, - WorkId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["WorkId"].Value), - WorkName = dataGridView.SelectedRows[0].Cells["WorkName"].Value.ToString(), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), - }); - - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - - private void buttonIssuedOrder_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); - - try - { - - var operationResult = _orderLogic.FinishOrder(new OrderBindingModel - { - Id = id, - WorkId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["WorkId"].Value), - WorkName = dataGridView.SelectedRows[0].Cells["WorkName"].Value.ToString(), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + Id = id }); if (!operationResult) @@ -206,20 +98,14 @@ namespace PlumbingRepairView private void списокЗаказовToolStripMenuItem_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(FormReportWorkComponents)); - if (service is FormReportWorkComponents form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void списокРаботToolStripMenuItem_Click(object sender, EventArgs e) @@ -238,33 +124,46 @@ namespace PlumbingRepairView } 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) { - _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); + _workProcess.DoWork(DependencyManager.Instance.Resolve(), _orderLogic); MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); - - if (service is FormImplementers form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } 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 BackUpSaveBindingModel + { + FolderName = fbd.SelectedPath + }); + MessageBox.Show("Бекап создан", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } diff --git a/PlumbingRepair/PlumbingRepair/FormWork.Designer.cs b/PlumbingRepair/PlumbingRepair/FormWork.Designer.cs index 7efd0de..f844c3e 100644 --- a/PlumbingRepair/PlumbingRepair/FormWork.Designer.cs +++ b/PlumbingRepair/PlumbingRepair/FormWork.Designer.cs @@ -35,7 +35,7 @@ buttonDel = new Button(); buttonUpd = new Button(); buttonAdd = new Button(); - dataGridView = new DataGridView(); + DataGridView = new DataGridView(); ComponentId = new DataGridViewTextBoxColumn(); ComponentName = new DataGridViewTextBoxColumn(); Count = new DataGridViewTextBoxColumn(); @@ -44,7 +44,7 @@ buttonCancel = new Button(); buttonSave = new Button(); groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit(); SuspendLayout(); // // label1 @@ -73,7 +73,7 @@ groupBox1.Controls.Add(buttonDel); groupBox1.Controls.Add(buttonUpd); groupBox1.Controls.Add(buttonAdd); - groupBox1.Controls.Add(dataGridView); + groupBox1.Controls.Add(DataGridView); groupBox1.Location = new Point(40, 108); groupBox1.Margin = new Padding(4, 4, 4, 4); groupBox1.Name = "groupBox1"; @@ -129,15 +129,15 @@ // // dataGridView // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { ComponentId, ComponentName, Count }); - dataGridView.Location = new Point(0, 32); - dataGridView.Margin = new Padding(4, 4, 4, 4); - dataGridView.Name = "dataGridView"; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(668, 344); - dataGridView.TabIndex = 0; + DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + DataGridView.Columns.AddRange(new DataGridViewColumn[] { ComponentId, ComponentName, Count }); + DataGridView.Location = new Point(0, 32); + DataGridView.Margin = new Padding(4, 4, 4, 4); + DataGridView.Name = "dataGridView"; + DataGridView.RowHeadersWidth = 51; + DataGridView.RowTemplate.Height = 29; + DataGridView.Size = new Size(668, 344); + DataGridView.TabIndex = 0; // // ComponentId // @@ -215,7 +215,7 @@ Name = "FormWork"; Text = "Работа"; groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -225,7 +225,7 @@ private Label label1; private Label label2; private GroupBox groupBox1; - private DataGridView dataGridView; + private DataGridView DataGridView; private TextBox textBoxName; private TextBox textBoxCost; private Button buttonRef; diff --git a/PlumbingRepair/PlumbingRepair/FormWork.cs b/PlumbingRepair/PlumbingRepair/FormWork.cs index d79d70e..6f57bf9 100644 --- a/PlumbingRepair/PlumbingRepair/FormWork.cs +++ b/PlumbingRepair/PlumbingRepair/FormWork.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.BusinessLogicsContracts; +using PlumbingRepairContracts.DI; using PlumbingRepairContracts.SearchModels; using PlumbingRepairDataModels.Models; using System; @@ -69,10 +70,10 @@ namespace PlumbingRepairView { if (_workComponents != null) { - dataGridView.Rows.Clear(); + DataGridView.Rows.Clear(); foreach (var pc in _workComponents) { - dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); + DataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); } textBoxCost.Text = CalcPrice().ToString(); } @@ -85,10 +86,40 @@ namespace PlumbingRepairView } private void AddButton_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormWorkComponent)); + var form = DependencyManager.Instance.Resolve(); - if (service is FormWorkComponent form) + if (form.ShowDialog() == DialogResult.OK) { + if (form.ComponentModel == null) + { + return; + } + + _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); + + if (_workComponents.ContainsKey(form.Id)) + { + _workComponents[form.Id] = (form.ComponentModel, form.Count); + } + + else + { + _workComponents.Add(form.Id, (form.ComponentModel, form.Count)); + } + + LoadData(); + } + } + + private void ChangeButton_Click(object sender, EventArgs e) + { + if (DataGridView.SelectedRows.Count == 1) + { + var form = DependencyManager.Instance.Resolve(); + int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _workComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) @@ -96,60 +127,23 @@ namespace PlumbingRepairView return; } - _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); - - if (_workComponents.ContainsKey(form.Id)) - { - _workComponents[form.Id] = (form.ComponentModel, form.Count); - } - - else - { - _workComponents.Add(form.Id, (form.ComponentModel, form.Count)); - } - + _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); + _workComponents[form.Id] = (form.ComponentModel, form.Count); LoadData(); } } } - private void ChangeButton_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - var service = Program.ServiceProvider?.GetService(typeof(FormWorkComponent)); - - if (service is FormWorkComponent form) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); - form.Id = id; - form.Count = _workComponents[id].Item2; - - if (form.ShowDialog() == DialogResult.OK) - { - if (form.ComponentModel == null) - { - return; - } - - _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); - _workComponents[form.Id] = (form.ComponentModel, form.Count); - LoadData(); - } - } - } - } - private void DeleteButton_Click(object sender, EventArgs e) { - if (dataGridView.SelectedRows.Count == 1) + if (DataGridView.SelectedRows.Count == 1) { if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { - _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); - _workComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", DataGridView.SelectedRows[0].Cells[1].Value); + _workComponents?.Remove(Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) { diff --git a/PlumbingRepair/PlumbingRepair/FormWorks.Designer.cs b/PlumbingRepair/PlumbingRepair/FormWorks.Designer.cs index f8f1e5a..e34b933 100644 --- a/PlumbingRepair/PlumbingRepair/FormWorks.Designer.cs +++ b/PlumbingRepair/PlumbingRepair/FormWorks.Designer.cs @@ -28,23 +28,23 @@ /// private void InitializeComponent() { - dataGridView = new DataGridView(); + DataGridView = new DataGridView(); buttonAdd = new Button(); buttonUpd = new Button(); buttonDel = new Button(); buttonRef = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit(); SuspendLayout(); // // dataGridView // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(1, 0); - dataGridView.Name = "dataGridView"; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(611, 449); - dataGridView.TabIndex = 0; + DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + DataGridView.Location = new Point(1, 0); + DataGridView.Name = "dataGridView"; + DataGridView.RowHeadersWidth = 51; + DataGridView.RowTemplate.Height = 29; + DataGridView.Size = new Size(611, 449); + DataGridView.TabIndex = 0; // // buttonAdd // @@ -95,17 +95,17 @@ Controls.Add(buttonDel); Controls.Add(buttonUpd); Controls.Add(buttonAdd); - Controls.Add(dataGridView); + Controls.Add(DataGridView); Name = "FormWorks"; Text = "Работы"; Load += FormComponents_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); ResumeLayout(false); } #endregion - private DataGridView dataGridView; + private DataGridView DataGridView; private Button buttonAdd; private Button buttonUpd; private Button buttonDel; diff --git a/PlumbingRepair/PlumbingRepair/FormWorks.cs b/PlumbingRepair/PlumbingRepair/FormWorks.cs index b09fdda..829ad67 100644 --- a/PlumbingRepair/PlumbingRepair/FormWorks.cs +++ b/PlumbingRepair/PlumbingRepair/FormWorks.cs @@ -1,15 +1,7 @@ using Microsoft.Extensions.Logging; using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.BusinessLogicsContracts; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; +using PlumbingRepairContracts.DI; namespace PlumbingRepairView { @@ -34,16 +26,7 @@ namespace PlumbingRepairView { try { - var list = _logic.ReadList(null); - - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["WorkName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["WorkComponents"].Visible = false; - } - + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка изделий"); } @@ -56,40 +39,32 @@ namespace PlumbingRepairView private void AddButton_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormWork)); - - if (service is FormWork form) + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) { + LoadData(); + } + } + private void ChangeButton_Click(object sender, EventArgs e) + { + if (DataGridView.SelectedRows.Count == 1) + { + var form = DependencyManager.Instance.Resolve(); + form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) { LoadData(); } } } - private void ChangeButton_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - var service = Program.ServiceProvider?.GetService(typeof(FormWork)); - - if (service is FormWork form) - { - form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } - } - } private void DeleteButton_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); + int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Удаление изделия"); try -- 2.25.1 From 68ac8cbe51728e39fc5586145250e622e2e9bc28 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Wed, 22 May 2024 09:58:59 +0400 Subject: [PATCH 3/3] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs | 2 +- PlumbingRepair/PlumbingRepair/FormComponents.cs | 1 + .../PlumbingRepairContracts/ViewModels/OrderViewModel.cs | 1 + .../PlumbingRepairDataBaseImplement.csproj | 4 ++++ .../PlumbingRepairFileImplement.csproj | 4 ++++ .../PlumbingRepairListImplement.csproj | 4 ++++ 7 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ca1c7a3..52737dc 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +# dll файлы +*.dll + # Mono auto generated files mono_crash.* diff --git a/PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs b/PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs index 0dae034..36c602a 100644 --- a/PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs +++ b/PlumbingRepair/PlumbingRepair/DataGridViewExtension.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace PlumbingRepairContracts +namespace PlumbingRepairView { public static class DataGridViewExtension { diff --git a/PlumbingRepair/PlumbingRepair/FormComponents.cs b/PlumbingRepair/PlumbingRepair/FormComponents.cs index 2db540d..04cb58b 100644 --- a/PlumbingRepair/PlumbingRepair/FormComponents.cs +++ b/PlumbingRepair/PlumbingRepair/FormComponents.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using PlumbingRepairContracts; using PlumbingRepairContracts.Attributes; using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.BusinessLogicsContracts; diff --git a/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs b/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs index e3f7aa2..d1301f6 100644 --- a/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs +++ b/PlumbingRepair/PlumbingRepairContracts/ViewModels/OrderViewModel.cs @@ -36,6 +36,7 @@ namespace PlumbingRepairContracts.ViewModels public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); [Column("Дата выполнения", width: 130)] public DateTime? DateImplement { get; set; } + [Column("Почта пользователя", width: 250)] public string ClientEmail { get; set; } = string.Empty; } } diff --git a/PlumbingRepair/PlumbingRepairDataBaseImplement/PlumbingRepairDataBaseImplement.csproj b/PlumbingRepair/PlumbingRepairDataBaseImplement/PlumbingRepairDataBaseImplement.csproj index 851d6a0..129554b 100644 --- a/PlumbingRepair/PlumbingRepairDataBaseImplement/PlumbingRepairDataBaseImplement.csproj +++ b/PlumbingRepair/PlumbingRepairDataBaseImplement/PlumbingRepairDataBaseImplement.csproj @@ -25,4 +25,8 @@ + + + + diff --git a/PlumbingRepair/PlumbingRepairFileImplement/PlumbingRepairFileImplement.csproj b/PlumbingRepair/PlumbingRepairFileImplement/PlumbingRepairFileImplement.csproj index 05f8377..bb7fb48 100644 --- a/PlumbingRepair/PlumbingRepairFileImplement/PlumbingRepairFileImplement.csproj +++ b/PlumbingRepair/PlumbingRepairFileImplement/PlumbingRepairFileImplement.csproj @@ -11,4 +11,8 @@ + + + + diff --git a/PlumbingRepair/PlumbingRepairListImplement/PlumbingRepairListImplement.csproj b/PlumbingRepair/PlumbingRepairListImplement/PlumbingRepairListImplement.csproj index 05f8377..bb7fb48 100644 --- a/PlumbingRepair/PlumbingRepairListImplement/PlumbingRepairListImplement.csproj +++ b/PlumbingRepair/PlumbingRepairListImplement/PlumbingRepairListImplement.csproj @@ -11,4 +11,8 @@ + + + + -- 2.25.1