From 63512cf10325ce8cc2649934c883d8015164d9c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=BA=20=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Fri, 26 May 2023 02:11:24 +0400 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D1=81?= =?UTF-8?q?=20=D0=BF=D0=BE=D1=87=D1=82=D0=BE=D0=B9,=20=D0=B8=D1=81=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=80=D0=B0=D0=BD=D1=81=D1=82=D0=B2=20=D0=B8?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ReportLogic.cs | 6 +-- .../CarServiceBusinessLogic.csproj | 1 + .../MailWorker/AbstractMailWorker.cs | 42 ++++++++++++++++++ .../MailWorker/MailKitWorker.cs | 34 ++++++++++++++ .../OfficePackage/AbstractSaveToExcel.cs | 6 +-- .../OfficePackage/AbstractSaveToPdf.cs | 6 +-- .../OfficePackage/AbstractSaveToWord.cs | 6 +-- .../HelperEnums/ExcelStyleInfoType.cs | 2 +- .../HelperEnums/PdfParagraphAlignmentType.cs | 2 +- .../HelperEnums/WordJustificationType.cs | 2 +- .../HelperModels/ExcelCellParameters.cs | 4 +- .../OfficePackage/HelperModels/ExcelInfo.cs | 2 +- .../HelperModels/ExcelMergeParameters.cs | 2 +- .../OfficePackage/HelperModels/PdfInfo.cs | 2 +- .../HelperModels/PdfParagraph.cs | 4 +- .../HelperModels/PdfRowParameters.cs | 4 +- .../OfficePackage/HelperModels/WordInfo.cs | 2 +- .../HelperModels/WordParagraph.cs | 2 +- .../HelperModels/WordTextProperties.cs | 4 +- .../OfficePackage/Implements/SaveToExcel.cs | 6 +-- .../OfficePackage/Implements/SaveToPdf.cs | 6 +-- .../OfficePackage/Implements/SaveToWord.cs | 6 +-- .../BindingModels/MailSendInfoBindingModel.cs | 9 ++++ .../Controllers/ReportController.cs | 16 ++++++- .../CarServiceWebApp/Files/ReportPdf.pdf | Bin 38109 -> 38109 bytes CarService/CarServiceWebApp/Program.cs | 7 ++- .../CarServiceWebApp/Views/Report/Mail.cshtml | 6 +++ .../Views/Report/ReportPayments.cshtml | 5 ++- CarService/CarServiceWebApp/log4net.config | 2 +- 29 files changed, 153 insertions(+), 43 deletions(-) create mode 100644 CarService/CarServiceBusinessLogic/MailWorker/AbstractMailWorker.cs create mode 100644 CarService/CarServiceBusinessLogic/MailWorker/MailKitWorker.cs create mode 100644 CarService/CarServiceContracts/BindingModels/MailSendInfoBindingModel.cs create mode 100644 CarService/CarServiceWebApp/Views/Report/Mail.cshtml diff --git a/CarService/CarServiceBusinessLogic/BusinessLogics/ReportLogic.cs b/CarService/CarServiceBusinessLogic/BusinessLogics/ReportLogic.cs index 7fae25b..7f96a2a 100644 --- a/CarService/CarServiceBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/CarService/CarServiceBusinessLogic/BusinessLogics/ReportLogic.cs @@ -1,6 +1,6 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage; -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels; -using BlacksmithWorkshopBusinessLogic.OfficePackage.Implements; +using CarServiceBusinessLogic.OfficePackage; +using CarServiceBusinessLogic.OfficePackage.HelperModels; +using CarServiceBusinessLogic.OfficePackage.Implements; using CarServiceContracts.BindingModels; using CarServiceContracts.BusinessLogicsContracts; using CarServiceContracts.StorageContracts; diff --git a/CarService/CarServiceBusinessLogic/CarServiceBusinessLogic.csproj b/CarService/CarServiceBusinessLogic/CarServiceBusinessLogic.csproj index a54394f..f35d873 100644 --- a/CarService/CarServiceBusinessLogic/CarServiceBusinessLogic.csproj +++ b/CarService/CarServiceBusinessLogic/CarServiceBusinessLogic.csproj @@ -8,6 +8,7 @@ + diff --git a/CarService/CarServiceBusinessLogic/MailWorker/AbstractMailWorker.cs b/CarService/CarServiceBusinessLogic/MailWorker/AbstractMailWorker.cs new file mode 100644 index 0000000..f17049a --- /dev/null +++ b/CarService/CarServiceBusinessLogic/MailWorker/AbstractMailWorker.cs @@ -0,0 +1,42 @@ +using CarServiceContracts.BindingModels; +using DocumentFormat.OpenXml.Spreadsheet; +using Microsoft.Extensions.Logging; + +namespace CarServiceBusinessLogic.MailWorker +{ + public abstract class AbstractMailWorker + { + protected string _mailLogin = string.Empty; + protected string _mailPassword = string.Empty; + protected string _smtpClientHost = string.Empty; + protected int _smtpClientPort; + private readonly ILogger _logger; + public AbstractMailWorker(ILogger logger) + { + _logger = logger; + _mailLogin = "igors20111@gmail.com"; + _mailPassword = "xzjt gzal aoek rjmp"; + _smtpClientHost = "smtp.gmail.com"; + _smtpClientPort = 465; + _logger.LogDebug("Config: {login}, {password}, {clientHost}, {clientPort}", _mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort); + } + public void MailSend(MailSendInfoBindingModel info) + { + if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword)) + { + return; + } + if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0) + { + return; + } + if (string.IsNullOrEmpty(info.MailAddress)) + { + return; + } + _logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject); + SendMail(info); + } + protected abstract void SendMail(MailSendInfoBindingModel info); + } +} diff --git a/CarService/CarServiceBusinessLogic/MailWorker/MailKitWorker.cs b/CarService/CarServiceBusinessLogic/MailWorker/MailKitWorker.cs new file mode 100644 index 0000000..dd8e8b3 --- /dev/null +++ b/CarService/CarServiceBusinessLogic/MailWorker/MailKitWorker.cs @@ -0,0 +1,34 @@ +using Microsoft.Extensions.Logging; +using System.Net; +using MimeKit; +using CarServiceContracts.BindingModels; + +namespace CarServiceBusinessLogic.MailWorker +{ + public class MailKitWorker : AbstractMailWorker + { + public MailKitWorker(ILogger logger) : base(logger) { } + protected override void SendMail(MailSendInfoBindingModel info) + { + using var message = new MimeMessage(); + using var smtpClient = new MailKit.Net.Smtp.SmtpClient(); + smtpClient.Connect(_smtpClientHost, 465, true); + smtpClient.Authenticate(new NetworkCredential(_mailLogin, _mailPassword)); + + try + { + var builder = new BodyBuilder(); + builder.Attachments.Add("C:\\Users\\igors\\source\\repos\\ISEbd-21_Melnikov_I.O._CarService\\CarService\\CarServiceWebApp\\Files\\ReportPdf.pdf"); + message.Body = builder.ToMessageBody(); + message.From.Add (new MailboxAddress("СТО Руки-крюки", _mailLogin)); + message.To.Add(new MailboxAddress("igors_2011", "igors-2011@mail.ru")); + message.Subject = info.Subject; + smtpClient.Send(message); + } + catch (Exception) + { + throw; + } + } + } +} diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index b520bd7..4e3954b 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -1,7 +1,7 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums; -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels; +using CarServiceBusinessLogic.OfficePackage.HelperEnums; +using CarServiceBusinessLogic.OfficePackage.HelperModels; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage +namespace CarServiceBusinessLogic.OfficePackage { public abstract class AbstractSaveToExcel { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index cf9adc5..51fcfb1 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -1,7 +1,7 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums; -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels; +using CarServiceBusinessLogic.OfficePackage.HelperEnums; +using CarServiceBusinessLogic.OfficePackage.HelperModels; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage +namespace CarServiceBusinessLogic.OfficePackage { public abstract class AbstractSaveToPdf { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToWord.cs index e7a1b96..d9866b0 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -1,7 +1,7 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums; -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels; +using CarServiceBusinessLogic.OfficePackage.HelperEnums; +using CarServiceBusinessLogic.OfficePackage.HelperModels; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage +namespace CarServiceBusinessLogic.OfficePackage { public abstract class AbstractSaveToWord { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs index d5cecc1..edfada6 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs @@ -1,4 +1,4 @@ -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums +namespace CarServiceBusinessLogic.OfficePackage.HelperEnums { public enum ExcelStyleInfoType { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs index 51202ca..b8f4feb 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs @@ -1,4 +1,4 @@ -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums +namespace CarServiceBusinessLogic.OfficePackage.HelperEnums { public enum PdfParagraphAlignmentType { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs index d05b578..13eec5d 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs @@ -1,4 +1,4 @@ -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums +namespace CarServiceBusinessLogic.OfficePackage.HelperEnums { public enum WordJustificationType { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs index 6ce7979..bd0f861 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs @@ -1,5 +1,5 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels +using CarServiceBusinessLogic.OfficePackage.HelperEnums; +namespace CarServiceBusinessLogic.OfficePackage.HelperModels { public class ExcelCellParameters { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index a5d9dfc..7a4064d 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -1,7 +1,7 @@  using CarServiceContracts.ViewModels; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels +namespace CarServiceBusinessLogic.OfficePackage.HelperModels { public class ExcelInfo { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs index 2db633b..fa9f3fc 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs @@ -1,4 +1,4 @@ -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels +namespace CarServiceBusinessLogic.OfficePackage.HelperModels { public class ExcelMergeParameters { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index 1505445..2b9d9d6 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -1,6 +1,6 @@ using CarServiceContracts.ViewModels; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels +namespace CarServiceBusinessLogic.OfficePackage.HelperModels { public class PdfInfo { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs index c7b8302..17d6634 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs @@ -1,6 +1,6 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums; +using CarServiceBusinessLogic.OfficePackage.HelperEnums; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels +namespace CarServiceBusinessLogic.OfficePackage.HelperModels { public class PdfParagraph { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs index 7d2afec..528489a 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs @@ -1,6 +1,6 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums; +using CarServiceBusinessLogic.OfficePackage.HelperEnums; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels +namespace CarServiceBusinessLogic.OfficePackage.HelperModels { public class PdfRowParameters { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index c8c1f20..1de1492 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -1,6 +1,6 @@ using CarServiceContracts.ViewModels; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels +namespace CarServiceBusinessLogic.OfficePackage.HelperModels { public class WordInfo { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs index 3111dfd..e20e330 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs @@ -1,4 +1,4 @@ -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels +namespace CarServiceBusinessLogic.OfficePackage.HelperModels { public class WordParagraph { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs index 703cc05..a9436ef 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs @@ -1,6 +1,6 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums; +using CarServiceBusinessLogic.OfficePackage.HelperEnums; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels +namespace CarServiceBusinessLogic.OfficePackage.HelperModels { public class WordTextProperties { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToExcel.cs index 6e7d701..d5d6946 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToExcel.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToExcel.cs @@ -1,5 +1,5 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums; -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels; +using CarServiceBusinessLogic.OfficePackage.HelperEnums; +using CarServiceBusinessLogic.OfficePackage.HelperModels; using DocumentFormat.OpenXml.Office2010.Excel; using DocumentFormat.OpenXml.Office2013.Excel; using DocumentFormat.OpenXml.Office2016.Excel; @@ -7,7 +7,7 @@ using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Spreadsheet; using DocumentFormat.OpenXml; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements +namespace CarServiceBusinessLogic.OfficePackage.Implements { public class SaveToExcel : AbstractSaveToExcel { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToPdf.cs index b44f346..ca10bb6 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToPdf.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -1,10 +1,10 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums; -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels; +using CarServiceBusinessLogic.OfficePackage.HelperEnums; +using CarServiceBusinessLogic.OfficePackage.HelperModels; using MigraDoc.DocumentObjectModel; using MigraDoc.DocumentObjectModel.Tables; using MigraDoc.Rendering; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements +namespace CarServiceBusinessLogic.OfficePackage.Implements { public class SaveToPdf : AbstractSaveToPdf { diff --git a/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToWord.cs index 5cd3963..85346df 100644 --- a/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/CarService/CarServiceBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -1,10 +1,10 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums; -using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels; +using CarServiceBusinessLogic.OfficePackage.HelperEnums; +using CarServiceBusinessLogic.OfficePackage.HelperModels; using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Wordprocessing; using DocumentFormat.OpenXml; -namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements +namespace CarServiceBusinessLogic.OfficePackage.Implements { public class SaveToWord : AbstractSaveToWord { diff --git a/CarService/CarServiceContracts/BindingModels/MailSendInfoBindingModel.cs b/CarService/CarServiceContracts/BindingModels/MailSendInfoBindingModel.cs new file mode 100644 index 0000000..1e4e4c7 --- /dev/null +++ b/CarService/CarServiceContracts/BindingModels/MailSendInfoBindingModel.cs @@ -0,0 +1,9 @@ +namespace CarServiceContracts.BindingModels +{ + public class MailSendInfoBindingModel + { + public string MailAddress { get; set; } = string.Empty; + public string Subject { get; set; } = string.Empty; + public string Text { get; set; } = string.Empty; + } +} diff --git a/CarService/CarServiceWebApp/Controllers/ReportController.cs b/CarService/CarServiceWebApp/Controllers/ReportController.cs index 57b9d2f..ed3bc0f 100644 --- a/CarService/CarServiceWebApp/Controllers/ReportController.cs +++ b/CarService/CarServiceWebApp/Controllers/ReportController.cs @@ -1,4 +1,5 @@ -using CarServiceContracts.BindingModels; +using CarServiceBusinessLogic.MailWorker; +using CarServiceContracts.BindingModels; using CarServiceContracts.BusinessLogicsContracts; using CarServiceWebApp.Models; using log4net; @@ -10,16 +11,19 @@ namespace CarServiceWebApp.Controllers { private readonly IReportLogic _reportLogic; private readonly IWorkLogic _workLogic; + private readonly AbstractMailWorker _mailWorker; + private static List SelectedWorks = new(); private static ReportBindingModel PaymentsModel = new() { FileName = "C:\\Users\\igors\\source\\repos\\ISEbd-21_Melnikov_I.O._CarService\\CarService\\CarServiceWebApp\\Files\\ReportPdf.pdf" }; - public ReportController(IReportLogic reportLogic, IWorkLogic workLogic) + public ReportController(IReportLogic reportLogic, IWorkLogic workLogic, AbstractMailWorker mailWorker) { _reportLogic = reportLogic; _workLogic = workLogic; + _mailWorker = mailWorker; } public IActionResult Index() @@ -121,5 +125,13 @@ namespace CarServiceWebApp.Controllers return File(fileBytes, "application/force-download", fileName); } + public IActionResult Mail() => View(); + [HttpPost] + public IActionResult Mail(string MailAddress) + { + _reportLogic.SavePaymentsToPdfFile(PaymentsModel); + _mailWorker.MailSend(new() { MailAddress = MailAddress, Subject = $"Отчет по оплатам с {(PaymentsModel.DateFrom ?? new DateTime()).ToShortDateString()} по {(PaymentsModel.DateTo ?? new DateTime()).ToShortDateString()}" }); + return Redirect("~/Report/Index"); + } } } diff --git a/CarService/CarServiceWebApp/Files/ReportPdf.pdf b/CarService/CarServiceWebApp/Files/ReportPdf.pdf index 6efea3a16fb24724fe7500f9e0531eedf27cd31b..487e1a99d07320ae16837ba1423487792a1ce6a2 100644 GIT binary patch delta 285 zcmcb+lIiYBrU{1ZW(G!v1|~)uEs8nWB0}8#y_`31jCVp3vCs;-f-rMa$&v3ZKFWumFMuBDk}l5wJ8N}{>NBC$mqm z#wHvxVLBG!&3`8(GCR4N8oN51J6V{T8yPsenK)Zox|uqfS-6@RnL3&~I~m#85K=LD H!4z8nK_^bB delta 285 zcmcb+lIiYBrU{1Zrbfo52F8XPEs8nWd_#Q$oIE#ggimr)8s=2O7qFI`5VxoDnZfdG|nyFcmrGc5{J4Xlg}^(@UTO-)UWC$mqm z#wHvxVLBG!&3`8(GCLW%TAI6B8d{n=nVLJfnK(MSIvF||n7TN-SU4FPo0{0!5K=LD H!4z8naoJBC diff --git a/CarService/CarServiceWebApp/Program.cs b/CarService/CarServiceWebApp/Program.cs index ba0e723..0837ddf 100644 --- a/CarService/CarServiceWebApp/Program.cs +++ b/CarService/CarServiceWebApp/Program.cs @@ -1,6 +1,7 @@ -using BlacksmithWorkshopBusinessLogic.OfficePackage; -using BlacksmithWorkshopBusinessLogic.OfficePackage.Implements; using CarServiceBusinessLogic.BusinessLogics; +using CarServiceBusinessLogic.MailWorker; +using CarServiceBusinessLogic.OfficePackage; +using CarServiceBusinessLogic.OfficePackage.Implements; using CarServiceContracts.BusinessLogicsContracts; using CarServiceContracts.StorageContracts; using CarServiceDatabase.Implements; @@ -31,6 +32,8 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddSingleton(); + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/CarService/CarServiceWebApp/Views/Report/Mail.cshtml b/CarService/CarServiceWebApp/Views/Report/Mail.cshtml new file mode 100644 index 0000000..4e4ecfd --- /dev/null +++ b/CarService/CarServiceWebApp/Views/Report/Mail.cshtml @@ -0,0 +1,6 @@ +@using CarServiceContracts.BindingModels +@model MailSendInfoBindingModel +
+
+
+
\ No newline at end of file diff --git a/CarService/CarServiceWebApp/Views/Report/ReportPayments.cshtml b/CarService/CarServiceWebApp/Views/Report/ReportPayments.cshtml index c718a4f..b8f7219 100644 --- a/CarService/CarServiceWebApp/Views/Report/ReportPayments.cshtml +++ b/CarService/CarServiceWebApp/Views/Report/ReportPayments.cshtml @@ -57,5 +57,8 @@ {

Нет оплат за указанный период

} + - \ No newline at end of file + + + diff --git a/CarService/CarServiceWebApp/log4net.config b/CarService/CarServiceWebApp/log4net.config index 51357b2..42b1cb2 100644 --- a/CarService/CarServiceWebApp/log4net.config +++ b/CarService/CarServiceWebApp/log4net.config @@ -1,7 +1,7 @@  - +