B2022-083: Support Conditional RO Values (v2.1) [Part-2]

This commit is contained in:
Jake
2022-07-28 10:03:07 +00:00
parent bcbc52c774
commit 6dff9463ad
10 changed files with 2722 additions and 735 deletions

View File

@@ -353,11 +353,11 @@ namespace VEPROMS.CSLA.Library
if (!string.IsNullOrEmpty(rc.roid) && Regex.IsMatch(accPageKey, @".*\.[A-Z]") && rc.children != null && rc.children.Count() > 0)
{
// Check if AccPageID/Key has a return value specific extension. Try to find the RoChild record with the specific return value type,
// If not found then return the first/default return value type in the list of children
// If not found Or the specific extension value is (Null or Empty), then just return the first/default return value type in the list of children
var accPageExt = Convert.ToString(accPageKey.ToCharArray().LastOrDefault());
var roExt = Extensions.Where(x => x.AccPageExt.Equals(accPageExt)).SingleOrDefault();
return (rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Any()) ? rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Single() : rc.children.First();
return (rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt && !string.IsNullOrEmpty(x.value)).Any()) ? rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Single() : rc.children.First();
}
return rc; // If RoChild is not found, then a default (ROFSTLookup.rochild) object will be returned, but its ID will be -1
@@ -421,6 +421,7 @@ namespace VEPROMS.CSLA.Library
}
public string GetRoValue(string roid)
{
return GetRoChild(roid).value;
@@ -603,13 +604,11 @@ namespace VEPROMS.CSLA.Library
public void LoadChildren(ref ROFSTLookup.rochild child)
{
// If Children is null then it hasn't been loaded yet
//if (child.children == null || child.children.Length <= 0)
if (child.children == null)
{
if (!string.IsNullOrEmpty(child.appid))
child = GetRoChild12(child.roid, true);
else
//child.children = GetRoChildrenByRoid(child.roid, true);
child.children = GetRoChildrenByRoid(child.roid, false);
}
}
@@ -617,9 +616,7 @@ namespace VEPROMS.CSLA.Library
public void LoadChildren(ref ROFSTLookup.rodbi db)
{
// If Children is null then it hasn't been loaded yet
//if (child.children == null || child.children.Length <= 0)
if (db.children == null)
//db.children = GetRoChildrenByID(db.ID, db.dbiID, true);
db.children = GetRoChildrenByID(db.ID, db.dbiID, false);
}
@@ -1957,10 +1954,11 @@ namespace VEPROMS.CSLA.Library
if (!string.IsNullOrEmpty(roid))
{
rc.roid = FormatRoidKey(roid).Substring(0, 12);
DocVersionConfig dvc = (_myDocVersionInfo != null) ? _myDocVersionInfo.DocVersionConfig : null;
rc.roid = FormatRoidKey(roid).Substring(0, 12);
if (dvc != null) dvc.SelectedSlave = this.SelectedSlave;
switch (rc.roid)
{
case "FFFF00000001":

View File

@@ -410,12 +410,14 @@ namespace VEPROMS.CSLA.Library
public class DSOFile : IDisposable
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Fields
private bool _IsDisposed;
private DocumentInfo _MyDocument = null;
private FileInfo _MyFile = null;
private string _Extension = "DOC";
#endregion
#region Properties
public DocumentInfo MyDocument
{
@@ -438,6 +440,7 @@ namespace VEPROMS.CSLA.Library
set { _Extension = value; }
}
#endregion
#region Private Methods
private void TryDelete()
{
@@ -757,7 +760,7 @@ namespace VEPROMS.CSLA.Library
private static List<int> _MissingDocs = new List<int>();
private static bool _Automatic = false;
// [JAKE CODE]: Added an internal rochild dictionary cache specifically for printing
// B2022-083: Support Conditional RO Values --> Added an internal rochild dictionary cache specifically for printing
//
// As you loop through all of the specific RO AccPageKeys for the current MsWord Document Section, the code will first
// check the internal rochild cache for the base (12) digit roid Key/Value, if it doesn't already exist, then load the
@@ -825,11 +828,9 @@ namespace VEPROMS.CSLA.Library
set { MSWordToPDF._FormForPlotGraphics = value; }
}
/// <summary>
/// C2018-035 Don't use a MessageBox if in automatic (Baseline) testing mode.
/// </summary>
public static bool Automatic
{
// C2018-035 Don't use a MessageBox if in automatic (Baseline) testing mode.
get { return MSWordToPDF._Automatic; }
set { MSWordToPDF._Automatic = value; }
}
@@ -940,9 +941,11 @@ namespace VEPROMS.CSLA.Library
DocStyle myDocStyle = sect.MyDocStyle;
ProcedureInfo proc = sect.MyProcedure;
DocVersionInfo dvi = proc.ActiveParent as DocVersionInfo;
bool hasRos = false;
ROFstInfo rofst = null;
ROFSTLookup lookup = null;
string igPrefix = null;
string spPrefix = null;
bool convertCaretToDeltaSymbol = (sect.ActiveSection != null) ? sect.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta : false; // C2018-003 fixed use of getting the active section
@@ -1321,6 +1324,8 @@ namespace VEPROMS.CSLA.Library
}
lastStart = sel.Start;
sel = FindRO();
if (sel != null && !string.IsNullOrEmpty(sel.Text) && sel.Start == lastStart)
@@ -1371,16 +1376,16 @@ namespace VEPROMS.CSLA.Library
if (statusChange != null) statusChange(VolianStatusType.Complete, 0, string.Empty);
if (Volian.Base.Library.BaselineMetaFile.IsOpen && Volian.Base.Library.BaselineMetaFile.IncludeWordSecText) Volian.Base.Library.BaselineMetaFile.WriteLine("++EndTxt++");
//GC.Collect(); //jsj 2-15-2016 - for memory garbage collection
// [jpr 2022.07.26] - For memory optimization
//GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
//GC.Collect();
//jsj 2-15-2016 - for memory garbage collection
//GC.Collect();
return fileName;
}
}
private static ROFSTLookup.rochild GetCachedRoByAccPageID(ROFSTLookup lookup, string selText, string spPrefix, string igPrefix, bool convertCaretToDeltaSymbol)
{
string accPageBase = string.Empty;
@@ -1415,14 +1420,18 @@ namespace VEPROMS.CSLA.Library
return roc;
// All ROs should have a specific accPageExt or the default (A/0041), except for the "Unit Information" ("FFFF")
roc = (roc.children.Where(x => x.appid.EndsWith(accPageExt)).Any()) ? roc.children.Where(x => x.appid.EndsWith(accPageExt)).Single() : roc.children.First();
// All ROs at this point should have a specific accPageExt or the default (A/0041)
roc = (roc.children.Where(x => x.appid.EndsWith(accPageExt) && !string.IsNullOrEmpty(x.value)).Any()) ? roc.children.Where(x => x.appid.EndsWith(accPageExt)).Single() : roc.children.First();
// Check the RoType
roc.type = ((roc.type & 4) == 4 && roc.value.StartsWith("<<G")) ? 4 : roc.type;
// Check the RoValue
if (roc.type != 8 && !string.IsNullOrEmpty(roc.value)) // Exclude Images
if (string.IsNullOrEmpty(roc.value))
{
roc.value = null;
}
else if (roc.type != 8) // Exclude Images
{
roc.value = roc.value.Replace("`", "\xB0");
roc.value = roc.value.Replace("\xF8", "\xB0");
@@ -1437,59 +1446,6 @@ namespace VEPROMS.CSLA.Library
return ROFSTLookup.GetEmptyRoChild();
}
//if (roc.children != null && roc.children.Count() > 0)
//{
// roc = (roc.children.Where(x => x.appid.EndsWith(accPageExt)).Any()) ? roc.children.Where(x => x.appid.EndsWith(accPageExt)).Single() : roc.children.First();
// //roc = (roc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Any()) ? rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Single() : rc.children.First();
// // Convert.ToString(accPageKey.ToCharArray().LastOrDefault())
//}
//// All ROs should have a specific accPageExt, except for the "Unit Information" ("FFFF")
//// if (!string.IsNullOrEmpty(rc.roid) && Regex.IsMatch(accPageKey, @".*\.[A-Z]") && rc.children != null && rc.children.Count() > 0)
//if (!string.IsNullOrEmpty(accPageExt))
//{
// if (roc.children != null && roc.children.Count() > 0)
// {
// roc = (roc.children.Where(x => x.appid.EndsWith(accPageExt)).Any()) ? roc.children.Where(x => x.appid.EndsWith(accPageExt)).Single() : roc.children.First();
// //roc = (roc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Any()) ? rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Single() : rc.children.First();
// // Convert.ToString(accPageKey.ToCharArray().LastOrDefault())
// }
// // Get specific RO return value by Extension, if not exists then return default ("0041")
// // var roExt = lookup.Extensions.Where(x => x.AccPageExt.Equals(accPageExt)).SingleOrDefault();
//}
// var accPageExt = Convert.ToString(accPageKey.ToCharArray().LastOrDefault());
// Regex.IsMatch(accPageKey, @".*\.[A-Z]")
// Get the RoChild object once and cache it for any future calls to the same Ro while printing
//ROFSTLookup.rochild roc = lookup.GetROChildByAccPageID(sel.Text, spPrefix, igPrefix);
//if (!_roPrintCache.ContainsKey(accPageKey))
// _roPrintCache.Add(accPageKey, roc);
//// Check the RoType
//int roType = roType = ((roc.type & 4) == 4 && roc.value.StartsWith("<<G")) ? 4 : roc.type;
//// If multiple return values includes X-Y Plot, check to see if it is an X-Y Plot
////string roValue = (roc.value == null) ? lookup.GetUnitInfoTagValue(sel.Text.ToUpper()) : roc.value;
//string roValue = roc.value;
//if (roType != 8 && !string.IsNullOrEmpty(roValue)) // Exclude Images
//{
// roValue = roValue.Replace("`", "\xB0");
// roValue = roValue.Replace("\xF8", "\xB0");
// roValue = roValue.Replace("\x7F", "\x394"); //delta
// if (convertCaretToDeltaSymbol) roValue = roValue.Replace("^", "\x394"); // delta
//}
}
public static RectangleF CreatePlot(string pngFile, string xyPlot, float resolution, System.Windows.Forms.Form myForm)
@@ -1757,14 +1713,6 @@ namespace VEPROMS.CSLA.Library
}
}
//public static void CloseApp()
//{
// // WaitMS(900);// This was added because MSWord will sometimes get the following error: [Microsoft Office Word has stopped working]
// // It appears that this is caused by quitting the MS Word application to soon after closing the document or doing an export.
// MyApp.Quit(false);
// _MyApp = null;
//}
/// <summary>
/// This closes the MS Word Application, but, delays for about 1 second.
/// It appears that closing MSWord to quickly causes a:
@@ -1781,16 +1729,6 @@ namespace VEPROMS.CSLA.Library
#region Private Methods
//private static void WaitMS(int n)
//{
// DateTime dtw = DateTime.Now.AddMilliseconds(n);
// while (DateTime.Now < dtw)
// {
// System.Windows.Forms.Application.DoEvents();
// }
//}
private static void CloseDocument()
{
int attempts = 0;
@@ -1800,7 +1738,7 @@ namespace VEPROMS.CSLA.Library
System.Windows.Forms.Application.DoEvents();
if (TryToClose(attempts)) return;
System.Threading.Thread.Sleep(1000);
System.Threading.Thread.Sleep(500);
//WaitMS(1000);
}
}
@@ -1829,13 +1767,13 @@ namespace VEPROMS.CSLA.Library
private static void InsertROValue(LBSelection sel, string roValue, bool upRoIfPrevUpper, float indent, bool convertUnderline)
{
if (roValue == null)
if (string.IsNullOrEmpty(roValue))
{
string orgtext = sel.Text;
sel.Text = string.Format("RO ({0}) Not Found", orgtext.Replace("<", string.Empty).Replace(">", string.Empty));
sel.Font.Color = LBWdColor.wdColorRed;
}
else if (roValue != string.Empty)
else // RO has a value
{
if (upRoIfPrevUpper && sel.LastWasUpper) roValue = roValue.ToUpper();
@@ -2167,11 +2105,16 @@ namespace VEPROMS.CSLA.Library
private class CloseWordApp : System.Windows.Forms.Timer
{
#region Fields
// B2019-161 When tracking timing time this action
private static VolianTimer _TimeActivity = new VolianTimer("DocumentExt.cs CloseWordApp_Tick", 1548);
LBApplicationClass _MyApp;
#endregion
#region Constructor
public LBApplicationClass MyApp
{
@@ -2179,6 +2122,9 @@ namespace VEPROMS.CSLA.Library
set { _MyApp = value; }
}
#endregion
#region Public Methods
public CloseWordApp(LBApplicationClass myApp, int interval)
{
@@ -2188,6 +2134,10 @@ namespace VEPROMS.CSLA.Library
Enabled = true;
}
#endregion
#region Private Methods
private void CloseWordApp_Tick(object sender, EventArgs e)
{
_TimeActivity.Open();
@@ -2205,6 +2155,8 @@ namespace VEPROMS.CSLA.Library
Dispose();
_TimeActivity.Close();
}
#endregion
}
#endregion