Supporting logic to handle the use of the backslash character

Supporting logic to handle the use of the backslash character, and question marks
Supporting logic to handle the use of the backslash character, dashes, and symbols
Supporting logic to handle the use of the backslash character and dashes
This commit is contained in:
2016-06-21 15:15:01 +00:00
parent 66b9792324
commit 4c6d09803d
17 changed files with 149 additions and 31 deletions

View File

@@ -1017,6 +1017,7 @@ BEGIN
Set @SearchString = replace(@SearchString,'\%','*')
Set @SearchString = replace(@SearchString,'\_','?')
Set @SearchString = replace(@SearchString,'-','\u8209?')
Set @SearchString = replace(@SearchString,'\','\u9586?')
IF(@SearchString like '[%]%') RETURN @SearchString
IF(@SearchString like '%[%]') RETURN @SearchString
Set @SearchString = replace('%' + @SearchString + '%','%%','%')
@@ -2952,11 +2953,18 @@ RETURNS @FoundContents TABLE
WITH EXECUTE AS OWNER
AS
BEGIN
DECLARE @Dashes varchar(25)
set @Dashes = '\u8209?'
if(@SearchString not like '%\u8209?%')
BEGIN
set @Dashes='-'
END
IF(ISNULL(@DocVersionList,'')='')
BEGIN
INSERT INTO @FoundContents -- Do a case insensitive search
select ContentID,Type,Text from contents
where .dbo.vefn_RemoveExtraText(Replace([Text],'-','\u8209?'),@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) like @SearchString Collate SQL_Latin1_General_CP1_CI_AS
where replace(.dbo.vefn_RemoveExtraText(Replace([Text],'-','\u8209?'),@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters),'\u8209?',@Dashes) like @SearchString Collate SQL_Latin1_General_CP1_CI_AS
--where .dbo.vefn_RemoveExtraText(Replace(Replace([Text],'-','\u8209?'),'\','\u9586?'),@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) like @SearchString Collate SQL_Latin1_General_CP1_CI_AS
-- where Replace([Text],'-','\u8209?') like @SearchString Collate SQL_Latin1_General_CP1_CI_AS
--where Replace(Replace([Text],'-','\u8209?'),'\u160?',' ') like @SearchString Collate SQL_Latin1_General_CP1_CI_AS
END
@@ -2966,7 +2974,8 @@ ELSE
select ContentID,Type,Text from contents
where [ContentID] in (select [ContentID] from vefn_DVContent(@DocVersionList))
-- bug fix B2014-056 and B2014-102 now use vefn_RemoveExtraText which fixes searching for hard spaces and finding procedure text when it is bolded (or italics or underlined etc)
AND .dbo.vefn_RemoveExtraText(Replace([Text],'-','\u8209?'),@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) like @SearchString Collate SQL_Latin1_General_CP1_CI_AS
AND Replace(.dbo.vefn_RemoveExtraText(Replace([Text],'-','\u8209?'),@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters),'\u8209?',@Dashes) like @SearchString Collate SQL_Latin1_General_CP1_CI_AS
--AND .dbo.vefn_RemoveExtraText(Replace(Replace([Text],'-','\u8209?'),'\','\u9586?'),@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) like @SearchString Collate SQL_Latin1_General_CP1_CI_AS
--AND Replace([Text],'-','\u8209?') like @SearchString Collate SQL_Latin1_General_CP1_CI_AS
--AND Replace(Replace([Text],'-','\u8209?'),'\u160?',' ') like @SearchString Collate SQL_Latin1_General_CP1_CI_AS
END
@@ -3023,6 +3032,7 @@ ELSE
BEGIN
Declare @SearchStringx nvarchar(200) --kbr
set @SearchStringx = replace(@SearchString,'-','\u8209?') --kbr
--set @SearchStringx = replace(replace(@SearchString,'-','\u8209?'),'\','\u9586?') --kbr
IF @CaseSensitive = 0 -- Not Case Sensitive
BEGIN
insert into @FoundContents
@@ -5845,6 +5855,7 @@ BEGIN TRY -- Try Block
)
DECLARE @NewTopID as int
INSERT INTO @Procs select ZZ.ItemID, isnull(Replace(CC.Number,'\u8209?','-'),'') + ':' + substring('0000000000000000' + cast(ItemID as varchar(16)), 1+ len( cast(ItemID as varchar(16))), 16) ProcNum from vefn_SiblingItems(@TopID,0) ZZ Join Contents CC on CC.ContentID = ZZ.ContentID
--INSERT INTO @Procs select ZZ.ItemID, isnull(Replace(Replace(CC.Number,'\u8209?','-'),'\','\u9586?'),'') + ':' + substring('0000000000000000' + cast(ItemID as varchar(16)), 1+ len( cast(ItemID as varchar(16))), 16) ProcNum from vefn_SiblingItems(@TopID,0) ZZ Join Contents CC on CC.ContentID = ZZ.ContentID
--select * from @Procs order by ProcNum + cast(ItemID as nvarchar(max))
select top 1 @NewTopID = ItemID from @Procs order by ProcNum
INSERT INTO @Organize
@@ -5896,6 +5907,7 @@ DECLARE @index int
DECLARE @index2 int
-- Replace Hard Hyphen with Hyphen
SET @text = replace(@text,'\u8209?','-')
--SET @text = replace(replace(@text,'\u8209?','-'),'\u9586?','\')
-- Replace Hard Space with Space
-- commenting out the bottom two lines will fix the global search for hard space bug (B2014-056)
--SET @text = replace(@text,'\u160?',' ')
@@ -5965,6 +5977,7 @@ if(@includeSpecialCharacters=0)
END
-- Replace Hyphen with Hard Hyphen
SET @text = replace(@text,'-','\u8209?')
--SET @text = replace(replace(@text,'-','\u8209?'),'\','\u9586?')
RETURN @text
END
@@ -11008,7 +11021,7 @@ with Itemz(ItemCount,ItemID,PreviousID,FromType,CType,Number,Text,PPath, Path) a
)
select @Path = path From Itemz where ItemCount=1 and CType=0
OPTION (MAXRECURSION 10000)
return REPLACE(@Path,'\u8209?','-')
return REPLACE(REPLACE(@Path,'\u8209?','-'),'u9586?','\\')
END;
GO
-- Display the status of Proc creation
@@ -12335,6 +12348,7 @@ BEGIN
insert into @EnhancedDocuments
select VN.VersionID,VN.FolderName, VI.ItemID
, replace(cc.Number,'\u8209?','-') ProcNum, replace(cc.Text,'\u8209?','-') ProcName
--, replace(replace(cc.Number,'\u8209?','-'),'\u9586?','\') ProcNum, replace(replace(cc.Text,'\u8209?','-'),'\u9586?','\') ProcName
, xEnhanced.value('@Type','int') EnhType, xenhanced.value('@ItemID','int') EnhItemID
--, xEnhanced.query('.') qEnhanced
from (select *, cast(config as xml) xconfig from Contents Where config like '%Enhanced%' and Type =0) CC
@@ -12696,6 +12710,7 @@ AS
BEGIN
declare @ProcNum varchar(255)
select @ProcNum = replace(Number,'\u8209?','-') from contents CC
--select @ProcNum = replace(replace(Number,'\u8209?','-'),'\u9586?','\') from contents CC
join Items II on II.ContentID = CC.ContentID
Where ItemID = @ItemID
Begin
@@ -12767,9 +12782,11 @@ Insert into @EnhItems-- Procedures
select @SourceID SrcItemID, (select ContentID from Items Where ItemID = @SourceID) SrcContentID
,'<Enhanced Type="' + cast(@EnhType as varchar(12)) + '" ItemID = "' + cast(@EnhanceID as varchar(12)) + '"/>' SrcConfig
,isnull(VSO.ProcName,replace(CCS.Number,'\u8209?','-')) SrcProcName, null SrcRecID
--,isnull(VSO.ProcName,replace(replace(CCS.Number,'\u8209?','-'),'\u9586?','\')) SrcProcName, null SrcRecID
,@EnhanceID EnhItemID, (select ContentID from Items Where ItemID = @EnhanceID) EnhContentID
,'<Enhanced Type="0" ItemID = "' + cast(@SourceID as varchar(12)) + '"/>' EnhConfig
,isnull(VEO.ProcName ,replace(CCE.Number,'\u8209?','-')) EnhProcNam, null EnhRecID
--,isnull(VEO.ProcName ,replace(replace(CCE.Number,'\u8209?','-'),'\u9586?','\')) EnhProcNam, null EnhRecID
From vefn_GetOldEnhancedData(@SourceID) VSO
cross apply vefn_GetOldEnhancedData(@EnhanceID) VEO
JOIN Contents CCS ON VSO.ContentID = CCs.ContentID