send message
This commit is contained in:
parent
67257c30ca
commit
d43bff822f
@ -18,19 +18,17 @@ namespace HardwareShopContracts.BusinessLogicsContracts
|
|||||||
|
|
||||||
private readonly IPurchaseStorage _purchaseStorage;
|
private readonly IPurchaseStorage _purchaseStorage;
|
||||||
|
|
||||||
private readonly IBuildStorage _buildStorage;
|
|
||||||
|
|
||||||
private readonly AbstractSaveToExcel _saveToExcel;
|
private readonly AbstractSaveToExcel _saveToExcel;
|
||||||
|
|
||||||
private readonly AbstractSaveToWord _saveToWord;
|
private readonly AbstractSaveToWord _saveToWord;
|
||||||
|
|
||||||
private readonly AbstractSaveToPdf _saveToPdf;
|
private readonly AbstractSaveToPdf _saveToPdf;
|
||||||
private readonly MailKitWorker _mailKitWorker;
|
|
||||||
|
|
||||||
public WorkerReportLogic(IPurchaseStorage purchaseStorage, MailKitWorker mailKitWorker, IBuildStorage buildStorage, AbstractSaveToPdf saveToPdf, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord)
|
private readonly AbstractMailWorker _mailKitWorker;
|
||||||
|
|
||||||
|
public WorkerReportLogic(IPurchaseStorage purchaseStorage, AbstractMailWorker mailKitWorker, AbstractSaveToPdf saveToPdf, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord)
|
||||||
{
|
{
|
||||||
_purchaseStorage = purchaseStorage;
|
_purchaseStorage = purchaseStorage;
|
||||||
_buildStorage = buildStorage;
|
|
||||||
_saveToExcel = saveToExcel;
|
_saveToExcel = saveToExcel;
|
||||||
_saveToWord = saveToWord;
|
_saveToWord = saveToWord;
|
||||||
_saveToPdf = saveToPdf;
|
_saveToPdf = saveToPdf;
|
||||||
@ -162,14 +160,14 @@ namespace HardwareShopContracts.BusinessLogicsContracts
|
|||||||
DateTo = model.DateTo,
|
DateTo = model.DateTo,
|
||||||
ReportPurchases = GetPurchase(model)
|
ReportPurchases = GetPurchase(model)
|
||||||
});
|
});
|
||||||
// _mailKitWorker.SendMailAsync(new()
|
_mailKitWorker.MailSendAsync(new()
|
||||||
// {
|
{
|
||||||
// MailAddress = reportModel.UserEmail,
|
MailAddress = model.UserEmail,
|
||||||
// Subject = "Отчет по покупкам",
|
Subject = "Отчет по покупкам",
|
||||||
// Text = $"За период с {reportModel.DateFrom.ToShortDateString()} " +
|
Text = $"За период с {model.DateFrom.ToShortDateString()} " +
|
||||||
//$"по {reportModel.DateTo.ToShortDateString()}.",
|
$"по {model.DateTo.ToShortDateString()}.",
|
||||||
// File = file
|
File = file
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,6 +25,8 @@ namespace HardwareShopBusinessLogic.MailWorker
|
|||||||
objMailMessage.Body = info.Text;
|
objMailMessage.Body = info.Text;
|
||||||
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||||
objMailMessage.BodyEncoding = Encoding.UTF8;
|
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||||
|
MemoryStream ms = new(info.File);
|
||||||
|
objMailMessage.Attachments.Add(new Attachment(ms, "report.pdf", "application/pdf"));
|
||||||
|
|
||||||
objSmtpClient.UseDefaultCredentials = false;
|
objSmtpClient.UseDefaultCredentials = false;
|
||||||
objSmtpClient.EnableSsl = true;
|
objSmtpClient.EnableSsl = true;
|
||||||
|
@ -7,5 +7,7 @@
|
|||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Text { get; set; } = string.Empty;
|
public string Text { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public byte[] File { get; set; } = Array.Empty<byte>();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,8 @@
|
|||||||
{
|
{
|
||||||
public class ReportBindingModel
|
public class ReportBindingModel
|
||||||
{
|
{
|
||||||
|
public string UserEmail { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public DateTime DateFrom { get; set; }
|
public DateTime DateFrom { get; set; }
|
||||||
|
@ -37,8 +37,8 @@ builder.Services.AddTransient<IReportStorekeeperLogic, ReportStorekeeperLogic>()
|
|||||||
builder.Services.AddTransient<IWorkerReportLogic, WorkerReportLogic>();
|
builder.Services.AddTransient<IWorkerReportLogic, WorkerReportLogic>();
|
||||||
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
|
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||||
builder.Services.AddTransient<AbstractMailWorker, MailKitWorker>();
|
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
|
@ -98,7 +98,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/home/sendbymailepurchasereport",
|
url: "/home/SendByMailPurchaseReport",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
data: JSON.stringify(reportModel)
|
data: JSON.stringify(reportModel)
|
||||||
@ -129,7 +129,7 @@
|
|||||||
let cellsData = ["", "", "", "", ""];
|
let cellsData = ["", "", "", "", ""];
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
cellsData[0] = record.id;
|
cellsData[0] = record.id;
|
||||||
cellsData[1] = record.purchaseDate;
|
cellsData[1] = getDate(record.purchaseDate);
|
||||||
cellsData[2] = record.purchaseSum;
|
cellsData[2] = record.purchaseSum;
|
||||||
createTableRow(cellsData);
|
createTableRow(cellsData);
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user