Merged PR 16782: Added logic to display Category and Training Notification fields on PDF

Added logic to display Category and Training Notification fields on PDF

Related work items: #135474, #225483
This commit is contained in:
Mike Phares 2025-05-19 22:20:00 +02:00
parent 032c971472
commit 8bae94de96
4 changed files with 148 additions and 77 deletions

View File

@ -883,6 +883,8 @@ public class ECNController : PdfViewController {
string outputFileName = "";
ecn = ecnDMO.GetECNPdf(ecnNumber);
ViewBag.Category = ecnDMO.GetCategoryID(ecn);
ViewBag.TrainingNotificationTo = ecnDMO.GetTrainingNotificationTo(ecn, trainingDMO);
outputFileName = ecnNumber.ToString() + ".pdf";
string ecnFolderPath = _AppSettings.AttachmentFolder + "ECN\\" + ecnNumber.ToString();
@ -910,6 +912,8 @@ public class ECNController : PdfViewController {
string outputFileName = "";
ecn = ecnDMO.GetECNPdf(ecnNumber);
ViewBag.Category = ecnDMO.GetCategoryID(ecn);
ViewBag.TrainingNotificationTo = ecnDMO.GetTrainingNotificationTo(ecn, trainingDMO);
outputFileName = ecnNumber.ToString() + ".pdf";
string ecnFolderPath = _AppSettings.AttachmentFolder + "ECN\\" + folderName.ToString();
@ -935,13 +939,15 @@ public class ECNController : PdfViewController {
ECNPdf ecn;
try {
ecn = ecnDMO.GetECNPdf(ecnNumber);
ViewBag.Category = ecnDMO.GetCategoryID(ecn);
ViewBag.TrainingNotificationTo = ecnDMO.GetTrainingNotificationTo(ecn, trainingDMO);
// To render a PDF instead of an HTML, all we need to do is call ViewPdf instead of View. This
// requires the controller to be inherited from MyController instead of MVC's Controller.
return this.ViewPdf("", "ECNPdf", ecn);
} catch (Exception ex) {
EventLogDMO.Add(new WinEventLog() { IssueID = ecnNumber, UserID = @User.Identity.Name, DocumentType = "ECN", OperationType = "Print PDF", Comments = ex.Message });
ecn = null;
return Content("");
return Content("An unexpected error has occurred!");
}
}

View File

@ -356,14 +356,17 @@ public class ECN_DMO {
List<string> affectedAreas = multipleResultItems.Read<string>().ToList();
List<string> affectedTechnologies = multipleResultItems.Read<string>().ToList();
List<string> acknowledgementBy = multipleResultItems.Read<string>().ToList();
List<string> trainingBy = multipleResultItems.Read<string>().ToList();
List<int> trainingby = multipleResultItems.Read<int>().ToList();
if (ecnItem != null && trainingby != null) {
if (trainingby.Count > 0)
ecnItem.TrainingByIDs.AddRange(trainingby);
}
List<string> productfamilies = multipleResultItems.Read<string>().ToList();
ecnItem.AffectedModules = string.Join(", ", modules);
ecnItem.AffectedDepartments = string.Join(", ", departments);
ecnItem.AffectedAreas = string.Join(",", affectedAreas);
ecnItem.AffectedTechnologies = string.Join(",", affectedTechnologies);
ecnItem.TrainingBy = string.Join(",", trainingBy);
ecnItem.AcknowledgementBy = string.Join(",", acknowledgementBy);
ecnItem.AffectedProductFamilies = string.Join(",", productfamilies);
@ -714,4 +717,26 @@ public class ECN_DMO {
return r;
}
internal string GetCategoryID(ECNPdf ecn) {
string result;
if (ecn.CategoryID is null) {
result = string.Empty;
} else {
List<ECNCategory> categories = GetCategories();
result = (from l in categories where l.CategoryID == ecn.CategoryID.Value select l.CategoryName).FirstOrDefault();
}
return result;
}
internal string GetTrainingNotificationTo(ECNPdf ecn, TrainingDMO trainingDMO) {
string result;
if (ecn.TrainingByIDs is null) {
result = string.Empty;
} else {
List<TrainingGroup> trainingGroups = trainingDMO.GetTrainingGroups();
result = string.Join(", ", (from l in trainingGroups where ecn.TrainingByIDs.Contains(l.TrainingGroupID) select l.TrainingGroupName).ToArray());
}
return result;
}
}

View File

@ -30,7 +30,7 @@ public class ECNPdf {
public string AffectedDepartments { get; set; }
public string AffectedAreas { get; set; }
public string AffectedTechnologies { get; set; }
public string TrainingBy { get; set; }
public List<int> TrainingByIDs { get; set; }
public string AcknowledgementBy { get; set; }
public bool IsECN { get; set; }
public bool IsTECN { get; set; }
@ -79,6 +79,7 @@ public class ECNPdf {
public int? ConvertedToNumber { get; set; }
public int? ConvertedFromNumber { get; set; }
public int WorkFlowNumber { get; set; }
public int? CategoryID { get; set; }
public bool FIChangeRequired { get; set; }
public string NumberOfLotsAffected { get; set; }
public string RecipeChange { get; set; }
@ -87,6 +88,7 @@ public class ECNPdf {
public ECNPdf() {
Approvalog = new List<ECNApprovalLog>();
Attachments = new List<string>();
TrainingByIDs = new List<int>();
}
}

View File

@ -84,6 +84,16 @@
</font>
</td>
</tr>
<tr>
<td>
<font size="2">
Category:&nbsp;
</font>
<font size="1">
@(ViewBag.Category)
</font>
</td>
</tr>
<tr>
<td>
<font size="2">
@ -327,7 +337,35 @@
@(Model.SPNChangeRequired ? "Yes" : "No")
</font>
</td>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="1">
<tr bgcolor="#c4baba" color="#000000">
<td colspan="5">Training Notification</td>
</tr>
<tr style="display:block;">
<td>
<font size="2">
Training:
</font>
<font size="1">
@(Model.TrainingRequired ? "Yes" : "No")
</font>
</td>
<td>
<font size="2">
Training Notification to: &nbsp;
@(ViewBag.TrainingNotificationTo)
</font>
</td>
</tr>
</table>