add sending pdf report to email

This commit is contained in:
Zakharov_Rostislav 2024-05-27 02:35:01 +04:00
parent f691fc1512
commit 1de0fc1239
4 changed files with 144 additions and 11 deletions

View File

@ -28,7 +28,7 @@ namespace BankBusinessLogic.MailWorker
objMailMessage.Body = info.Text;
objMailMessage.SubjectEncoding = Encoding.UTF8;
objMailMessage.BodyEncoding = Encoding.UTF8;
Attachment attachment = new Attachment("C:\\Users\\pdffile.pdf", new ContentType(MediaTypeNames.Application.Pdf));
Attachment attachment = new Attachment("C:\\forpdf\\pdffile.pdf", new ContentType(MediaTypeNames.Application.Pdf));
objMailMessage.Attachments.Add(attachment);
objSmtpClient.UseDefaultCredentials = false;
objSmtpClient.EnableSsl = true;

View File

@ -14,6 +14,7 @@ namespace BankBusinessLogic.OfficePackage
public void CreateCreateTransfersDocDoc(PdfInfo info)
{
CreatePdf(info);
//title
CreateParagraph(new PdfParagraph
{
Text = info.Title,
@ -24,30 +25,162 @@ namespace BankBusinessLogic.OfficePackage
{
Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
//sender transfers
CreateParagraph(new PdfParagraph
{
Text = "Переводы на другие счета",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер", "Дата заказа", "Компьютер", "Сумма", "Статус" },
Texts = new List<string> { "Номер счёта", "Номер перевода", "Время перевода", "Сумма", "Номер счёта получателя" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var entry in info.OperationsRequests)
foreach (var report in info.TransfersWithdrawals)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { entry.CardNumber.ToString(), },
Texts = new List<string>
{
report.AccountNumber.ToString(),
"",
"",
"",
"",
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
foreach(var senderTransfer in report.SenderTransfers)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
"",
senderTransfer.Id.ToString(),
senderTransfer.TransferTime.ToString(),
senderTransfer.Sum.ToString(),
senderTransfer.RecipientAccountNumber.ToString(),
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
}
CreateParagraph(new PdfParagraph
{
Text = "",
Style = "Normal",
ParagraphAlignment =
PdfParagraphAlignmentType.Right
ParagraphAlignment = PdfParagraphAlignmentType.Right
});
SavePdf(info);
//recipient transfers
CreateParagraph(new PdfParagraph
{
Text = "Переводы с других счетов",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер счёта", "Номер перевода", "Время перевода", "Сумма", "Номер счёта отправителя" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var report in info.TransfersWithdrawals)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
report.AccountNumber.ToString(),
"",
"",
"",
"",
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
foreach (var recipientTransfer in report.RecipientTransfers)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
"",
recipientTransfer.Id.ToString(),
recipientTransfer.TransferTime.ToString(),
recipientTransfer.Sum.ToString(),
recipientTransfer.SenderAccountId.ToString(),
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
}
CreateParagraph(new PdfParagraph
{
Text = "",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Right
});
//withdrawals
CreateParagraph(new PdfParagraph
{
Text = "Выдачи наличных",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер счёта", "Номер выдачи", "Время выдачи", "Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var report in info.TransfersWithdrawals)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
report.AccountNumber.ToString(),
"",
"",
"",
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
foreach (var withdrawal in report.Withdrawals)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string>
{
"",
withdrawal.Id.ToString(),
withdrawal.WithdrawalTime.ToString(),
withdrawal.Sum.ToString(),
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
}
CreateParagraph(new PdfParagraph
{
Text = "",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Right
});
//
SavePdf(info);
}
public void CreateOperationsRequestsDoc(PdfInfo info)
{

View File

@ -522,12 +522,12 @@ namespace BankManagersClientApp.Controllers
}
APIClient.PostRequest("api/report/sendtransferswithdrawalstoemail", new ReportBindingModel
{
FileName = "C:\\Users\\pdffile.pdf",
FileName = "C:\\forpdf\\pdffile.pdf",
DateFrom = dateFrom,
DateTo = dateTo,
Email = APIClient.Client.Email,
});
Response.Redirect("TransfersWithdrawalsListReport");
Response.Redirect("Index");
}
#endregion

View File

@ -30,7 +30,7 @@
<thead>
<tr>
<th>Номер</th>
<th>Дата/th>
<th>Дата</th>
<th>Счёт</th>
<th>Перевод</th>
<th>Выдача</th>