From 9958a4b1d188a76b5af33cb689e493a93757524f Mon Sep 17 00:00:00 2001 From: misya Date: Thu, 5 Jun 2025 16:18:11 +0800 Subject: [PATCH] added 'time' column, fix image sorting generation based on naming format --- Areas/MMS/Controllers/MarineController.cs | 13 ++- Areas/MMS/Models/PDFGenerator/TarBallPDF.cs | 10 +-- Areas/MMS/Views/Marine/TarBallForm.cshtml | 90 +++++++++++++-------- 3 files changed, 69 insertions(+), 44 deletions(-) diff --git a/Areas/MMS/Controllers/MarineController.cs b/Areas/MMS/Controllers/MarineController.cs index 1a18fdc..a325004 100644 --- a/Areas/MMS/Controllers/MarineController.cs +++ b/Areas/MMS/Controllers/MarineController.cs @@ -55,16 +55,17 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers return View(); } - public IActionResult TarBallForm()//Queries the database and returns a view with tarball data + public IActionResult TarBallForm() { try { - var marineTarballs = _context.MarineTarballs //ERRORRRRRRR====================================== + var marineTarballs = _context.MarineTarballs .Select(t => new { - t.Id, - Date = t.DateSample.ToString("yyyy/MM/dd"), - Station = t.StationID + id = t.Id, + date = t.DateSample.ToString("yyyy/MM/dd"), + station = t.StationID, + time = t.TimeSample.ToString("hh\\:mm\\:ss") }) .ToList(); @@ -73,10 +74,8 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers } catch (Exception ex) { - // Show the real error in the browser (for debugging only) return Content($"Error: {ex.Message}
{ex.StackTrace}", "text/html"); } - } [HttpGet] // Explicitly mark as a GET endpoint diff --git a/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs b/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs index 379f31c..7fe9c82 100644 --- a/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs +++ b/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs @@ -308,11 +308,11 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator // Row 2: Captions table.Cell().Element(CellStyle) - .Text(string.IsNullOrEmpty(_photoPath5) ? "" : $"Figure 5: {_optionalName1}") + .Text($"Figure 5: {(_optionalName1 ?? "")}") .FontSize(12).AlignLeft(); table.Cell().Element(CellStyle) - .Text(string.IsNullOrEmpty(_photoPath6) ? "" : $"Figure 6: {_optionalName2}") + .Text($"Figure 6: {(_optionalName2 ?? "")}") .FontSize(12).AlignLeft(); // Row 3: Optional images 7 & 8 @@ -321,11 +321,11 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator // Row 4: Captions table.Cell().Element(CellStyle) - .Text(string.IsNullOrEmpty(_photoPath7) ? "" : $"Figure 7: {_optionalName3}") + .Text($"Figure 7: {(_optionalName3 ?? "")}") .FontSize(12).AlignLeft(); table.Cell().Element(CellStyle) - .Text(string.IsNullOrEmpty(_photoPath8) ? "" : $"Figure 8: {_optionalName4}") + .Text($"Figure 8: {(_optionalName4 ?? "")}") .FontSize(12).AlignLeft(); }); @@ -360,7 +360,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator table.Cell().Element(CellStyle).Text("Signature").FontSize(12); table.Cell().Element(CellStyle).Text(""); table.Cell().Element(CellStyle).Text("Date").FontSize(12); - table.Cell().Element(CellStyle).Text($"{_dateSample:yyyyMMdd}").FontSize(12); + table.Cell().Element(CellStyle).Text($"{_dateSample:dd/MM/yyyy}").FontSize(12); table.Cell().Element(CellStyle).Text("Designation").FontSize(12); table.Cell().ColumnSpan(3).Element(CellStyle).Text(_levelName).FontSize(12); diff --git a/Areas/MMS/Views/Marine/TarBallForm.cshtml b/Areas/MMS/Views/Marine/TarBallForm.cshtml index 2ee56d5..add8d50 100644 --- a/Areas/MMS/Views/Marine/TarBallForm.cshtml +++ b/Areas/MMS/Views/Marine/TarBallForm.cshtml @@ -69,6 +69,7 @@ No. Date Station + Time Status PDF @@ -86,16 +87,26 @@