B2022-083: Support Conditional RO Values

This commit is contained in:
Jake
2022-07-26 20:01:25 +00:00
parent 439cf9de7a
commit d327ab08af
16 changed files with 2670 additions and 1743 deletions

View File

@@ -81,7 +81,7 @@ namespace Volian.Controls.Library
public bool RoTreeNeedsReloaded
{
get { return (MyROFST != null && _currRofstID != null && MyROFST.ROFstID != (int)_currRofstID) || (MyDvi != null && _currDocVersionID != null && MyDvi.VersionID != (int)_currDocVersionID) ; }
get { return (MyROFST != null && _currRofstID != null && MyROFST.ROFstID != (int)_currRofstID) || (MyDvi != null && _currDocVersionID != null && MyDvi.VersionID != (int)_currDocVersionID); }
}
public ROFstInfo MyROFST
@@ -110,7 +110,7 @@ namespace Volian.Controls.Library
if (!_isInitializedRofstID && IsRofstValid)
{
_currRofstID = (IsRofstValid) ? (int?)_myROFST.RODbID : null;
_currRofstID = (IsRofstValid) ? (int?)_myROFST.ROFstID : null;
}
}
}
@@ -142,15 +142,7 @@ namespace Volian.Controls.Library
public E_ROValueType ROTypeFilter
{
get { return _roTypeFilter; }
set
{
_roTypeFilter = value;
//if (!Visible) return; // don't reset anything if the form is invisible.
//_roTypeFilter = value;
// LoadTree();
}
set {_roTypeFilter = value; }
}
public RoUsageInfo CurROLink
@@ -188,13 +180,6 @@ namespace Volian.Controls.Library
get { return _myRTB; }
set
{
//if (_myRTB != null)
//{
// MyRTB.LinkChanged -= new StepRTBLinkEvent(MyRTB_LinkChanged);
// MyRTB.SelectionChanged -= new EventHandler(MyRTB_SelectionChanged);
//}
if (value == null)
{
_myRTB = value;
@@ -318,11 +303,6 @@ namespace Volian.Controls.Library
_searchTimer.Stop();
_searchTimer.Start();
//if (!string.IsNullOrEmpty(MyRTB.SelectedText))
//{
// _searchTimer.Start();
//}
_timeActivity.Close();
}
@@ -373,25 +353,24 @@ namespace Volian.Controls.Library
if (chld.value != null)
{
RoUsageInfo SavROLink = null;
if (_savCurROLink != null) SavROLink = _savCurROLink;
lbROId.Text = chld.appid;
// Allow the user to select a different return value.
string childroid = string.Format("{0}{1}", chld.roid.ToLower(), "0000").Substring(0, 16);
string childroid = ROFSTLookup.FormatRoidKey(chld.roid, true);
//B2017-245 Disable SaveRO button for Procedures and Sections
//B2020-049: Save button not enabled on Word docs, only if a procedure was opened first and immediately after the word document
// section is opened (added 'IsInWorDoc')
btnSaveRO.Enabled = (IsInWordDoc || (!IsNotStep && !IsEnhancedStep)) && UserInfo.CanEdit(MyUserInfo, MyDvi) && ((_savCurROLink == null) || !(childroid.Equals(SavROLink.ROID.ToLower()))); //added security check (UserInfo.CanEdit)
btnCancelRO.Enabled = (_savCurROLink != null && childroid != SavROLink.ROID.ToLower());
btnSaveRO.Enabled = (IsInWordDoc || (!IsNotStep && !IsEnhancedStep)) && UserInfo.CanEdit(MyUserInfo, MyDvi) && ((SavROLink == null) || !(childroid.Equals(SavROLink.ROID.ToUpper()))); //added security check (UserInfo.CanEdit)
btnCancelRO.Enabled = (_savCurROLink != null && (SavROLink != null && childroid != SavROLink.ROID.ToUpper()));
btnGoToRO.Enabled = UserInfo.CanEditROs(MyUserInfo, MyDvi); // Writers and Reviewers cannot edit ROs (run the RO Editor)
switch (chld.type)
{
case 1: // standard (regular) text RO type
string roval = chld.value.Replace(@"\u160?", " ");
roval = GetPCDefaultValue(roval); // C2021-026 get the default RO value from P/C RO value information
tbROValue.Text = roval;
tbROValue.Text = chld.value;
btnPreviewRO.Enabled = false;
if (chld.roid.StartsWith("FFFF")) btnGoToRO.Enabled = false;
break;
@@ -530,7 +509,7 @@ namespace Volian.Controls.Library
ROFSTLookup.rochild roch = (ROFSTLookup.rochild)obj;
_selectedRoidBeforeRoEditor = roch.roid;
string args = "\"" + MyROFST.MyRODb.FolderPath + "\" " + roch.roid.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 + "\"";
@@ -574,8 +553,6 @@ namespace Volian.Controls.Library
{
if (MyROFST == null)
{
//_curROFST = null;
//_curROFSTLookup = null;
tvROFST.Nodes.Clear();
lbFound.Visible = false;
return;
@@ -599,6 +576,7 @@ namespace Volian.Controls.Library
_currRofstID = (int?)MyROFST.ROFstID;
_currDocVersionID = null;
if(_docVersionInfo != null) _currDocVersionID = (int?)_docVersionInfo.VersionID;
}
@@ -610,30 +588,39 @@ namespace Volian.Controls.Library
if (unitInfoNode == null)
{
TreeNode tnn = tvROFST.Nodes.Add("Unit Information");
TreeNode cn = null;
ROFSTLookup.rochild roc = MyROFSTLookup.GetRoChild("FFFF00000001");
cn = tnn.Nodes.Add(roc.title);
cn.Tag = roc;
TreeNode cn = tnn.Nodes.Add("Number");
cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000001");
roc = MyROFSTLookup.GetRoChild("FFFF00000002");
cn = tnn.Nodes.Add(roc.title);
cn.Tag = roc;
cn = tnn.Nodes.Add("Other Number");
cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000002");
roc = MyROFSTLookup.GetRoChild("FFFF00000003");
cn = tnn.Nodes.Add(roc.title);
cn.Tag = roc;
cn = tnn.Nodes.Add("Text");
cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000003");
roc = MyROFSTLookup.GetRoChild("FFFF00000004");
cn = tnn.Nodes.Add(roc.title);
cn.Tag = roc;
cn = tnn.Nodes.Add("Other Text");
cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000004");
roc = MyROFSTLookup.GetRoChild("FFFF00000005");
cn = tnn.Nodes.Add(roc.title);
cn.Tag = roc;
cn = tnn.Nodes.Add("ID");
cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000005");
roc = MyROFSTLookup.GetRoChild("FFFF00000006");
cn = tnn.Nodes.Add(roc.title);
cn.Tag = roc;
cn = tnn.Nodes.Add("Other ID");
cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000006");
roc = MyROFSTLookup.GetRoChild("FFFF00000007");
cn = tnn.Nodes.Add(roc.title);
cn.Tag = roc;
cn = tnn.Nodes.Add("Name");
cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000007");
cn = tnn.Nodes.Add("Other Name");
cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000008");
roc = MyROFSTLookup.GetRoChild("FFFF00000008");
cn = tnn.Nodes.Add(roc.title);
cn.Tag = roc;
}
}
else if (unitInfoNode != null) // Add Unit Information Database if it doesn't exist [Not Multi-Unit DocVersion]
@@ -644,61 +631,6 @@ namespace Volian.Controls.Library
_curROTypeFilter = _roTypeFilter;
//if (MyROFST != _curROFST || MyROFSTLookup != _curROFSTLookup || tvROFST.Nodes == null || tvROFST.Nodes.Count <= 0)
//{
// ROFSTLookup.rodbi[] dbs = MyROFSTLookup.GetRODatabaseList(true);
// for (int i = 0; i < dbs.Length; i++)
// {
// ROFSTLookup.rodbi db = dbs[i];
// TreeNode tn = new TreeNode(db.dbiTitle);
// tn.Tag = db;
// tvROFST.Nodes.Add(tn);
// AddDummyGroup(db, tn);
// }
//}
//var unitInfoNode = tvROFST.Nodes.Cast<TreeNode>().Where(x => x.Text == "Unit Information").FirstOrDefault();
//if ((ROTypeFilter == E_ROValueType.Text || ROTypeFilter == E_ROValueType.All) && this.MyDvi != null && this.MyDvi.MultiUnitCount > 1)
//{
// // Add Unit Information Database if it doesn't exist
// if (unitInfoNode == null)
// {
// TreeNode tnn = tvROFST.Nodes.Add("Unit Information");
// TreeNode cn = tnn.Nodes.Add("Number");
// cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000001");
// cn = tnn.Nodes.Add("Other Number");
// cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000002");
// cn = tnn.Nodes.Add("Text");
// cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000003");
// cn = tnn.Nodes.Add("Other Text");
// cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000004");
// cn = tnn.Nodes.Add("ID");
// cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000005");
// cn = tnn.Nodes.Add("Other ID");
// cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000006");
// cn = tnn.Nodes.Add("Name");
// cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000007");
// cn = tnn.Nodes.Add("Other Name");
// cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000008");
// }
//}
//else if (unitInfoNode != null) // Add Unit Information Database if it doesn't exist [Not Multi-Unit DocVersion]
//{
// tvROFST.Nodes.Remove(unitInfoNode);
//}
//_curROFST = _myROFST;
//_curROFSTLookup = _myROFSTLookup;
//_curROTypeFilter = _roTypeFilter;
@@ -732,7 +664,7 @@ namespace Volian.Controls.Library
#endregion
#region Private Methods?
#region Private Methods
private void LoadChildren(TreeNode tn)
{
@@ -760,15 +692,11 @@ namespace Volian.Controls.Library
// if children, add dummy node
if (children != null && children.Length > 0)
{
//ProgressBar_Initialize(children.Length, tn.Text);
for (int i = 0; i < children.Length; i++)
{
//ProgressBar_SetValue(i);
TreeNode tmp = null;
ROFSTLookup.rochild roc = children[i];
// if this is a group, i.e. type 0, add a dummy node
if (roc.type == 0 && !MyROFSTLookup.HasChildren(ref roc))
{
@@ -778,10 +706,20 @@ namespace Volian.Controls.Library
{
continue; // Ignore: Filter Doesn't Match
}
else if (roc.value == null)
else if (!string.IsNullOrEmpty(roc.appid))
{
MyROFSTLookup.LoadChildren(ref roc);
if (roc.children.Length == 1 && roc.children.First().roid.Length == 16)
{
roc.appid = roc.children.First().appid;
roc.roid = roc.children.First().roid;
roc.value = roc.children.First().value;
}
}
if (roc.value == null)
{
tmp = new TreeNode(roc.title);
tmp.Tag = roc;
@@ -793,9 +731,7 @@ namespace Volian.Controls.Library
}
else
{
string ntitle = roc.title.Replace(@"\u160?", " ");
ntitle = GetPCDefaultValue(ntitle); // C2021-026 get the default RO value from P/C RO value information
tmp = new TreeNode(ntitle);
tmp = new TreeNode(roc.title);
tmp.Tag = roc;
if (roc.roid.Length == 16)
@@ -810,8 +746,6 @@ namespace Volian.Controls.Library
}
}
}
//ProgressBar_Clear();
}
private void AddDummyGroup(ROFSTLookup.rodbi rodbi, TreeNode tn)
@@ -825,17 +759,20 @@ namespace Volian.Controls.Library
private void ExpandNode(string roid)
{
// Clean-up Roid if necessary
roid = ROFSTLookup.FormatRoidKey(roid);
bool multValSel = (roid.Length == 16) ? true : false;
string db = roid.Substring(0, 4);
int dbiID = MyROFSTLookup.GetRODatabaseTitleIndex(roid);
bool multValSel = (roid.Length == 16) ? true : false;
ROFSTLookup.rochild rochld = MyROFSTLookup.GetRoChild(roid.Substring(0, 12).ToUpper());
// use this to walk up tree until database - this is used to expand tree.
List<int> path = new List<int>();
int myid = rochld.ID;
while (myid > 0)
while (myid >= 0)
{
path.Insert(0, myid);
myid = rochld.ParentID;
@@ -849,7 +786,13 @@ namespace Volian.Controls.Library
//Find Database Node First
TreeNode dbNode = tvROFST.Nodes.Cast<TreeNode>().Where(x => (x.Tag is ROFSTLookup.rodbi) && ((ROFSTLookup.rodbi)x.Tag).dbiID == dbiID).FirstOrDefault();
TreeNode dbNode = null;
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();
if (dbNode != null)
{
LoadChildren(dbNode);
@@ -891,30 +834,6 @@ namespace Volian.Controls.Library
tvROFST.SelectedNode = tnExpand;
}
private string GetPCDefaultValue(string roval)
{
// C2021-026 Get the Parent (Default) RO value if the return value include P/C information
// otherwise return the RO value as is.
// This is used for the insert RO interface on the Step Properties panel
string rntval = roval;
while (rntval.Contains("<APL DefaultVal=")) // C2021-026 remove Parent/Child values for the menu item text
{
int startCVIdx = rntval.IndexOf("<APL DefaultVal=");
int EndCVidx = rntval.IndexOf(" /APL>", startCVIdx);
string aplicValues = rntval.Substring(startCVIdx, EndCVidx + 6 - startCVIdx);
int endDefIdx = rntval.IndexOf(",", startCVIdx);
// C2022-001 - handle if there is no child value in the RO FSt
// B2022-051 - was sometimes leaving "/APL>" when processing return value made up from multiple RO (editor) fields
// added check to make where next found comma was within the current <APL ... /APL>
string defValue = rntval.Substring(startCVIdx + 16, ((endDefIdx > 0 && endDefIdx < EndCVidx) ? endDefIdx : EndCVidx) - (startCVIdx + 16));
rntval = rntval.Replace(aplicValues, defValue);
}
return rntval;
}
private int FindIndex(TreeNodeCollection nodes, string value)
{
int index = 0;
@@ -947,47 +866,22 @@ namespace Volian.Controls.Library
if (dti.MyDSOTabPanel != null) // A Word Document tab is the active tab
{
string AccPageID = string.Empty;
if (roc.roid.StartsWith("FFFF"))
{
AccPageID = "<" + roc.appid + ">";
}
else
{
int dbiID = MyROFSTLookup.GetRODatabaseTitleIndex(roc.roid);
ROFSTLookup.rodbi db = MyROFSTLookup.GetRODatabase(roc.roid, true, false);
if (db.dbiID == dbiID)
{
string accPrefix = db.dbiAP.Replace(MyDvi.DocVersionConfig.RODefaults_graphicsprefix, "IG");
accPrefix = accPrefix.Replace(MyDvi.DocVersionConfig.RODefaults_setpointprefix, "SP");
string suffix = (roc.roid.Length == 12 || roc.roid.Substring(12, 4) == "0041") ? string.Empty : "." + ((char)Convert.ToInt32(roc.roid.Substring(12, 4), 16)).ToString();
AccPageID = string.Format("<{0}-{1}{2}>", accPrefix, roc.appid, suffix);// makes <SP1-A.1.B> for example
}
else
{
FlexibleMessageBox.Show("Error occurred finding RO. Contact Volian");
return;
}
}
string accPageID = string.Format("<{0}>", roc.appid);
// 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
{
if (CheckROSelection(roc)) // check for RO type is valid for this type of step/substep
{
// the roid may be 12 or 16 chars long, with the last 4 set if there is unit specific
// menuing. Pad to 12 to store in the rousage table.
string padroid = (roc.roid.Length <= 12) ? roc.roid + "0000" : roc.roid;
// the roid may be 12 or 16 chars long, with the last 4 set if there is unit specific value
// Pad to 16 to store in the RoUsage table.
string padroid = ROFSTLookup.FormatRoidKey(roc.roid, true);
string linktxt = string.Format(@"#Link:ReferencedObject:<NewID> {0} {1}", padroid, MyROFST.RODbID);
// Resolve symbols and scientific notation in the RO return value
@@ -1133,7 +1027,7 @@ namespace Volian.Controls.Library
{
if (MyROFST != null && searchValue.Length >= 2)
{
dicRoVals = MyROFSTLookup.Search(searchValue, searchTypeID, MaxNumSearchRecords);
dicRoVals = MyROFSTLookup.Search(searchValue, searchTypeID, false, MaxNumSearchRecords);
}
if (dicRoVals != null && dicRoVals.Count > 0)

View File

@@ -715,13 +715,16 @@ namespace Volian.Controls.Library
get { return _MyLinkText; }
set
{
//if (value != _MyLinkText)
//{
// updates to the info panel were not always occurring when the previous two
// lines were active
if (value != _MyLinkText)
{
//updates to the info panel were not always occurring when the previous two lines were active
_MyLinkText = value;
OnLinkChanged(this, new StepPanelLinkEventArgs(_MyLinkText));
//}
}
else
{
_MyLinkText = value;
}
}
}
#endregion
@@ -1768,11 +1771,20 @@ namespace Volian.Controls.Library
DebugPrint("RS------ SelectionChange > {0}", FindRangeStatus());
if (SelectionLength > 0 && IsSelectionLinked(SelectionStart, SelectionLength))
{
if (SelectedText.IndexOf(@"[END>") > 0) MyLinkText = SelectedText.Substring(0, SelectedText.IndexOf(@"[END>"));
else MyLinkText = SelectedText;
if (SelectedText.IndexOf(@"[END>") > 0)
{
MyLinkText = SelectedText.Substring(0, SelectedText.IndexOf(@"[END>"));
}
else
{
MyLinkText = SelectedText;
}
}
else
{
MyLinkText = null;
}
OnRTBSelectionChanged(this, new EventArgs());
_LastWasLeftArrow = false;
}

View File

@@ -423,7 +423,8 @@ namespace Volian.Controls.Library
//}
#endregion
string accPageID = GetAccPageID(data);
ROFSTLookup.rochild? roc = MyLookup.GetRoChildByAccPagID(accPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
ROFSTLookup.rochild? roc = MyLookup.GetROChildByAccPageID(accPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
if (roc != null)
{
int index = GetROValueIndex(data);
@@ -449,7 +450,7 @@ namespace Volian.Controls.Library
for (int i = 1; i < 4; i++)
{
tmpAccPageID = accPageID + suffix + i.ToString();
roc = MyLookup.GetRoChildByAccPagID(tmpAccPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
roc = MyLookup.GetROChildByAccPageID(tmpAccPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
if (roc != null)
{
int index = GetROValueIndex(data);
@@ -460,12 +461,13 @@ namespace Volian.Controls.Library
}
}
}
//try LO1,2,3
suffix = "-LO";
for (int i = 1; i < 4; i++)
{
tmpAccPageID = accPageID + suffix + i.ToString();
roc = MyLookup.GetRoChildByAccPagID(tmpAccPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
roc = MyLookup.GetROChildByAccPageID(tmpAccPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
if (roc != null)
{
int index = GetROValueIndex(data);
@@ -481,6 +483,7 @@ namespace Volian.Controls.Library
}
return rv;
}
private string GetAccPageID(string txt)
{
//<MEL FWS-MP-02B \\n \\H>
@@ -491,11 +494,14 @@ namespace Volian.Controls.Library
txt = txt.Replace("<ARP ", "ARP-");
int i = txt.IndexOf(" ");
txt = txt.Substring(0, i);
return txt;
}
private int GetROValueIndex(string data)
{
int rv = -1;
if (data.StartsWith("<ARP"))
{
// arp children = \n alarm, \s value, \t type, \d description
@@ -510,7 +516,7 @@ namespace Volian.Controls.Library
else
rv = -1;
}
if (data.StartsWith("<MEL"))
else if (data.StartsWith("<MEL"))
{
//mel children = \n name, \d description, \r room
if (data.IndexOf(@"\n") > 0)
@@ -522,7 +528,7 @@ namespace Volian.Controls.Library
else
rv = -1;
}
if (data.StartsWith("<STP"))
else if (data.StartsWith("<STP"))
{
//stp children = \v value, \d description, \n id
if (data.IndexOf(@"\v") > 0)
@@ -534,8 +540,10 @@ namespace Volian.Controls.Library
else
rv = -1;
}
return rv;
}
private void SaveRO_Click(object sender, EventArgs e)
{
DevComponents.DotNetBar.BaseItem btn = sender as DevComponents.DotNetBar.BaseItem;
@@ -1252,10 +1260,12 @@ namespace Volian.Controls.Library
_MyLog.WarnFormat("Equation Editor executable could not be found.");
return retval;
}
private static string GetVisio() // Added support for Visio
{
string retval = _SpecifiedVisioPath; // use the Visio path specified by the user
if (retval != null && retval != "")
if (!string.IsNullOrEmpty(retval))
{
if (!retval.ToUpper().EndsWith(".EXE"))
retval += (retval.EndsWith("\\")) ? "visio.exe" : "\\visio.exe";
@@ -1265,7 +1275,8 @@ namespace Volian.Controls.Library
retval = null; // look in the registry
}
}
if (retval == null || retval == "")
if (!string.IsNullOrEmpty(retval))
{
try
{
@@ -1279,7 +1290,8 @@ namespace Volian.Controls.Library
_MyLog.WarnFormat("Visio was not found in the registry.");
}
}
return retval;
return retval;
}
private static string _EqnEdtPath = null;
public static string EqnEdtPath