clean
This commit is contained in:
parent
c857468d91
commit
6ad2f11e9e
@ -1,20 +1,20 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using PSTW_CentralSystem.DBContext;
|
using PSTW_CentralSystem.DBContext;
|
||||||
using PSTW_CentralSystem.Areas.MMS.Models;
|
//using PSTW_CentralSystem.Areas.MMS.Models;
|
||||||
using System.IO;
|
//using System.IO;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator;
|
using PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator;
|
||||||
using QuestPDF.Fluent;
|
using QuestPDF.Fluent;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
using System.Threading;
|
//using System.Threading;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using Microsoft.Data.SqlClient;
|
//using Microsoft.Data.SqlClient;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MySqlConnector;
|
using MySqlConnector;
|
||||||
|
|
||||||
namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
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
|
// From tbl_marine_tarball
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
@ -55,11 +55,11 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult TarBallForm()
|
public async Task<IActionResult> TarBallForm()//make it async in case of traffic/frequent usage
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var marineTarballs = _context.MarineTarballs
|
var marineTarballs = await _context.MarineTarballs
|
||||||
.Select(t => new
|
.Select(t => new
|
||||||
{
|
{
|
||||||
id = t.Id,
|
id = t.Id,
|
||||||
@ -67,9 +67,9 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
station = t.StationID,
|
station = t.StationID,
|
||||||
time = t.TimeSample.ToString("hh\\:mm\\:ss")
|
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);
|
return View(marineTarballs);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -79,6 +79,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet] // Explicitly mark as a GET endpoint
|
[HttpGet] // Explicitly mark as a GET endpoint
|
||||||
|
//removal TBD===============!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
public IActionResult TestCredentials()
|
public IActionResult TestCredentials()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -102,6 +103,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
return StatusCode(500, $"Credentials test failed: {ex.Message}");
|
return StatusCode(500, $"Credentials test failed: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//====================!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
public IActionResult GetImage(string fileName)
|
public IActionResult GetImage(string fileName)
|
||||||
{
|
{
|
||||||
@ -156,6 +158,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
Console.WriteLine($"Attempting to access image at: {imagePath}");
|
Console.WriteLine($"Attempting to access image at: {imagePath}");
|
||||||
|
|
||||||
// Verify file exists
|
// Verify file exists
|
||||||
|
//removal TBD
|
||||||
if (!System.IO.File.Exists(imagePath))
|
if (!System.IO.File.Exists(imagePath))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Image not found at path: {imagePath}");
|
Console.WriteLine($"Image not found at path: {imagePath}");
|
||||||
@ -163,6 +166,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify file is an image
|
// Verify file is an image
|
||||||
|
//consider removal if/since verification already happened during image uploading (other program)
|
||||||
if (!IsImageValid(imagePath))
|
if (!IsImageValid(imagePath))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Invalid image file at path: {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)");
|
Console.WriteLine($"Successfully read image: {sanitizedFileName} ({imageBytes.Length} bytes)");
|
||||||
|
|
||||||
// Determine content type based on extension
|
// Determine content type based on extension
|
||||||
|
//removal TBD??? IF image type verification already done during image uploading =========!!!!!!!!!!!
|
||||||
string contentType = "image/jpeg"; // default
|
string contentType = "image/jpeg"; // default
|
||||||
string extension = Path.GetExtension(sanitizedFileName).ToLower();
|
string extension = Path.GetExtension(sanitizedFileName).ToLower();
|
||||||
//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);
|
return await GeneratePdfResponse(id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> DownloadPDF(int id)
|
//public async Task<IActionResult> DownloadPDF(int id)
|
||||||
{
|
//{
|
||||||
return await GeneratePdfResponse(id, true);
|
// return await GeneratePdfResponse(id, true);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
public IActionResult ViewPDF(int id)
|
public IActionResult ViewPDF(int id)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -116,10 +116,10 @@ public class NetworkShareAccess : IDisposable
|
|||||||
public ResourceType ResourceType;
|
public ResourceType ResourceType;
|
||||||
public ResourceDisplayType DisplayType;
|
public ResourceDisplayType DisplayType;
|
||||||
public int Usage;
|
public int Usage;
|
||||||
public string? LocalName;
|
public string? LocalName; //? or required TBD
|
||||||
public string? RemoteName;
|
public string? RemoteName; //
|
||||||
public string? Comment;
|
public string? Comment; //
|
||||||
public string? Provider;
|
public string? Provider; //
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum ResourceScope { Connected = 1, GlobalNetwork, Remembered, Recent, Context }
|
private enum ResourceScope { Connected = 1, GlobalNetwork, Remembered, Recent, Context }
|
||||||
|
|||||||
@ -177,6 +177,7 @@
|
|||||||
<a href="/MMS/Marine/ViewPDF?id=${data.id}" class="btn btn-primary" target="_blank">View PDF</a>
|
<a href="/MMS/Marine/ViewPDF?id=${data.id}" class="btn btn-primary" target="_blank">View PDF</a>
|
||||||
<a href="/MMS/Marine/GenerateReport?id=${data.id}" class="btn btn-primary">Download PDF</a>
|
<a href="/MMS/Marine/GenerateReport?id=${data.id}" class="btn btn-primary">Download PDF</a>
|
||||||
`
|
`
|
||||||
|
//uses ViewPDF for view, GenerateReport for downloading
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rowCallback": function(row, data, index) {
|
"rowCallback": function(row, data, index) {
|
||||||
@ -214,7 +215,7 @@
|
|||||||
this.updateDataTable(newData);
|
this.updateDataTable(newData);
|
||||||
//trigger search function after updating data(?)
|
//trigger search function after updating data(?)
|
||||||
if(this.dataTable) {
|
if(this.dataTable) {
|
||||||
this.dataTable.search('').draw();//clear existing search
|
this.dataTable.search('').draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user