B2022-098: ROs not being resolved in Word Sections

This commit is contained in:
Jake 2022-08-16 15:02:30 +00:00
parent 9bdaebadfc
commit ac8e8432b7
10 changed files with 913 additions and 302 deletions

View File

@ -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

View File

@ -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

View File

@ -4116,15 +4116,11 @@ 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 == "?")
{

View File

@ -129,7 +129,8 @@ namespace VEPROMS.CSLA.Library
public const string RoMissingDefaultValue = "[TBD]";
private static List<RoExtension> _extensions;
private List<RoExtension> _extensions;
private List<string> _baseAccPageKeys;
// RofstLookup/Conversion Variables
private int _rofstID;
@ -197,6 +198,18 @@ namespace VEPROMS.CSLA.Library
}
}
public List<string> 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("<U-") && useDefaultExt) ? "A" : string.Empty;
return FormatAccPageKeyWithExt(accPageID, spDefault, igDefault, ref accPageBase, ref accPageExt);
}
return accPageKey;
public string FormatAccPageKey(string accPageID, string spDefault, string igDefault)
{
string accPageBase = string.Empty;
string accPageExt = string.Empty;
return FormatAccPageKeyWithExt(accPageID, spDefault, igDefault, ref accPageBase, ref accPageExt);
}
public static string FormatAccPageKey(string accPageID, string spDefault, string igDefault)
public string FormatAccPageKey(string accPageID, string spDefault, string igDefault, ref string accPageBase, ref string accPageExt)
{
if (!string.IsNullOrEmpty(accPageID))
{
accPageID = accPageID.ToUpper();
if (!accPageID.StartsWith("<"))
accPageID = string.Format("<{0}", accPageID);
if (!accPageID.EndsWith(">"))
accPageID = string.Format("{0}>", accPageID);
accPageID = accPageID.Replace("<U>", "<U-NUMBER>");
accPageID = accPageID.ToCleanString(); // Removes any spaces
// Clean up the AccPageID before using it to do a lookup
if (!string.IsNullOrEmpty(spDefault))
accPageID = accPageID.Replace("<SP-", "<" + spDefault + "-");
if (!string.IsNullOrEmpty(igDefault))
accPageID = accPageID.Replace("<IG-", "<" + igDefault + "-");
if (!accPageID.StartsWith("<U-"))
accPageID = accPageID.Trim("<>".ToCharArray()); // String < and >
accPageID = regRoKeyHigh.Replace(accPageID, "_HIGH$3");
accPageID = regRoKeyLow.Replace(accPageID, "_LOW$3");
accPageID = accPageID.ToUpper();
}
return accPageID;
}
public static string FormatAccPageKey(string accPageID, string spDefault, string igDefault, ref string accPageBase, ref string accPageExt, bool useDefaultExt = true)
{
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("<U-") && useDefaultExt) ? "A" : string.Empty;
}
return accPageKey;
return FormatAccPageKeyWithExt(accPageID, spDefault, igDefault, ref accPageBase, ref accPageExt);
}
public ROFSTLookup.rochild GetROChildByAccPageID(string accPageID)
@ -392,16 +357,19 @@ namespace VEPROMS.CSLA.Library
public ROFSTLookup.rochild GetROChildByAccPageID(string accPageID, string spDefault, string igDefault)
{
string accPageBase = string.Empty;
string accPageExt = string.Empty;
// Cleanup accPageID if necessary [Note* This will also handle any UnitInfo Ro Values (ex: "<U-NUMBER>")]
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<string> GetBaseAccPageKeys()
{
try
{
List<string> lst = new List<string>();
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: "<U-NUMBER>")
string accPageKey = FormatAccPageKey(accPageID, spDefault, igDefault);
// Check if roid is for a Unit Information RO Value Tag
if (!string.IsNullOrEmpty(accPageKey) && accPageKey.StartsWith("<U-"))
if (!string.IsNullOrEmpty(accPageID) && accPageID.StartsWith("<U-"))
{
return GetUnitInfoRoChild(GetUnitInfoRoidByAccPageID(accPageKey));
return GetUnitInfoRoChild(GetUnitInfoRoidByAccPageID(accPageID));
}
// Lookup RO Value in the database based on the AccPageKey
@ -1286,13 +1285,13 @@ namespace VEPROMS.CSLA.Library
cmd.CommandText = "vesp_RofstDataGetChildByAccPageID";
cmd.Parameters.Add(new SqlParameter("@RofstID", SqlDbType.Int)).Value = rofstID;
cmd.Parameters.Add(new SqlParameter("@AccPageID", SqlDbType.VarChar)).Value = accPageKey;
cmd.Parameters.Add(new SqlParameter("@AccPageID", SqlDbType.VarChar)).Value = accPageID;
using (SafeDataReader dr = new SafeDataReader(cmd.ExecuteReader()))
{
if (dr.Read())
{
return ConvertToRochildObject(dr, loadChildren, loadAllChildren);
return ConvertToRochildObject(dr, false, false);
}
}
}
@ -1306,6 +1305,53 @@ namespace VEPROMS.CSLA.Library
}
}
private string FormatAccPageKeyWithExt(string accPageID, string spDefault, string igDefault, ref string accPageBase, ref string accPageExt)
{
accPageBase = string.Empty;
accPageExt = string.Empty;
if (!string.IsNullOrEmpty(accPageID))
{
accPageID = accPageID.ToUpper();
if (!accPageID.StartsWith("<")) accPageID = string.Format("<{0}", accPageID);
if (!accPageID.EndsWith(">")) accPageID = string.Format("{0}>", accPageID);
accPageID = accPageID.Replace("<U>", "<U-NUMBER>");
accPageID = accPageID.ToCleanString(); // Removes any spaces
// Clean up the AccPageID before using it to do a lookup
if (accPageID.StartsWith("<U-"))
{
accPageBase = accPageID;
accPageExt = string.Empty;
}
else
{
if (!string.IsNullOrEmpty(spDefault)) accPageID = accPageID.Replace("<SP-", "<" + spDefault + "-");
if (!string.IsNullOrEmpty(igDefault)) accPageID = accPageID.Replace("<IG-", "<" + igDefault + "-");
accPageID = regRoKeyHigh.Replace(accPageID, "_HIGH$3");
accPageID = regRoKeyLow.Replace(accPageID, "_LOW$3");
accPageID = accPageID.Trim("<>".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)

View File

@ -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 != "?")

View File

@ -947,16 +947,12 @@ 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
@ -1162,7 +1158,9 @@ 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,6 +1413,7 @@ namespace VEPROMS.CSLA.Library
// All ROs at this point should have a specific accPageExt or the default (A/0041)
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
@ -2033,7 +2032,9 @@ namespace VEPROMS.CSLA.Library
executeResult = find.Execute();
// B2022-053 if the found text does not begin with a "<" and end with a ">", 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;

View File

@ -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,26 +2970,37 @@ 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;
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 (!string.IsNullOrEmpty(retval))
{
if (stripRTF) retval = StripRtfFormatting(retval);
retval = StripLinks(retval);
retval = ReplaceSpecialCharacters(retval);
@ -2995,11 +3009,17 @@ namespace VEPROMS.CSLA.Library
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;
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 ?", "");
@ -3018,17 +3038,26 @@ namespace VEPROMS.CSLA.Library
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;
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;
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,10 +3211,15 @@ namespace VEPROMS.CSLA.Library
{
return RemoveRtfStyles(rtf, ActiveFormat);
}
public string RemoveRtfStyles(string rtf, FormatInfo fmt)
{
string retval = rtf;
if (!string.IsNullOrEmpty(retval))
{
VE_Font TextFont = GetItemFont(fmt);
if (TextFont != null)
{
// remove rtf commands for any styles that were added. Note that if
@ -3204,8 +3246,12 @@ namespace VEPROMS.CSLA.Library
retval = RemoveToken(retval, @"\\i");
}
}
}
return retval;
}
public bool SameRowAsParent
{
get
@ -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;
}

View File

@ -531,6 +531,10 @@ namespace VEPROMS.CSLA.Library
{
List<string> roids = new List<string>();
// 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)
{
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);
@ -548,6 +552,7 @@ namespace VEPROMS.CSLA.Library
}
}
}
}
return roids;
}
@ -600,10 +605,13 @@ namespace VEPROMS.CSLA.Library
{
Dictionary<string, int> myRoImagesList = new Dictionary<string, int>();
if (myROImages != null)
{
foreach (ROImageInfo myROImage in myROImages)
{
myRoImagesList.Add(ROImageKey(myROImage.FileName, myROImage.DTS), myROImage.ImageID);
}
}
return myRoImagesList;
}
@ -616,13 +624,19 @@ namespace VEPROMS.CSLA.Library
private static string buildImageIDString(List<int> myROImageIDs)
{
StringBuilder sb = new StringBuilder();
string sep = "";
// 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)
{
string sep = string.Empty;
foreach (int imageID in myROImageIDs)
{
sb.Append(sep + imageID.ToString());
sep = ",";
}
}
return sb.ToString();
}

