Сон в метре от меня

This commit is contained in:
Владимир Данилов 2024-05-30 01:49:05 +04:00
parent 305719faef
commit 92f4c08128
4 changed files with 19 additions and 19 deletions

View File

@ -85,7 +85,20 @@ namespace VeterinaryClinicBusinessLogics.MailWorker
{ {
return; return;
} }
if (string.IsNullOrEmpty(info.MailAddress))
{
_logger.LogWarning("MailAddress is null or empty");
}
if (string.IsNullOrEmpty(info.Subject))
{
_logger.LogWarning("Subject is null or empty");
}
if (string.IsNullOrEmpty(info.Path))
{
_logger.LogWarning("Path is null or empty");
}
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Path)) if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Path))
{ {
return; return;

View File

@ -276,7 +276,7 @@ public class HomeController : Controller
_reportLogic.SaveVisitsInfoToPdfFile(new ReportBindingModel _reportLogic.SaveVisitsInfoToPdfFile(new ReportBindingModel
{ {
FileName = $@"D:\ {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.pdf", FileName = $@"D:\report.pdf",
UserId = APIClient.User.Id, UserId = APIClient.User.Id,
DateFrom = dateFrom, DateFrom = dateFrom,
DateTo = dateTo DateTo = dateTo
@ -289,23 +289,19 @@ public class HomeController : Controller
/// Îòïðàâèòü ïî ïî÷òå îò÷¸ò /// Îòïðàâèòü ïî ïî÷òå îò÷¸ò
/// </summary> /// </summary>
[HttpPost] [HttpPost]
public void SendReport(DateTime dateFrom, DateTime dateTo) public void SendReport()
{ {
if (APIClient.User == null) if (APIClient.User == null)
{ {
throw new Exception("Íåîáõîäèìî àâòîðèçîâàòüñÿ!"); throw new Exception("Íåîáõîäèìî àâòîðèçîâàòüñÿ!");
} }
if (dateFrom == DateTime.MinValue || dateTo == DateTime.MinValue)
{
throw new Exception("Ââåäåíû íå âñå äàííûå!");
}
_mailLogic.MailSendAsync(new MailSendInfoBindingModel _mailLogic.MailSendAsync(new MailSendInfoBindingModel
{ {
MailAddress = APIClient.User.Email, MailAddress = APIClient.User.Email,
Subject = $"Îò÷åò {APIClient.User.FullName}", Subject = $"Îò÷åò {APIClient.User.FullName}",
Text = $"Îò÷åò ñ {dateFrom.ToShortDateString()} ïî {dateTo.ToShortDateString()}" Text = "Âàø îò÷åò",
Path = "D:\\report.pdf"
}); });
Response.Redirect("/Home/Reports"); Response.Redirect("/Home/Reports");

View File

@ -60,8 +60,6 @@ mailSender?.MailConfig(new MailConfigBindingModel
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString()) PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
}); });
APIClient.Connect(builder.Configuration);
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
{ {

View File

@ -41,16 +41,9 @@
</div> </div>
<!-- Отправить отчет на почту --> <!-- Отправить отчет на почту -->
@* <div class="d-flex"> <div class="d-flex">
<label for="fileUpload" class="d-block"></label>
<input type="file" id="fileUpload" name="fileUpload" class="form-control-file d-inline-block w-auto">
<button type="submit" class="btn btn-primary" formaction="@Url.Action("SendReport", "Home")">Отправить отчет на почту</button> <button type="submit" class="btn btn-primary" formaction="@Url.Action("SendReport", "Home")">Отправить отчет на почту</button>
</div> *@ </div>
<form asp-controller="Home" asp-action="SendReport" method="post">
<input type="hidden" name="dateFrom" readonly value="@(ViewBag.DateFrom)" />
<input type="hidden" name="dateTo" readonly value="@(ViewBag.DateTo)" />
<button type="submit" class="btn btn-primary">Отправить отчет на почту</button>
</form>
<!-- Вывести отчет на форму --> <!-- Вывести отчет на форму -->
<div class="text-center"> <div class="text-center">