From 2109fcaa73f77a13c3bdbaa080c20ed1ab63112c Mon Sep 17 00:00:00 2001 From: AnnZhimol Date: Fri, 5 May 2023 10:20:32 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=BC=D0=B5=D0=B6=D1=83=D1=82?= =?UTF-8?q?=D0=BE=D1=87=D0=BD=D1=8B=D0=B9=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8?= =?UTF-8?q?=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SoftwareInstallation/FormMails.cs | 12 +- .../SoftwareInstallation/FormStores.cs | 23 +- .../SoftwareInstallation/Program.cs | 17 - .../ImplementationBusinessLogicExtension.cs | 39 ++ .../SoftwareInstallationBusinessLogic.csproj | 4 + ...ftwareInstallationDataBaseModelSnapshot.cs | 387 ------------------ .../FileImplementationExtension.cs | 1 + .../ListImplementationExtension.cs | 1 + 8 files changed, 56 insertions(+), 428 deletions(-) create mode 100644 SoftwareInstallation/SoftwareInstallationBusinessLogic/ImplementationBusinessLogicExtension.cs delete mode 100644 SoftwareInstallation/SoftwareInstallationDataBaseImplement/Migrations/SoftwareInstallationDataBaseModelSnapshot.cs diff --git a/SoftwareInstallation/SoftwareInstallation/FormMails.cs b/SoftwareInstallation/SoftwareInstallation/FormMails.cs index 179cf5c..0f34b47 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormMails.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormMails.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.Logging; using System.Windows.Forms; using SofrwareInstallationContracts.ViewModels; +using SofrwareInstallationContracts.DI; namespace SoftwareInstallationView { @@ -84,13 +85,10 @@ namespace SoftwareInstallationView private void DataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormReplyMail)); - if (service is FormReplyMail form) - { - form.MessageId = (string)DataGridView.Rows[e.RowIndex].Cells["MessageId"].Value; - form.ShowDialog(); - LoadData(); - } + var form = DependencyManager.Instance.Resolve(); + form.MessageId = (string)DataGridView.Rows[e.RowIndex].Cells["MessageId"].Value; + form.ShowDialog(); + LoadData(); } } } diff --git a/SoftwareInstallation/SoftwareInstallation/FormStores.cs b/SoftwareInstallation/SoftwareInstallation/FormStores.cs index 7c09a2d..27e19c2 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormStores.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormStores.cs @@ -1,6 +1,8 @@ using Microsoft.Extensions.Logging; using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BusinessLogicsContracts; +using SofrwareInstallationContracts.DI; +using System.Windows.Forms; namespace SoftwareInstallationView { @@ -24,16 +26,7 @@ namespace SoftwareInstallationView { try { - var list = _logic.ReadList(null); - - if (list != null) - { - DataGridView.DataSource = list; - DataGridView.Columns["Id"].Visible = false; - DataGridView.Columns["StoreName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - DataGridView.Columns["StorePackages"].Visible = false; - } - + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка магазинов"); } @@ -83,7 +76,7 @@ namespace SoftwareInstallationView { if (DataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormStore)); + var service = DependencyManager.Instance.Resolve(); if (service is FormStore form) { @@ -99,14 +92,10 @@ namespace SoftwareInstallationView private void AddButton_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormStore)); - - if (service is FormStore form) + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) { - if (form.ShowDialog() == DialogResult.OK) - { LoadData(); - } } } } diff --git a/SoftwareInstallation/SoftwareInstallation/Program.cs b/SoftwareInstallation/SoftwareInstallation/Program.cs index 5f9515d..9821391 100644 --- a/SoftwareInstallation/SoftwareInstallation/Program.cs +++ b/SoftwareInstallation/SoftwareInstallation/Program.cs @@ -52,23 +52,6 @@ namespace SoftwareInstallationView option.AddNLog("nlog.config"); }); - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); - - DependencyManager.Instance.RegisterType(true); - - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); - DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/ImplementationBusinessLogicExtension.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/ImplementationBusinessLogicExtension.cs new file mode 100644 index 0000000..d20f1a2 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/ImplementationBusinessLogicExtension.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SoftwareInstallationBusinessLogic.BusinessLogic; +using SoftwareInstallationBusinessLogic.MailWorker; +using SoftwareInstallationBusinessLogic.OfficePackage.Implements; +using SoftwareInstallationBusinessLogic.OfficePackage; +using SofrwareInstallationContracts.BusinessLogicsContracts; +using SofrwareInstallationContracts.DI; + +namespace SoftwareInstallationBusinessLogic +{ + public class ImplementationBusinessLogicExtension : IImplementationBusinessLogicExtension + { + 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(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + + DependencyManager.Instance.RegisterType(true); + + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + } + } +} diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj b/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj index 1f3f49c..579e3ba 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/SoftwareInstallationBusinessLogic.csproj @@ -46,4 +46,8 @@ + + + + diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Migrations/SoftwareInstallationDataBaseModelSnapshot.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Migrations/SoftwareInstallationDataBaseModelSnapshot.cs deleted file mode 100644 index d57f607..0000000 --- a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Migrations/SoftwareInstallationDataBaseModelSnapshot.cs +++ /dev/null @@ -1,387 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using SoftwareInstallationDataBaseImplement; - -#nullable disable - -namespace SoftwareInstallationDataBaseImplement.Migrations -{ - [DbContext(typeof(SoftwareInstallationDataBase))] - partial class SoftwareInstallationDataBaseModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Implementer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ImplementerFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Qualification") - .HasColumnType("int"); - - b.Property("WorkExperience") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Implementers"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Message", b => - { - b.Property("MessageId") - .HasColumnType("nvarchar(450)"); - - b.Property("Body") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .IsRequired() - .HasColumnType("int"); - - b.Property("DateDelivery") - .HasColumnType("datetime2"); - - b.Property("HasRead") - .HasColumnType("bit"); - - b.Property("Reply") - .HasColumnType("nvarchar(max)"); - - b.Property("SenderName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Subject") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("MessageId"); - - b.HasIndex("ClientId"); - - b.ToTable("Messages"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("ImplementerId") - .HasColumnType("int"); - - b.Property("PackageId") - .HasColumnType("int"); - - b.Property("PackageName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ImplementerId"); - - b.HasIndex("PackageId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Package", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PackageName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Packages"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.PackageComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("PackageId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("PackageId"); - - b.ToTable("PackageComponents"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Store", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("OpeningDate") - .HasColumnType("datetime2"); - - b.Property("PackageMaxCount") - .HasColumnType("int"); - - b.Property("StoreAdress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StoreName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Stores"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.StorePackage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("PackageId") - .HasColumnType("int"); - - b.Property("StoreId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("PackageId"); - - b.HasIndex("StoreId"); - - b.ToTable("StorePackages"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Message", b => - { - b.HasOne("SoftwareInstallationDataBaseImplement.Models.Client", "Client") - .WithMany("Messages") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Client"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Order", b => - { - b.HasOne("SoftwareInstallationDataBaseImplement.Models.Client", "Client") - .WithMany("Orders") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("SoftwareInstallationDataBaseImplement.Models.Implementer", "Implementer") - .WithMany("Orders") - .HasForeignKey("ImplementerId"); - - b.HasOne("SoftwareInstallationDataBaseImplement.Models.Package", "Package") - .WithMany("Orders") - .HasForeignKey("PackageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Client"); - - b.Navigation("Implementer"); - - b.Navigation("Package"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.PackageComponent", b => - { - b.HasOne("SoftwareInstallationDataBaseImplement.Models.Component", "Component") - .WithMany("PackageComponents") - .HasForeignKey("ComponentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("SoftwareInstallationDataBaseImplement.Models.Package", "Package") - .WithMany("Components") - .HasForeignKey("PackageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Component"); - - b.Navigation("Package"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.StorePackage", b => - { - b.HasOne("SoftwareInstallationDataBaseImplement.Models.Package", "Package") - .WithMany("StorePackages") - .HasForeignKey("PackageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("SoftwareInstallationDataBaseImplement.Models.Store", "Store") - .WithMany("Packages") - .HasForeignKey("StoreId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Package"); - - b.Navigation("Store"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Client", b => - { - b.Navigation("Messages"); - - b.Navigation("Orders"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Component", b => - { - b.Navigation("PackageComponents"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Implementer", b => - { - b.Navigation("Orders"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Package", b => - { - b.Navigation("Components"); - - b.Navigation("Orders"); - - b.Navigation("StorePackages"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Store", b => - { - b.Navigation("Packages"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/SoftwareInstallation/SoftwareInstallationFileImplement/FileImplementationExtension.cs b/SoftwareInstallation/SoftwareInstallationFileImplement/FileImplementationExtension.cs index bae4390..dbf4129 100644 --- a/SoftwareInstallation/SoftwareInstallationFileImplement/FileImplementationExtension.cs +++ b/SoftwareInstallation/SoftwareInstallationFileImplement/FileImplementationExtension.cs @@ -17,6 +17,7 @@ namespace SoftwareInstallationFileImplement DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); } } } diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/ListImplementationExtension.cs b/SoftwareInstallation/SoftwareInstallationListImplement/ListImplementationExtension.cs index c1adfa8..5a7b2c9 100644 --- a/SoftwareInstallation/SoftwareInstallationListImplement/ListImplementationExtension.cs +++ b/SoftwareInstallation/SoftwareInstallationListImplement/ListImplementationExtension.cs @@ -17,6 +17,7 @@ namespace SoftwareInstallationListImplement DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); } }