2 Commits

Author SHA1 Message Date
7650bf2869 Removed PdfViewController, HtmlViewRenderer and FakeView to be replaced with ViewEngineResult Render method
Added HttpException class for missing HttpException for net8

Wrapped HttpContext.Session, GetJsonResult, IsAjaxRequest and GetUserIdentityName in controllers for net8

Added AuthenticationService to test Fab2ApprovalMKLink code for net8

Compile conditionally flags to debug in dotnet core
2025-05-23 12:51:42 -07:00
184e97fce3 Removed PdfViewController, HtmlViewRenderer and FakeView to be replaced with ViewEngineResult Render method 2025-05-23 12:39:34 -07:00
7 changed files with 23 additions and 18 deletions

View File

@ -700,7 +700,6 @@ public class ECNController : Controller {
} }
#if !NET8 #if !NET8
public ActionResult GetApproversList([DataSourceRequest] DataSourceRequest request, int issueID, byte step, bool isTECN, bool isEmergrncyTECN) { public ActionResult GetApproversList([DataSourceRequest] DataSourceRequest request, int issueID, byte step, bool isTECN, bool isEmergrncyTECN) {
int isITARCompliant = 0; int isITARCompliant = 0;
ECN ecn = new ECN(); ECN ecn = new ECN();
@ -946,11 +945,13 @@ public class ECNController : Controller {
try { try {
#if !NET8 #if !NET8
ViewEngineResult viewResult = ViewEngines.Engines.FindView(ControllerContext, viewName, string.Empty); ViewEngineResult viewResult = ViewEngines.Engines.FindView(ControllerContext, viewName, string.Empty);
if (viewResult is null) if (viewResult is null) {
return $"A view with the name '{viewName}' could not be found"; return $"A view with the name '{viewName}' could not be found";
}
ViewContext viewContext = new(ControllerContext, viewResult.View, ViewData, TempData, writer); ViewContext viewContext = new(ControllerContext, viewResult.View, ViewData, TempData, writer);
viewResult.View.Render(viewContext, writer); viewResult.View.Render(viewContext, writer);
result = writer.GetStringBuilder().ToString(); string htmlText = writer.GetStringBuilder().ToString();
result = htmlText.Replace("navbar-header", "navbar-header-hidden");
#endif #endif
#if NET8 #if NET8
ViewEngineResult viewResult; ViewEngineResult viewResult;

View File

@ -243,11 +243,13 @@ public class LotTravelerController : Controller {
try { try {
#if !NET8 #if !NET8
ViewEngineResult viewResult = ViewEngines.Engines.FindView(ControllerContext, viewName, string.Empty); ViewEngineResult viewResult = ViewEngines.Engines.FindView(ControllerContext, viewName, string.Empty);
if (viewResult is null) if (viewResult is null) {
return $"A view with the name '{viewName}' could not be found"; return $"A view with the name '{viewName}' could not be found";
}
ViewContext viewContext = new(ControllerContext, viewResult.View, ViewData, TempData, writer); ViewContext viewContext = new(ControllerContext, viewResult.View, ViewData, TempData, writer);
viewResult.View.Render(viewContext, writer); viewResult.View.Render(viewContext, writer);
result = writer.GetStringBuilder().ToString(); string htmlText = writer.GetStringBuilder().ToString();
result = htmlText.Replace("navbar-header", "navbar-header-hidden");
#endif #endif
#if NET8 #if NET8
ViewEngineResult viewResult; ViewEngineResult viewResult;

View File

@ -326,6 +326,9 @@
<Compile Include="Models\WinEventLogModel.cs" /> <Compile Include="Models\WinEventLogModel.cs" />
<Compile Include="Models\WorkFlowModels.cs" /> <Compile Include="Models\WorkFlowModels.cs" />
<Compile Include="PdfGenerator\BinaryContentResult.cs" /> <Compile Include="PdfGenerator\BinaryContentResult.cs" />
<Compile Include="PdfGenerator\FakeView.cs" />
<Compile Include="PdfGenerator\HtmlViewRenderer.cs" />
<Compile Include="PdfGenerator\PdfViewController.cs" />
<Compile Include="PdfGenerator\PrintHeaderFooter.cs" /> <Compile Include="PdfGenerator\PrintHeaderFooter.cs" />
<Compile Include="PdfGenerator\StandardPdfRenderer.cs" /> <Compile Include="PdfGenerator\StandardPdfRenderer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -0,0 +1 @@


View File

@ -15,11 +15,10 @@ public class StandardPdfRenderer {
public static byte[] GetPortableDocumentFormatBytes(string pageTitle, string htmlText) { public static byte[] GetPortableDocumentFormatBytes(string pageTitle, string htmlText) {
byte[] results; byte[] results;
using (MemoryStream memoryStream = GetPortableDocumentFormat(pageTitle, htmlText)) { MemoryStream memoryStream = GetPortableDocumentFormat(pageTitle, htmlText);
results = new byte[memoryStream.Position]; results = new byte[memoryStream.Position];
memoryStream.Position = 0; memoryStream.Position = 0;
memoryStream.Read(results, 0, results.Length); memoryStream.Read(results, 0, results.Length);
}
return results; return results;
} }
@ -35,7 +34,7 @@ public class StandardPdfRenderer {
MemoryStream result = new(); MemoryStream result = new();
#if !NET8 #if !NET8
using (Document pdfDocument = new Document(PageSize.A4, HorizontalMargin, HorizontalMargin, VerticalMargin, VerticalMargin)) { using (Document pdfDocument = new Document(PageSize.A4, HorizontalMargin, HorizontalMargin, VerticalMargin, VerticalMargin)) {
using (PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDocument, result)) { PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDocument, result);
pdfWriter.CloseStream = false; pdfWriter.CloseStream = false;
pdfWriter.PageEvent = new PrintHeaderFooter { Title = pageTitle }; pdfWriter.PageEvent = new PrintHeaderFooter { Title = pageTitle };
pdfDocument.Open(); pdfDocument.Open();
@ -45,7 +44,6 @@ public class StandardPdfRenderer {
} }
} }
} }
}
#endif #endif
return result; return result;
} }