From 0dd4889e5c6903b847d087edca5c822593e022d7 Mon Sep 17 00:00:00 2001 From: Kathy Date: Wed, 14 Jul 2021 15:27:56 +0000 Subject: [PATCH] B2021-066: Procedure Level PC/PC in tree view --- PROMS/VEPROMS User Interface/frmVEPROMS.cs | 1 + .../frmVersionsProperties.cs | 2 + .../VEPROMS.CSLA.Library/Config/ProcConfig.cs | 6 ++ .../Extension/DocVersionExt.cs | 87 +++++++++++++++++++ .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 14 ++- PROMS/Volian.Controls.Library/vlnTreeView.cs | 20 ++++- .../Volian.Print.Library/VlnSvgPageHelper.cs | 2 + 7 files changed, 130 insertions(+), 2 deletions(-) diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 5a6eecf5..e6f017d4 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -2850,6 +2850,7 @@ namespace VEPROMS toolsPanel.Expanded = true; toolsTabs.SelectedTab = toolstabResults; } + if (frmver._refreshProcedureList) tv.RefreshDocVersion(); //B2021-066: Refresh Procedure Numbers if Working Draft (docversion) applicability change MySessionInfo.CheckInItem(ownerID); } else if (args.ProcedureConfig != null) diff --git a/PROMS/VEPROMS User Interface/frmVersionsProperties.cs b/PROMS/VEPROMS User Interface/frmVersionsProperties.cs index 909046f1..0a16b657 100644 --- a/PROMS/VEPROMS User Interface/frmVersionsProperties.cs +++ b/PROMS/VEPROMS User Interface/frmVersionsProperties.cs @@ -255,6 +255,7 @@ namespace VEPROMS Settings.Default.Save(); DialogResult = DialogResult.OK; _DocVersionConfig.MyDocVersion.Config = _DocVersionConfig.ToString(); + _refreshProcedureList = true; _DocVersionConfig.MyDocVersion.Save().Dispose(); if (_EnhNeedToUnlink) { @@ -1509,6 +1510,7 @@ namespace VEPROMS lbApplicabilities.SelectedItem = cfg; } public bool _showApplicSearchResults = false; + public bool _refreshProcedureList = false; private bool ApplicIsUsed(MiniConfig cfg) // B2017-230 - don't allow user to remove an applicability that is being used (specified) { if (_showApplicSearchResults) diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs index a9f4d6af..65c45fa9 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs @@ -162,6 +162,12 @@ namespace VEPROMS.CSLA.Library { _Xp[group, item] = newvalue; } + public int GetItemId() + { + if (_Procedure != null) return _Procedure.ItemID; + if (_ProcedureInfo != null) return _ProcedureInfo.ItemID; + return -1; + } #endregion #region Local Properties [Category("General")] diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs index ae838900..0d391bbd 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs @@ -17,6 +17,7 @@ using System.Collections.Generic; using System.IO; using System.Threading; using System.Xml; +using System.Text.RegularExpressions; //using VEPROMS.Properties; namespace VEPROMS.CSLA.Library @@ -387,7 +388,93 @@ namespace VEPROMS.CSLA.Library return buff; } + // B2021-066: Procedure PC/PC resolve procedure number with Unit Specific info + public string UnitSpecific(string str, int len, ItemInfo ii) + { + ProcedureInfo pi = ii as ProcedureInfo; + if (pi == null) return ""; + string unitdes = "ID"; + string prefix = null; + string fromunitdes = null; + str = ItemInfo.ConvertToDisplayText(pi.MyContent.Number); + bool hastoken = false; + // Determine if there is a token in the procedure number data, default is ID + if (str.ToUpper().Contains(@" -1) + { + try + { + int sindx = str.ToUpper().IndexOf(@"", sindx + 1); + unitdes = str.Substring(sindx + 3, eindx - (sindx + 3)); + unitdes = unitdes.ToUpper(); + } + catch + { + unitdes = "ID"; + } + } + } + if (unitdes == "NUMBER") + fromunitdes = DocVersionConfig.Unit_Number; + else if (unitdes == "ID") + fromunitdes = DocVersionConfig.Unit_ID; + else if (unitdes == "NAME") + fromunitdes = DocVersionConfig.Unit_Name; + else if (unitdes == "TEXT") + fromunitdes = DocVersionConfig.Unit_Text; + else + fromunitdes = DocVersionConfig.Unit_ID; + + // adjustments to the procedure number for applicability can be defined in 2 places: + // 1) mstr below: working draft properties/Applicability/Procedure number field for each unit can have text. The '#' in this + // field represents the procdure number & any text prefixing it, will be used to prefix the procedure number + // 2) fromunitdes above: this is defined on the procedure number, seen on procedure properties, and is a token with + // optional '-xxx' after the U, see above for possible tokens. + string mstr = (MyConfig as DocVersionConfig).Unit_ProcedureNumber; + string[] units = mstr.Split(",".ToCharArray()); + string[] fromdata = fromunitdes.Split(",".ToCharArray()); + // SelectedSlave is > 0 if a unit has been selected, for example from print or approve. It represents that index into + // the list of units. + if (DocVersionConfig.SelectedSlave > 0) + { + prefix = units[0].Replace("#", ""); + if (str.ToUpper().IndexOf(@" -1) return prefix + Regex.Replace(str, @"\<[uU]-[a-zA-Z]+\>", fromunitdes); + return prefix + Regex.Replace(str, @"\<[uU]\>", fromunitdes); + } + + // The following code is used to handle the treeview/tree node representation of the procedure number with any appropriate + // unit specifications resolved, as follows: + // 1) [] (square brackets) are placed around any prefixes determined from the token or the Procedure Number data on + // the working draft properties. If None, i.e. no units, are applicable, as selected from the Step Properties/Applicability tab. + // there will be no text between the brackets to represent no applicability + // 2) , (commas) are used as a delimeter. Only have 1 comma separating the prefix, there may be no text if some units are + // not applicable, but code exists here so that ',,,' does not appear in the treenode + // 3) don't duplicate resolved text, for example if NUMBER is used, and prefix text would be '[A,A,B,C,C]', only show '[A,B,C]' + + bool sometext = false; // flag to use since don't want ',,,,,' before number + List prefs = new List(); + for (int i = 1; i <= UnitNames.Length; i++) + { + bool procAppl = pi.ApplInclude(i); + string tokRepAndPrefix = units[i - 1].Replace("#", "") + (hastoken ? fromdata[i - 1] : ""); + if (tokRepAndPrefix != "") + { + sometext = true; + if (prefs.Count > 0 && prefs.Contains(tokRepAndPrefix)) + tokRepAndPrefix = ""; + else + if (procAppl) prefs.Add(tokRepAndPrefix); + } + if (procAppl && tokRepAndPrefix != "") prefix = prefix + (prefix == null ? tokRepAndPrefix : (prefix != null && prefix.Length > 0 && prefix[prefix.Length - 1] != ',' ? "," : "") + tokRepAndPrefix); + } + str = Regex.Replace(str, @"\<[uU]-[a-zA-Z]+\>", ""); + str = Regex.Replace(str, @"\<[uU]\>", ""); + return (!sometext) ? str: "[" + prefix + "]" + str; + } public string UnitSpecific(string str, int len) { diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 913662be..476d2daf 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -2875,7 +2875,18 @@ namespace VEPROMS.CSLA.Library string str = MyContent.Number; if (MyDocVersion != null) { - str = (this.IsProcedure) ? MyDocVersion.UnitSpecific(MyContent.Number, 0) : MyContent.Number; + // call to UnitSpecific 0 is all, need what is applicable + if (IsProcedure) + { + // B2021-066: show Procedure level applicability in tree view + if (ActiveFormat.PlantFormat.FormatData.ProcData.ProcAppl) + str = MyDocVersion.UnitSpecific(MyContent.Number, 1, this); + else + str = MyDocVersion.UnitSpecific(MyContent.Number, 1); + + } + else + str = MyContent.Number; str = Regex.Replace(str, @"\", MyDocVersion.DocVersionConfig.Unit_ID, RegexOptions.IgnoreCase); str = Regex.Replace(str, @"\", MyDocVersion.DocVersionConfig.Unit_ID, RegexOptions.IgnoreCase); } @@ -6917,6 +6928,7 @@ namespace VEPROMS.CSLA.Library { if (ActiveFormat.PlantFormat.FormatData.ProcData.ProcAppl) { + MyConfig = null; // force refresh ProcedureConfig cfg = MyConfig as ProcedureConfig; return (cfg.MasterSlave_Applicability.GetFlags().Count == 0 || cfg.MasterSlave_Applicability.GetFlags().Contains(ApplicabilityIndex)); } diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index f7c27750..30111f27 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -3975,7 +3975,25 @@ namespace Volian.Controls.Library Console.WriteLine("vlntreeview:refreshrelatednote:end"); return child; } - + // B2021-066: refresh the procedure numbers within Working Draft (docversion) for applicability changed + public void RefreshDocVersion() + { + VETreeNode vetn = SelectedNode as VETreeNode; + if (vetn != null) + { + DocVersionInfo dvi = vetn.VEObject as DocVersionInfo; + if (dvi != null) + { + if (SelectedNode.Nodes != null && SelectedNode.Nodes.Count > 0 && SelectedNode.Nodes[0] is VETreeNode) + { + foreach (VETreeNode tn in SelectedNode.Nodes) + { + tn.RefreshNode(); + } + } + } + } + } private VETreeNode GetChildNode(IVEDrillDownReadOnly selectedItem, VETreeNode parent) { foreach (TreeNode childNode in parent.Nodes) diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index baf99a26..be40a9bb 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -1759,6 +1759,8 @@ i = 0; eopnum = unitnum.Replace("!", unitname); if (eopnum == string.Empty) eopnum = section.MyProcedure.MyContent.Number; + // B2021-066: found and fixed during proc pc/pc work + if (eopnum.ToUpper().Contains(@"