C2026-043-Tech-Debt_v1 - Stash 1

This commit is contained in:
2026-07-21 06:49:28 -04:00
parent 0fed1acfd8
commit 9486b37300
70 changed files with 4222 additions and 10191 deletions
+45 -237
View File
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using VEPROMS.CSLA.Library;
using System.IO;
@@ -11,7 +9,7 @@ using System.Text.RegularExpressions;
using JR.Utils.GUI.Forms;
using Volian.Base.Library;
using System.Linq;
namespace Volian.Controls.Library
{
public partial class DisplayHistory : UserControl
@@ -21,30 +19,22 @@ namespace Volian.Controls.Library
public event DisplayHistoryReportEvent SummaryPrintRequest;
private void OnChronologyPrintRequest(DisplayHistoryReportEventArgs args)
{
if (ChronologyPrintRequest != null)
ChronologyPrintRequest(this, args);
}
ChronologyPrintRequest?.Invoke(this, args);
}
private void OnSummaryPrintRequest(DisplayHistoryReportEventArgs args)
{
if (SummaryPrintRequest != null)
SummaryPrintRequest(this, args);
}
SummaryPrintRequest?.Invoke(this, args);
}
public event DisplayHistoryEvent HistorySelectionChanged;
private void OnHistorySelectionChanged(DisplayHistoryEventArgs args)
{
if (HistorySelectionChanged != null)
HistorySelectionChanged(this, args);
}
public event ItemRestoredHandler ItemRestored;
private void OnItemRestored(ItemInfo restoredItemInfo)
{
if (ItemRestored != null) ItemRestored(restoredItemInfo);
}
HistorySelectionChanged?.Invoke(this, args);
}
public event AnnotationRestoredHandler AnnotationRestored;
private void OnAnnotationRestored(AnnotationInfo restoredAnnotationInfo, ItemInfo currentItem)
{
if (AnnotationRestored != null) AnnotationRestored(restoredAnnotationInfo, currentItem);
}
AnnotationRestored?.Invoke(restoredAnnotationInfo, currentItem);
}
#endregion
private ContentAuditInfoList _ChronologyAuditList;
private ContentAuditInfoList _SummaryAuditList;
@@ -176,10 +166,8 @@ namespace Volian.Controls.Library
SetRevDate(MyProcedureInfo.DTS);
else
{
DateTime revDate;
if (!DateTime.TryParse(cfg.Print_RevDate, out revDate)) revDate = MyProcedureInfo.ChangeBarDate; // DateTime.Now;
SetRevDate(revDate);
//SetRevDate(DateTime.Parse(cfg.Print_RevDate));
if (!DateTime.TryParse(cfg.Print_RevDate, out DateTime revDate)) revDate = MyProcedureInfo.ChangeBarDate; // DateTime.Now;
SetRevDate(revDate);
}
}
}
@@ -222,42 +210,39 @@ namespace Volian.Controls.Library
{
if (lbChanges.SelectedIndex > -1)
{
ContentAuditInfo cai = lbChanges.SelectedItem as ContentAuditInfo;
if (cai != null)
{
// The following line was incorrectly showing a message stating that the item was deleted when it was not.
//if (cai.DeleteStatus > 0 || (cai.DeleteStatus == 0 && cai.ActionWhen.Year == DateTime.MinValue.Year))
if (cai.DeleteStatus > 0)
FlexibleMessageBox.Show("This item has been deleted.", "Deleted Item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
else
{
try
{
OnHistorySelectionChanged(new DisplayHistoryEventArgs(cai.ItemID));
}
// If the selected item is deleted display a message rather than crashing
catch (Exception ex)
{
FlexibleMessageBox.Show("This item has been deleted.", "Deleted Item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
else
{
AnnotationAuditInfo aai = lbChanges.SelectedItem as AnnotationAuditInfo;
OnHistorySelectionChanged(new DisplayHistoryEventArgs(aai.ItemID));
}
}
if (lbChanges.SelectedItem is ContentAuditInfo cai)
{
// The following line was incorrectly showing a message stating that the item was deleted when it was not.
//if (cai.DeleteStatus > 0 || (cai.DeleteStatus == 0 && cai.ActionWhen.Year == DateTime.MinValue.Year))
if (cai.DeleteStatus > 0)
FlexibleMessageBox.Show("This item has been deleted.", "Deleted Item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
else
{
try
{
OnHistorySelectionChanged(new DisplayHistoryEventArgs(cai.ItemID));
}
// If the selected item is deleted display a message rather than crashing
catch (Exception)
{
FlexibleMessageBox.Show("This item has been deleted.", "Deleted Item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
else
{
AnnotationAuditInfo aai = lbChanges.SelectedItem as AnnotationAuditInfo;
OnHistorySelectionChanged(new DisplayHistoryEventArgs(aai.ItemID));
}
}
}
private void UpdateHistory()
{
this.Cursor = Cursors.WaitCursor;
//DateTime start = DateTime.Now;
//Console.WriteLine(start);
#region setup
btnRestore.Enabled = false;
myRTB.Clear();
//myRTB.LastRtf = string.Empty;
myVFG.Clear();
myPicBox.Image = null;
if (!tvAudits.IsDisposed) // fixes a crash that happend while debugging separate windows, have not been able to reproduce. left this IF check in just in case. - jsj 2-1-2018
@@ -269,8 +254,6 @@ namespace Volian.Controls.Library
}
MyItemInfo.RefreshItemAnnotations();
#endregion
//if (AnnotationOnly)
//{
#region annotation deleted
//annotation deleted by itemid
TreeNode annotationDeleted = null;
@@ -319,14 +302,11 @@ namespace Volian.Controls.Library
}
//end annotation change
#endregion
// return;
//}
#region content changes
//content changes
TreeNode contentHistory = null;
if (MyItemInfo == null) return;
ContentAuditInfoList cail = ContentAuditInfoList.Get(MyItemInfo.ContentID, MyItemInfo.MyProcedure.DTS);
// ContentAuditInfoList cail = ContentAuditInfoList.GetChronology(MyItemInfo.MyProcedure.ItemID, MyItemInfo.ItemID, false);
ContentInfo ci = ContentInfo.Get(MyItemInfo.ContentID);
foreach (ContentAuditInfo cai in cail)
{
@@ -378,155 +358,10 @@ namespace Volian.Controls.Library
#endregion
#region items
TreeNode deletedItems = null;
TreeNode previousItem = null;
TreeNode nextItem = null;
TreeNode procedurePart = null;
TreeNode sectionPart = null;
TreeNode cautionPart = null;
TreeNode notePart = null;
TreeNode rnoPart = null;
TreeNode stepPart = null;
TreeNode tablePart = null;
#endregion
ItemAuditInfoList iail = ItemAuditInfoList.Get(MyItemInfo.ItemID);
foreach (ItemAuditInfo iai in iail)
{
#region old style
// switch (iai.Level)
// {
// #region previous item
// case 0: //previous item
// {
// #region old style
// //if (previousItem == null)
// // previousItem = tvAudits.Nodes.Add("Deleted Previous Item"); //previousItem = tvAudits.Nodes.Add("Previous Item");
// //TreeNode tn = previousItem.Nodes.Add(iai.ToString());
// //tn.Tag = iai;
// #endregion
// #region new style
// if (deletedItems == null)
// deletedItems = tvAudits.Nodes.Add("Deleted Items");
// TreeNode tnn = deletedItems.Nodes.Add(iai.ToString());
// tnn.Tag = iai;
// #endregion
// break;
// }
// #endregion
// #region next item
// case 1: //next item
// {
// #region old style
// //if (nextItem == null)
// // nextItem = tvAudits.Nodes.Add("Deleted Next Item"); //nextItem = tvAudits.Nodes.Add("Next Item");
// //TreeNode tn = nextItem.Nodes.Add(iai.ToString());
// //tn.Tag = iai;
// #endregion
// #region new style
// if (deletedItems == null)
// deletedItems = tvAudits.Nodes.Add("Deleted Items");
// TreeNode tnn = deletedItems.Nodes.Add(iai.ToString());
// tnn.Tag = iai;
// #endregion
// break;
// }
// #endregion
// case 2: //parts
// {
// #region old style
// //PartAuditInfoList pail = null;
// //pail = PartAuditInfoList.GetByDeleteStatus(iai.DeleteStatus);
// //if (pail.Count == 0)
// // pail = PartAuditInfoList.GetByItemID(iai.ItemID);
// //foreach (PartAuditInfo pai in pail)
// //{
// // if (pai.ContentID == MyItemInfo.ContentID)
// // {
// // switch (pai.FromType)
// // {
// // #region procedure part
// // case 1: //procedures
// // {
// // if (procedurePart == null)
// // procedurePart = tvAudits.Nodes.Add("Deleted Procedures"); //procedurePart = tvAudits.Nodes.Add("Procedures");
// // TreeNode tn = procedurePart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region section part
// // case 2: //sections
// // {
// // if (sectionPart == null)
// // sectionPart = tvAudits.Nodes.Add("Deleted Sections"); //sectionPart = tvAudits.Nodes.Add("Sections");
// // TreeNode tn = sectionPart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region caution part
// // case 3: //cautions
// // {
// // if (cautionPart == null)
// // cautionPart = tvAudits.Nodes.Add("Deleted Cautions"); //cautionPart = tvAudits.Nodes.Add("Cautions");
// // TreeNode tn = cautionPart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region note part
// // case 4: //notes
// // {
// // if (notePart == null)
// // notePart = tvAudits.Nodes.Add("Deleted Notes"); //notePart = tvAudits.Nodes.Add("Notes");
// // TreeNode tn = notePart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region rno part
// // case 5: //rnos
// // {
// // if (rnoPart == null)
// // rnoPart = tvAudits.Nodes.Add("Deleted RNOs"); //rnoPart = tvAudits.Nodes.Add("RNOs");
// // TreeNode tn = rnoPart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region step part
// // case 6: //steps
// // {
// // if (stepPart == null)
// // stepPart = tvAudits.Nodes.Add("Deleted Steps"); //stepPart = tvAudits.Nodes.Add("Steps");
// // TreeNode tn = stepPart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // #region table part
// // case 7: //tables
// // {
// // if (tablePart == null)
// // tablePart = tvAudits.Nodes.Add("Deleted Tables"); //tablePart = tvAudits.Nodes.Add("Tables");
// // TreeNode tn = tablePart.Nodes.Add(iai.ToString());
// // tn.Tag = iai;
// // break;
// // }
// // #endregion
// // }
// // }
// //}
// #endregion
// #region new style
// if (deletedItems == null)
// deletedItems = tvAudits.Nodes.Add("Deleted Items");
// TreeNode tnn = deletedItems.Nodes.Add(iai.ToString());
// tnn.Tag = iai;
// #endregion
// break;
// }
//}
#endregion
#region new style
// B2023-117 if DeleteStatus is zero,don't try to get Audit Info List
if (iai.DeleteStatus == 0) continue;
@@ -552,7 +387,7 @@ namespace Volian.Controls.Library
}
}
}
TreeNode tnn = deletedItems.Nodes.Add(iai.ToString() + "; Reason: " + strR);
TreeNode tnn = deletedItems.Nodes.Add($"{iai}; Reason: {strR}");
tnn.Tag = iai;
#endregion
}
@@ -572,10 +407,8 @@ namespace Volian.Controls.Library
}
private void WalkProcedure()
{
//return;
this.ParentForm.Cursor = Cursors.WaitCursor;
Application.DoEvents();
//DateTime start = DateTime.Now;
//Console.WriteLine(start);
lbChanges.Items.Clear();
if (MyProcedureInfo == null)
@@ -584,10 +417,10 @@ namespace Volian.Controls.Library
btnViewSummaryReport.Enabled = btnViewChronologyReport.Enabled = cbSumExcludeAnn.Enabled = DT_SumAsOf.Enabled = lbChanges.Items.Count > 0;
return;
}
ContentAuditInfoList cail2;
ContentAuditInfoList cail3;
AnnotationAuditInfoList aail2;
if (ApplDisplayMode > 0)
ContentAuditInfoList cail2;
ContentAuditInfoList cail3;
AnnotationAuditInfoList aail2;
if (ApplDisplayMode > 0)
{
cail2 = ContentAuditInfoList.GetChronologyByUnit(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID, false, ApplDisplayMode, MyProcedureInfo.ChangeBarDate);
cail3 = ContentAuditInfoList.GetSummaryByUnit(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID, false, ApplDisplayMode, MyProcedureInfo.ChangeBarDate);
@@ -611,8 +444,8 @@ namespace Volian.Controls.Library
// in the list box and should not be because some MyRevDate's did not have time included.
if (CompareDateOrDateTime(cai.DTS, MyRevDate) || cai.ActionWhen > MyRevDate)
{
string itemTitle = FixPath(cai.Path);
lbChanges.Items.Add(cai);
_ = FixPath(cai.Path);
lbChanges.Items.Add(cai);
}
}
foreach (AnnotationAuditInfo aai in aail2)
@@ -630,7 +463,7 @@ namespace Volian.Controls.Library
{
ItemInfo iii = aai.MyItemInfo;
if (iii != null)
stepnum = FixPath(iii.SearchPath);
_ = FixPath(iii.SearchPath);
}
if (aai.DTS > MyRevDate)
lbChanges.Items.Add(aai);
@@ -650,25 +483,13 @@ namespace Volian.Controls.Library
private void btnViewChronologyReport_Click(object sender, EventArgs e)
{
RefreshList();
//if (lbChanges.Items.Count > 0)
//{
//jcb added 20120425 to suppress annotations in report
//jcb commented out 20130409 per bug C2012-022
//_AnnotationList = AnnotationAuditInfoList.GetChronology(0, 0, MyProcedureInfo.ChangeBarDate);
//added setting selected slave in order for reports to replace unit number,etc jcb 20101010
MyItemInfo.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = ApplDisplayMode;
// OnChronologyPrintRequest(new DisplayHistoryReportEventArgs(Volian.Base.Library.VlnSettings.TemporaryFolder + @"\MyChronology.pdf", MyItemInfo.MyProcedure, _ChronologyAuditList, _AnnotationList));
OnChronologyPrintRequest(new DisplayHistoryReportEventArgs(string.Format(@"{0}\{1} Chronology of Changes.pdf", Volian.Base.Library.VlnSettings.TemporaryFolder, MyItemInfo.MyProcedure.PDFNumber), MyItemInfo.MyProcedure, _ChronologyAuditList, _AnnotationList));
//}
}
private void btnViewSummaryReport_Click(object sender, EventArgs e)
{
RefreshList();
//if (lbChanges.Items.Count > 0)
//{
//jcb added 20120425 to suppress annotations in report
//jcb commented out 20130409 per bug C2012-022
//_AnnotationList = AnnotationAuditInfoList.GetChronology(0, 0, MyProcedureInfo.ChangeBarDate);
//added setting selected slave in order for reports to replace unit number,etc jcb 20101010
MyItemInfo.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = ApplDisplayMode;
@@ -676,7 +497,6 @@ namespace Volian.Controls.Library
//C2024- 038 - Summary of Changes report generation enhancements
//check if need to modify
// _SummaryAuditList
if (DT_SumAsOf.Checked)
dhr.AuditList = FilterSummaryByDate(_SummaryAuditList, DT_SumAsOf.Value);
else
@@ -685,7 +505,6 @@ namespace Volian.Controls.Library
//C2024- 038 - Summary of Changes report generation enhancements
// if Exclude Annotations Checked
// send an empty list instead of
//_AnnotationList
if (cbSumExcludeAnn.Checked)
dhr.AnnotationList = new AnnotationAuditInfoList(null);
else if (DT_SumAsOf.Checked)
@@ -799,11 +618,7 @@ namespace Volian.Controls.Library
if (myRoFst != null) myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ii = MyItemInfo.RestoreItem(iai, myRoFst);
if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
//_MyEditItem.AddChild((E_FromType)fromtype, contenttype);
//ii.ItemParts[0].FromType
//ii.MyContent.Type
EditItem nextItem = MyEditItem.GetNextItem((E_FromType)ii.ItemParts[0].FromType, ii);
//MyEditItem.AddChild(ii.MyContent.Text, (E_FromType)ii.ItemParts[0].FromType, (int)ii.MyContent.Type, null);
if (ii.IsStep)
ii = StepInfo.Get(ii.ItemID);
else if (ii.IsSection)
@@ -1051,10 +866,6 @@ namespace Volian.Controls.Library
myRTB.Visible = true;
myRTB.BringToFront();
myVFG.Visible = false;
// myRTB.Font = new Font("Arial", 12, FontStyle.Regular);
// myRTB.Text = cai.Text;
//myRTB.SetupRichText("bozo", MyItemInfo.FormatStepData == null ? MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font : MyItemInfo.FormatStepData.Font);
//myRTB.LastRtf = string.Empty;
myRTB.SetupRichText(cai.Text, MyItemInfo.FormatStepData == null ? MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font : MyItemInfo.FormatStepData.Font);
}
}
@@ -1067,8 +878,6 @@ namespace Volian.Controls.Library
{
if (cai.DeleteStatus == iai.DeleteStatus)
{
//myRTB.Font = new Font("Arial", 12, FontStyle.Regular);
//myRTB.Text = cai.Text;
myRTB.SetupRichText(cai.Text, MyItemInfo.FormatStepData == null ? MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font : MyItemInfo.FormatStepData.Font);
}
}
@@ -1079,7 +888,6 @@ namespace Volian.Controls.Library
AnnotationAuditInfo iai = tn.Tag as AnnotationAuditInfo;
myRTB.Font = new Font("Arial", 12, FontStyle.Regular);
myRTB.Rtf = iai.RtfText;
//myRTB.Rtf = iai.RtfText;
}
}
else
@@ -1121,7 +929,7 @@ namespace Volian.Controls.Library
myTimer.Enabled = true;
}
// B2019-161 When tracking timing time this action
private static VolianTimer _TimeActivity = new VolianTimer("DisplayHistory myTimer_Tick", 974);
private static readonly VolianTimer _TimeActivity = new VolianTimer("DisplayHistory myTimer_Tick", 974);
private void myTimer_Tick(object sender, System.EventArgs e)
{