Compare commits
2 Commits
42982bcdab
...
84d8c3dc4a
Author | SHA1 | Date | |
---|---|---|---|
|
84d8c3dc4a | ||
|
3226311dd2 |
@ -252,13 +252,13 @@ public class ReportLogic : IReportLogic
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendDisciplinesToEmail(ReportDateRangeBindingModel option, string email)
|
public void SendDisciplinesToEmail(ReportDateRangeBindingModel option)
|
||||||
{
|
{
|
||||||
_saveToPdfWorker.CreateDoc(new PdfInfoWorker
|
_saveToPdfStorekeeper.CreateDoc(new PdfInfoStorekeeper
|
||||||
{
|
{
|
||||||
FileName = option.FileName,
|
FileName = option.FileName,
|
||||||
Title = "Отчёт по дисциплинам",
|
Title = "Отчёт по дисциплинам",
|
||||||
PlanOfStudyAndStudent = GetPlanOfStudyAndStudents()
|
Disciplines = GetDisciplines(option)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,15 +217,32 @@ namespace UniversityClientApp.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*[HttpGet]
|
[HttpPost]
|
||||||
public IActionResult ReportDisciplines()
|
public void ReportDisciplines(string type, DateOnly dateFrom, DateOnly dateTo)
|
||||||
{
|
{
|
||||||
if (APIStorekeeper.Client == null)
|
if (APIStorekeeper.Client == null)
|
||||||
{
|
{
|
||||||
return Redirect("~/Home/Enter");
|
Redirect("~/Home/Enter");
|
||||||
}
|
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
|
||||||
return View();
|
}
|
||||||
}*/
|
if (type == "pdf")
|
||||||
|
{
|
||||||
|
APIStorekeeper.PostRequest("api/discipline/createreporttopdffile", new ReportDateRangeBindingModel
|
||||||
|
{
|
||||||
|
FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\Ñâåäåíèÿ ïî ïëàíàì îáó÷åíèÿ.pdf",
|
||||||
|
DateFrom = dateFrom,
|
||||||
|
DateTo = dateTo
|
||||||
|
});
|
||||||
|
APIStorekeeper.PostRequest("api/discipline/sendpdftomail", new MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
MailAddress = APIStorekeeper.Client.Email,
|
||||||
|
Subject = "Îò÷åò",
|
||||||
|
Text = "Ñâåäåíèÿ ïî äèñöèïëèíàì"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Response.Redirect("Index");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult ReportDisciplines(DateOnly dateFrom, DateOnly dateTo)
|
public IActionResult ReportDisciplines(DateOnly dateFrom, DateOnly dateTo)
|
||||||
|
@ -16,6 +16,13 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4"><input type="submit" value="Вывести здесь" class="btn btn-primary" /></div>
|
<div class="col-4"><input type="submit" value="Вывести здесь" class="btn btn-primary" /></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<form method="post" action="/Home/ReportDisciplines">
|
||||||
|
<input type="hidden" name="type" value="pdf" />
|
||||||
|
<input type="submit" value="Отправить в формате Pdf на почту" class="btn btn-primary" />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@if (Model != null && Model.Any())
|
@if (Model != null && Model.Any())
|
||||||
|
@ -24,7 +24,7 @@ namespace UniversityContracts.BusinessLogicContracts
|
|||||||
void SavePlanOfStudyToWord(ReportBindingModel option);
|
void SavePlanOfStudyToWord(ReportBindingModel option);
|
||||||
void SaveTeachersToExcel(ReportBindingModel option);
|
void SaveTeachersToExcel(ReportBindingModel option);
|
||||||
void SavePlanOfStudyToExcel(ReportBindingModel option);
|
void SavePlanOfStudyToExcel(ReportBindingModel option);
|
||||||
void SendDisciplinesToEmail(ReportDateRangeBindingModel option, string email);
|
void SendDisciplinesToEmail(ReportDateRangeBindingModel option);
|
||||||
public void SendPlanOfStudyToEmail(ReportBindingModel option);
|
public void SendPlanOfStudyToEmail(ReportBindingModel option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using UniversityBusinessLogic.MailWorker;
|
||||||
using UniversityContracts.BindingModels;
|
using UniversityContracts.BindingModels;
|
||||||
using UniversityContracts.BusinessLogicContracts;
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
using UniversityContracts.BusinessLogicsContracts;
|
using UniversityContracts.BusinessLogicsContracts;
|
||||||
@ -14,11 +15,13 @@ namespace UniversityRestApi.Controllers
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IDisciplineLogic _logic;
|
private readonly IDisciplineLogic _logic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
public DisciplineController(IDisciplineLogic logic, ILogger<DisciplineController> logger, IReportLogic reportLogic)
|
private readonly AbstractMailWorker _mailWorker;
|
||||||
|
public DisciplineController(IDisciplineLogic logic, ILogger<DisciplineController> logger, IReportLogic reportLogic, AbstractMailWorker mailWorker)
|
||||||
{
|
{
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
|
_mailWorker = mailWorker;
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<DisciplineViewModel>? GetDisciplines(int userId)
|
public List<DisciplineViewModel>? GetDisciplines(int userId)
|
||||||
@ -99,6 +102,35 @@ namespace UniversityRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateReportToPDFFile(ReportDateRangeBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||||
|
_reportLogic.SendDisciplinesToEmail(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания отчета");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void SendPDFToMail(MailSendInfoBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_mailWorker.MailSendAsync(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка отправки письма");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user