View File

@ -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,18 +365,16 @@ 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)
@ -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,6 +903,7 @@ namespace Volian.Controls.Library
MyRTB.OnRoInsert(this, new StepRTBRoEventArgs(valtxt, selectedChld.value, linktxt, padroid, MyROFST.RODbID));
}
}
btnGoToRO.Enabled = false;
btnSaveRO.Enabled = false;
@ -898,7 +914,6 @@ namespace Volian.Controls.Library
_savCurROLink = null;
}
}
}
private bool CheckROSelection(ROFSTLookup.rochild selectedRO)
{
@ -1014,23 +1029,48 @@ 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<string, string> dicRoVals = new Dictionary<string, string>();
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 RO is valid then select node in tree view
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);
ExpandNode(roc.roid);
}
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)
{
@ -1051,23 +1091,37 @@ namespace Volian.Controls.Library
}
else
{
searchValue = string.Empty;
lbFound.DataSource = null;
lbFound.Visible = false;
}
}
else
{
searchValue = string.Empty;
lbFound.DataSource = null;
lbFound.Visible = false;
}
_lastSearchValue = searchValue;
}
}
else
{
_lastSearchValue = string.Empty;
lbFound.DataSource = null;
lbFound.Visible = false;
}
}
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
}
}

View File

@ -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<ROFSTLookup.rochild>().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];
if (roc.roid.Length == 16)
{
tn.Nodes.Add(tmp);
}
else
{
int index = FindIndex(tn.Nodes, tmp.Text);
tn.Nodes.Insert(index, tmp);
//tn.Nodes.Add(tmp);
}
}
}
}