Merge branch 'stage9_10' of https://git.is.ulstu.ru/ns.potapov/PIbd-21_CourseWork_Polyclinic_BeSick into stage9_10
This commit is contained in:
commit
a7b8d36892
@ -100,6 +100,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
|
|||||||
DateFrom = reportModel.DateStart,
|
DateFrom = reportModel.DateStart,
|
||||||
DateTo = reportModel.DateEnd,
|
DateTo = reportModel.DateEnd,
|
||||||
FileName = reportInfo.FileName,
|
FileName = reportInfo.FileName,
|
||||||
|
PeriodString = reportInfo.GetPeriodString(),
|
||||||
Report = reportModel
|
Report = reportModel
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,14 @@ namespace PolyclinicBusinessLogic.OfficePackage.AbstractImplementerReports
|
|||||||
});
|
});
|
||||||
CreateParagraph(new PdfParagraph
|
CreateParagraph(new PdfParagraph
|
||||||
{
|
{
|
||||||
Text = $"с {(info.DateFrom == null ? "-" : info.DateFrom?.ToShortDateString())} по {(info.DateTo == null ? "-" : info.DateTo?.ToShortDateString())}",
|
Text = info.PeriodString,
|
||||||
Style = "Normal",
|
Style = "Normal",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
});
|
});
|
||||||
CreateTable(new List<string> { "1cm", "4cm", "3cm", "3cm", "4cm", "4cm" });
|
CreateTable(new List<string> { "3cm", "3cm", "3cm", "4cm", "5cm" });
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = new List<string> { "#", "Название", "Начало", "Конец", "Симптомы", "Курсы" },
|
Texts = new List<string> { "Название", "Начало", "Конец", "Симптомы", "Курсы" },
|
||||||
Style = "NormalTitle",
|
Style = "NormalTitle",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
});
|
});
|
||||||
@ -35,7 +35,6 @@ namespace PolyclinicBusinessLogic.OfficePackage.AbstractImplementerReports
|
|||||||
{
|
{
|
||||||
Texts = new List<string>
|
Texts = new List<string>
|
||||||
{
|
{
|
||||||
diagnose.Id.ToString(),
|
|
||||||
diagnose.Name,
|
diagnose.Name,
|
||||||
diagnose.DateStartDiagnose.ToShortDateString(),
|
diagnose.DateStartDiagnose.ToShortDateString(),
|
||||||
diagnose.DateStopDiagnose?.ToShortDateString() ?? string.Empty,
|
diagnose.DateStopDiagnose?.ToShortDateString() ?? string.Empty,
|
||||||
@ -57,7 +56,6 @@ namespace PolyclinicBusinessLogic.OfficePackage.AbstractImplementerReports
|
|||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
|
||||||
symptom?.Name ?? string.Empty,
|
symptom?.Name ?? string.Empty,
|
||||||
(course == null ? string.Empty : $"#{course.Id} {course.Comment}")
|
(course == null ? string.Empty : $"#{course.Id} {course.Comment}")
|
||||||
},
|
},
|
||||||
|
@ -6,6 +6,7 @@ namespace PolyclinicBusinessLogic.OfficePackage.HelperModels.PDF
|
|||||||
{
|
{
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string PeriodString { get; set; } = string.Empty;
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
public ReportDiagnosesByPeriodViewModel Report { get; set; } = new();
|
public ReportDiagnosesByPeriodViewModel Report { get; set; } = new();
|
||||||
|
@ -1,9 +1,33 @@
|
|||||||
namespace PolyclinicContracts.BindingModels
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace PolyclinicContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class ReportBindingModel
|
public class ReportBindingModel
|
||||||
{
|
{
|
||||||
public string? FileName { get; set; }
|
public string? FileName { get; set; }
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
|
public string GetPeriodString()
|
||||||
|
{
|
||||||
|
string txt = "";
|
||||||
|
if (DateFrom == null && DateTo == null)
|
||||||
|
{
|
||||||
|
txt = "за все время";
|
||||||
|
}
|
||||||
|
else if (DateFrom == null)
|
||||||
|
{
|
||||||
|
txt = $"по {DateTo?.ToShortDateString()}";
|
||||||
|
}
|
||||||
|
else if (DateTo == null)
|
||||||
|
{
|
||||||
|
txt = $"с {DateFrom?.ToShortDateString()}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
txt = $"с {DateFrom?.ToShortDateString()} по {DateTo?.ToShortDateString()}";
|
||||||
|
}
|
||||||
|
return txt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using PolyclinicBusinessLogic.BusinessLogics;
|
||||||
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
|
using PolyclinicBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using PolyclinicContracts.BindingModels;
|
using PolyclinicContracts.BindingModels;
|
||||||
using PolyclinicContracts.BusinessLogicsContracts;
|
using PolyclinicContracts.BusinessLogicsContracts;
|
||||||
@ -12,11 +13,13 @@ namespace PolyclinicWebAppImplementer.Controllers
|
|||||||
{
|
{
|
||||||
private readonly IImplementerReportLogic _reportLogic;
|
private readonly IImplementerReportLogic _reportLogic;
|
||||||
private readonly IDiagnoseLogic _diagnoseLogic;
|
private readonly IDiagnoseLogic _diagnoseLogic;
|
||||||
|
private readonly SendMailLogic _sendMailLogic;
|
||||||
|
|
||||||
public ReportsController(IImplementerReportLogic reportLogic, IDiagnoseLogic diagnoseLogic)
|
public ReportsController(IImplementerReportLogic reportLogic, IDiagnoseLogic diagnoseLogic, SendMailLogic sendMailLogic)
|
||||||
{
|
{
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
_diagnoseLogic = diagnoseLogic;
|
_diagnoseLogic = diagnoseLogic;
|
||||||
|
_sendMailLogic = sendMailLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -54,7 +57,26 @@ namespace PolyclinicWebAppImplementer.Controllers
|
|||||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(), fileName);
|
var filePath = Path.Combine(Directory.GetCurrentDirectory(), fileName);
|
||||||
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
|
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
|
||||||
|
|
||||||
return File(fileBytes, "application/pdf", fileName);
|
if (System.IO.File.Exists(filePath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string txt = reportInfo.GetPeriodString();
|
||||||
|
var userEmail = currentUser.Email;
|
||||||
|
_sendMailLogic.SendEmail(userEmail, $"Здравствуйте, {currentUser.FIO}! В приложении отчет по болезням {txt} от {DateTime.Now.ToString()}", filePath);
|
||||||
|
|
||||||
|
model.Message = $"Отчет в формате .pdf был отправлен на почту {currentUser.Email}";
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
model.Error = $"Произошла ошибка при отправке отчета";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model.Error = "Произошла ошибка при генерации отчета";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
@ -102,7 +124,7 @@ namespace PolyclinicWebAppImplementer.Controllers
|
|||||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(), reportInfo.FileName);
|
var filePath = Path.Combine(Directory.GetCurrentDirectory(), reportInfo.FileName);
|
||||||
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
|
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
|
||||||
string mimeType = model.ReportType == ReportType.Word ? "application/vnd.openxmlformats-officedocument.wordprocessingml.document" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
string mimeType = model.ReportType == ReportType.Word ? "application/vnd.openxmlformats-officedocument.wordprocessingml.document" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||||
|
|
||||||
return File(fileBytes, mimeType, reportInfo.FileName);
|
return File(fileBytes, mimeType, reportInfo.FileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,7 @@ namespace PolyclinicWebAppImplementer.Models
|
|||||||
public DateTime? DateEnd { get; set; }
|
public DateTime? DateEnd { get; set; }
|
||||||
public ReportType ReportType { get; set; }
|
public ReportType ReportType { get; set; }
|
||||||
public ReportDiagnosesByPeriodViewModel? Report { get; set; }
|
public ReportDiagnosesByPeriodViewModel? Report { get; set; }
|
||||||
|
public string? Error { get; set; }
|
||||||
|
public string? Message { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@ builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
|
|||||||
builder.Services.AddTransient<IMedicamentStorage, MedicamentStorage>();
|
builder.Services.AddTransient<IMedicamentStorage, MedicamentStorage>();
|
||||||
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
|
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<SendMailLogic>();
|
||||||
|
|
||||||
builder.Services.AddTransient<AbstractReportMedicamentsByDiagnosesSaveToExcel, ReportMedicamentsByDiagnosesSaveToExcel>();
|
builder.Services.AddTransient<AbstractReportMedicamentsByDiagnosesSaveToExcel, ReportMedicamentsByDiagnosesSaveToExcel>();
|
||||||
builder.Services.AddTransient<AbstractReportMedicamentsByDiagnosesSaveToWord, ReportMedicamentsByDiagnosesSaveToWord>();
|
builder.Services.AddTransient<AbstractReportMedicamentsByDiagnosesSaveToWord, ReportMedicamentsByDiagnosesSaveToWord>();
|
||||||
builder.Services.AddTransient<AbstractReportDiagnosesByPeriodSaveToPdf, ReportDiagnosesByPeriodSaveToPdf>();
|
builder.Services.AddTransient<AbstractReportDiagnosesByPeriodSaveToPdf, ReportDiagnosesByPeriodSaveToPdf>();
|
||||||
|
@ -4,6 +4,18 @@
|
|||||||
ViewBag.SelectedSiteMenuItem = SiteMenuItems.DiagnosesReport;
|
ViewBag.SelectedSiteMenuItem = SiteMenuItems.DiagnosesReport;
|
||||||
}
|
}
|
||||||
<div class="d-flex flex-column">
|
<div class="d-flex flex-column">
|
||||||
|
@if (Model.Error != null)
|
||||||
|
{
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
@Model.Error
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (Model.Message != null)
|
||||||
|
{
|
||||||
|
<div class="alert alert-success" role="alert">
|
||||||
|
@Model.Message
|
||||||
|
</div>
|
||||||
|
}
|
||||||
<form id="diagnosesReportForm" method="post" class="d-flex mb-4">
|
<form id="diagnosesReportForm" method="post" class="d-flex mb-4">
|
||||||
<div class="me-5">
|
<div class="me-5">
|
||||||
<label asp-for="DateStart"></label>
|
<label asp-for="DateStart"></label>
|
||||||
|
@ -5,5 +5,12 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"Smtp": {
|
||||||
|
"Host": "smtp.beget.com",
|
||||||
|
"Port": "2525",
|
||||||
|
"Username": "polyclinic@ekallin.ru",
|
||||||
|
"Password": "tlmu50*zAwN1",
|
||||||
|
"EnableSsl": "false"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user