network path
This commit is contained in:
parent
43466c85e6
commit
1b6b25d7e7
@ -11,9 +11,9 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
[Area("MMS")]
|
[Area("MMS")]
|
||||||
public class MarineController : Controller
|
public class MarineController : Controller
|
||||||
{
|
{
|
||||||
private readonly MMSSystemContext _context;
|
private readonly MMSSystemContext _context;//Used in TarBallForm and GeneratePdfResponse to query the database.
|
||||||
private readonly NetworkShareAccess _networkAccessService;
|
private readonly NetworkShareAccess _networkAccessService;//used in GetImage and GeneratePdfResponse
|
||||||
private const string PhotoBasePath = "\\192.168.12.42\\images\\marine\\manual_tarball";
|
private const string PhotoBasePath = "\\192.168.12.42\\images\\marine\\manual_tarball";//used in GetImage and GeneratePdfResponse
|
||||||
|
|
||||||
public MarineController(MMSSystemContext context, NetworkShareAccess networkAccessService)
|
public MarineController(MMSSystemContext context, NetworkShareAccess networkAccessService)
|
||||||
{
|
{
|
||||||
@ -26,7 +26,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult TarBallForm()
|
public IActionResult TarBallForm()//Queries the database and returns a view with tarball data
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -50,6 +50,30 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet] // Explicitly mark as a GET endpoint
|
||||||
|
public IActionResult TestCredentials()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Use the EXACT same path/credentials as in Program.cs
|
||||||
|
var testService = new NetworkShareAccess(
|
||||||
|
@"\\192.168.12.42\images\marine\manual_tarball",
|
||||||
|
"installer",
|
||||||
|
"mms@pstw"
|
||||||
|
);
|
||||||
|
|
||||||
|
testService.ConnectToNetworkPath();
|
||||||
|
testService.DisconnectFromNetworkShare();
|
||||||
|
|
||||||
|
return Ok("Network credentials and path are working correctly!");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Log the full error (including stack trace)
|
||||||
|
Console.WriteLine($"TestCredentials failed: {ex}");
|
||||||
|
return StatusCode(500, $"Credentials test failed: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IActionResult GetImage(string fileName)
|
public IActionResult GetImage(string fileName)
|
||||||
{
|
{
|
||||||
@ -82,7 +106,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult GenerateReport(int id)
|
public IActionResult GenerateReport(int id)//calls GeneratePdfResponse to generate a PDF for inline viewing
|
||||||
{
|
{
|
||||||
return GeneratePdfResponse(id, true);
|
return GeneratePdfResponse(id, true);
|
||||||
}
|
}
|
||||||
@ -99,7 +123,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Connect to the network path
|
// Connect to the network path
|
||||||
_networkAccessService.ConnectToNetworkPath();
|
_networkAccessService.ConnectToNetworkPath();//------------------
|
||||||
|
|
||||||
// 1. Fetch core data from database
|
// 1. Fetch core data from database
|
||||||
var tarballData = (from marine in _context.MarineTarballs
|
var tarballData = (from marine in _context.MarineTarballs
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public class NetworkShareAccess : IDisposable
|
|||||||
RemoteName = _networkPath
|
RemoteName = _networkPath
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = WNetAddConnection2(netResource, _password, _username, 0);
|
var result = WNetAddConnection2(netResource, _password, _username, 0);//
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -351,7 +351,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
|
|||||||
.Text(text =>
|
.Text(text =>
|
||||||
{
|
{
|
||||||
text.Span("CHECKED BY: ").Bold().FontSize(12);
|
text.Span("CHECKED BY: ").Bold().FontSize(12);
|
||||||
text.Span("Rifaie Azhari").FontSize(10);
|
text.Span("***RIFAIE AZHARI").FontSize(10);
|
||||||
});
|
});
|
||||||
table.Cell().Element(CellStyle).Text("Signature").FontSize(12);
|
table.Cell().Element(CellStyle).Text("Signature").FontSize(12);
|
||||||
table.Cell().ColumnSpan(2).Element(CellStyle).Text("");
|
table.Cell().ColumnSpan(2).Element(CellStyle).Text("");
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
<title>Tarball Report</title>
|
<title>Tarball Report</title>
|
||||||
<style>
|
<style>
|
||||||
.container {
|
.container {
|
||||||
width: 1200px; /* Approximate width for A4 aspect ratio */
|
width: 1400px; /* Approximate width for A4 aspect ratio */
|
||||||
margin: 20px auto;
|
margin: 20px auto;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user