Готовые репорты пдф у кладовщика

This commit is contained in:
DyCTaTOR 2024-05-30 01:19:26 +04:00
parent 84d8c3dc4a
commit 520441bd07
6 changed files with 19 additions and 8 deletions

View File

@ -10,7 +10,7 @@ namespace UniversityBusinessLogic.OfficePackage
CreatePdf(info); CreatePdf(info);
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "4 cm" }); CreateTable(new List<string> { "4cm", "5cm", "6cm", "5cm", "5 cm" });
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {

View File

@ -225,13 +225,15 @@ namespace UniversityClientApp.Controllers
Redirect("~/Home/Enter"); Redirect("~/Home/Enter");
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì"); throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
} }
if (dateFrom == DateOnly.MinValue || dateTo == DateOnly.MaxValue)
{
throw new Exception();
}
if (type == "pdf") if (type == "pdf")
{ {
APIStorekeeper.PostRequest("api/discipline/createreporttopdffile", new ReportDateRangeBindingModel APIStorekeeper.PostRequest($"api/discipline/createreporttopdffile?dateFrom={dateFrom:yyyy-MM-dd}&dateTo={dateTo:yyyy-MM-dd}", new ReportDateRangeBindingModel
{ {
FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\Ñâåäåíèÿ ïî ïëàíàì îáó÷åíèÿ.pdf", FileName = "C:\\ÂðåìåííûåÎò÷¸òû\\Ñâåäåíèÿ ïî ïëàíàì îáó÷åíèÿ.pdf"
DateFrom = dateFrom,
DateTo = dateTo
}); });
APIStorekeeper.PostRequest("api/discipline/sendpdftomail", new MailSendInfoBindingModel APIStorekeeper.PostRequest("api/discipline/sendpdftomail", new MailSendInfoBindingModel
{ {

View File

@ -21,6 +21,14 @@
<form method="post" action="/Home/ReportDisciplines"> <form method="post" action="/Home/ReportDisciplines">
<div class="form-group">
<label class="mb-3" for="dateFrom">Начало периода:</label>
<input type="date" placeholder="Выберите дату начала периода" id="dateFrom" name="dateFrom" />
</div>
<div class="form-group">
<label class="mb-3" for="dateTo">Окончание периода:</label>
<input type="date" placeholder="Выберите дату окончания периода" id="dateTo" name="dateTo" />
</div>
<input type="hidden" name="type" value="pdf" /> <input type="hidden" name="type" value="pdf" />
<input type="submit" value="Отправить в формате Pdf на почту" class="btn btn-primary" /> <input type="submit" value="Отправить в формате Pdf на почту" class="btn btn-primary" />
</form> </form>

View File

@ -10,7 +10,6 @@ namespace UniversityContracts.BindingModels
{ {
public string? FileName { get; set; } public string? FileName { get; set; }
public Stream? Stream { get; set; } public Stream? Stream { get; set; }
public DateOnly DateFrom { get; set; } public DateOnly DateFrom { get; set; }
public DateOnly DateTo { get; set; } public DateOnly DateTo { get; set; }
} }

View File

@ -11,7 +11,7 @@ namespace UniversityDatabaseImplement
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR //Возможно понадобится писать вместо (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); base.OnConfiguring(optionsBuilder);
} }

View File

@ -105,11 +105,13 @@ namespace UniversityRestApi.Controllers
[HttpPost] [HttpPost]
public void CreateReportToPDFFile(ReportDateRangeBindingModel model) public void CreateReportToPDFFile(ReportDateRangeBindingModel model, DateOnly dateFrom, DateOnly dateTo)
{ {
try try
{ {
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
model.DateTo = dateTo;
model.DateFrom = dateFrom;
_reportLogic.SendDisciplinesToEmail(model); _reportLogic.SendDisciplinesToEmail(model);
} }
catch (Exception ex) catch (Exception ex)