I missed all the time i've got...
This commit is contained in:
parent
a207814faa
commit
afa42aa2f9
@ -19,4 +19,8 @@
|
||||
<ProjectReference Include="..\BeautyStudioContracts\BeautyStudioContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="OfficePackage\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -0,0 +1,59 @@
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BeautyStudioBusinessLogic.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 IStoreKeeperLogic _executorLogic;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public AbstractMailWorker(ILogger<AbstractMailWorker> logger, IStoreKeeperLogic 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);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
using StoreKeeperContracts.BindingModels;
|
||||
using StoreKeeperContracts.BusinessLogicContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Net.Mail;
|
||||
using System.Net.Mime;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using BeautyStudioBusinessLogic.MailWorker;
|
||||
|
||||
namespace StoreKeeperBusinessLogic.MailWorker
|
||||
{
|
||||
public class MailKitWorker : AbstractMailWorker
|
||||
{
|
||||
public MailKitWorker(ILogger<MailKitWorker> logger, IStoreKeeperLogic _storekeeperLogic) : base(logger, _storekeeperLogic) { }
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
BeautyStudio/BeautyStudioRestAPI/Controllers/ReportController.cs
Normal file
133
BeautyStudio/BeautyStudioRestAPI/Controllers/ReportController.cs
Normal file
@ -0,0 +1,133 @@
|
||||
using BeautyStudioBusinessLogic.MailWorker;
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace HotelRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ReportController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportStoreKeeperLogic _reportStoreKeeperLogic;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
|
||||
public ReportController(ILogger<ReportController> logger, IReportStoreKeeperLogic reportStoreKeeperLogic, AbstractMailWorker mailWorker)
|
||||
{
|
||||
_logger = logger;
|
||||
_reportStoreKeeperLogic = reportStoreKeeperLogic;
|
||||
_mailWorker = mailWorker;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateStoreKeeperReportToPdfFile(ReportStoreKeeperBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportStoreKeeperLogic.SaveClientsToPdfFile(new ReportStoreKeeperBindingModel
|
||||
{
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo,
|
||||
StoreKeeperId = model.StoreKeeperId,
|
||||
FileName = "C:\\Reports\\pdffile.pdf",
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void SendPdfToMail(MailSendInfoBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mailWorker.MailSendAsync(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отправки письма");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateStoreKeeperReportToWordFile(ReportStoreKeeperBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportStoreKeeperLogic.SaveClientHearingToWordFile(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateOrganiserReportToExcelFile(ReportStoreKeeperBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportStoreKeeperLogic.SaveClientHearingToExcelFile(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/*[HttpPost]
|
||||
public void CreateHeadwaiterReportToWordFile(ReportHeadwaiterBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportHeadwaiterLogic.SaveLunchRoomToWordFile(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateHeadwaiterReportToExcelFile(ReportHeadwaiterBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportHeadwaiterLogic.SaveLunchRoomToExcelFile(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateHeadwaiterReportToPdfFile(ReportHeadwaiterBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportHeadwaiterLogic.SaveLunchesToPdfFile(new ReportHeadwaiterBindingModel
|
||||
{
|
||||
FileName = "C:\\Reports\\pdffile.pdf",
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo,
|
||||
HeadwaiterId = model.HeadwaiterId,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
@ -5,5 +5,11 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"SmtpClientHost": "smtp.gmail.com",
|
||||
"SmtpClientPort": "587",
|
||||
"PopHost": "pop.gmail.com",
|
||||
"PopPort": "995",
|
||||
"MailLogin": "rpplabs724@gmail.com",
|
||||
"MailPassword": "pyen krno ssaj rlvm"
|
||||
}
|
||||
|
@ -34,7 +34,6 @@
|
||||
<th>Дата создания</th>
|
||||
<th>Услуга</th>
|
||||
<th>Стоимость</th>
|
||||
<th>Бренд косметики</th>
|
||||
<th>Наименование</th>
|
||||
<th>Стоимость косметики</th>
|
||||
<th>Процедуры</th>
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
<h4 class="fw-bold">Создать трудозатрату</h4>
|
||||
|
||||
<form method="post" asp-controller="LaborCosts" asp-action="Create">
|
||||
<form method="post" asp-controller="LaborCost" asp-action="Create">
|
||||
<p class="mb-0">Количество часов:</p>
|
||||
<input type="number" name="numberHours" class="form-control mb-3" />
|
||||
<input type="number" name="TimeSpent" class="form-control mb-3" />
|
||||
<p class="mb-0">Сложность:</p>
|
||||
<input type="text" name="difficulty" class="form-control mb-3" />
|
||||
<button type="submit" class="btn button-primary">
|
||||
|
@ -4,12 +4,12 @@
|
||||
|
||||
<h4 class="fw-bold">Обновить трудозатраты</h4>
|
||||
|
||||
<form method="post" asp-controller="LaborCosts" asp-action="Update">
|
||||
<input name="id" value="@ViewBag.LaborCosts.Id" style="display: none;" />
|
||||
<form method="post" asp-controller="LaborCost" asp-action="Update">
|
||||
<input name="id" value="@ViewBag.LaborCost.Id" style="display: none;" />
|
||||
<p class="mb-0">Количество часов:</p>
|
||||
<input type="number" value="@ViewBag.LaborCosts.NumberHours" name="numberHours" class="form-control mb-3" />
|
||||
<input type="number" value="@ViewBag.LaborCost.TimeSpent" name="timeSpent" class="form-control mb-3" />
|
||||
<p class="mb-0">Сложность:</p>
|
||||
<input type="text" value="@ViewBag.LaborCosts.Difficulty" name="difficulty" class="form-control mb-3" />
|
||||
<input type="text" value="@ViewBag.LaborCost.Difficulty" name="difficulty" class="form-control mb-3" />
|
||||
<button type="submit" class="btn button-primary">
|
||||
Обновить
|
||||
</button>
|
||||
|
@ -17,7 +17,6 @@
|
||||
<table class="table mb-0">
|
||||
<thead class="table-head">
|
||||
<tr>
|
||||
<th>Бренд</th>
|
||||
<th>Наименование</th>
|
||||
<th>Стоимость</th>
|
||||
<th>Количество</th>
|
||||
|
Loading…
Reference in New Issue
Block a user