diff --git a/PROMS/DataLoader/PROMSFixes.Sql b/PROMS/DataLoader/PROMSFixes.Sql index dc88e401..48859d35 100644 --- a/PROMS/DataLoader/PROMSFixes.Sql +++ b/PROMS/DataLoader/PROMSFixes.Sql @@ -21026,6 +21026,235 @@ GO ========================================================================================================== */ + +/* +========================================================================================================== + Start: B2022-088: [JPR] Find Doc Ro button not working in Word Sections + B2022-098: [JPR] ROs not being resolved in Word Sections +========================================================================================================== +*/ + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildByAccPageID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetChildByAccPageID]; +GO + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +/***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. +*****************************************************************************/ +/* +========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2022 + Description: Check if the AccPageID passed in has a specific Return Value Type Extension (.A, .B, .C, etc.) + If so, then strip off the return value specific extension to get the BaseAccPageID for the lookup. + Use the BaseAccPageID to lookup the BaseRoid, then use the Roid to lookup the Ro Child Object + + Note** Using the AccPageID to first lookup the roid, then using the roid to lookup the data is + significantly faster than directly looking up the data using the AccPageID because of the indexes +========================================================================================================== + */ +Create Procedure [dbo].[vesp_RofstDataGetChildByAccPageID] +( + @RofstID int, + @AccPageID VarChar(50) +) +With Execute as Owner +As +Begin + + Declare @BaseAccPageID VarChar(Max); + Declare @BaseRoid VarChar(Max); + + -- Check if AccPageID has a valid extension + If ((PatIndex('%.[A-Z]', @AccPageID) > 0) And ((Select Count(1) From vwRofstData_RofstBaseRoids Where BaseAccPageID = @AccPageID) <= 0)) + Set @BaseAccPageID = Left(@AccPageID, Len(@AccPageID)-2); + Else + Set @BaseAccPageID = @AccPageID; + + -- Use the AccPageID to get the BaseRoid + Select @BaseRoid = rb.BaseRoid + From vwRofstData_RofstBaseRoids rb + Where rb.RofstID = @RofstID + And rb.BaseAccPageID = @BaseAccPageID; + + -- Then use the BaseRoid to lookup the Ro Child Object + Select rc.ROFstID, + rc.dbiID, + rc.ID, + rc.ParentID, + rc.[type], + rc.title, + rc.roid, + rc.appid, + rc.[value], + rc.AccPageID + From vwRofstData_RofstChildren rc + Where rc.RofstID = @RofstID? + And rc.roid = @BaseRoid; + + Return; +End +GO + + +IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetChildByAccPageID] Succeeded' +ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetChildByAccPageID] Error on Creation' +GO + + + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetBaseAccPageKeys]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetBaseAccPageKeys]; +GO + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +/*****************************************************************************? + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. +*****************************************************************************/ +/* +========================================================================================================== + Author: Jake Ropar + Create Date: 08/11/2022 + Description: Gets all the Base AccPageKeys that end with a "." period followed by an Alpha Character (A through Z) +========================================================================================================== + */ +Create Procedure [dbo].[vesp_RofstDataGetBaseAccPageKeys] +( + @RofstID int +) +With Execute as Owner +As +Begin + + Select BaseAccPageID + From vwRofstData_RofstBaseRoids + Where BaseAccPageID like '%.[A-Z]'; + + Return; +End +GO + + +IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetBaseAccPageKeys] Succeeded' +ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetBaseAccPageKeys] Error on Creation' +GO + + + + + +If Exists(Select * From sys.objects Where type = 'FN' And object_id = OBJECT_ID('[dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults]')) + Drop Function [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults]; + + + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 06/21/2022 +-- Description: Replaces any legacy applicability tags with the default value +-- ========================================================================================== + +CREATE FUNCTION [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults](@Values VarChar(Max)) Returns VarChar(Max) +WITH EXECUTE AS OWNER +AS +BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @DefaultValue VarChar(Max) = ''; + + Declare @StartTagIndex Int; + Declare @EndTagIndex Int; + Declare @StartTagValue VarChar(Max); + Declare @StartValIndex Int; + Declare @EndValIndex Int; + + Declare @TagName VarChar(Max); + Declare @LegacyTagNames VarChar(Max) = 'U-ID,U-NUMBER,U-NAME,U-TEXT,U-OTHERID,U-OTHERNUMBER,U-OTHERNAME,U-OTHERTEXT'; + + -- Make Sure all tag instances are upper case & Remove any internal spaces + Set @RetVal = dbo.vefn_RofstDataCleanUnitInfoTags(@Values, 0); + + -- Remove any instances of double "}" that have a spaces between them ex: "} }" + Set @RetVal = Replace(@RetVal, '} }', '}}'); + + Declare LegacyTags_Cursor Cursor Fast_Forward For + Select '{' + x.ListValue + '{' as 'TagName' + From [dbo].[vefn_ParseStringListToTable](@LegacyTagNames, ',') x + + Open LegacyTags_Cursor + + Fetch Next From LegacyTags_Cursor Into @TagName + + While (@@FETCH_STATUS = 0) + Begin + + -- Get Start/End Index of Tag + Set @StartTagIndex = PatIndex('%' + @TagName + '%', @RetVal); + Set @EndTagIndex = PatIndex('%}}%', @RetVal); + + While (@StartTagIndex > 0) + Begin + + Set @StartTagValue = SubString(@RetVal, @StartTagIndex, (@EndTagIndex - @StartTagIndex) + 2); + + Set @StartValIndex = PatIndex('%=%', @StartTagValue); + Set @EndValIndex = PatIndex('%}%', @StartTagValue); + + Set @DefaultValue = SubString(@StartTagValue, @StartValIndex + 1, (@EndValIndex - @StartValIndex) - 1); + Set @RetVal = Replace(@RetVal, @StartTagValue, @DefaultValue); + + Set @StartTagIndex = PatIndex('%' + @TagName + '%', @RetVal); + Set @EndTagIndex = PatIndex('%}}%', @RetVal); + + End -- While (@StartTagIndex > 0) + + + Fetch Next From LegacyTags_Cursor Into @TagName + End + + Close LegacyTags_Cursor; + Deallocate LegacyTags_Cursor; + + + Return @RetVal; + +END +Go + + +IF (@@Error = 0) PRINT 'Procedure Creation: [vefn_RofstDataReplaceLegacyTagsWithDefaults] Succeeded' +ELSE PRINT 'Procedure Creation: [vefn_RofstDataReplaceLegacyTagsWithDefaults] Error on Creation' +GO + + + +/* +========================================================================================================== + End: B2022-088: [JPR] Find Doc Ro button not working in Word Sections + B2022-098: [JPR] ROs not being resolved in Word Sections +========================================================================================================== +*/ + + + + ----------------------------------------------------------------------------- /* --------------------------------------------------------------------------- @@ -21060,8 +21289,8 @@ BEGIN TRY -- Try Block DECLARE @RevDate varchar(255) DECLARE @RevDescription varchar(255) - set @RevDate = '08/03/2022 9:00 AM' - set @RevDescription = 'B2022-049 Unlink single procedure for enhanced (if data got corrupted) ' + set @RevDate = '08/16/2022 10:00 AM' + set @RevDescription = 'B2022-088: [JPR] Find Doc Ro button not working in Word Sections & B2022-098: [JPR] ROs not being resolved in Word Sections ' Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription diff --git a/PROMS/VEPROMS User Interface/PROMSFixes.Sql b/PROMS/VEPROMS User Interface/PROMSFixes.Sql index dc88e401..48859d35 100644 --- a/PROMS/VEPROMS User Interface/PROMSFixes.Sql +++ b/PROMS/VEPROMS User Interface/PROMSFixes.Sql @@ -21026,6 +21026,235 @@ GO ========================================================================================================== */ + +/* +========================================================================================================== + Start: B2022-088: [JPR] Find Doc Ro button not working in Word Sections + B2022-098: [JPR] ROs not being resolved in Word Sections +========================================================================================================== +*/ + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetChildByAccPageID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetChildByAccPageID]; +GO + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +/***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. +*****************************************************************************/ +/* +========================================================================================================== + Author: Jake Ropar + Create Date: 03/24/2022 + Description: Check if the AccPageID passed in has a specific Return Value Type Extension (.A, .B, .C, etc.) + If so, then strip off the return value specific extension to get the BaseAccPageID for the lookup. + Use the BaseAccPageID to lookup the BaseRoid, then use the Roid to lookup the Ro Child Object + + Note** Using the AccPageID to first lookup the roid, then using the roid to lookup the data is + significantly faster than directly looking up the data using the AccPageID because of the indexes +========================================================================================================== + */ +Create Procedure [dbo].[vesp_RofstDataGetChildByAccPageID] +( + @RofstID int, + @AccPageID VarChar(50) +) +With Execute as Owner +As +Begin + + Declare @BaseAccPageID VarChar(Max); + Declare @BaseRoid VarChar(Max); + + -- Check if AccPageID has a valid extension + If ((PatIndex('%.[A-Z]', @AccPageID) > 0) And ((Select Count(1) From vwRofstData_RofstBaseRoids Where BaseAccPageID = @AccPageID) <= 0)) + Set @BaseAccPageID = Left(@AccPageID, Len(@AccPageID)-2); + Else + Set @BaseAccPageID = @AccPageID; + + -- Use the AccPageID to get the BaseRoid + Select @BaseRoid = rb.BaseRoid + From vwRofstData_RofstBaseRoids rb + Where rb.RofstID = @RofstID + And rb.BaseAccPageID = @BaseAccPageID; + + -- Then use the BaseRoid to lookup the Ro Child Object + Select rc.ROFstID, + rc.dbiID, + rc.ID, + rc.ParentID, + rc.[type], + rc.title, + rc.roid, + rc.appid, + rc.[value], + rc.AccPageID + From vwRofstData_RofstChildren rc + Where rc.RofstID = @RofstID? + And rc.roid = @BaseRoid; + + Return; +End +GO + + +IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetChildByAccPageID] Succeeded' +ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetChildByAccPageID] Error on Creation' +GO + + + + +IF EXISTS (Select * From dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[vesp_RofstDataGetBaseAccPageKeys]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP Procedure [dbo].[vesp_RofstDataGetBaseAccPageKeys]; +GO + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +/*****************************************************************************? + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2020 - Volian Enterprises, Inc. All rights reserved. +*****************************************************************************/ +/* +========================================================================================================== + Author: Jake Ropar + Create Date: 08/11/2022 + Description: Gets all the Base AccPageKeys that end with a "." period followed by an Alpha Character (A through Z) +========================================================================================================== + */ +Create Procedure [dbo].[vesp_RofstDataGetBaseAccPageKeys] +( + @RofstID int +) +With Execute as Owner +As +Begin + + Select BaseAccPageID + From vwRofstData_RofstBaseRoids + Where BaseAccPageID like '%.[A-Z]'; + + Return; +End +GO + + +IF (@@Error = 0) PRINT 'Procedure Creation: [vesp_RofstDataGetBaseAccPageKeys] Succeeded' +ELSE PRINT 'Procedure Creation: [vesp_RofstDataGetBaseAccPageKeys] Error on Creation' +GO + + + + + +If Exists(Select * From sys.objects Where type = 'FN' And object_id = OBJECT_ID('[dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults]')) + Drop Function [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults]; + + + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- ========================================================================================== +-- Author: Jake Ropar +-- Create Date: 06/21/2022 +-- Description: Replaces any legacy applicability tags with the default value +-- ========================================================================================== + +CREATE FUNCTION [dbo].[vefn_RofstDataReplaceLegacyTagsWithDefaults](@Values VarChar(Max)) Returns VarChar(Max) +WITH EXECUTE AS OWNER +AS +BEGIN + + Declare @RetVal VarChar(Max) = ''; + Declare @DefaultValue VarChar(Max) = ''; + + Declare @StartTagIndex Int; + Declare @EndTagIndex Int; + Declare @StartTagValue VarChar(Max); + Declare @StartValIndex Int; + Declare @EndValIndex Int; + + Declare @TagName VarChar(Max); + Declare @LegacyTagNames VarChar(Max) = 'U-ID,U-NUMBER,U-NAME,U-TEXT,U-OTHERID,U-OTHERNUMBER,U-OTHERNAME,U-OTHERTEXT'; + + -- Make Sure all tag instances are upper case & Remove any internal spaces + Set @RetVal = dbo.vefn_RofstDataCleanUnitInfoTags(@Values, 0); + + -- Remove any instances of double "}" that have a spaces between them ex: "} }" + Set @RetVal = Replace(@RetVal, '} }', '}}'); + + Declare LegacyTags_Cursor Cursor Fast_Forward For + Select '{' + x.ListValue + '{' as 'TagName' + From [dbo].[vefn_ParseStringListToTable](@LegacyTagNames, ',') x + + Open LegacyTags_Cursor + + Fetch Next From LegacyTags_Cursor Into @TagName + + While (@@FETCH_STATUS = 0) + Begin + + -- Get Start/End Index of Tag + Set @StartTagIndex = PatIndex('%' + @TagName + '%', @RetVal); + Set @EndTagIndex = PatIndex('%}}%', @RetVal); + + While (@StartTagIndex > 0) + Begin + + Set @StartTagValue = SubString(@RetVal, @StartTagIndex, (@EndTagIndex - @StartTagIndex) + 2); + + Set @StartValIndex = PatIndex('%=%', @StartTagValue); + Set @EndValIndex = PatIndex('%}%', @StartTagValue); + + Set @DefaultValue = SubString(@StartTagValue, @StartValIndex + 1, (@EndValIndex - @StartValIndex) - 1); + Set @RetVal = Replace(@RetVal, @StartTagValue, @DefaultValue); + + Set @StartTagIndex = PatIndex('%' + @TagName + '%', @RetVal); + Set @EndTagIndex = PatIndex('%}}%', @RetVal); + + End -- While (@StartTagIndex > 0) + + + Fetch Next From LegacyTags_Cursor Into @TagName + End + + Close LegacyTags_Cursor; + Deallocate LegacyTags_Cursor; + + + Return @RetVal; + +END +Go + + +IF (@@Error = 0) PRINT 'Procedure Creation: [vefn_RofstDataReplaceLegacyTagsWithDefaults] Succeeded' +ELSE PRINT 'Procedure Creation: [vefn_RofstDataReplaceLegacyTagsWithDefaults] Error on Creation' +GO + + + +/* +========================================================================================================== + End: B2022-088: [JPR] Find Doc Ro button not working in Word Sections + B2022-098: [JPR] ROs not being resolved in Word Sections +========================================================================================================== +*/ + + + + ----------------------------------------------------------------------------- /* --------------------------------------------------------------------------- @@ -21060,8 +21289,8 @@ BEGIN TRY -- Try Block DECLARE @RevDate varchar(255) DECLARE @RevDescription varchar(255) - set @RevDate = '08/03/2022 9:00 AM' - set @RevDescription = 'B2022-049 Unlink single procedure for enhanced (if data got corrupted) ' + set @RevDate = '08/16/2022 10:00 AM' + set @RevDescription = 'B2022-088: [JPR] Find Doc Ro button not working in Word Sections & B2022-098: [JPR] ROs not being resolved in Word Sections ' Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index 33d01b17..ddf946f6 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -4116,16 +4116,12 @@ namespace VEPROMS ROFSTLookup lookup = MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyDocVersion); - // B2022-088: Find Doc Ro button not working in Word Sections - string roidBase = string.Empty; - string roidExt = string.Empty; - - string roid16 = ROFSTLookup.FormatRoidKey(roid, ref roidBase, ref roidExt, true); - ROFSTLookup.rochild roc = lookup.GetRoChild(roid16); - + // B2022-088: [JPR] Find Doc Ro button not working in Word Sections + // B2022-098: [JPR] ROs not being resolved in Word Sections + roid = ROFSTLookup.FormatRoidKey(roid, true); + ROFSTLookup.rochild roc = lookup.GetRoChild(roid); string roval = roc.value; - //string roval = (roc.ID < 0 || string.IsNullOrEmpty(roc.value)) ? "?" : roc.value; - + if (roval == "?") { RoUsageInfo roui = RoUsageInfo.Get(int.Parse(rousageid)); diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs index 0c43d91a..7cd3806d 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs @@ -129,7 +129,8 @@ namespace VEPROMS.CSLA.Library public const string RoMissingDefaultValue = "[TBD]"; - private static List _extensions; + private List _extensions; + private List _baseAccPageKeys; // RofstLookup/Conversion Variables private int _rofstID; @@ -197,6 +198,18 @@ namespace VEPROMS.CSLA.Library } } + public List BaseAccPageKeys + { + get + { + if (_baseAccPageKeys == null) + { + _baseAccPageKeys = GetBaseAccPageKeys(); + } + + return _baseAccPageKeys; + } + } public bool AutoCombineSingleRetValues { @@ -304,82 +317,34 @@ namespace VEPROMS.CSLA.Library public string FormatAccPageKey(string accPageID) { - if (string.IsNullOrEmpty(accPageID)) - return accPageID; + string accPageBase = string.Empty; + string accPageExt = string.Empty; string spDefault = (MyDocVersionInfo != null && MyDocVersionInfo.DocVersionConfig != null) ? MyDocVersionInfo.DocVersionConfig.RODefaults_setpointprefix : string.Empty; string igDefault = (MyDocVersionInfo != null && MyDocVersionInfo.DocVersionConfig != null) ? MyDocVersionInfo.DocVersionConfig.RODefaults_graphicsprefix : string.Empty; - return FormatAccPageKey(accPageID, spDefault, igDefault); + return FormatAccPageKeyWithExt(accPageID, spDefault, igDefault, ref accPageBase, ref accPageExt); } - public string FormatAccPageKey(string accPageID, ref string accPageBase, ref string accPageExt, bool useDefaultExt = true) + public string FormatAccPageKey(string accPageID, ref string accPageBase, ref string accPageExt) { - string accPageKey = FormatAccPageKey(accPageID); + string spDefault = (MyDocVersionInfo != null && MyDocVersionInfo.DocVersionConfig != null) ? MyDocVersionInfo.DocVersionConfig.RODefaults_setpointprefix : string.Empty; + string igDefault = (MyDocVersionInfo != null && MyDocVersionInfo.DocVersionConfig != null) ? MyDocVersionInfo.DocVersionConfig.RODefaults_graphicsprefix : string.Empty; - if (Regex.IsMatch(accPageKey, @".*\.[A-Z]")) - { - accPageBase = accPageKey.Substring(0, accPageKey.Length - 2); - accPageExt = Convert.ToString(accPageKey.ToCharArray().LastOrDefault()); - } - else - { - accPageBase = accPageKey; - accPageExt = (!accPageKey.StartsWith("")) - accPageID = string.Format("{0}>", accPageID); - - accPageID = accPageID.Replace("", ""); - accPageID = accPageID.ToCleanString(); // Removes any spaces - - // Clean up the AccPageID before using it to do a lookup - if (!string.IsNullOrEmpty(spDefault)) - accPageID = accPageID.Replace("".ToCharArray()); // String < and > - - accPageID = regRoKeyHigh.Replace(accPageID, "_HIGH$3"); - accPageID = regRoKeyLow.Replace(accPageID, "_LOW$3"); - accPageID = accPageID.ToUpper(); - } - - return accPageID; + return FormatAccPageKeyWithExt(accPageID, spDefault, igDefault, ref accPageBase, ref accPageExt); } - public static string FormatAccPageKey(string accPageID, string spDefault, string igDefault, ref string accPageBase, ref string accPageExt, bool useDefaultExt = true) + public string FormatAccPageKey(string accPageID, string spDefault, string igDefault, ref string accPageBase, ref string accPageExt) { - string accPageKey = FormatAccPageKey(accPageID, spDefault, igDefault); - - if (Regex.IsMatch(accPageKey, @".*\.[A-Z]")) - { - accPageBase = accPageKey.Substring(0, accPageKey.Length - 2); - accPageExt = Convert.ToString(accPageKey.ToCharArray().LastOrDefault()); - } - else - { - accPageBase = accPageKey; - accPageExt = (!accPageKey.StartsWith("")] - string accPageKey = FormatAccPageKey(accPageID, spDefault, igDefault); + string accPageKey = FormatAccPageKeyWithExt(accPageID, spDefault, igDefault, ref accPageBase, ref accPageExt); - ROFSTLookup.rochild rc = RofstDataGetChildByAccPageID(_rofstID, accPageID, spDefault, igDefault); + ROFSTLookup.rochild rc = RofstDataGetChildByAccPageID(_rofstID, accPageBase); - if (!string.IsNullOrEmpty(rc.roid) && rc.roid.Length < 16 && Regex.IsMatch(accPageKey, @".*\.[A-Z]") && rc.children != null && rc.children.Count() > 0) + //if (rc.ID >=0 && rc.roid.Length < 16 && Regex.IsMatch(accPageKey, @".*\.[A-Z]") && rc.children != null && rc.children.Count() > 0) + if (rc.ID >= 0 && rc.roid.Length < 16 && !string.IsNullOrEmpty(accPageExt) && 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 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 && !string.IsNullOrEmpty(x.value)).Any()) ? rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Single() : rc.children.First(); @@ -476,12 +444,12 @@ namespace VEPROMS.CSLA.Library public string GetTranslatedRoValue(string roid, bool DoCaret, bool DoDOSSuperSubScript) { - roid = FormatRoidKey(roid); + roid = FormatRoidKey(roid, true); string retval = GetRoChild(roid).value; if (string.IsNullOrEmpty(retval)) - return string.Empty; + return "?"; // Returning a "?" character indicates that the selected RO Value no longer exists or has been deleted. retval = ReplaceUnicode(retval, DoCaret); retval = ConvertFortranFormatToScienctificNotation(retval); @@ -1216,6 +1184,40 @@ namespace VEPROMS.CSLA.Library } } + private List GetBaseAccPageKeys() + { + try + { + List lst = new List(); + + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cmd = cn.CreateCommand()) + { + cmd.CommandTimeout = Database.DefaultTimeout; + cmd.CommandType = CommandType.StoredProcedure; + cmd.CommandText = "vesp_RofstDataGetBaseAccPageKeys"; + + cmd.Parameters.Add(new SqlParameter("@RofstID", SqlDbType.Int)).Value = _rofstID; + + using (SafeDataReader dr = new SafeDataReader(cmd.ExecuteReader())) + { + while (dr.Read()) + { + lst.Add(dr.GetValue("BaseAccPageID").ToString()); + } + } + } + } + + return lst; + } + catch (Exception ex) + { + throw new DbCslaException("RofstData.vesp_RofstDataGetBaseAccPageKeys", ex); + } + } + #endregion #region (Core/Base logic for RO Values & UnitInfo RO Values) @@ -1263,17 +1265,14 @@ namespace VEPROMS.CSLA.Library } } - private ROFSTLookup.rochild RofstDataGetChildByAccPageID(int rofstID, string accPageID, string spDefault, string igDefault, bool loadChildren = false, bool loadAllChildren = false) + private ROFSTLookup.rochild RofstDataGetChildByAccPageID(int rofstID, string accPageID) { try { - // Cleanup / Reformat the AccPageID if necessary (Note* This method also handles the UnitInfo Ro Values. ex: "") - string accPageKey = FormatAccPageKey(accPageID, spDefault, igDefault); - // Check if roid is for a Unit Information RO Value Tag - if (!string.IsNullOrEmpty(accPageKey) && accPageKey.StartsWith("")) accPageID = string.Format("{0}>", accPageID); + + accPageID = accPageID.Replace("", ""); + accPageID = accPageID.ToCleanString(); // Removes any spaces + + // Clean up the AccPageID before using it to do a lookup + if (accPageID.StartsWith("".ToCharArray()); // String < and > + + // Check the end of the AccPageID to determine if its an extension or part of the base key + // If the AccPageID doesn't have an extension then set to default + if (!Regex.IsMatch(accPageID, @".*\.[A-Z]") || BaseAccPageKeys.Contains(accPageID)) + { + // No Extension, set to default + accPageID = string.Format("{0}.A", accPageID); + } + + // Set AccPage Base and Extension return values + accPageBase = accPageID.Substring(0, (accPageID.Length - 2)); + accPageExt = Convert.ToString(accPageID.ToCharArray().LastOrDefault()); + } + } + + return (!string.IsNullOrEmpty(accPageID)) ? accPageID.ToUpper() : accPageID; + } + #endregion #region (Parse/Load) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs index af11181a..184c59e5 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs @@ -955,6 +955,7 @@ namespace VEPROMS.CSLA.Library { string fileNameOnly = null; + //B2020-127 don't try to parse out a file name from "?" (happens with the RO figure no longer exists) // - this allows it to drop through and put an annotation on the step if (ii.IsFigure && Text != null && Text.Length > 0 && value != "?") diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index 3335dd9d..f95e73a3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -947,17 +947,13 @@ namespace VEPROMS.CSLA.Library 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 if (dvi.DocVersionAssociationCount > 0) { hasRos = true; rofst = dvi.DocVersionAssociations[0].MyROFst; - igPrefix = dvi.DocVersionConfig.RODefaults_graphicsprefix; - spPrefix = dvi.DocVersionConfig.RODefaults_setpointprefix; - + // The following code sets the DocVersionInfo and the OtherChild properties for the current RofstLookup instance (lookup), and also enables Caching // When printing or converting word sections to pdf, any RoChild "value" is the Unit Specific Value for the SelectedSlave lookup = rofst.GetROFSTLookup(dvi, Convert.ToString(sect.MyDocVersion.DocVersionConfig.SelectedSlave)); @@ -1161,8 +1157,10 @@ namespace VEPROMS.CSLA.Library { if (Volian.Base.Library.BaselineMetaFile.IsOpen && Volian.Base.Library.BaselineMetaFile.IncludeWordSecText) roTokenForBaseline = sel.Text; if (statusChange != null) statusChange(VolianStatusType.Update, sel.Start, string.Format("{0} ROs Refreshed", roCount++)); - - ROFSTLookup.rochild roc = GetCachedRoByAccPageID(lookup, sel.Text, spPrefix, igPrefix, convertCaretToDeltaSymbol); + + // B2022-088: [JPR] Find Doc Ro button not working in Word Sections + // B2022-098: [JPR] ROs not being resolved in Word Sections + ROFSTLookup.rochild roc = GetCachedRoByAccPageID(lookup, sel.Text, convertCaretToDeltaSymbol); int roType = roc.type; string roValue = roc.value; @@ -1380,7 +1378,7 @@ namespace VEPROMS.CSLA.Library } } - private static ROFSTLookup.rochild GetCachedRoByAccPageID(ROFSTLookup lookup, string selText, string spPrefix, string igPrefix, bool convertCaretToDeltaSymbol) + private static ROFSTLookup.rochild GetCachedRoByAccPageID(ROFSTLookup lookup, string selText, bool convertCaretToDeltaSymbol) { string accPageBase = string.Empty; string accPageExt = string.Empty; @@ -1389,13 +1387,13 @@ namespace VEPROMS.CSLA.Library { ROFSTLookup.rochild roc = ROFSTLookup.GetEmptyRoChild(); - string accPageKey = ROFSTLookup.FormatAccPageKey(selText, spPrefix, igPrefix, ref accPageBase, ref accPageExt, true); + string accPageKey = lookup.FormatAccPageKey(selText, ref accPageBase, ref accPageExt); // Check if the Rochild is in the PrintCache (use base accPageID without specific extension) if (!RoPrintCache.ContainsKey(accPageBase)) { // Lookup RoChild Info from database - roc = lookup.GetROChildByAccPageID(accPageBase, spPrefix, igPrefix); + roc = lookup.GetROChildByAccPageID(accPageBase); // Check if RO is valid if (roc.ID < 0 || string.IsNullOrEmpty(roc.roid)) @@ -1415,7 +1413,8 @@ namespace VEPROMS.CSLA.Library // 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(); + if (roc.children != null && roc.children.Count() > 0) + 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("<", then // move past that text and try the Word Find function again. - if (executeResult && !sel.Text.StartsWith("<") && !sel.Text.EndsWith(">")) + // B2022-088: [JPR] Find Doc Ro button not working in Word Sections + // B2022-098: [JPR] ROs not being resolved in Word Sections + if (executeResult && !string.IsNullOrEmpty(sel.Text) && !sel.Text.StartsWith("<") && !sel.Text.EndsWith(">")) { sel.MoveStart(LBWdUnits.wdCharacter, sel.Text.Length - 1); tryagain = true; diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index a3467265..860327a8 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -882,10 +882,13 @@ namespace VEPROMS.CSLA.Library if (this.ActiveSection != null) { string oldText = this.MyContent.Text; + string roval = lookup.GetTranslatedRoValue(rousage.ROID, this.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, this.ActiveSection.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues); ROFSTLookup.rochild roch = lookup.GetRoChild(rousage.ROID); + this.MyContent.FixContentText(rousage, roval, roch.type, rofstinfo, this); string newText = this.MyContent.Text; + if (newText != oldText) { Content content = Content.Get(this.MyContent.ContentID); @@ -936,8 +939,10 @@ namespace VEPROMS.CSLA.Library { ROCheckCount++; string oldText = itemInfo.MyContent.Text; + string roval = lookup.GetTranslatedRoValue(rousage.ROID, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, sectionInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues); ROFSTLookup.rochild roch = lookup.GetRoChild(rousage.ROID); + itemInfo.MyContent.FixContentText(rousage, roval, roch.type, origROFst, itemInfo); string newText = itemInfo.MyContent.Text; @@ -1901,7 +1906,6 @@ namespace VEPROMS.CSLA.Library return includeOnCAS; } } - // F2022-024 Time Critical Action Step // determine if the the current step should automatically be placed on the Time Critical Action Summary // Note, this logic only checks the format setting of the step. We will check the value of the Tag's Check Box later on. @@ -1933,7 +1937,6 @@ namespace VEPROMS.CSLA.Library return includeOnTCAS; } } - public bool IsSameType(ItemInfo cmpItmInfo) { return (((int)MyContent.Type) % 10000) == (((int)cmpItmInfo.MyContent.Type) % 10000); @@ -2967,68 +2970,94 @@ namespace VEPROMS.CSLA.Library } //get { return ConvertToDisplayText(MyContent.Number); } } + // for step designators (a redefined caution type used in Comanche Peak with the SameRowAsParentMultiLines format flag) // we what to allow for a hard return to allow for multiple designator lines - jsj 5/21/2015 public static string ConvertToMulitLineStepDesignatorDisplayText(string txt) { string retval = txt; - retval = StripRtfFormatting(retval); - retval = StripLinks(retval); - retval = ReplaceSpecialCharacters(retval); - retval = retval.Replace("\u2011", "-"); - retval = retval.Replace("\r\n", @"\line"); - retval = retval.Replace("\n", @"\line"); + + if (!string.IsNullOrEmpty(retval)) + { + retval = StripRtfFormatting(retval); + retval = StripLinks(retval); + retval = ReplaceSpecialCharacters(retval); + retval = retval.Replace("\u2011", "-"); + retval = retval.Replace("\r\n", @"\line"); + retval = retval.Replace("\n", @"\line"); + } + return retval; } + public static string ConvertToDisplayText(string txt) { return ConvertToDisplayText(txt, true); } + public static string ConvertToDisplayText(string txt, bool stripRTF) { string retval = txt; - if (stripRTF) retval = StripRtfFormatting(retval); - retval = StripLinks(retval); - retval = ReplaceSpecialCharacters(retval); - retval = retval.Replace("\u2011", "-"); - retval = retval.Replace("\u2572", @"\"); // replace backslash symbol with a backslash - retval = Regex.Replace(retval, @"\\line ?", ";"); // better handing of hard returns - replace with semi-colon for use on tree view - retval = retval.Replace("\r\n", ";"); - retval = retval.Replace("\n", ";"); //added for consistency checking with approved version + + if (!string.IsNullOrEmpty(retval)) + { + if (stripRTF) retval = StripRtfFormatting(retval); + retval = StripLinks(retval); + retval = ReplaceSpecialCharacters(retval); + retval = retval.Replace("\u2011", "-"); + retval = retval.Replace("\u2572", @"\"); // replace backslash symbol with a backslash + retval = Regex.Replace(retval, @"\\line ?", ";"); // better handing of hard returns - replace with semi-colon for use on tree view + retval = retval.Replace("\r\n", ";"); + retval = retval.Replace("\n", ";"); //added for consistency checking with approved version + } + return retval; } + public static string StripRtfFormatting(string rtf) { string retval = rtf; - // B2022-082: underline/bold of word removes space between 2 words in DisplayText - retval = Regex.Replace(retval, @"\\ulnone\\b0 ?", ""); - retval = Regex.Replace(retval, @"\\b0\\ulnone ?", ""); - retval = Regex.Replace(retval, @"\\b0 ?", ""); - retval = Regex.Replace(retval, @"\\b ?", ""); - retval = Regex.Replace(retval, @"\\ulnone ?", ""); - retval = Regex.Replace(retval, @"\\ul0 ?", ""); - retval = Regex.Replace(retval, @"\\ul ?", ""); - retval = Regex.Replace(retval, @"\\i0 ?", ""); - retval = Regex.Replace(retval, @"\\i ?", ""); - //retval = Regex.Replace(retval, @"\\super ?", ""); - //retval = Regex.Replace(retval, @"\\sub ?", ""); - //retval = Regex.Replace(retval, @"\\nosupersub ?", ""); - retval = Regex.Replace(retval, @"\\up[320] ?", ""); - retval = Regex.Replace(retval, @"\\dn[320] ?", ""); - retval = Regex.Replace(retval, @"\\li[0-9]+ ?", ""); // changed the * to a + to "\\line " for hard returns part of bug fix B2015-140 - retval = Regex.Replace(retval, @"\\fi-[0-9]+ ?", ""); - retval = Regex.Replace(retval, @"\\fs[0-9]+ ?", ""); // B2020-065: removed font size definition (introduced when allowing font sizes in tables) + + if (!string.IsNullOrEmpty(retval)) + { + // B2022-082: underline/bold of word removes space between 2 words in DisplayText + retval = Regex.Replace(retval, @"\\ulnone\\b0 ?", ""); + retval = Regex.Replace(retval, @"\\b0\\ulnone ?", ""); + retval = Regex.Replace(retval, @"\\b0 ?", ""); + retval = Regex.Replace(retval, @"\\b ?", ""); + retval = Regex.Replace(retval, @"\\ulnone ?", ""); + retval = Regex.Replace(retval, @"\\ul0 ?", ""); + retval = Regex.Replace(retval, @"\\ul ?", ""); + retval = Regex.Replace(retval, @"\\i0 ?", ""); + retval = Regex.Replace(retval, @"\\i ?", ""); + //retval = Regex.Replace(retval, @"\\super ?", ""); + //retval = Regex.Replace(retval, @"\\sub ?", ""); + //retval = Regex.Replace(retval, @"\\nosupersub ?", ""); + retval = Regex.Replace(retval, @"\\up[320] ?", ""); + retval = Regex.Replace(retval, @"\\dn[320] ?", ""); + retval = Regex.Replace(retval, @"\\li[0-9]+ ?", ""); // changed the * to a + to "\\line " for hard returns part of bug fix B2015-140 + retval = Regex.Replace(retval, @"\\fi-[0-9]+ ?", ""); + retval = Regex.Replace(retval, @"\\fs[0-9]+ ?", ""); // B2020-065: removed font size definition (introduced when allowing font sizes in tables) + } + return retval; } + public static string StripLinks(string rtf) { string retval = rtf; - retval = Regex.Replace(retval, @"\\v.*?\\v0 ?", ""); - retval = retval.Replace("\u252C", "");// Unicode 9516 Transition - retval = retval.Replace("\u2566", "");// Unicode 9574 Transition - retval = retval.Replace("\u0015", "");// Unicode 21 RO + + if (!string.IsNullOrEmpty(retval)) + { + retval = Regex.Replace(retval, @"\\v.*?\\v0 ?", ""); + retval = retval.Replace("\u252C", "");// Unicode 9516 Transition + retval = retval.Replace("\u2566", "");// Unicode 9574 Transition + retval = retval.Replace("\u0015", "");// Unicode 21 RO + } + return retval; } + private static string ReplaceSpecialCharacter(Match m) { StringBuilder sb = new StringBuilder(); @@ -3036,6 +3065,7 @@ namespace VEPROMS.CSLA.Library sb.Append((char)i); return sb.ToString(); } + private static string ReplaceSpecialHexCharacter(Match m) { StringBuilder sb = new StringBuilder(); @@ -3043,14 +3073,21 @@ namespace VEPROMS.CSLA.Library sb.Append((char)i); return sb.ToString(); } + private static string ReplaceSpecialCharacters(string rtf) { string retval = rtf; - retval = retval.Replace("`", "\u00B0");// Degree - retval = Regex.Replace(retval, @"\\u[0-9]+[?]", new MatchEvaluator(ReplaceSpecialCharacter)); - retval = Regex.Replace(retval, @"\\'[0-9A-Fa-f][0-9A-Fa-f]", new MatchEvaluator(ReplaceSpecialHexCharacter)); + + if (!string.IsNullOrEmpty(retval)) + { + retval = retval.Replace("`", "\u00B0");// Degree + retval = Regex.Replace(retval, @"\\u[0-9]+[?]", new MatchEvaluator(ReplaceSpecialCharacter)); + retval = Regex.Replace(retval, @"\\'[0-9A-Fa-f][0-9A-Fa-f]", new MatchEvaluator(ReplaceSpecialHexCharacter)); + } + return retval; } + //public void ShowThis(string title) //{ // Console.WriteLine("'{0}',,,,'i{1}','u{2}',{3},'{4}','{5}','{6}','{7}'", title, ItemID, MyItemInfoUnique, PreviousID, this, _MyPrevious, _MyParent, _ActiveParent); @@ -3174,38 +3211,47 @@ namespace VEPROMS.CSLA.Library { return RemoveRtfStyles(rtf, ActiveFormat); } + public string RemoveRtfStyles(string rtf, FormatInfo fmt) { string retval = rtf; - VE_Font TextFont = GetItemFont(fmt); - if (TextFont != null) + + if (!string.IsNullOrEmpty(retval)) { - // remove rtf commands for any styles that were added. Note that if - // the entire item has a style, and also contains 'pieces' of text with - // the same style, the underlying rtf box removes the embedded rtf commands, - // for example, if the entire step is bolded, and 'THEN' has bold on/off - // surrounding it, the rtf box removes the bold around the 'THEN' - // These remove the command with a following space or the command alone, - // either case may exist, because if there are rtf commands following the - // style command, there will be no space character following the style command. - if (((TextFont.Style & E_Style.Bold) > 0) || ((TextFont.Style & E_Style.MmBold) > 0)) + VE_Font TextFont = GetItemFont(fmt); + + if (TextFont != null) { - retval = RemoveToken(retval, @"\\b0"); - retval = RemoveToken(retval, @"\\b"); - } - if ((TextFont.Style & E_Style.Underline) > 0) - { - retval = RemoveToken(retval, @"\\ulnone"); - retval = RemoveToken(retval, @"\\ul"); - } - if ((TextFont.Style & E_Style.Italics) > 0) - { - retval = RemoveToken(retval, @"\\i0"); - retval = RemoveToken(retval, @"\\i"); + // remove rtf commands for any styles that were added. Note that if + // the entire item has a style, and also contains 'pieces' of text with + // the same style, the underlying rtf box removes the embedded rtf commands, + // for example, if the entire step is bolded, and 'THEN' has bold on/off + // surrounding it, the rtf box removes the bold around the 'THEN' + // These remove the command with a following space or the command alone, + // either case may exist, because if there are rtf commands following the + // style command, there will be no space character following the style command. + if (((TextFont.Style & E_Style.Bold) > 0) || ((TextFont.Style & E_Style.MmBold) > 0)) + { + retval = RemoveToken(retval, @"\\b0"); + retval = RemoveToken(retval, @"\\b"); + } + if ((TextFont.Style & E_Style.Underline) > 0) + { + retval = RemoveToken(retval, @"\\ulnone"); + retval = RemoveToken(retval, @"\\ul"); + } + if ((TextFont.Style & E_Style.Italics) > 0) + { + retval = RemoveToken(retval, @"\\i0"); + retval = RemoveToken(retval, @"\\i"); + } } + } + return retval; } + public bool SameRowAsParent { get @@ -4483,7 +4529,7 @@ namespace VEPROMS.CSLA.Library } } } - macroindx = tbformat.IndexOf("{!diamond1}"); + macroindx = tbformat.IndexOf("{!diamond1}"); if (macroindx > -1) //i found it { cltext = cltext == null ? tbformat.Remove(macroindx, 11) : cltext.Remove(macroindx, 11); @@ -4578,7 +4624,7 @@ namespace VEPROMS.CSLA.Library } else { - newtab = @"\ul " + newtab.Substring(0, newtab.IndexOf(":") + 1) + @"\ulnone " + newtab.Substring(newtab.IndexOf(":") + 1); + newtab = @"\ul " + newtab.Substring(0, newtab.IndexOf(":") + 1) + @"\ulnone " + newtab.Substring(newtab.IndexOf(":") + 1); } } // also see if there is the 'pagelist' string in this tab: @@ -5067,7 +5113,7 @@ namespace VEPROMS.CSLA.Library private string ReplaceStepToken(string tbformat) { - if (tbformat.Trim().EndsWith("`")) + if (!string.IsNullOrEmpty(tbformat) && tbformat.Trim().EndsWith("`")) { ItemInfo tmp = this; string sep = string.Empty; @@ -5080,6 +5126,7 @@ namespace VEPROMS.CSLA.Library } while (!tmp.IsHigh); tbformat = tbformat.Replace("`", " " + hlsOrdinal); } + return tbformat; } diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs index 5b9d4731..a55e7846 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs @@ -530,21 +530,26 @@ namespace VEPROMS.CSLA.Library private static List GetROIDsFromLookup(ROFstInfo rofst, List ChangedFiles, DocVersionInfo docver) { List roids = new List(); - - ROFSTLookup myLookup = new ROFSTLookup(rofst.ROFstID, docver); - // B2022-026 RO Memory Reduction code - get only the Image type of ROs - ROFSTLookup.rochild[] children = myLookup.GetRoChildrenByType(E_ROValueType.Image); - - if (children != null && children.Length > 0) + + // B2022-088: [JPR] Find Doc Ro button not working in Word Sections + // B2022-098: [JPR] ROs not being resolved in Word Sections + if(rofst != null && ChangedFiles != null && ChangedFiles.Count > 0) { - for (int i = 0; i < children.Length; i++) - { - string filename = children[i].value; - filename = filename.Substring(0, filename.IndexOf('\n')); + ROFSTLookup myLookup = new ROFSTLookup(rofst.ROFstID, docver); + // B2022-026 RO Memory Reduction code - get only the Image type of ROs + ROFSTLookup.rochild[] children = myLookup.GetRoChildrenByType(E_ROValueType.Image); - if (ChangedFiles.Contains(filename)) + if (children != null && children.Length > 0) + { + for (int i = 0; i < children.Length; i++) { - roids.Add(children[i].roid); + string filename = children[i].value; + filename = filename.Substring(0, filename.IndexOf('\n')); + + if (ChangedFiles.Contains(filename)) + { + roids.Add(children[i].roid); + } } } } @@ -600,11 +605,14 @@ namespace VEPROMS.CSLA.Library { Dictionary myRoImagesList = new Dictionary(); - foreach (ROImageInfo myROImage in myROImages) + if (myROImages != null) { - myRoImagesList.Add(ROImageKey(myROImage.FileName, myROImage.DTS), myROImage.ImageID); + foreach (ROImageInfo myROImage in myROImages) + { + myRoImagesList.Add(ROImageKey(myROImage.FileName, myROImage.DTS), myROImage.ImageID); + } } - + return myRoImagesList; } @@ -616,12 +624,18 @@ namespace VEPROMS.CSLA.Library private static string buildImageIDString(List myROImageIDs) { StringBuilder sb = new StringBuilder(); - string sep = ""; - - foreach (int imageID in myROImageIDs) + + // B2022-088: [JPR] Find Doc Ro button not working in Word Sections + // B2022-098: [JPR] ROs not being resolved in Word Sections + if (myROImageIDs != null) { - sb.Append(sep + imageID.ToString()); - sep = ","; + string sep = string.Empty; + + foreach (int imageID in myROImageIDs) + { + sb.Append(sep + imageID.ToString()); + sep = ","; + } } return sb.ToString(); diff --git a/PROMS/Volian.Controls.Library/DisplayRO.cs b/PROMS/Volian.Controls.Library/DisplayRO.cs index 4819b90a..d6d7139c 100644 --- a/PROMS/Volian.Controls.Library/DisplayRO.cs +++ b/PROMS/Volian.Controls.Library/DisplayRO.cs @@ -150,6 +150,8 @@ namespace Volian.Controls.Library get { return _curROLink; } set { + // Volian.Base.Library.vlnStackTrace.ShowStack("value={0} MyRTB={1}", value, ((MyRTB != null) ? MyRTB.SelectedText : "" )); + // modify - set the controls to the current ro if (value != null) { @@ -158,19 +160,25 @@ namespace Volian.Controls.Library _curROLink = value; _savCurROLink = _curROLink; - ExpandNode(_curROLink.ROID); + // B2022-088: [JPR] Find Doc Ro button not working in Word Sections + // B2022-098: [JPR] ROs not being resolved in Word Sections + string roid = ROFSTLookup.FormatRoidKey(_curROLink.ROID, true); + ExpandNode(roid); } } - else // insert - clear out controls + else // if (_curROLink != null) // insert - clear out controls { _curROLink = value; - tbROValue.Text = null; - lbROId.Text = string.Empty; tvROFST.SelectedNode = null; + ResetSearch(); - btnGoToRO.Enabled = false; - btnSaveRO.Enabled = false; - btnCancelRO.Enabled = false; + //tbROValue.Text = null; + //lbROId.Text = string.Empty; + + //btnGoToRO.Enabled = false; + //btnSaveRO.Enabled = false; + //btnCancelRO.Enabled = false; + //btnPreviewRO.Enabled = false; } } } @@ -184,6 +192,11 @@ namespace Volian.Controls.Library { _myRTB = value; MyROFST = null; + + // B2022-088: [JPR] Find Doc Ro button not working in Word Sections + // B2022-098: [JPR] ROs not being resolved in Word Sections + CurROLink = null; + _savCurROLink = null; } else if(_myRTB != value) { @@ -192,7 +205,7 @@ namespace Volian.Controls.Library MyRTB.LinkChanged += new StepRTBLinkEvent(MyRTB_LinkChanged); MyRTB.SelectionChanged += new EventHandler(MyRTB_SelectionChanged); - if (MyRTB.MyLinkText == null) + if (string.IsNullOrEmpty(MyRTB.MyLinkText)) { CurROLink = null; _savCurROLink = null; @@ -244,7 +257,7 @@ namespace Volian.Controls.Library if (_searchTimer == null) { _searchTimer = new Timer(); - _searchTimer.Interval = 500; + _searchTimer.Interval = 1000; _searchTimer.Tick += new EventHandler(SelectionTimer_Tick); _searchTimer.Stop(); } @@ -300,6 +313,10 @@ namespace Volian.Controls.Library { _timeActivity.Open(); + // B2022-088: [JPR] Find Doc Ro button not working in Word Sections + // B2022-098: [JPR] ROs not being resolved in Word Sections + // Need to call Stop then Start just in case the uses has changed their selection + // before the timer.Tick event fires. Calling Stop/Start is the same as Reset for the timer _searchTimer.Stop(); _searchTimer.Start(); @@ -338,13 +355,8 @@ namespace Volian.Controls.Library private void tvROFST_AfterSelect(object sender, TreeViewEventArgs e) { - tbROValue.Text = null; - lbROId.Text = string.Empty; - btnCancelRO.Enabled = false; - btnSaveRO.Enabled = false; - btnPreviewRO.Enabled = false; - btnGoToRO.Enabled = false; - + // 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) { ROFSTLookup.rochild chld = (ROFSTLookup.rochild)e.Node.Tag; @@ -353,24 +365,22 @@ 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 = ROFSTLookup.FormatRoidKey(chld.roid, true); + // Set the Display Text to the AccPageID + lbROId.Text = chld.appid; //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) && ((SavROLink == null) || !(childroid.Equals(SavROLink.ROID.ToUpper()))); //added security check (UserInfo.CanEdit) - btnCancelRO.Enabled = (_savCurROLink != null && (SavROLink != null && childroid != SavROLink.ROID.ToUpper())); + btnSaveRO.Enabled = (IsInWordDoc || (!IsNotStep && !IsEnhancedStep)) && UserInfo.CanEdit(MyUserInfo, MyDvi) && ((SavROLink == null) || !(chld.roid.Equals(SavROLink.ROID.ToUpper()))); //added security check (UserInfo.CanEdit) + btnCancelRO.Enabled = (_savCurROLink != null && (SavROLink != null && chld.roid != 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 - tbROValue.Text = chld.value; + tbROValue.Text = chld.value; btnPreviewRO.Enabled = false; if (chld.roid.StartsWith("FFFF")) btnGoToRO.Enabled = false; break; @@ -393,6 +403,12 @@ namespace Volian.Controls.Library } } } + else + { + // B2022-088: [JPR] Find Doc Ro button not working in Word Sections + // B2022-098: [JPR] ROs not being resolved in Word Sections + ResetSearch(); + } } #endregion @@ -556,7 +572,6 @@ namespace Volian.Controls.Library return; } - //if (MyROFST != _curROFST || tvROFST.Nodes == null || tvROFST.Nodes.Count <= 0) if(RoTreeNeedsReloaded || tvROFST.Nodes == null || tvROFST.Nodes.Count <= 0) { ROFSTLookup.rodbi[] dbs = MyROFSTLookup.GetRODatabaseList(true); @@ -888,15 +903,15 @@ namespace Volian.Controls.Library MyRTB.OnRoInsert(this, new StepRTBRoEventArgs(valtxt, selectedChld.value, linktxt, padroid, MyROFST.RODbID)); } - - btnGoToRO.Enabled = false; - btnSaveRO.Enabled = false; - btnCancelRO.Enabled = false; - btnPreviewRO.Enabled = false; - - CurROLink = null; - _savCurROLink = null; } + + btnGoToRO.Enabled = false; + btnSaveRO.Enabled = false; + btnCancelRO.Enabled = false; + btnPreviewRO.Enabled = false; + + CurROLink = null; + _savCurROLink = null; } } @@ -1014,60 +1029,99 @@ namespace Volian.Controls.Library // tries to process a search while the main tab/procedure is closing try { - if (this.Enabled && !string.IsNullOrEmpty(searchValue)) + searchValue = (!string.IsNullOrEmpty(searchValue)) ? searchValue.Replace('\u2011', '-').Replace(@"\u9586?", @"\\").Trim() : searchValue; + + if (this.Enabled && !string.IsNullOrEmpty(searchValue) && searchValue.Length >= 2 && !searchValue.Contains("#Link:Transition")) { Dictionary dicRoVals = new Dictionary(); - searchValue = searchValue.Replace('\u2011', '-').Replace(@"\u9586?", @"\\"); - - // B2022-088: Find Doc Ro button not working in Word Sections - if (searchValue.StartsWith("<") && searchValue.EndsWith(">")) + + // B2022-088: [JPR] Find Doc Ro button not working in Word Sections + // B2022-098: [JPR] ROs not being resolved in Word Sections + if (searchValue.StartsWith("<") && searchValue.EndsWith(">")) // RO Link (accPageID) { ROFSTLookup.rochild roc = MyROFSTLookup.GetROChildByAccPageID(searchValue); - if (roc.ID >= 0 && !string.IsNullOrEmpty(roc.value)) - dicRoVals.Add(roc.roid, roc.value); - } - else if (searchValue.Length >= 2 && searchValue != _lastSearchValue) - { - dicRoVals = MyROFSTLookup.Search(searchValue, searchTypeID, false, MaxNumSearchRecords); - } + // If RO is valid then select node in tree view + if (roc.ID >= 0 && !string.IsNullOrEmpty(roc.value)) + { + ExpandNode(roc.roid); + } - if (dicRoVals.Count > 0) - { - lbFound.SelectedValueChanged -= new EventHandler(lbFound_SelectedValueChanged); - - lbFound.DataSource = new BindingSource(dicRoVals, null); - lbFound.ValueMember = "Key"; // roid - lbFound.DisplayMember = "Value"; // default value - - lbFound.SelectionMode = SelectionMode.One; - lbFound.SelectedIndex = -1; - lbFound.Visible = true; - - lbFound.SelectedValueChanged += new EventHandler(lbFound_SelectedValueChanged); - - if (lbFound.Items != null && lbFound.Items.Count == 1) - lbFound.SelectedIndex = 0; - } - else - { - searchValue = string.Empty; lbFound.DataSource = null; lbFound.Visible = false; + + _lastSearchValue = searchValue; } + else if (searchValue.Contains("#Link:ReferencedObject")) // RO Link (roid) + { + searchValue = searchValue.Replace("1[END>", string.Empty).Trim(); + string roid = ROFSTLookup.FormatRoidKey(searchValue.Substring(searchValue.LastIndexOf(" ")), true); + + if (roid != selectedChld.roid) + { + ROFSTLookup.rochild roc = MyROFSTLookup.GetRoChild(roid); + ExpandNode(roc.roid); + } + + lbFound.DataSource = null; + lbFound.Visible = false; + + _lastSearchValue = searchValue; + } + else // if (searchValue != _lastSearchValue) + { + dicRoVals = MyROFSTLookup.Search(searchValue, searchTypeID, false, MaxNumSearchRecords); + + if (dicRoVals.Count > 0) + { + lbFound.SelectedValueChanged -= new EventHandler(lbFound_SelectedValueChanged); + + lbFound.DataSource = new BindingSource(dicRoVals, null); + lbFound.ValueMember = "Key"; // roid + lbFound.DisplayMember = "Value"; // default value + + lbFound.SelectionMode = SelectionMode.One; + lbFound.SelectedIndex = -1; + lbFound.Visible = true; + + lbFound.SelectedValueChanged += new EventHandler(lbFound_SelectedValueChanged); + + if (lbFound.Items != null && lbFound.Items.Count == 1) + lbFound.SelectedIndex = 0; + } + else + { + lbFound.DataSource = null; + lbFound.Visible = false; + } + + _lastSearchValue = searchValue; + } } else { - searchValue = string.Empty; + _lastSearchValue = string.Empty; lbFound.DataSource = null; lbFound.Visible = false; } - _lastSearchValue = searchValue; } catch { } } + private void ResetSearch() + { + // Clear the Display/Info for Prev Selected RO Child + tbROValue.Text = null; + lbROId.Text = string.Empty; + + // Disable all buttons by default + btnGoToRO.Enabled = false; + btnSaveRO.Enabled = false; + btnCancelRO.Enabled = false; + btnPreviewRO.Enabled = false; + } + #endregion } } diff --git a/PROMS/Volian.Controls.Library/DisplaySearch.cs b/PROMS/Volian.Controls.Library/DisplaySearch.cs index 62443b98..22399c0e 100644 --- a/PROMS/Volian.Controls.Library/DisplaySearch.cs +++ b/PROMS/Volian.Controls.Library/DisplaySearch.cs @@ -11,6 +11,7 @@ using DevComponents.AdvTree; using Volian.Base.Library; using System.Text.RegularExpressions; using JR.Utils.GUI.Forms; +using System.Linq; namespace Volian.Controls.Library { @@ -1346,25 +1347,15 @@ namespace Volian.Controls.Library { for (int i = 0; i < dbs.Length; i++) { - DevComponents.AdvTree.Node tn = new DevComponents.AdvTree.Node(); - ROFSTLookup.rodbi db = dbs[i]; - tn.Text = db.dbiTitle; + + DevComponents.AdvTree.Node tn = new DevComponents.AdvTree.Node(db.dbiTitle); tn.Tag = db; cmboTreeROs.Nodes.Add(tn); AddDummyGroup(db, tn); } } - - //for (int i = 0; i < _MyROFSTLookup.myHdr.myDbs.Length; i++) - //{ - // DevComponents.AdvTree.Node tn = new DevComponents.AdvTree.Node(); - // tn.Text = _MyROFSTLookup.myHdr.myDbs[i].dbiTitle; - // tn.Tag = _MyROFSTLookup.myHdr.myDbs[i]; - // cmboTreeROs.Nodes.Add(tn); - // AddDummyGroup(_MyROFSTLookup.myHdr.myDbs[i], tn); - //} } } } @@ -1395,10 +1386,9 @@ namespace Volian.Controls.Library private void AddDummyGroup(ROFSTLookup.rodbi rodbi, DevComponents.AdvTree.Node tn) { - if (rodbi.children != null && rodbi.children.Length > 0) + if (MyROFSTLookup.HasChildren(ref rodbi)) { - DevComponents.AdvTree.Node tmp = new DevComponents.AdvTree.Node(); - tmp.Text = DummyNodeText; + DevComponents.AdvTree.Node tmp = new DevComponents.AdvTree.Node(DummyNodeText); tn.Nodes.Add(tmp); } } @@ -1410,29 +1400,21 @@ namespace Volian.Controls.Library private void LoadChildren(DevComponents.AdvTree.Node tn) { - object tag = tn.Tag; if (tn.HasChildNodes && tn.Nodes[0].Text != DummyNodeText) return; // already loaded. if (tn.HasChildNodes && tn.Nodes[0].Text == DummyNodeText) tn.Nodes[0].Remove(); + ROFSTLookup.rochild[] chld = null; if (tn.Tag is ROFSTLookup.rodbi) { ROFSTLookup.rodbi db = (ROFSTLookup.rodbi)tn.Tag; - - // Try to Lazy Load children - B2022-026 RO Memory Reduction code - if (db.children == null || db.children.Length <= 0) - db.children = MyROFSTLookup.GetRoChildrenByID(db.ID, db.dbiID, true); - + MyROFSTLookup.LoadChildren(ref db); chld = db.children; } else if (tn.Tag is ROFSTLookup.rochild) { ROFSTLookup.rochild ch = (ROFSTLookup.rochild)tn.Tag; - - // Try to Lazy Load children - B2022-026 RO Memory Reduction code - if (ch.children == null || ch.children.Length <= 0) - ch.children = MyROFSTLookup.GetRoChildrenByRoid(ch.roid, true); - + MyROFSTLookup.LoadChildren(ref ch); chld = ch.children; } else @@ -1440,6 +1422,7 @@ namespace Volian.Controls.Library Console.WriteLine("error - no type"); return; } + // if children, add dummy node // B2022-026 RO Memory Reduction code - need to check length if (chld != null && chld.Length > 0) @@ -1451,43 +1434,54 @@ namespace Volian.Controls.Library ProgressBar_SetValue(i); DevComponents.AdvTree.Node tmp = null; - // Try to Lazy Load children - B2022-026 RO Memory Reduction code - if (chld[i].children == null || chld[i].children.Length <= 0) - chld[i].children = MyROFSTLookup.GetRoChildrenByRoid(chld[i].roid, true); + ROFSTLookup.rochild roc = chld[i]; // if this is a group, i.e. type 0, add a dummy node // B2022-026 RO Memory Reduction code - check children length - if (chld[i].type == 0 && (chld[i].children == null || chld[i].children.Length <= 0)) + if (roc.type == 0 && !MyROFSTLookup.HasChildren(ref roc)) { - //skip it. - // TODO: KBR how to handle this? - //Console.WriteLine("ro junk"); - continue; + continue; // Ignore: Junk Scenario } - else if (chld[i].value == null) + else if (!string.IsNullOrEmpty(roc.appid)) { - tmp = new DevComponents.AdvTree.Node(); + 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; + + roc.children = new List().ToArray(); + } + } + + + if (roc.value == null) + { + tmp = new DevComponents.AdvTree.Node(roc.title); + tmp.Tag = roc; - tmp.Text = chld[i].title; - tmp.Tag = chld[i]; int index = FindIndex(tn.Nodes, tmp.Text); tn.Nodes.Insert(index, tmp); - //tn.Nodes.Add(tmp); - DevComponents.AdvTree.Node sub = new DevComponents.AdvTree.Node(); - sub.Text = DummyNodeText; + DevComponents.AdvTree.Node sub = new DevComponents.AdvTree.Node(DummyNodeText); tmp.Nodes.Add(sub); } else { - tmp = new DevComponents.AdvTree.Node(); + tmp = new DevComponents.AdvTree.Node(roc.title); + tmp.Tag = roc; - tmp.Text = chld[i].title; - tmp.Tag = chld[i]; - int index = FindIndex(tn.Nodes, tmp.Text); - - tn.Nodes.Insert(index, tmp); - //tn.Nodes.Add(tmp); + if (roc.roid.Length == 16) + { + tn.Nodes.Add(tmp); + } + else + { + int index = FindIndex(tn.Nodes, tmp.Text); + tn.Nodes.Insert(index, tmp); + } } } }