diff --git a/LawCompany/LawCompanyBusinessLogic/BusinessLogics/ReportLogicExecutor.cs b/LawCompany/LawCompanyBusinessLogic/BusinessLogics/ReportLogicExecutor.cs
new file mode 100644
index 0000000..7efe614
--- /dev/null
+++ b/LawCompany/LawCompanyBusinessLogic/BusinessLogics/ReportLogicExecutor.cs
@@ -0,0 +1,39 @@
+using LawCompanyBusinessLogic.OfficePackage.HelperModels;
+using LawCompanyBusinessLogic.OfficePackage;
+using LawCompanyContracts.BindingModels;
+using LawCompanyContracts.BusinessLogicContracts;
+using LawCompanyContracts.SearchModels;
+using LawCompanyContracts.StoragesContracts;
+using LawCompanyContracts.ViewModels;
+using LawCompanyDatabaseImplement.Models;
+
+namespace HotelBusinessLogic.BusinessLogics
+{
+ public class ReportLogicExecutor : IReportExecutorLogic
+ {
+ private readonly IHearingStorage _hearingStorage;
+ private readonly ILawyerStorage _lawyerStorage;
+ private readonly IVisitStorage _visitStorage;
+ private readonly IConsultationStorage _consultationStorage;
+ private readonly ICaseStorage _caseStorage;
+ private readonly AbstractSaveToExcelExecutor _saveToExcel;
+ private readonly AbstractSaveToWordExecutor _saveToWord;
+ private readonly AbstractSaveToPdfExecutor _saveToPdf;
+
+ public ReportLogicGuarantor(IHearingStorage hearingStorage, ILawyerStorage lawyerStorage,
+ IVisitStorage visitStorage, IConsultationStorage consultationStorage, ICaseStorage caseStorage,
+ AbstractSaveToExcelExecutor saveToExcel, AbstractSaveToWordExecutor saveToWord, AbstractSaveToPdfExecutor saveToPdf)
+ {
+ _hearingStorage = hearingStorage;
+ _lawyerStorage = lawyerStorage;
+ _visitStorage = visitStorage;
+ _consultationStorage = consultationStorage;
+ _caseStorage = caseStorage;
+ _saveToExcel = saveToExcel;
+ _saveToWord = saveToWord;
+ _saveToPdf = saveToPdf;
+ }
+
+
+ }
+}
diff --git a/LawCompany/LawCompanyBusinessLogic/BusinessLogics/ReportLogicGuarantor.cs b/LawCompany/LawCompanyBusinessLogic/BusinessLogics/ReportLogicGuarantor.cs
new file mode 100644
index 0000000..16a9049
--- /dev/null
+++ b/LawCompany/LawCompanyBusinessLogic/BusinessLogics/ReportLogicGuarantor.cs
@@ -0,0 +1,39 @@
+using LawCompanyBusinessLogic.OfficePackage.HelperModels;
+using LawCompanyBusinessLogic.OfficePackage;
+using LawCompanyContracts.BindingModels;
+using LawCompanyContracts.BusinessLogicContracts;
+using LawCompanyContracts.SearchModels;
+using LawCompanyContracts.StoragesContracts;
+using LawCompanyContracts.ViewModels;
+using LawCompanyDatabaseImplement.Models;
+
+namespace LawCompanyBusinessLogic.BusinessLogics
+{
+ public class ReportLogicGuarantor : IReportGuarantorLogic
+ {
+ private readonly IVisitStorage _visitStorage;
+ private readonly IClientStorage _clientStorage;
+ private readonly ICaseStorage _caseStorage;
+ private readonly IConsultationStorage _consultationStorage;
+ private readonly IHearingStorage _hearingStorage;
+ private readonly AbstractSaveToExcelGuarantor _saveToExcel;
+ private readonly AbstractSaveToWordGuarantor _saveToWord;
+ private readonly AbstractSaveToPdfGuarantor _saveToPdf;
+
+ public ReportLogicOrganiser(IVisitStorage visitStorage, IClientStorage clientStorage, ICaseStorage caseStorage,
+ IConsultationStorage consultationStorage, IHearingStorage hearingStorage,
+ AbstractSaveToExcelGuarantor saveToExcel, AbstractSaveToWordGuarantor saveToWord, AbstractSaveToPdfGuarantor saveToPdf)
+ {
+ _visitStorage = visitStorage;
+ _clientStorage = clientStorage;
+ _caseStorage = caseStorage;
+ _consultationStorage = consultationStorage;
+ _hearingStorage = hearingStorage;
+ _saveToExcel = saveToExcel;
+ _saveToWord = saveToWord;
+ _saveToPdf = saveToPdf;
+ }
+
+
+ }
+}
diff --git a/LawCompany/LawCompanyBusinessLogic/LawCompanyBusinessLogic.csproj b/LawCompany/LawCompanyBusinessLogic/LawCompanyBusinessLogic.csproj
index 90b8bbc..e5ba6c0 100644
--- a/LawCompany/LawCompanyBusinessLogic/LawCompanyBusinessLogic.csproj
+++ b/LawCompany/LawCompanyBusinessLogic/LawCompanyBusinessLogic.csproj
@@ -15,4 +15,8 @@
+
+
+
+
diff --git a/LawCompany/LawCompanyBusinessLogic/MailWorker/AbstractMailWorker.cs b/LawCompany/LawCompanyBusinessLogic/MailWorker/AbstractMailWorker.cs
new file mode 100644
index 0000000..628e322
--- /dev/null
+++ b/LawCompany/LawCompanyBusinessLogic/MailWorker/AbstractMailWorker.cs
@@ -0,0 +1,59 @@
+using LawCompanyContracts.BindingModels;
+using LawCompanyContracts.BusinessLogicContracts;
+using Microsoft.Extensions.Logging;
+
+namespace LawCompanyBusinessLogic.MailWorker
+{
+ public abstract class AbstractMailWorker
+ {
+ protected string _mailLogin = string.Empty;
+ protected string _mailPassword = string.Empty;
+ protected string _smtpClientHost = string.Empty;
+ protected int _smtpClientPort;
+ protected string _popHost = string.Empty;
+ protected int _popPort;
+ private readonly IExecutorLogic _executorLogic;
+ private readonly ILogger _logger;
+
+ public AbstractMailWorker(ILogger logger, IExecutorLogic executorLogic)
+ {
+ _logger = logger;
+ _executorLogic = executorLogic;
+ }
+
+ public void MailConfig(MailConfigBindingModel config)
+ {
+ _mailLogin = config.MailLogin;
+ _mailPassword = config.MailPassword;
+ _smtpClientHost = config.SmtpClientHost;
+ _smtpClientPort = config.SmtpClientPort;
+ _popHost = config.PopHost;
+ _popPort = config.PopPort;
+ _logger.LogDebug("Config: {login}, {password}, {clientHost}, {clientPOrt}, {popHost}, {popPort}", _mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
+ }
+
+ public async void MailSendAsync(MailSendInfoBindingModel info)
+ {
+ if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
+ {
+ return;
+ }
+
+ if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
+ {
+ return;
+ }
+
+ if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
+ {
+ return;
+ }
+
+ _logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
+
+ await SendMailAsync(info);
+ }
+
+ protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
+ }
+}
diff --git a/LawCompany/LawCompanyBusinessLogic/MailWorker/MailKitWorker.cs b/LawCompany/LawCompanyBusinessLogic/MailWorker/MailKitWorker.cs
new file mode 100644
index 0000000..c69c49f
--- /dev/null
+++ b/LawCompany/LawCompanyBusinessLogic/MailWorker/MailKitWorker.cs
@@ -0,0 +1,44 @@
+using LawCompanyContracts.BindingModels;
+using LawCompanyContracts.BusinessLogicContracts;
+using Microsoft.Extensions.Logging;
+using System.Net.Mail;
+using System.Net.Mime;
+using System.Net;
+using System.Text;
+
+namespace LawCompanyBusinessLogic.MailWorker
+{
+ public class MailKitWorker : AbstractMailWorker
+ {
+ public MailKitWorker(ILogger logger, IExecutorLogic _executorLogic) : base(logger, _executorLogic) { }
+
+ protected override async Task SendMailAsync(MailSendInfoBindingModel info)
+ {
+ using var objMailMessage = new MailMessage();
+ using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
+
+ try
+ {
+ objMailMessage.From = new MailAddress(_mailLogin);
+ objMailMessage.To.Add(new MailAddress(info.MailAddress));
+ objMailMessage.Subject = info.Subject;
+ objMailMessage.Body = info.Text;
+ objMailMessage.SubjectEncoding = Encoding.UTF8;
+ objMailMessage.BodyEncoding = Encoding.UTF8;
+ Attachment attachment = new Attachment("C:\\Reports\\pdffile.pdf", new ContentType(MediaTypeNames.Application.Pdf));
+ objMailMessage.Attachments.Add(attachment);
+
+ objSmtpClient.UseDefaultCredentials = false;
+ objSmtpClient.EnableSsl = true;
+ objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
+ objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
+
+ await Task.Run(() => objSmtpClient.Send(objMailMessage));
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+ }
+ }
+}
diff --git a/LawCompany/LawCompanyGuarantorApp/Properties/launchSettings.json b/LawCompany/LawCompanyGuarantorApp/Properties/launchSettings.json
index 3474387..03211a1 100644
--- a/LawCompany/LawCompanyGuarantorApp/Properties/launchSettings.json
+++ b/LawCompany/LawCompanyGuarantorApp/Properties/launchSettings.json
@@ -1,21 +1,13 @@
-{
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:19906",
- "sslPort": 44345
- }
- },
+{
"profiles": {
"LawCompanyGuarantorApp": {
"commandName": "Project",
- "dotnetRunMessages": true,
"launchBrowser": true,
- "applicationUrl": "https://localhost:7250;http://localhost:5131",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
- }
+ },
+ "dotnetRunMessages": true,
+ "applicationUrl": "https://localhost:7250;http://localhost:5131"
},
"IIS Express": {
"commandName": "IISExpress",
@@ -24,5 +16,13 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
+ },
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:19906",
+ "sslPort": 44345
+ }
}
-}
+}
\ No newline at end of file