Наконец-то

This commit is contained in:
Yunusov_Niyaz 2024-05-07 22:38:27 +04:00
parent d3fe1a06c8
commit 37f88a13f0
13 changed files with 41 additions and 57 deletions

View File

@ -5,7 +5,7 @@
<add key="SmtpClientPort" value="587" /> <add key="SmtpClientPort" value="587" />
<add key="PopHost" value="pop.gmail.com" /> <add key="PopHost" value="pop.gmail.com" />
<add key="PopPort" value="995" /> <add key="PopPort" value="995" />
<add key="MailLogin" value="labwork73@gmail.com" /> <add key="MailLogin" value="niiiyaziiik@gmail.com" />
<add key="MailPassword" value="laba73" /> <add key="MailPassword" value="fbuz lxpx sirr rzbp" />
</appSettings> </appSettings>
</configuration> </configuration>

View File

@ -48,8 +48,8 @@
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(800, 450);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Name = "Почта"; Name = "FormMails";
Text = "FormMails"; Text = "Почты";
Load += ViewMailForm_Load; Load += ViewMailForm_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->

View File

@ -40,10 +40,9 @@ namespace CarRepairShop
string.Empty, string.Empty,
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ??
string.Empty, string.Empty,
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClient Port"]), SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty, PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"]) PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])});
});
// ñîçäàåì òàéìåð // ñîçäàåì òàéìåð
var timer = new System.Threading.Timer(new var timer = new System.Threading.Timer(new
TimerCallback(MailCheck!), null, 0, 100000); TimerCallback(MailCheck!), null, 0, 100000);

View File

@ -108,7 +108,7 @@ namespace CarRepairShopBusinessLogic.BusinessLogics
{ {
throw new ArgumentException("Некорретно введен email клиента", nameof(model.Email)); throw new ArgumentException("Некорретно введен email клиента", nameof(model.Email));
} }
if (!Regex.IsMatch(model.Password, @"^(?=.*\d)(?=.*\W)(?=.*[^\d\s]).+$")) if (!Regex.IsMatch(model.Password, @"^(?=.*\d)(?=.*\w)(?=.*[^\d\s]).+$"))
{ {
throw new ArgumentException("Некорректно введен пароль клиента", nameof(model.Password)); throw new ArgumentException("Некорректно введен пароль клиента", nameof(model.Password));
} }

View File

@ -38,7 +38,7 @@ namespace CarRepairShopDatabaseImplement.Implements
public MessageInfoViewModel? Insert(MessageInfoBindingModel model) public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
{ {
using var context = new RepairsShopDatabase(); using var context = new RepairsShopDatabase();
var newMessage = MessageInfo.Create(model); var newMessage = MessageInfo.Create(context, model);
if (newMessage == null || context.Messages.Any(x => x.MessageId.Equals(model.MessageId))) if (newMessage == null || context.Messages.Any(x => x.MessageId.Equals(model.MessageId)))
{ {
return null; return null;

View File

@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace CarRepairShopDatabaseImplement.Migrations namespace CarRepairShopDatabaseImplement.Migrations
{ {
[DbContext(typeof(RepairsShopDatabase))] [DbContext(typeof(RepairsShopDatabase))]
[Migration("20240506164851_InitialCreate")] [Migration("20240507162722_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
/// <inheritdoc /> /// <inheritdoc />

View File

@ -15,7 +15,7 @@ namespace CarRepairShopDatabaseImplement.Models
public string Subject { get; private set; } = string.Empty; public string Subject { get; private set; } = string.Empty;
public string Body { get; private set; } = string.Empty; public string Body { get; private set; } = string.Empty;
public Client? Client { get; private set; } public Client? Client { get; private set; }
public static MessageInfo? Create(MessageInfoBindingModel model) public static MessageInfo? Create(RepairsShopDatabase context, MessageInfoBindingModel model)
{ {
if (model == null) if (model == null)
{ {
@ -25,7 +25,8 @@ namespace CarRepairShopDatabaseImplement.Models
{ {
Body = model.Body, Body = model.Body,
Subject = model.Subject, Subject = model.Subject,
ClientId = model.ClientId, ClientId = context.Clients.FirstOrDefault(x => x.Email == model.SenderName).Id,
Client = context.Clients.FirstOrDefault(x => x.Email == model.SenderName),
MessageId = model.MessageId, MessageId = model.MessageId,
SenderName = model.SenderName, SenderName = model.SenderName,
DateDelivery = model.DateDelivery, DateDelivery = model.DateDelivery,

View File

@ -9,7 +9,7 @@ namespace CarRepairShopDatabaseImplement
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=RepairsShopDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True" optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=CarRepairsShopDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"
); );
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);

View File

@ -20,7 +20,7 @@ builder.Services.AddTransient<IClientLogic, ClientLogic>();
builder.Services.AddTransient<IRepairLogic, RepairLogic>(); builder.Services.AddTransient<IRepairLogic, RepairLogic>();
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>(); builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>(); builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
builder.Services.AddTransient<AbstractMailWorker, MailKitWorker>(); builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
builder.Services.AddControllers(); builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at // Learn more about configuring Swagger/OpenAPI at
https://aka.ms/aspnetcore/swashbuckle https://aka.ms/aspnetcore/swashbuckle

View File

@ -10,6 +10,6 @@
"SmtpClientPort": "587", "SmtpClientPort": "587",
"PopHost": "pop.gmail.com", "PopHost": "pop.gmail.com",
"PopPort": "995", "PopPort": "995",
"MailLogin": "labwork73@gmail.com", "MailLogin": "niiiyaziiik@gmail.com",
"MailPassword": "laba73" "MailPassword": "fbuz lxpx sirr rzbp"
} }

View File

@ -6,10 +6,6 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Content Remove="Views\Home\Mails.cshtml" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>
@ -19,16 +15,4 @@
<ProjectReference Include="..\CarRepairShopRestApi\CarRepairShopRestApi.csproj" /> <ProjectReference Include="..\CarRepairShopRestApi\CarRepairShopRestApi.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<UpToDateCheckInput Remove="Views\Home\Mails.cshtml" />
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="Views\Home\Mails.cshtml" />
</ItemGroup>
<ItemGroup>
<None Include="Views\Home\Mails.cshtml" />
</ItemGroup>
</Project> </Project>