B2022-082: Search for THEN STOP not finding occurrences in RNOs

This commit is contained in:
Kathy Ruffing 2022-07-29 13:32:16 +00:00
parent 8b21a92729
commit 78bd41dc56
3 changed files with 35 additions and 18 deletions

View File

@ -1681,7 +1681,8 @@ GO
==========================================================================================================
*/
Create Function [dbo].[vefn_SiblingAndChildrenItemsNewByWord](@DocVersionList VarChar(Max), @UnitPrefix VarChar(Max), @SearchString VarChar(Max),
@SearchStringx VarChar(Max), @StepTypeList VarChar(Max))
@SearchStringx VarChar(Max), @StepTypeList VarChar(Max),
@includeLinks int, @includeRtfFormatting int , @includeSpecialCharacters int)
Returns @SiblingAndChildren Table
(
ILastChanged VarBinary(8),
@ -1888,8 +1889,11 @@ Begin
join dbo.vefn_DocVersionSplit(@DocVersionList) dv on dv.VersionID = zi.VersionID
left join Entries e with (NoLock) on e.ContentID = zi.ContentID
left join Documents d with (NoLock) on d.DocID = e.DocID
Where (@TextPrefix + zi.[Text] + @TextSuffix like @SearchString Or Replace(d.DocAscii, nChar(176), '\''B0') like @SearchString
Or @TextPrefix + zi.[Text] + @TextSuffix like @SearchStringx Or Replace(d.DocAscii, nChar(176), '\''B0') like @SearchStringx)
-- B2022-082: use the vefn_RemoveExtraText to get rid of rtf commands before comparing text
Where (dbo.vefn_RemoveExtraText(@TextPrefix + zi.[Text] + @TextSuffix, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters)
like @SearchString Or Replace(d.DocAscii, nChar(176), '\''B0') like @SearchString
Or dbo.vefn_RemoveExtraText(@TextPrefix + zi.[Text] + @TextSuffix, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters)
like @SearchStringx Or Replace(d.DocAscii, nChar(176), '\''B0') like @SearchStringx)
And (IsNull(@StepTypeList,'') = '' or (dbo.vefn_AllSections(zi.CType) in (Select ID from dbo.vefn_SplitInt(@StepTypeList,','))))
Option (Recompile, MaxRecursion 10000);
@ -6329,6 +6333,9 @@ IF @includeLink < 2 -- Remove Comments
if(@includeRtfFormatting=0)
-- Remove Rtf Formatting
BEGIN
-- B2022-082: underline/bold of word removes space between 2 words so was not finding cases
SET @text = Replace(@text, '\ulnone\b0 ', '');
SET @text = Replace(@text, '\b0\ulnone ', '');
SET @text = Replace(@text, '\b0 ', '');
SET @text = Replace(@text, '\b ', '');
SET @text = Replace(@text, '\ulnone ', '');
@ -15956,7 +15963,7 @@ Begin
(Select Count(1) From RoUsages ru with (NoLock) Where ru.ContentID = z.ContentID) as 'RoUsageCount',
(Select Count(1) From Transitions t with (NoLock) Where t.FromID = z.ContentID) as 'TransitionCount',
(Select Count(1) From ZContents zc with (NoLock) Where zc.ContentID = z.ContentID) as 'ZContentCount'
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList) z
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters) z
Order By z.DvPath Asc
Option (Recompile);
@ -16004,7 +16011,7 @@ Begin
(Select Count(1) From RoUsages ru with (NoLock) Where ru.ContentID = z.ContentID) as 'RoUsageCount',
(Select Count(1) From Transitions t with (NoLock) Where t.FromID = z.ContentID) as 'TransitionCount',
(Select Count(1) From ZContents zc with (NoLock) Where zc.ContentID = z.ContentID) as 'ZContentCount'
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList) z
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters) z
Where (@TextPrefix + z.Text + @TextSuffix Collate SQL_Latin1_General_CP1_CS_AS like @SearchString
or @TextPrefix + z.Text + @TextSuffix Collate SQL_Latin1_General_CP1_CS_AS like @SearchStringx
or Replace(z.DocAscii,nChar(176),'\''B0') Collate SQL_Latin1_General_CP1_CS_AS like @SearchString
@ -16063,7 +16070,7 @@ Begin
(Select Count(1) From RoUsages ru with (NoLock) Where ru.ContentID = z.ContentID) as 'RoUsageCount',
(Select Count(1) From Transitions t with (NoLock) Where t.FromID = z.ContentID) as 'TransitionCount',
(Select Count(1) From ZContents zc with (NoLock) Where zc.ContentID = z.ContentID) as 'ZContentCount'
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList) z
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters) z
Where (dbo.vefn_RemoveExtraText(@TextPrefix + z.Text + @TextSuffix, @IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) Collate SQL_Latin1_General_CP1_CI_AS like @SearchString
Or dbo.vefn_RemoveExtraText(@TextPrefix + z.Text + @TextSuffix, @IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) Collate SQL_Latin1_General_CP1_CI_AS like @SearchStringx
Or Replace(z.DocAscii, nChar(176), '\''B0') Collate SQL_Latin1_General_CP1_CI_AS like @SearchString
@ -16117,7 +16124,7 @@ Begin
(Select Count(1) From RoUsages ru with (NoLock) Where ru.ContentID = z.ContentID) as 'RoUsageCount',
(Select Count(1) From Transitions t with (NoLock) Where t.FromID = z.ContentID) as 'TransitionCount',
(Select Count(1) From ZContents zc with (NoLock) Where zc.ContentID = z.ContentID) as 'ZContentCount'
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList) z
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters) z
Where (dbo.vefn_RemoveExtraText(Replace(@TextPrefix + z.Text + @TextSuffix,'\''b0', '\''B0'), @IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) Collate SQL_Latin1_General_CP1_CS_AS like Replace(@SearchString,'\''b0', '\''B0')
Or dbo.vefn_RemoveExtraText(Replace(@TextPrefix + z.Text + @TextSuffix,'\''b0', '\''B0'), @IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) Collate SQL_Latin1_General_CP1_CS_AS like Replace(@SearchStringx,'\''b0', '\''B0')
Or Replace(z.DocAscii,nChar(176),'\''B0') Collate SQL_Latin1_General_CP1_CS_AS like @SearchString
@ -20979,8 +20986,8 @@ BEGIN TRY -- Try Block
DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255)
set @RevDate = '07/27/2022 1:20 PM'
set @RevDescription = 'B2022-083: Support Conditional RO Values (v2.1)'
set @RevDate = '07/29/2022 9:00 AM'
set @RevDescription = 'B2022-082: Search not finding occurrences that use bold and underline'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription

View File

@ -1681,7 +1681,8 @@ GO
==========================================================================================================
*/
Create Function [dbo].[vefn_SiblingAndChildrenItemsNewByWord](@DocVersionList VarChar(Max), @UnitPrefix VarChar(Max), @SearchString VarChar(Max),
@SearchStringx VarChar(Max), @StepTypeList VarChar(Max))
@SearchStringx VarChar(Max), @StepTypeList VarChar(Max),
@includeLinks int, @includeRtfFormatting int , @includeSpecialCharacters int)
Returns @SiblingAndChildren Table
(
ILastChanged VarBinary(8),
@ -1888,8 +1889,11 @@ Begin
join dbo.vefn_DocVersionSplit(@DocVersionList) dv on dv.VersionID = zi.VersionID
left join Entries e with (NoLock) on e.ContentID = zi.ContentID
left join Documents d with (NoLock) on d.DocID = e.DocID
Where (@TextPrefix + zi.[Text] + @TextSuffix like @SearchString Or Replace(d.DocAscii, nChar(176), '\''B0') like @SearchString
Or @TextPrefix + zi.[Text] + @TextSuffix like @SearchStringx Or Replace(d.DocAscii, nChar(176), '\''B0') like @SearchStringx)
-- B2022-082: use the vefn_RemoveExtraText to get rid of rtf commands before comparing text
Where (dbo.vefn_RemoveExtraText(@TextPrefix + zi.[Text] + @TextSuffix, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters)
like @SearchString Or Replace(d.DocAscii, nChar(176), '\''B0') like @SearchString
Or dbo.vefn_RemoveExtraText(@TextPrefix + zi.[Text] + @TextSuffix, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters)
like @SearchStringx Or Replace(d.DocAscii, nChar(176), '\''B0') like @SearchStringx)
And (IsNull(@StepTypeList,'') = '' or (dbo.vefn_AllSections(zi.CType) in (Select ID from dbo.vefn_SplitInt(@StepTypeList,','))))
Option (Recompile, MaxRecursion 10000);
@ -6329,6 +6333,9 @@ IF @includeLink < 2 -- Remove Comments
if(@includeRtfFormatting=0)
-- Remove Rtf Formatting
BEGIN
-- B2022-082: underline/bold of word removes space between 2 words so was not finding cases
SET @text = Replace(@text, '\ulnone\b0 ', '');
SET @text = Replace(@text, '\b0\ulnone ', '');
SET @text = Replace(@text, '\b0 ', '');
SET @text = Replace(@text, '\b ', '');
SET @text = Replace(@text, '\ulnone ', '');
@ -15956,7 +15963,7 @@ Begin
(Select Count(1) From RoUsages ru with (NoLock) Where ru.ContentID = z.ContentID) as 'RoUsageCount',
(Select Count(1) From Transitions t with (NoLock) Where t.FromID = z.ContentID) as 'TransitionCount',
(Select Count(1) From ZContents zc with (NoLock) Where zc.ContentID = z.ContentID) as 'ZContentCount'
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList) z
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters) z
Order By z.DvPath Asc
Option (Recompile);
@ -16004,7 +16011,7 @@ Begin
(Select Count(1) From RoUsages ru with (NoLock) Where ru.ContentID = z.ContentID) as 'RoUsageCount',
(Select Count(1) From Transitions t with (NoLock) Where t.FromID = z.ContentID) as 'TransitionCount',
(Select Count(1) From ZContents zc with (NoLock) Where zc.ContentID = z.ContentID) as 'ZContentCount'
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList) z
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters) z
Where (@TextPrefix + z.Text + @TextSuffix Collate SQL_Latin1_General_CP1_CS_AS like @SearchString
or @TextPrefix + z.Text + @TextSuffix Collate SQL_Latin1_General_CP1_CS_AS like @SearchStringx
or Replace(z.DocAscii,nChar(176),'\''B0') Collate SQL_Latin1_General_CP1_CS_AS like @SearchString
@ -16063,7 +16070,7 @@ Begin
(Select Count(1) From RoUsages ru with (NoLock) Where ru.ContentID = z.ContentID) as 'RoUsageCount',
(Select Count(1) From Transitions t with (NoLock) Where t.FromID = z.ContentID) as 'TransitionCount',
(Select Count(1) From ZContents zc with (NoLock) Where zc.ContentID = z.ContentID) as 'ZContentCount'
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList) z
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters) z
Where (dbo.vefn_RemoveExtraText(@TextPrefix + z.Text + @TextSuffix, @IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) Collate SQL_Latin1_General_CP1_CI_AS like @SearchString
Or dbo.vefn_RemoveExtraText(@TextPrefix + z.Text + @TextSuffix, @IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) Collate SQL_Latin1_General_CP1_CI_AS like @SearchStringx
Or Replace(z.DocAscii, nChar(176), '\''B0') Collate SQL_Latin1_General_CP1_CI_AS like @SearchString
@ -16117,7 +16124,7 @@ Begin
(Select Count(1) From RoUsages ru with (NoLock) Where ru.ContentID = z.ContentID) as 'RoUsageCount',
(Select Count(1) From Transitions t with (NoLock) Where t.FromID = z.ContentID) as 'TransitionCount',
(Select Count(1) From ZContents zc with (NoLock) Where zc.ContentID = z.ContentID) as 'ZContentCount'
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList) z
From dbo.vefn_SiblingAndChildrenItemsNewByWord(@DocVersionList, @UnitPrefix, @SearchString, @SearchStringx, @StepTypeList, @includeLinks, @includeRtfFormatting, @includeSpecialCharacters) z
Where (dbo.vefn_RemoveExtraText(Replace(@TextPrefix + z.Text + @TextSuffix,'\''b0', '\''B0'), @IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) Collate SQL_Latin1_General_CP1_CS_AS like Replace(@SearchString,'\''b0', '\''B0')
Or dbo.vefn_RemoveExtraText(Replace(@TextPrefix + z.Text + @TextSuffix,'\''b0', '\''B0'), @IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) Collate SQL_Latin1_General_CP1_CS_AS like Replace(@SearchStringx,'\''b0', '\''B0')
Or Replace(z.DocAscii,nChar(176),'\''B0') Collate SQL_Latin1_General_CP1_CS_AS like @SearchString
@ -20979,8 +20986,8 @@ BEGIN TRY -- Try Block
DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255)
set @RevDate = '07/27/2022 1:20 PM'
set @RevDescription = 'B2022-083: Support Conditional RO Values (v2.1)'
set @RevDate = '07/29/2022 9:00 AM'
set @RevDescription = 'B2022-082: Search not finding occurrences that use bold and underline'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription

View File

@ -2965,6 +2965,9 @@ namespace VEPROMS.CSLA.Library
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 ?", "");