B2026 053 find unlinked values of selected #795

Merged
mschill merged 28 commits from B2026-053-Find-Unlinked-Values-of-Selected into Development 2026-07-30 15:29:20 -04:00
Showing only changes of commit a89c2d3d22 - Show all commits
+21 -23
View File
3
@@ -2078,9 +2078,27 @@ namespace Volian.Controls.Library
if (cbxFndUnLnkROVals.Enabled && cbxFndUnLnkROVals.Checked)
{
string ROSearchList2 = exactsearch(ROSearchList); // B2026-053 match exact string
// B2022-031 - added a exactsearch to filter out procedure and section titles from global search results.
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, ROSearchList2, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, cbxProcSectSrch.Checked ? 1 : 0, ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars, unitPrefix, string.Empty, string.Empty);
string byWordPrefix = string.Empty;
string byWordSuffix = string.Empty;
if (Regex.IsMatch(ROSearchList, @"^[\d\.]")) // starts with a number or '.' decimal pt
Outdated
Review

lines 2092 - 2099 - the setting of ByWordPrefeix and ByWordSuffixL

Regexes are very hard on applications performance wise --- If just want to determine if a string ends in a Number, can't you use something like:

char.IsNumber(ROSearchList, ROSearchList.Length - 1);
char.IsLetter(ROSearchList, ROSearchList.Length - 1);
char.IsNumber(ROSearchList, 0);
char.IsLetter(ROSearchList, 0);

There are also functions like char.IsDigit if needed.

Obviously, you would need to 1st check that temp.Length > 0

Side question - if all we are doing is adding a regex prefix/suffix onto the checking code --- could we end up with stuff like 3.5 matching 3.52 since both end in a number and contain 3.5 ? -- You may be able to do something like pull back all the matches and then use LINQ to filter the list to ones that either end with the match or contain a space/bracket/parenthesis/punctuation after the match .

lines 2092 - 2099 - the setting of ByWordPrefeix and ByWordSuffixL Regexes are very hard on applications performance wise --- If just want to determine if a string ends in a Number, can't you use something like: char.IsNumber(ROSearchList, ROSearchList.Length - 1); char.IsLetter(ROSearchList, ROSearchList.Length - 1); char.IsNumber(ROSearchList, 0); char.IsLetter(ROSearchList, 0); There are also functions like char.IsDigit if needed. Obviously, you would need to 1st check that temp.Length > 0 Side question - if all we are doing is adding a regex prefix/suffix onto the checking code --- could we end up with stuff like 3.5 matching 3.52 since both end in a number and contain 3.5 ? -- You may be able to do something like pull back all the matches and then use LINQ to filter the list to ones that either end with the match or contain a space/bracket/parenthesis/punctuation after the match .
Outdated
Review

Matt,
I don't know if this makes any difference, but the byWordPrex and byWordSuffix strings get passed to a SQL stored procedure.

That same code is used above this code block for doing a By Word text search. I was going to suggest that instead of copying the code, to make it it's own function and call it in the two places.

Matt, I don't know if this makes any difference, but the byWordPrex and byWordSuffix strings get passed to a SQL stored procedure. That same code is used above this code block for doing a By Word text search. I was going to suggest that instead of copying the code, to make it it's own function and call it in the two places.
Outdated
Review

Would agree - if it is repeated code / a repeated idea - better to make it it's own function. That being said, while regexes are necessary in some places, any place that it works where we can replace a call with function calls like char.IsNumeric, it will benefit performance,

Would agree - if it is repeated code / a repeated idea - better to make it it's own function. That being said, while regexes are necessary in some places, any place that it works where we can replace a call with function calls like char.IsNumeric, it will benefit performance,
{
byWordPrefix = @"[^0-9a-zA-Z.vbpi:\\-]";
}
else if (Regex.IsMatch(ROSearchList, @"^[a-zA-Z]")) // starts with a letter
{
byWordPrefix = @"[^a-zA-Z]";
}
if (Regex.IsMatch(ROSearchList, @"[\d\.]$")) // ends with a number or decimal
{
byWordSuffix = @"[^0-9a-zA-Z.vbpi:\\-]";
}
else if (Regex.IsMatch(ROSearchList, @"[a-zA-Z]$")) // ends with a letter
{
byWordSuffix = @"[^a-zA-Z]";
}
string ROSearchList2 = ROSearchList;
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, ROSearchList2, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, cbxProcSectSrch.Checked ? 1 : 0, ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars, unitPrefix, byWordPrefix, byWordSuffix);
cmbResultsStyleIndex = 3; // display step text in results
}
else
5
@@ -2190,26 +2208,6 @@ namespace Volian.Controls.Library
}
mschill marked this conversation as resolved Outdated
Outdated
Review

With working on tech debt project --- moving forward need to follow suggested code practices / suggestions by SonarLint --- if (isNumeric == true) should be
if (isNumeric)

With working on tech debt project --- moving forward need to follow suggested code practices / suggestions by SonarLint --- if (isNumeric == true) should be if (isNumeric)
OnSearchComplete(new DisplaySearchEventArgs(TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks)));
}
mschill marked this conversation as resolved Outdated
Outdated
Review

With working on technical debt - should avoid concatenating strings & use string interpolation instead.

With working on technical debt - should avoid concatenating strings & use string interpolation instead.
private string exactsearch(string SearchString) // B2026-053
{
StringBuilder ss = new StringBuilder();
int sl = SearchString.Length;
int LstIdxSp = SearchString.LastIndexOf(' ');
if (sl == LstIdxSp + 1) // B2026-053 if ' ' the last char.
{
ss.Append(' ');
ss.Append(SearchString); // B2026-053 add a space prefix to make the search exact if the end of the searchString is a space.
}
else
{
ss.Append(' ');
ss.Append(SearchString); // B2026-053 Exact match add spaces before and after searchString.
ss.Append(' ');
}
return ss.ToString();
}
private void ClearResults() // B2021-103 if no results when RNO only, clear results list. (moved from btnSearch_Click)
{
if (tabSearchTypes.SelectedTab != tabSearchTypes.Tabs[4])
4