From d9fe78134397eca0f8e599f378f090de49ca9c62 Mon Sep 17 00:00:00 2001 From: misya Date: Tue, 20 May 2025 17:08:03 +0800 Subject: [PATCH] fix arrangement --- Areas/MMS/Controllers/MarineController.cs | 47 +++++++++------------ Areas/MMS/Models/PDFGenerator/TarBallPDF.cs | 9 ++-- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/Areas/MMS/Controllers/MarineController.cs b/Areas/MMS/Controllers/MarineController.cs index 68c3262..985be85 100644 --- a/Areas/MMS/Controllers/MarineController.cs +++ b/Areas/MMS/Controllers/MarineController.cs @@ -278,7 +278,10 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers // ===== 1. NEW SQL QUERY APPROACH ===== var query = @" SELECT - marine.*, station.LocationName, state.StateName,user.FullName,level.LevelName + marine.*, + station.LocationName, + state.StateName, + user.FullName,level.LevelName FROM tbl_marine_tarball marine JOIN tbl_marine_station station ON marine.StationID = station.StationID JOIN tbl_state state ON station.StateID = state.StateID @@ -305,48 +308,38 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers var sampleTimePrefix = ((int)tarball.TimeSample.TotalHours).ToString("D2") + tarball.TimeSample.Minutes.ToString("D2"); var stationFolder = Path.Combine(PhotoBasePath, tarball.StationID); + + //Image collection var stationImages = new Dictionary(); if (Directory.Exists(stationFolder)) { - var allImages = Directory.GetFiles(stationFolder) - .Where(f => - { - var fileName = Path.GetFileNameWithoutExtension(f); - var parts = fileName.Split('_'); - return parts.Length >= 3 && - parts[0] == tarball.StationID && - parts[1] == sampleDateString && - parts[2].StartsWith(sampleTimePrefix); - }) - .ToList(); - - var imageTypes = new List + var imageTypes = new Dictionary { - "LEFTSIDECOASTALVIEW", - "RIGHTSIDECOASTALVIEW", - "DRAWINGVERTICALLINES", - "DRAWINGHORIZONTALLINES", - "OPTIONAL01", - "OPTIONAL02", - "OPTIONAL03", - "OPTIONAL04" + { "LEFTSIDECOASTALVIEW", null }, + { "RIGHTSIDECOASTALVIEW", null }, + { "DRAWINGVERTICALLINES", null }, + { "DRAWINGHORIZONTALLINES", null }, + { "OPTIONAL01", null }, // Will remain null if not found + { "OPTIONAL02", null }, + { "OPTIONAL03", null }, + { "OPTIONAL04", null } }; - foreach (var imagePath in allImages) + foreach (var imagePath in Directory.GetFiles(stationFolder)) { var fileName = Path.GetFileNameWithoutExtension(imagePath); - foreach(var type in imageTypes) + foreach (var type in imageTypes.Keys.ToList()) { - if(fileName.EndsWith(type,StringComparison.OrdinalIgnoreCase)) + if (fileName.EndsWith(type, StringComparison.OrdinalIgnoreCase)) { - stationImages[type] = imagePath; + imageTypes[type] = imagePath; break; } } } + stationImages = imageTypes; } - //Mandatory images var mandatoryImages = new List { diff --git a/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs b/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs index 6997236..da2f52e 100644 --- a/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs +++ b/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs @@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal; namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator { - public class TarBallPDF(string stationID, string stateName, string locationName, + public class TarBallPDF(string stateName, string stationID, string locationName, string longitude, string latitude, DateTime dateSample, TimeSpan timeSample, string classifyID, bool tarBallYes, bool tarBallNo, bool isSand, bool isNonSandy, bool isCoquina, string photoPath1, string photoPath2, string photoPath3, string photoPath4, @@ -17,8 +17,9 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator ) : IDocument { - private readonly string _stationId = stationID; + //have to be arranged accordingly(?) private readonly string _stateName = stateName; + private readonly string _stationId = stationID; private readonly string _locationName = locationName; private readonly string _longitude = longitude; private readonly string _latitude = latitude; @@ -343,10 +344,10 @@ 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(""); + table.Cell().Element(CellStyle).Text(_dateSample.ToString("yyyy/MM/dd")).FontSize(12); table.Cell().Element(CellStyle).Text("Designation").FontSize(12); - table.Cell().ColumnSpan(3).Element(CellStyle).Text(_levelName); + table.Cell().ColumnSpan(3).Element(CellStyle).Text(_levelName).FontSize(12); table.Cell().RowSpan(2).Element(CellStyle) .Text(text =>