Подготовка к отправке на почту

This commit is contained in:
Володя 2023-05-18 21:22:03 +03:00
parent 3f786d3886
commit 2cf4884362
5 changed files with 35 additions and 11 deletions

View File

@ -39,6 +39,7 @@ namespace SchoolAgainStudyBusinessLogic.BusinessLogic
public ReportLogic(IInterestStorage interestStorage, IMaterialStorage materialStorage, IProductStorage productStorage, IDiyStorage diyStorage, ITaskStorage taskStorage, ILessonStorage lessonStorage, AbstractSaveToExcelTeacher saveToExcelTeacher, AbstractSaveToWordTeacher saveToWordTeacher, AbstractSaveToPdfTeacher saveToPdfTeacher, AbstractSaveToExcelStudent saveToExcelStudent, AbstractSaveToWordStudent saveToWordStudent, AbstractSaveToPdfStudent saveToPdfStudent) public ReportLogic(IInterestStorage interestStorage, IMaterialStorage materialStorage, IProductStorage productStorage, IDiyStorage diyStorage, ITaskStorage taskStorage, ILessonStorage lessonStorage, AbstractSaveToExcelTeacher saveToExcelTeacher, AbstractSaveToWordTeacher saveToWordTeacher, AbstractSaveToPdfTeacher saveToPdfTeacher, AbstractSaveToExcelStudent saveToExcelStudent, AbstractSaveToWordStudent saveToWordStudent, AbstractSaveToPdfStudent saveToPdfStudent)
{ {
_interestStorage = interestStorage; _interestStorage = interestStorage;
_materialStorage = materialStorage; _materialStorage = materialStorage;
_productStorage = productStorage; _productStorage = productStorage;
@ -122,6 +123,7 @@ namespace SchoolAgainStudyBusinessLogic.BusinessLogic
public List<ReportInterestViewModel> GetInterests(ReportBindingModel model) public List<ReportInterestViewModel> GetInterests(ReportBindingModel model)
{ {
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
var interests = _interestStorage.GetFilteredList(new InterestSearchModel var interests = _interestStorage.GetFilteredList(new InterestSearchModel
{ {
StudentId = model.StudentId StudentId = model.StudentId
@ -151,7 +153,7 @@ namespace SchoolAgainStudyBusinessLogic.BusinessLogic
{ {
list.Add(new ReportInterestViewModel list.Add(new ReportInterestViewModel
{ {
InterestTitle = interests.FirstOrDefault(x => x.Id == interestProduct).ToString(), InterestTitle = interests.FirstOrDefault(x => x.Id == interestProduct).Title,
ProductTitle = product.Title, ProductTitle = product.Title,
DateCreateProduct = product.DateCreate, DateCreateProduct = product.DateCreate,
DiyTitle = diy.Title, DiyTitle = diy.Title,

View File

@ -8,6 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" /> <PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
<PackageReference Include="MailKit" Version="4.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" /> <PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
<PackageReference Include="System.Text.Encoding" Version="4.3.0" /> <PackageReference Include="System.Text.Encoding" Version="4.3.0" />

View File

@ -447,6 +447,26 @@ namespace StudentWebClient.Controllers
var items = _report.GetInterestLesson(new ReportBindingModel { Interests = list, StudentId = APIClient.Student.Id}); var items = _report.GetInterestLesson(new ReportBindingModel { Interests = list, StudentId = APIClient.Student.Id});
return PartialView("_LessonListPartial", items); return PartialView("_LessonListPartial", items);
} }
public IActionResult SendingEmail()
{
return View();
}
public IActionResult GetPartialForPDF(string dateFrom, string dateTo)
{
var _dateFrom = DateTime.SpecifyKind(DateTime.Parse(dateFrom), DateTimeKind.Utc);
var _dateTo = DateTime.SpecifyKind(DateTime.Parse(dateTo), DateTimeKind.Utc);
if(_dateFrom > _dateTo)
{
throw new Exception("Не верные даты");
}
_report.SaveInterestsToPdfFile
(new ReportBindingModel { FileName = $"C:\\Users\\Вова\\Documents\\Учеба\\Reports\\{APIClient.Student.Name} от {_dateFrom.ToString("dd/MM/yyyy")}.pdf" ,
DateFrom = _dateFrom, DateTo = _dateTo, StudentId = APIClient.Student.Id});
var items = _report.GetInterests(new ReportBindingModel { DateFrom = _dateFrom, DateTo = _dateTo, StudentId = APIClient.Student.Id });
return PartialView("_LessonListPartial", items);
}
} }
} }

View File

@ -1,16 +1,14 @@
@{ @{
ViewData["Title"] = "Report"; ViewData["Title"] = "Report";
} }
<form id="my_form" asp-action="Reports" method="get" data-ajax="true" data-ajax-method="get" data-ajax-update="#panel" data-ajax-mode='replace' data-ajax-url="@Url.Action("GetPartial","Home")"> <form id="my_form" asp-action="SendingEmail" method="get" data-ajax="true" data-ajax-method="get" data-ajax-update="#panel" data-ajax-mode='replace' data-ajax-url="@Url.Action("GetPartialForPDF","Home")">
<select id="mode" name="mode">
<option>Excel</option>
<option>Word</option>
</select>
<div class="row"> <div class="row">
<div class="col-4">Интересы:</div> <div class="col-4">От:</div>
<div class="col-8"> <div class="col-8">@Html.TextBox("dateFrom" ,"" ,new {type="Date"})</div>
@Html.ListBox("interests", (MultiSelectList)ViewBag.Interests)
</div> </div>
<div class="row">
<div class="col-4">До:</div>
<div class="col-8">@Html.TextBox("dateTo" ,"" ,new {type="Date"})</div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-8"></div> <div class="col-8"></div>
@ -19,4 +17,4 @@
</form> </form>
<div class="row pr-3 pl-3" id="panel"> <div class="row pr-3 pl-3" id="panel">
@section scripts{ @section scripts{
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajax-unobtrusive/3.2.6/jquery.unobtrusive-ajax.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajax-unobtrusive/3.2.6/jquery.unobtrusive-ajax.min.js"></script>}

View File

@ -44,6 +44,9 @@
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Reports">Отчеты</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Reports">Отчеты</a>
</li> </li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="SendingEmail">НаПочту</a>
</li>
</ul> </ul>
</div> </div>