public async Task <IActionResult> GetJournalPdf([FromBody] JournalRequest req) { await CheckPermission(); var html = @"<html><head> <style type='text/css'> .task { border-collapse: collapse; border: 1px solid black; } .task td { padding: 5px; border: 1px solid black; } .task th { padding: 5px; background-color: #909090; border: 1px solid black; } //.break { // page-break-after: always; //} hr.ex2 { border:none; border-top:3px dotted #aaa; color:#fff; background-color:#fff; height:1px; width:100%; } </style></head><body>"; var tr = new TaskRepository(_logger); var serviceTask = new TaskService(_logger); if (req.Tasks.Length > 0) { var tasksDictionary = await tr.GetTrainTasksForPdf(req.Tasks); foreach (var tasks in tasksDictionary) { html += "<table><tr><td>Поезд:</td><td>" + tasks.Key + "</td></tr></table>"; html += "<br /><h2>Задачи</h2>"; if (tasks.Value.Count > 0) { foreach (var task in tasks.Value) { html += "<table class='task'><tr><th>Вагон</th><th>Местоположение</th><th>Оборудование</th><th>Типовая неисправность</th><th>Описание</th><th>Метка</th><th>№ задачи</th><th>Время</th></tr>"; var history = await serviceTask.AddHistoryData(task.Id); html += "<tr><td>" + task.Carriage + "</td><td>" + task.Location + "</td><td>" + task.Equipment + "</td><td>" + task.Fault + "</td><td>" + task.Description + "</td><td>" + task.Label + "</td><td>" + task.Id + "</td><td>" + task.Created + "</td></tr>"; html += "<tr><td colspan='8'>"; if (history.Count > 0) { html += "<b>Комментарии:</b><br />"; html += ""; foreach (var item in history) { html += $"{item.Date} {item.User} ({TaskRepository.BrigadeTypeToString((BrigadeType?) item.UserBrigadeType)}): "; switch (item.Type) { case "Comment": html += $"{item.Text}<br />"; break; case "Status": html += $"<b>Смена статуса:</b> {tr.StatusToString((TaskStatus?) item.OldStatus)} > {tr.StatusToString((TaskStatus?) item.NewStatus)}<br />"; break; case "Executor": html += $"<b>Смена исполнителя:</b> {TaskRepository.BrigadeTypeToString((BrigadeType?) item.OldExecutorBrigadeType)} > {TaskRepository.BrigadeTypeToString((BrigadeType?) item.NewExecutorBrigadeType)}<br />"; break; } html += ""; } html += "<br />"; html += "</td></tr>"; html += "</table>"; html += "<br />"; html += "<hr class=\"ex2\"></hr>"; html += "<br />"; } } } html += "</table>"; } } var i = 0; var count = req.Inspections.Count(); foreach (var id in req.Inspections) { var insp = await GetInspectionHtmlForPdf(id); html += insp; if (++i != count) //not for last item //html += "<div class='break'></div>"; { html += "<hr class=\"ex2\"></hr>"; } } var output = _pdfConverter.Convert(new HtmlToPdfDocument { GlobalSettings = { ColorMode = ColorMode.Color, Orientation = Orientation.Portrait, PaperSize = PaperKind.A4, }, Objects = { new ObjectSettings { HtmlContent = html, WebSettings ={ DefaultEncoding = "utf-8" } } } }); // return(File(output, "application/pdf", "journal_" + new Random().Next(0, 10000) + ".pdf")); }