diff --git a/Bank/BankBusinessLogic/MailWorker/MailKitWorker.cs b/Bank/BankBusinessLogic/MailWorker/MailKitWorker.cs index 5c0799b..96403d7 100644 --- a/Bank/BankBusinessLogic/MailWorker/MailKitWorker.cs +++ b/Bank/BankBusinessLogic/MailWorker/MailKitWorker.cs @@ -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; diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index e83290c..10da23d 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -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 { "2cm", "3cm", "6cm", "3cm", "3cm" }); + //sender transfers + CreateParagraph(new PdfParagraph + { + Text = "Переводы на другие счета", + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "3cm" }); CreateRow(new PdfRowParameters { - Texts = new List { "Номер", "Дата заказа", "Компьютер", "Сумма", "Статус" }, + Texts = new List { "Номер счёта", "Номер перевода", "Время перевода", "Сумма", "Номер счёта получателя" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - foreach (var entry in info.OperationsRequests) + foreach (var report in info.TransfersWithdrawals) { CreateRow(new PdfRowParameters { - Texts = new List { entry.CardNumber.ToString(), }, + Texts = new List + { + report.AccountNumber.ToString(), + "", + "", + "", + "", + }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); + foreach(var senderTransfer in report.SenderTransfers) + { + CreateRow(new PdfRowParameters + { + Texts = new List + { + "", + 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 { "2cm", "3cm", "6cm", "3cm", "3cm" }); + CreateRow(new PdfRowParameters + { + Texts = new List { "Номер счёта", "Номер перевода", "Время перевода", "Сумма", "Номер счёта отправителя" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + foreach (var report in info.TransfersWithdrawals) + { + CreateRow(new PdfRowParameters + { + Texts = new List + { + report.AccountNumber.ToString(), + "", + "", + "", + "", + }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + foreach (var recipientTransfer in report.RecipientTransfers) + { + CreateRow(new PdfRowParameters + { + Texts = new List + { + "", + 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 { "2cm", "3cm", "6cm", "3cm", "3cm" }); + CreateRow(new PdfRowParameters + { + Texts = new List { "Номер счёта", "Номер выдачи", "Время выдачи", "Сумма" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + foreach (var report in info.TransfersWithdrawals) + { + CreateRow(new PdfRowParameters + { + Texts = new List + { + report.AccountNumber.ToString(), + "", + "", + "", + }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + foreach (var withdrawal in report.Withdrawals) + { + CreateRow(new PdfRowParameters + { + Texts = new List + { + "", + 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) { diff --git a/Bank/BankManagersClientApp/Controllers/HomeController.cs b/Bank/BankManagersClientApp/Controllers/HomeController.cs index dbfdee0..a22d14e 100644 --- a/Bank/BankManagersClientApp/Controllers/HomeController.cs +++ b/Bank/BankManagersClientApp/Controllers/HomeController.cs @@ -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 diff --git a/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml b/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml index f6300c9..cff1994 100644 --- a/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml @@ -30,7 +30,7 @@ Номер - Дата/th> + Дата Счёт Перевод Выдача