From 478fbf8b8a153704671f9a33539ad1420861df92 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Wed, 29 May 2024 21:06:39 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D1=8B=D0=B5=20?= =?UTF-8?q?=D0=BF=D0=B4=D1=84=20=D0=BE=D1=82=D1=87=D1=91=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MailWorker/MailKitWorker.cs | 2 +- .../OfficePackage/AbstractSaveToPdfWorker.cs | 56 +++++++++++-------- .../Controllers/HomeController.cs | 10 ++-- .../UniversityDatabase.cs | 2 +- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/University/UniversityBusinessLogic/MailWorker/MailKitWorker.cs b/University/UniversityBusinessLogic/MailWorker/MailKitWorker.cs index ac46a95..3bb5c2f 100644 --- a/University/UniversityBusinessLogic/MailWorker/MailKitWorker.cs +++ b/University/UniversityBusinessLogic/MailWorker/MailKitWorker.cs @@ -32,7 +32,7 @@ namespace UniversityBusinessLogic.MailWorker objMailMessage.Body = info.Text; objMailMessage.SubjectEncoding = Encoding.UTF8; objMailMessage.BodyEncoding = Encoding.UTF8; - Attachment attachment = new Attachment($"C:\\Users\\{Environment.UserName}\\Desktop\\Сведения по планам обучения.pdf", new ContentType(MediaTypeNames.Application.Pdf)); + Attachment attachment = new Attachment("C:\\ВременныеОтчёты\\Сведения по планам обучения.pdf", new ContentType(MediaTypeNames.Application.Pdf)); objMailMessage.Attachments.Add(attachment); objSmtpClient.UseDefaultCredentials = false; diff --git a/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs b/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs index 9ebc146..e16ad15 100644 --- a/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs +++ b/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs @@ -19,30 +19,38 @@ namespace UniversityBusinessLogic.OfficePackage ParagraphAlignment = PdfParagraphAlignmentType.Center }); - /*foreach (var item in info.PlanOfStudyAndStudent) - { - foreach (var studentName in item.StudentName) - { - foreach (var disciplineName in item.DisciplineName) - { - CreateRow(new PdfRowParameters - { - Texts = new List { item.Id.ToString(), item.PlanOfStudyName, studentName, disciplineName }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - } - } - }*/ - foreach(var item in info.PlanOfStudyAndStudent) - { - CreateRow(new PdfRowParameters - { - Texts = new List { item.Id.ToString(), item.PlanOfStudyName }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - } + foreach (var item in info.PlanOfStudyAndStudent) + { + foreach (var studentName in item.StudentName) + { + var rowTexts = new List { item.Id.ToString(), item.PlanOfStudyName, studentName }; + if (item.DisciplineName.Any()) + { + foreach (var disciplineName in item.DisciplineName) + { + rowTexts.Add(disciplineName); + CreateRow(new PdfRowParameters + { + Texts = rowTexts, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + rowTexts.RemoveAt(rowTexts.Count - 1); + } + } + else + { + // Если нет дисциплин, добавляем пустую строку + rowTexts.Add(""); + CreateRow(new PdfRowParameters + { + Texts = rowTexts, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + } + } SavePdf(info); } diff --git a/University/UniversityClientAppWorker/Controllers/HomeController.cs b/University/UniversityClientAppWorker/Controllers/HomeController.cs index 552d1b3..7962177 100644 --- a/University/UniversityClientAppWorker/Controllers/HomeController.cs +++ b/University/UniversityClientAppWorker/Controllers/HomeController.cs @@ -277,7 +277,7 @@ namespace UniversityClientAppWorker.Controllers { APIClient.PostRequest("api/planofstudys/loadreporttoword", new ReportBindingModel { - FileName = $"C:\\Users\\{Environment.UserName}\\Downloads\\ .docx" + FileName = "C:\\\\ .docx" }); return GetWordFile(); } @@ -286,7 +286,7 @@ namespace UniversityClientAppWorker.Controllers { APIClient.PostRequest("api/planofstudys/loadreporttoexcel", new ReportBindingModel { - FileName = $"C:\\Users\\{Environment.UserName}\\Downloads\\ .xlsx" + FileName = "C:\\\\ .xlsx" }); return GetExcelFile(); } @@ -313,13 +313,13 @@ namespace UniversityClientAppWorker.Controllers { APIClient.PostRequest("api/planofstudys/createreporttopdffile", new ReportBindingModel { - FileName = "C:\\Users\\{Environment.UserName}\\Desktop\\ .pdf" + FileName = "C:\\\\ .pdf" }); - APIClient.PostRequest("api/order/sendpdftomail", new MailSendInfoBindingModel + APIClient.PostRequest("api/planofstudys/sendpdftomail", new MailSendInfoBindingModel { MailAddress = APIClient.User.Email, Subject = "", - Text = " " + Text = " " }); } Response.Redirect("Index"); diff --git a/University/UniversityDatabaseImplement/UniversityDatabase.cs b/University/UniversityDatabaseImplement/UniversityDatabase.cs index 2b73bad..3eebb86 100644 --- a/University/UniversityDatabaseImplement/UniversityDatabase.cs +++ b/University/UniversityDatabaseImplement/UniversityDatabase.cs @@ -11,7 +11,7 @@ namespace UniversityDatabaseImplement if (optionsBuilder.IsConfigured == false) { //Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR - optionsBuilder.UseSqlServer(@"Data Source=DyCTaTOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-DYCTATOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); }