Документы
This commit is contained in:
parent
acaa63c004
commit
74259a391f
@ -5,6 +5,7 @@ using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelDataBaseImplement.Implemets;
|
||||
|
||||
namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -13,21 +14,23 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
private readonly IMealPlanStorage _mealPlanStorage;
|
||||
private readonly IMemberStorage _memberStorage;
|
||||
private readonly IConferenceStorage _conferenceStorage;
|
||||
private readonly IConferenceBookingStorage _conferenceBookingStorage;
|
||||
private readonly AbstractSaveToExcelOrganiser _saveToExcel;
|
||||
private readonly AbstractSaveToWordOrganiser _saveToWord;
|
||||
private readonly AbstractSaveToPdfOrganiser _saveToPdf;
|
||||
|
||||
public ReportLogicOrganiser(IMealPlanStorage mealPlanStorage, IMemberStorage memberStorage, IConferenceStorage conferenceStorage, AbstractSaveToExcelOrganiser saveToExcel, AbstractSaveToWordOrganiser saveToWord, AbstractSaveToPdfOrganiser saveToPdf)
|
||||
public ReportLogicOrganiser(IMealPlanStorage mealPlanStorage, IMemberStorage memberStorage, IConferenceStorage conferenceStorage, IConferenceBookingStorage conferenceBookingStorage, AbstractSaveToExcelOrganiser saveToExcel, AbstractSaveToWordOrganiser saveToWord, AbstractSaveToPdfOrganiser saveToPdf)
|
||||
{
|
||||
_mealPlanStorage = mealPlanStorage;
|
||||
_memberStorage = memberStorage;
|
||||
_conferenceStorage = conferenceStorage;
|
||||
_conferenceBookingStorage = conferenceBookingStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
|
||||
public List<ReportMemberConferenceViewModel> GetMemberConference(List<int> Ids)
|
||||
public List<ReportMemberConferenceViewModel> GetMemberConferenceBooking(List<int> Ids)
|
||||
{
|
||||
if (Ids == null)
|
||||
{
|
||||
@ -35,6 +38,7 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
}
|
||||
|
||||
var conferences = _conferenceStorage.GetFullList();
|
||||
var conferenceBookings = _conferenceBookingStorage.GetFullList();
|
||||
|
||||
List<MemberViewModel> members = new List<MemberViewModel>();
|
||||
foreach (var memberId in Ids)
|
||||
@ -53,13 +57,17 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
MemberSurname = member.MemberSurname,
|
||||
MemberName = member.MemberName,
|
||||
MemberPatronymic = member.MemberPatronymic,
|
||||
Conferences = new List<Tuple<string, DateTime>>()
|
||||
ConferenceBookings = new List<Tuple<string, DateTime>>()
|
||||
};
|
||||
foreach (var conference in conferences)
|
||||
{
|
||||
if (conference.ConferenceMembers.ContainsKey(member.Id))
|
||||
{
|
||||
record.Conferences.Add(new Tuple<string, DateTime>(conference.ConferenceName, conference.StartDate));
|
||||
var bookingsForConference = conferenceBookings.Where(cb => cb.ConferenceId == conference.Id).ToList();
|
||||
foreach (var booking in bookingsForConference)
|
||||
{
|
||||
record.ConferenceBookings.Add(new Tuple<string, DateTime>(booking.NameHall, booking.BookingDate.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
@ -122,7 +130,7 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список конференций",
|
||||
MemberConferences = GetMemberConference(model.Ids)
|
||||
MemberConferences = GetMemberConferenceBooking(model.Ids)
|
||||
});
|
||||
}
|
||||
|
||||
@ -132,7 +140,7 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список конференций",
|
||||
MemberConferences = GetMemberConference(model.Ids)
|
||||
MemberConferences = GetMemberConferenceBooking(model.Ids)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace HotelBusinessLogic.OfficePackage
|
||||
|
||||
rowIndex++;
|
||||
|
||||
foreach (var conference in mc.Conferences)
|
||||
foreach (var conference in mc.ConferenceBookings)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
@ -51,7 +51,7 @@ namespace HotelBusinessLogic.OfficePackage
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = conference.Item2.ToString(),
|
||||
Text = conference.Item2.ToString("d"),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace HotelBusinessLogic.OfficePackage
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var conference in mc.Conferences)
|
||||
foreach (var conference in mc.ConferenceBookings)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ namespace HotelContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportOrganiserLogic
|
||||
{
|
||||
List<ReportMemberConferenceViewModel> GetMemberConference(List<int> Ids);
|
||||
List<ReportMemberConferenceViewModel> GetMemberConferenceBooking(List<int> Ids);
|
||||
List<ReportMembersViewModel> GetMembers(ReportOrganiserBindingModel model);
|
||||
void SaveMemberConferenceToWordFile(ReportOrganiserBindingModel model);
|
||||
void SaveMemberConferenceToExcelFile(ReportOrganiserBindingModel model);
|
||||
|
@ -5,6 +5,6 @@
|
||||
public string MemberSurname { get; set; } = string.Empty;
|
||||
public string MemberName { get; set; } = string.Empty;
|
||||
public string MemberPatronymic { get; set; } = string.Empty;
|
||||
public List<Tuple<string, DateTime>> Conferences { get; set; } = new();
|
||||
public List<Tuple<string, DateTime>> ConferenceBookings { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,12 @@ namespace HotelOrganiserApp.Controllers
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IReportOrganiserLogic _report;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
public HomeController(ILogger<HomeController> logger, IReportOrganiserLogic report)
|
||||
{
|
||||
_logger = logger;
|
||||
_report = report;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
@ -553,7 +555,179 @@ namespace HotelOrganiserApp.Controllers
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
[HttpGet]
|
||||
public IActionResult ListMemberConferenceBookingToFile()
|
||||
{
|
||||
if (APIClient.Organiser == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<MemberViewModel>>($"api/member/getmembers?organiserId={APIClient.Organiser.Id}"));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void ListMemberConferenceBookingToFile(int[] Ids, string type)
|
||||
{
|
||||
if (APIClient.Organiser == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (Ids.Length <= 0)
|
||||
{
|
||||
throw new Exception("Количество должно быть больше 0");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(type))
|
||||
{
|
||||
throw new Exception("Неверный тип отчета");
|
||||
}
|
||||
|
||||
List<int> res = new List<int>();
|
||||
|
||||
foreach (var item in Ids)
|
||||
{
|
||||
res.Add(item);
|
||||
}
|
||||
|
||||
if (type == "docx")
|
||||
{
|
||||
APIClient.PostRequest("api/report/CreateOrganiserReportToWordFile", new ReportOrganiserBindingModel
|
||||
{
|
||||
Ids = res,
|
||||
FileName = "C:\\Reports\\wordfile.docx"
|
||||
});
|
||||
Response.Redirect("GetWordFile");
|
||||
}
|
||||
else
|
||||
{
|
||||
APIClient.PostRequest("api/report/CreateOrganiserReportToExcelFile", new ReportOrganiserBindingModel
|
||||
{
|
||||
Ids = res,
|
||||
FileName = "C:\\Reports\\excelfile.xlsx"
|
||||
});
|
||||
Response.Redirect("GetExcelFile");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetWordFile()
|
||||
{
|
||||
return new PhysicalFileResult("C:\\Reports\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetExcelFile()
|
||||
{
|
||||
return new PhysicalFileResult("C:\\Reports\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetPdfFile()
|
||||
{
|
||||
return new PhysicalFileResult("C:\\Reports\\pdffile.pdf", "application/pdf");
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult ListMembersToPdfFile()
|
||||
{
|
||||
if (APIClient.Organiser == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View("ListMembersToPdfFile");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void ListMembersToPdfFile(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIClient.Organiser == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
APIClient.PostRequest("api/report/CreateReportToPdfFile", new ReportOrganiserBindingModel
|
||||
{
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo,
|
||||
OrganiserId = APIClient.Organiser.Id
|
||||
});
|
||||
Response.Redirect("ListMembersToPdfFile");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string GetMembersReport(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIClient.Organiser == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
List<ReportMembersViewModel> result;
|
||||
try
|
||||
{
|
||||
result = _report.GetMembers(new ReportOrganiserBindingModel
|
||||
{
|
||||
OrganiserId = APIClient.Organiser.Id,
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
|
||||
double sum = 0;
|
||||
string table = "";
|
||||
table += $"<h2 class=\"u-text u-text-custom-color-1 u-text-default u-text-1\">Предварительный отчет</h2>";
|
||||
table += $"<table class=\"u-table-entity\">";
|
||||
table += "<colgroup>";
|
||||
table += "<col width=\"20%\" />";
|
||||
table += "<col width=\"20%\" />";
|
||||
table += "<col width=\"20%\" />";
|
||||
table += "<col width=\"20%\" />";
|
||||
table += "<col width=\"20%\" />";
|
||||
table += "</colgroup>";
|
||||
table += "<thead class=\"u-custom-color-1 u-table-header u-table-header-1\">";
|
||||
table += "<tr style=\"height: 31px\">";
|
||||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\">Участник</th>";
|
||||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\">Конференция</th>";
|
||||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\">Дата начала конференции</th>";
|
||||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\">План питания</th>";
|
||||
table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\">Стоимость плана питания</th>";
|
||||
table += "</tr>";
|
||||
table += "</thead>";
|
||||
foreach (var report in result)
|
||||
{
|
||||
bool IsDate = true;
|
||||
if (report.StartDate.ToShortDateString() == "01.01.0001")
|
||||
{
|
||||
IsDate = false;
|
||||
}
|
||||
bool IsCost = true;
|
||||
if (report.MealPlanPrice.ToString() == "0")
|
||||
{
|
||||
IsCost = false;
|
||||
}
|
||||
table += "<tbody class=\"u-table-body\">";
|
||||
table += "<tr style=\"height: 75px\">";
|
||||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\">" +
|
||||
$"{report.MemberSurname} {report.MemberName} {report.MemberPatronymic}</td>";
|
||||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\">{report.ConferenceName}</td>";
|
||||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\">{(IsDate is true ? report.StartDate.ToShortDateString() : string.Empty)}</td>";
|
||||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\">{report.MealPlanName}</td>";
|
||||
table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\">{(IsCost is true ? report.MealPlanPrice.ToString() : string.Empty)}</td>";
|
||||
table += "</tr>";
|
||||
table += "</tbody>";
|
||||
sum += report.MealPlanPrice;
|
||||
}
|
||||
table += "</table>";
|
||||
table += $"<h2 class=\"u-text u-text-custom-color-1 u-text-default u-text-1\">Итого: {sum}</h2>";
|
||||
return table;
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
|
@ -11,6 +11,7 @@ builder.Services.AddTransient<IReportOrganiserLogic, ReportLogicOrganiser>();
|
||||
builder.Services.AddTransient<IMemberStorage, MemberStorage>();
|
||||
builder.Services.AddTransient<IMealPlanStorage, MealPlanStorage>();
|
||||
builder.Services.AddTransient<IConferenceStorage, ConferenceStorage>();
|
||||
builder.Services.AddTransient<IConferenceBookingStorage, ConferenceBookingStorage>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcelOrganiser, SaveToExcelOrganiser>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfOrganiser, SaveToPdfOrganiser>();
|
||||
builder.Services.AddTransient<AbstractSaveToWordOrganiser, SaveToWordOrganiser>();
|
||||
|
@ -0,0 +1,75 @@
|
||||
@using HotelContracts.ViewModels
|
||||
|
||||
@model List<MemberViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "ListMemberConferenceBookingToFile";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<div class="title">
|
||||
<h2>Создание отчета по участникам</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<form method="post">
|
||||
<div class="file-format">
|
||||
<label class="form-label">Выберите формат файла:</label>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="type" value="docx" id="docx">
|
||||
<label class="form-check-label" for="docx">Word-файл</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="type" value="xlsx" id="xlsx" checked>
|
||||
<label class="form-check-label" for="xlsx">Excel-файл</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table">
|
||||
<table class="table table-hover">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th scope="col"></th>
|
||||
<th scope="col">Участник</th>
|
||||
<th scope="col">Номер телефона</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="Ids[]" value="@item.Id" id="@item.Id">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.MemberSurname) @Html.DisplayFor(modelItem => item.MemberName) @Html.DisplayFor(modelItem => item.MemberPatronymic)
|
||||
</td>
|
||||
<td>@Html.DisplayFor(modelItem => item.MemberPhoneNumber)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<br>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="submit" class="btn btn-block btn-outline-dark w-100">Создать</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.title {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.file-format {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.table {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
</style>
|
@ -35,7 +35,7 @@
|
||||
<a class="nav-link " asp-area="" asp-controller="Home" asp-action="ConferenceConferenceBookings">Связывание</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link " asp-area="" asp-controller="Home" asp-action="ListMemberConferenceToFile">Отчёт по бронированиям</a>
|
||||
<a class="nav-link " asp-area="" asp-controller="Home" asp-action="ListMemberConferenceBookingToFile">Отчёт по бронированиям</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link " asp-area="" asp-controller="Home" asp-action="ListMembersToPdfFile">Отчёт по участникам</a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user