fix arrangement

This commit is contained in:
misya 2025-05-20 17:08:03 +08:00
parent d5e5fe9a3f
commit d9fe781343
2 changed files with 25 additions and 31 deletions

View File

@ -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<string, string>();
if (Directory.Exists(stationFolder))
{
var allImages = Directory.GetFiles(stationFolder)
.Where(f =>
var imageTypes = new Dictionary<string, string>
{
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<string>
{
"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))
{
stationImages[type] = imagePath;
imageTypes[type] = imagePath;
break;
}
}
}
stationImages = imageTypes;
}
//Mandatory images
var mandatoryImages = new List<string>
{

View File

@ -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 =>