From df99f4ed49fe50ae603ab2a4efae4d547af9c9ce Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Sat, 3 Jun 2023 01:38:17 +0400 Subject: [PATCH] program fix --- ...ftwareInstallationDatabaseImplement.csproj | 2 +- .../20230602203557_mail2.Designer.cs | 298 ++++++++++++++++++ .../Migrations/20230602203557_mail2.cs | 22 ++ ...ftwareInstallationDatabaseModelSnapshot.cs | 4 +- .../Program.cs | 3 + .../SoftwareInstallation/Program.cs | 28 ++ 6 files changed, 355 insertions(+), 2 deletions(-) create mode 100644 SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/20230602203557_mail2.Designer.cs create mode 100644 SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/20230602203557_mail2.cs diff --git a/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/AbstractSoftwareInstallationDatabaseImplement.csproj b/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/AbstractSoftwareInstallationDatabaseImplement.csproj index 1f9db50..1ba9b66 100644 --- a/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/AbstractSoftwareInstallationDatabaseImplement.csproj +++ b/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/AbstractSoftwareInstallationDatabaseImplement.csproj @@ -1,4 +1,4 @@ - + net6.0 diff --git a/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/20230602203557_mail2.Designer.cs b/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/20230602203557_mail2.Designer.cs new file mode 100644 index 0000000..6fef5d6 --- /dev/null +++ b/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/20230602203557_mail2.Designer.cs @@ -0,0 +1,298 @@ +// +using System; +using AbstractSoftwareInstallationDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace AbstractSoftwareInstallationDatabaseImplement.Migrations +{ + [DbContext(typeof(AbstractSoftwareInstallationDatabase))] + [Migration("20230602203557_mail2")] + partial class mail2 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AbstractPackageInstallationDatabaseImplement.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("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("AbstractSoftwareInstallationDatabaseImplement.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("AbstractSoftwareInstallationDatabaseImplement.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("AbstractSoftwareInstallationDatabaseImplement.Models.MessageInfo", b => + { + b.Property("MessageId") + .HasColumnType("nvarchar(450)"); + + b.Property("Body") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("DateDelivery") + .HasColumnType("datetime2"); + + 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("AbstractSoftwareInstallationDatabaseImplement.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("AbstractSoftwareInstallationDatabaseImplement.Models.PackageSoftware", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("PackageId") + .HasColumnType("int"); + + b.Property("SoftwareId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PackageId"); + + b.HasIndex("SoftwareId"); + + b.ToTable("PackageSoftwares"); + }); + + modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Software", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("SoftwareName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Softwares"); + }); + + modelBuilder.Entity("AbstractPackageInstallationDatabaseImplement.Models.Order", b => + { + b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Package", "Package") + .WithMany("Orders") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Package"); + }); + + modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.MessageInfo", b => + { + b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Client", "Client") + .WithMany("Messages") + .HasForeignKey("ClientId"); + + b.Navigation("Client"); + }); + + modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.PackageSoftware", b => + { + b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Package", "Package") + .WithMany("Softwares") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Software", "Software") + .WithMany("PackageSoftwares") + .HasForeignKey("SoftwareId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Package"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Client", b => + { + b.Navigation("Messages"); + + b.Navigation("Orders"); + }); + + modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Package", b => + { + b.Navigation("Orders"); + + b.Navigation("Softwares"); + }); + + modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Software", b => + { + b.Navigation("PackageSoftwares"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/20230602203557_mail2.cs b/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/20230602203557_mail2.cs new file mode 100644 index 0000000..2795a5c --- /dev/null +++ b/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/20230602203557_mail2.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AbstractSoftwareInstallationDatabaseImplement.Migrations +{ + /// + public partial class mail2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/AbstractSoftwareInstallationDatabaseModelSnapshot.cs b/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/AbstractSoftwareInstallationDatabaseModelSnapshot.cs index 30daaa9..83020c8 100644 --- a/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/AbstractSoftwareInstallationDatabaseModelSnapshot.cs +++ b/SoftwareInstallation/AbstractSoftwareInstallationDatabaseImplement/Migrations/AbstractSoftwareInstallationDatabaseModelSnapshot.cs @@ -241,7 +241,7 @@ namespace AbstractSoftwareInstallationDatabaseImplement.Migrations modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.MessageInfo", b => { b.HasOne("AbstractSoftwareInstallationDatabaseImplement.Models.Client", "Client") - .WithMany() + .WithMany("Messages") .HasForeignKey("ClientId"); b.Navigation("Client"); @@ -268,6 +268,8 @@ namespace AbstractSoftwareInstallationDatabaseImplement.Migrations modelBuilder.Entity("AbstractSoftwareInstallationDatabaseImplement.Models.Client", b => { + b.Navigation("Messages"); + b.Navigation("Orders"); }); diff --git a/SoftwareInstallation/AbstractSoftwareInstallationRestApi/Program.cs b/SoftwareInstallation/AbstractSoftwareInstallationRestApi/Program.cs index bb260a3..7bde33c 100644 --- a/SoftwareInstallation/AbstractSoftwareInstallationRestApi/Program.cs +++ b/SoftwareInstallation/AbstractSoftwareInstallationRestApi/Program.cs @@ -16,11 +16,14 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle diff --git a/SoftwareInstallation/SoftwareInstallation/Program.cs b/SoftwareInstallation/SoftwareInstallation/Program.cs index 1a2b1aa..da3ebb4 100644 --- a/SoftwareInstallation/SoftwareInstallation/Program.cs +++ b/SoftwareInstallation/SoftwareInstallation/Program.cs @@ -9,6 +9,8 @@ using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using AbstractSoftwareInstallationBusinessLogic.OfficePackage; using AbstractSoftwareInstallationBusinessLogic.OfficePackage.Implements; +using AbstractSoftwareInstallationBusinessLogic.MailWorker; +using AbstractSoftwareInstallationContracts.BindingModels; namespace SoftwareInstallation { @@ -16,6 +18,8 @@ namespace SoftwareInstallation { private static ServiceProvider? _serviceProvider; public static ServiceProvider? ServiceProvider => _serviceProvider; + + /// /// The main entry point for the application. /// @@ -26,8 +30,31 @@ namespace SoftwareInstallation var services = new ServiceCollection(); ConfigureServices(services); _serviceProvider = services.BuildServiceProvider(); + try + { + var mailSender = _serviceProvider.GetService(); + mailSender?.MailConfig(new MailConfigBindingModel + { + MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty, + MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty, + SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty, + SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]), + PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty, + PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"]) + }); + // ñîçäàåì òàéìåð + var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000); + } + catch (Exception ex) + { + var logger = _serviceProvider.GetService(); + logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé"); + } + Application.Run(_serviceProvider.GetRequiredService()); } + + private static void MailCheck(object obj) => ServiceProvider?.GetService()?.MailCheck(); private static void ConfigureServices(ServiceCollection services) { services.AddLogging(option => @@ -54,6 +81,7 @@ namespace SoftwareInstallation services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddSingleton(); services.AddTransient(); services.AddTransient();