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
+40 -64
View File
@@ -7,7 +7,6 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using VEPROMS.CSLA.Library;
using Volian.Base.Library;
@@ -17,29 +16,22 @@ namespace Volian.Controls.Library
{
public partial class DisplayRO : UserControl
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Fields
private const string DummyNodeText = "VLN_DUMMY_NODE";
private const int MaxNumSearchRecords = 1000;
// B2019-161 When tracking timing time this action
private static VolianTimer _timeActivity = new VolianTimer("DisplayRO MyRTB_SelectionChanged", 117);
private static Regex _regExGetNumber = new Regex(@"^ *[+-]?[.,0-9/]+(E[+-]?[0-9]+)?");
private static readonly VolianTimer _timeActivity = new VolianTimer("DisplayRO MyRTB_SelectionChanged", 117);
private static readonly Regex _regExGetNumber = new Regex(@"^ *[+-]?[.,0-9/]+(E[+-]?[0-9]+)?");
private static UserInfo _myUserInfo = null;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Timer Not ReadOnly")]
private Timer _searchTimer = null;
private string _lastSearchValue = string.Empty;
private ProgressBarItem _progressBar;
private DisplayTabControl _tabControl;
private StepRTB _myRTB;
private string _selectedRoidBeforeRoEditor = null;
private ROFstInfo _myROFST;
private DocVersionInfo _docVersionInfo;
@@ -51,12 +43,9 @@ namespace Volian.Controls.Library
private int? _currDocVersionID = null;
private RoUsageInfo _curROLink;
private E_ROValueType _curROTypeFilter = E_ROValueType.All;
private ROFSTLookup.rochild selectedChld;
private DisplayTags displayTags;
#endregion
@@ -286,15 +275,17 @@ namespace Volian.Controls.Library
if (_searchTimer == null)
{
_searchTimer = new Timer();
_searchTimer.Interval = 1000;
_searchTimer = new Timer
{
Interval = 1000
};
_searchTimer.Tick += new EventHandler(SelectionTimer_Tick);
_searchTimer.Stop();
}
// Initialize the DisplayTags object
displayTags = new DisplayTags();
_ = new DisplayTags();
}
@@ -405,9 +396,8 @@ namespace Volian.Controls.Library
{
// B2022-088: [JPR] Find Doc Ro button not working in Word Sections
// B2022-098: [JPR] ROs not being resolved in Word Sections
if (e.Node.Tag is ROFSTLookup.rochild)
if (e.Node.Tag is ROFSTLookup.rochild chld)
{
ROFSTLookup.rochild chld = (ROFSTLookup.rochild)e.Node.Tag;
selectedChld = chld;
if (chld.value != null)
@@ -513,7 +503,7 @@ namespace Volian.Controls.Library
}
else if (selectedChld.type == 4) // x/y plot
{
frmXYPlot plot = new frmXYPlot(selectedChld.appid + " - " + selectedChld.title, selectedChld.value);
frmXYPlot plot = new frmXYPlot($"{selectedChld.appid} - {selectedChld.title}", selectedChld.value);
plot.Show();
}
}
@@ -527,7 +517,7 @@ namespace Volian.Controls.Library
private void btnFindDocRO_Click(object sender, EventArgs e)
{
// C2016-044: support click of the 'Find Doc RO' button:
DisplayTabItem dti = (_tabControl == null) ? null : _tabControl.SelectedDisplayTabItem;
DisplayTabItem dti = _tabControl?.SelectedDisplayTabItem;
if (dti != null && dti.MyDSOTabPanel != null)
{
@@ -567,15 +557,12 @@ namespace Volian.Controls.Library
string roapp = Volian.Base.Library.ExeInfo.GetROEditorPath(); // get the path to the RO Editor Executable
object obj = tvROFST.SelectedNode.Tag;
if (obj is ROFSTLookup.rochild)
if (obj is ROFSTLookup.rochild roch)
{
ROFSTLookup.rochild roch = (ROFSTLookup.rochild)obj;
_selectedRoidBeforeRoEditor = roch.roid;
string args = "\"" + MyROFST.MyRODb.FolderPath + "\" " + roch.roid.Substring(0,12).ToLower();
string args = $"\"{MyROFST.MyRODb.FolderPath}\" {roch.roid.Substring(0, 12).ToLower()}";
// C2017-003: ro data in sql server, check for sql connection string
if (MyROFST.MyRODb.DBConnectionString != "cstring") args = args + " \"" + MyROFST.MyRODb.DBConnectionString + "\"";
if (MyROFST.MyRODb.DBConnectionString != "cstring") args = $"{args} \"{MyROFST.MyRODb.DBConnectionString}\"";
// C2021-026 pass in Parent/Child information (list of the children)
// B2022-019 look at all DocVersions to find ParentChild information
@@ -589,7 +576,7 @@ namespace Volian.Controls.Library
DocVersionConfig dvc = dvi.DocVersionConfig;
if (dvc != null && dvc.Unit_Name != "" && dvc.Unit_Count > 1) // B2021-089 only pass in applicability info if defined for more than one unit
{
args += " \"PC=" + dvc.Unit_Name + "\"";
args += $" \"PC={dvc.Unit_Name}\"";
break;
}
}
@@ -700,8 +687,10 @@ namespace Volian.Controls.Library
{
ROFSTLookup.rodbi db = dbs[i];
TreeNode tn = new TreeNode(db.dbiTitle);
tn.Tag = db;
TreeNode tn = new TreeNode(db.dbiTitle)
{
Tag = db
};
tvROFST.Nodes.Add(tn);
AddDummyGroup(db, tn);
@@ -770,8 +759,6 @@ namespace Volian.Controls.Library
tvROFST.Nodes.Remove(unitInfoNode);
}
_curROTypeFilter = _roTypeFilter;
return updatedROs;
}
@@ -787,11 +774,9 @@ namespace Volian.Controls.Library
if (match1.Success && !match1.Value.Contains("/") && match2.Success && !match2.Value.Contains("/")) // Compare the numeric value?
{
double dbl1;
double dbl2;
//B2017-232 changed from Parse to TryParse. AEP had figure title that had a number containing two periods which caused Parse to error?
if (double.TryParse(match1.ToString(), out dbl1) && double.TryParse(match2.ToString(), out dbl2))
if (double.TryParse(match1.ToString(), out double dbl1) && double.TryParse(match2.ToString(), out double dbl2))
{
if (dbl1 != dbl2) //B2021-144 if the numerical is identical default to the string comparison?
return dbl1 > dbl2;
@@ -814,15 +799,13 @@ namespace Volian.Controls.Library
//object tag = tn.Tag;
ROFSTLookup.rochild[] children = null;
if (tn.Tag is ROFSTLookup.rodbi)
if (tn.Tag is ROFSTLookup.rodbi db)
{
ROFSTLookup.rodbi db = (ROFSTLookup.rodbi)tn.Tag;
MyROFSTLookup.LoadChildren(ref db);
children = db.children;
}
else if (tn.Tag is ROFSTLookup.rochild)
else if (tn.Tag is ROFSTLookup.rochild ch)
{
ROFSTLookup.rochild ch = (ROFSTLookup.rochild)tn.Tag;
MyROFSTLookup.LoadChildren(ref ch);
children = ch.children;
}
@@ -861,8 +844,10 @@ namespace Volian.Controls.Library
if (roc.value == null)
{
tmp = new TreeNode(roc.title);
tmp.Tag = roc;
tmp = new TreeNode(roc.title)
{
Tag = roc
};
int index = FindIndex(tn.Nodes, tmp.Text);
tn.Nodes.Insert(index, tmp);
@@ -873,8 +858,10 @@ namespace Volian.Controls.Library
else
{
tmp = new TreeNode(roc.title);
tmp.Tag = roc;
tmp = new TreeNode(roc.title)
{
Tag = roc
};
if (tmp.Text.IndexOf("\\u") > -1) // RO Editor add symbols C2022 - 003
{
@@ -909,7 +896,7 @@ namespace Volian.Controls.Library
// Clean-up Roid if necessary
roid = ROFSTLookup.FormatRoidKey(roid);
bool multValSel = (roid.Length == 16) ? true : false;
bool multValSel = (roid.Length == 16);
string db = roid.Substring(0, 4);
int dbiID = MyROFSTLookup.GetRODatabaseTitleIndex(roid);
@@ -938,7 +925,7 @@ namespace Volian.Controls.Library
if (roid.StartsWith("FFFF"))
dbNode = tvROFST.Nodes.Cast<TreeNode>().Where(x => (x.Tag.Equals(null)) && (x.Text.Equals("Unit Information"))).FirstOrDefault();
else
dbNode = tvROFST.Nodes.Cast<TreeNode>().Where(x => (x.Tag is ROFSTLookup.rodbi) && ((ROFSTLookup.rodbi)x.Tag).dbiID == dbiID).FirstOrDefault();
dbNode = tvROFST.Nodes.Cast<TreeNode>().Where(x => (x.Tag is ROFSTLookup.rodbi rodbi) && rodbi.dbiID == dbiID).FirstOrDefault();
if (dbNode != null)
{
@@ -954,7 +941,7 @@ namespace Volian.Controls.Library
LoadChildren(tnExpand);
tnExpand.Expand();
TreeNode chldNode = tnExpand.Nodes.Cast<TreeNode>().Where(x => (x.Tag is ROFSTLookup.rochild) && ((ROFSTLookup.rochild)x.Tag).ID == citm).FirstOrDefault();
TreeNode chldNode = tnExpand.Nodes.Cast<TreeNode>().FirstOrDefault(x => (x.Tag is ROFSTLookup.rochild rochild) && rochild.ID == citm);
if (chldNode != null)
{
tnExpand = chldNode;
@@ -1006,10 +993,9 @@ namespace Volian.Controls.Library
Object obj = tvROFST.SelectedNode.Tag;
if (obj is ROFSTLookup.rochild)
if (obj is ROFSTLookup.rochild roc)
{
ROFSTLookup.rochild roc = (ROFSTLookup.rochild)obj;
DisplayTabItem dti = TabControl.SelectedDisplayTabItem; //.OpenItem(_ItemInfo); // open the corresponding procedure text
DisplayTabItem dti = TabControl.SelectedDisplayTabItem;
if (dti.MyDSOTabPanel != null) // A Word Document tab is the active tab
{
@@ -1017,10 +1003,7 @@ namespace Volian.Controls.Library
// Insert the RO text at the current cursor position in the word document
// NOTE: assuming any type of RO can be put in an Accessory (MSWord) Document
if (dti.MyDSOTabPanel != null)
{
dti.MyDSOTabPanel.InsertText(accPageID);
}
dti.MyDSOTabPanel?.InsertText(accPageID);
}
else if (MyRTB != null) // a Procedure Steps section tab is active
{
@@ -1122,12 +1105,9 @@ namespace Volian.Controls.Library
string roapp = Volian.Base.Library.ExeInfo.GetROEditorPath(); // get the path to the RO Editor Executable
Object obj = tvROFST.SelectedNode.Tag;
if (obj is ROFSTLookup.rochild)
if (obj is ROFSTLookup.rochild roc)
{
ROFSTLookup.rochild roc = (ROFSTLookup.rochild)obj;
_selectedRoidBeforeRoEditor = roc.roid;
string args = "\"" + _myROFST.MyRODb.FolderPath + "\" " + roc.roid.ToLower();
string args = $"\"{_myROFST.MyRODb.FolderPath}\" {roc.roid.ToLower()}";
if (!Directory.Exists(_myROFST.MyRODb.FolderPath))
{
@@ -1136,7 +1116,7 @@ namespace Volian.Controls.Library
}
// C2017-003: ro data in sql server, check for sql connection string
if (_myROFST.MyRODb.DBConnectionString != "cstring") args = args + " \"" + _myROFST.MyRODb.DBConnectionString + "\"";
if (_myROFST.MyRODb.DBConnectionString != "cstring") args = $"{args} \"{_myROFST.MyRODb.DBConnectionString}\"";
// C2021-026 pass in Parent/Child information (list of the children)
// B2022-019 look at all DocVersions to find ParentChild information
@@ -1150,7 +1130,7 @@ namespace Volian.Controls.Library
if (jdvc != null && jdvc.Unit_Name != "" && jdvc.Unit_Count > 1) // B2021-089 only pass in applicability info if defined for more than one unit
{
args += " \"PC=" + jdvc.Unit_Name + "\"";
args += $" \"PC={jdvc.Unit_Name}\"";
break;
}
}
@@ -1194,7 +1174,6 @@ namespace Volian.Controls.Library
lbFound.DataSource = null;
lbFound.Visible = false;
_lastSearchValue = searchValue;
}
else if (searchValue.Contains("#Link:ReferencedObject")) // RO Link (roid)
{
@@ -1216,7 +1195,6 @@ namespace Volian.Controls.Library
lbFound.DataSource = null;
lbFound.Visible = false;
_lastSearchValue = searchValue;
}
else // if (searchValue != _lastSearchValue)
{
@@ -1245,12 +1223,10 @@ namespace Volian.Controls.Library
lbFound.Visible = false;
}
_lastSearchValue = searchValue;
}
}
else
{
_lastSearchValue = string.Empty;
lbFound.DataSource = null;
lbFound.Visible = false;
}