From 6ad2f11e9e74a96f9e01bdd47ceaa08f01e1cd21 Mon Sep 17 00:00:00 2001 From: misya Date: Fri, 20 Jun 2025 16:23:27 +0800 Subject: [PATCH] clean --- Areas/MMS/Controllers/MarineController.cs | 38 +++++++++++++---------- Areas/MMS/Models/NetworkAccessService.cs | 8 ++--- Areas/MMS/Views/Marine/TarBallForm.cshtml | 3 +- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/Areas/MMS/Controllers/MarineController.cs b/Areas/MMS/Controllers/MarineController.cs index a325004..3cacec2 100644 --- a/Areas/MMS/Controllers/MarineController.cs +++ b/Areas/MMS/Controllers/MarineController.cs @@ -1,20 +1,20 @@ using Microsoft.AspNetCore.Mvc; using PSTW_CentralSystem.DBContext; -using PSTW_CentralSystem.Areas.MMS.Models; -using System.IO; -using System.Linq; +//using PSTW_CentralSystem.Areas.MMS.Models; +//using System.IO; +//using System.Linq; using PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator; using QuestPDF.Fluent; -using System.Threading.Tasks; -using System.Threading; -using System.Collections.Generic; -using Microsoft.Data.SqlClient; +//using System.Threading.Tasks; +//using System.Threading; +//using System.Collections.Generic; +//using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using MySqlConnector; namespace PSTW_CentralSystem.Areas.MMS.Controllers { - public class TarballPdfDto + public class TarballPdfDto //data transfer object, only holds data, used to move data between programs { // From tbl_marine_tarball public int Id { get; set; } @@ -55,11 +55,11 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers return View(); } - public IActionResult TarBallForm() + public async Task TarBallForm()//make it async in case of traffic/frequent usage { try { - var marineTarballs = _context.MarineTarballs + var marineTarballs = await _context.MarineTarballs .Select(t => new { id = t.Id, @@ -67,9 +67,9 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers station = t.StationID, time = t.TimeSample.ToString("hh\\:mm\\:ss") }) - .ToList(); + .ToListAsync(); - Console.WriteLine($"Marine Tarballs Count: {marineTarballs.Count}"); + Console.WriteLine($"Marine Tarballs Count: {marineTarballs.Count}"); //??? return View(marineTarballs); } catch (Exception ex) @@ -79,6 +79,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers } [HttpGet] // Explicitly mark as a GET endpoint + //removal TBD===============!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! public IActionResult TestCredentials() { try @@ -102,6 +103,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers return StatusCode(500, $"Credentials test failed: {ex.Message}"); } } + //====================!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! public IActionResult GetImage(string fileName) { @@ -156,6 +158,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers Console.WriteLine($"Attempting to access image at: {imagePath}"); // Verify file exists + //removal TBD if (!System.IO.File.Exists(imagePath)) { Console.WriteLine($"Image not found at path: {imagePath}"); @@ -163,6 +166,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers } // Verify file is an image + //consider removal if/since verification already happened during image uploading (other program) if (!IsImageValid(imagePath)) { Console.WriteLine($"Invalid image file at path: {imagePath}"); @@ -174,6 +178,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers Console.WriteLine($"Successfully read image: {sanitizedFileName} ({imageBytes.Length} bytes)"); // Determine content type based on extension + //removal TBD??? IF image type verification already done during image uploading =========!!!!!!!!!!! string contentType = "image/jpeg"; // default string extension = Path.GetExtension(sanitizedFileName).ToLower(); //string extension = Path.GetExtension(sanitizedFileName)?.ToLower(); @@ -227,11 +232,10 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers return await GeneratePdfResponse(id, true); } - public async Task DownloadPDF(int id) - { - return await GeneratePdfResponse(id, true); - } - + //public async Task DownloadPDF(int id) + //{ + // return await GeneratePdfResponse(id, true); + //} public IActionResult ViewPDF(int id) { diff --git a/Areas/MMS/Models/NetworkAccessService.cs b/Areas/MMS/Models/NetworkAccessService.cs index a36244f..5d3a6c7 100644 --- a/Areas/MMS/Models/NetworkAccessService.cs +++ b/Areas/MMS/Models/NetworkAccessService.cs @@ -116,10 +116,10 @@ public class NetworkShareAccess : IDisposable public ResourceType ResourceType; public ResourceDisplayType DisplayType; public int Usage; - public string? LocalName; - public string? RemoteName; - public string? Comment; - public string? Provider; + public string? LocalName; //? or required TBD + public string? RemoteName; // + public string? Comment; // + public string? Provider; // } private enum ResourceScope { Connected = 1, GlobalNetwork, Remembered, Recent, Context } diff --git a/Areas/MMS/Views/Marine/TarBallForm.cshtml b/Areas/MMS/Views/Marine/TarBallForm.cshtml index add8d50..afae953 100644 --- a/Areas/MMS/Views/Marine/TarBallForm.cshtml +++ b/Areas/MMS/Views/Marine/TarBallForm.cshtml @@ -177,6 +177,7 @@ View PDF Download PDF ` + //uses ViewPDF for view, GenerateReport for downloading } ], "rowCallback": function(row, data, index) { @@ -214,7 +215,7 @@ this.updateDataTable(newData); //trigger search function after updating data(?) if(this.dataTable) { - this.dataTable.search('').draw();//clear existing search + this.dataTable.search('').draw(); } } }