B2026 053 find unlinked values of selected #795
@@ -2028,10 +2028,8 @@ namespace Volian.Controls.Library
|
||||
|
||||
SearchString = TextSearchString;
|
||||
|
||||
Dictionary<string, string> rtnByWord = GetByWordSettings(TextSearchString);
|
||||
|
||||
// B2022-031 - added a cbxProcSectSrch to filter out procedure and section titles from global search results.
|
||||
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, TextSearchString /*.Replace(@"\",@"\u9586?")*/, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, cbxProcSectSrch.Checked ? 1 : 0, cbxIncROTextSrch.Checked ? ItemSearchIncludeLinks.Value : ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars, unitPrefix, rtnByWord["byWordPrefix"], rtnByWord["byWordSuffix"]);
|
||||
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, TextSearchString /*.Replace(@"\",@"\u9586?")*/, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, cbxProcSectSrch.Checked ? 1 : 0, cbxIncROTextSrch.Checked ? ItemSearchIncludeLinks.Value : ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars, unitPrefix, GetByWordSettings(TextSearchString, true), GetByWordSettings(TextSearchString, false));
|
||||
|
||||
cmbResultsStyleIndex = 3; // display step text in results
|
||||
//}
|
||||
@@ -2065,9 +2063,7 @@ namespace Volian.Controls.Library
|
||||
if (cbxFndUnLnkROVals.Enabled && cbxFndUnLnkROVals.Checked)
|
||||
{
|
||||
|
||||
Dictionary<string, string> rtnByWord = GetByWordSettings(ROSearchList);
|
||||
|
||||
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, ROSearchList, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, cbxProcSectSrch.Checked ? 1 : 0, ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars, unitPrefix, rtnByWord["byWordPrefix"], rtnByWord["byWordSuffix"]);
|
||||
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, ROSearchList, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, cbxProcSectSrch.Checked ? 1 : 0, ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars, unitPrefix, GetByWordSettings(ROSearchList, true), GetByWordSettings(ROSearchList, false));
|
||||
cmbResultsStyleIndex = 3; // display step text in results
|
||||
}
|
||||
else
|
||||
@@ -2177,27 +2173,59 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
OnSearchComplete(new DisplaySearchEventArgs(TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks)));
|
||||
}
|
||||
private Dictionary<string, string> GetByWordSettings(string ss)
|
||||
private string GetByWordSettings(string ss, bool checkstart)
|
||||
{
|
||||
Dictionary<string, string> settings = new Dictionary<string, string>();
|
||||
//if (Regex.IsMatch(ss, @"^[\d\.]")) // starts with a number or '.' decimal pt
|
||||
|
jjenko marked this conversation as resolved
Outdated
|
||||
//{
|
||||
// settings.Add("byWordPrefix", @"[^0-9a-zA-Z.vbpi:\\-]");
|
||||
//}
|
||||
//else if (Regex.IsMatch(ss, @"^[a-zA-Z]")) // starts with a letter
|
||||
//{
|
||||
// settings.Add("byWordPrefix", @"[^a-zA-Z]");
|
||||
//}
|
||||
|
mschill marked this conversation as resolved
Outdated
mschill
commented
Previous comments regarding Regexes still apply -- also it appears now we have 2 variables that we declared but did not use in string byWordPrefix & string byWordSuffix Previous comments regarding Regexes still apply -- also it appears now we have 2 variables that we declared but did not use in string byWordPrefix & string byWordSuffix
plarsen
commented
I removed the two unneeded variable declarations. I used what was previous used for the regex string. If you notice both tests are looking to see what the first character is and not the whole searchstring and from that it selects different regex strings. On account of this I am not sure char.IsNumeric will work because there are searchstrings that start with a number but are a mix of numbers and characters. Example 5% code: "if (Regex.IsMatch(ss, @"^[\d.]")) // starts with a number or '.' decimal pt" I removed the two unneeded variable declarations. I used what was previous used for the regex string. If you notice both tests are looking to see what the first character is and not the whole searchstring and from that it selects different regex strings. On account of this I am not sure char.IsNumeric will work because there are searchstrings that start with a number but are a mix of numbers and characters. Example 5% code: "if (Regex.IsMatch(ss, @"^[\d\.]")) // starts with a number or '.' decimal pt"
|
||||
//if (Regex.IsMatch(ss, @"^[\d\.]")) // ends with a number or decimal
|
||||
//{
|
||||
// settings.Add("byWordSuffix", @"[^0-9a-zA-Z.vbpi:\\-]");
|
||||
//}
|
||||
//else if (Regex.IsMatch(ss, @"[a-zA-Z]$")) // ends with a letter
|
||||
//{
|
||||
// settings.Add("byWordSuffix", @"[^a-zA-Z]");
|
||||
//}
|
||||
//return settings;
|
||||
|
jjenko marked this conversation as resolved
Outdated
jjenko
commented
by always adding a space before the search text, it will not find places where the unlinked RO Value is the first thing on the line. Ex. an Equipment List might have only the unlinked RO Value. I noticed that the last two fields in the call to GetListFromTextSearch() are for a "by word" text search and passes in a Regx expression. Could that be used? - look for "if (cbxByWord.Checked)" by always adding a space before the search text, it will not find places where the unlinked RO Value is the first thing on the line. Ex. an Equipment List might have only the unlinked RO Value.
I noticed that the last two fields in the call to GetListFromTextSearch() are for a "by word" text search and passes in a Regx expression. Could that be used? - look for "if (cbxByWord.Checked)"
|
||||
if (ss.Length > 0)
|
||||
{
|
||||
//checking start
|
||||
if (checkstart)
|
||||
{
|
||||
// starts with a number or '.' decimal pt
|
||||
if (char.IsNumber(ss, 0) || ss[0] == '.')
|
||||
{
|
||||
|
mschill marked this conversation as resolved
Outdated
mschill
commented
What if multiple % signs? - like search for: What if multiple % signs? - like search for:
3% or 4% --- I believe the matches returned by the Regex object will give position of what is found.
|
||||
return @"[^0-9a-zA-Z.vbpi:\\-]";
|
||||
}
|
||||
// starts with a letter
|
||||
else if (char.IsLetter(ss, 0))
|
||||
{
|
||||
return @"[^a-zA-Z]";
|
||||
|
mschill marked this conversation as resolved
Outdated
mschill
commented
With working on tech debt project --- moving forward need to follow suggested code practices / suggestions by SonarLint --- if (isNumeric == true) should be With working on tech debt project --- moving forward need to follow suggested code practices / suggestions by SonarLint --- if (isNumeric == true) should be
if (isNumeric)
|
||||
}
|
||||
}
|
||||
|
mschill marked this conversation as resolved
Outdated
mschill
commented
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.
|
||||
//checking end
|
||||
else
|
||||
{
|
||||
// ends with a number or '.' decimal pt
|
||||
|
mschill marked this conversation as resolved
Outdated
mschill
commented
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.
|
||||
if (char.IsNumber(ss, ss.Length - 1) || ss[ss.Length - 1] == '.')
|
||||
{
|
||||
return @"[^0-9a-zA-Z.vbpi:\\-]";
|
||||
}
|
||||
// ends with a letter
|
||||
else if (char.IsLetter(ss, ss.Length - 1))
|
||||
{
|
||||
return @"[^a-zA-Z]";
|
||||
}
|
||||
}
|
||||
|
mschill marked this conversation as resolved
Outdated
mschill
commented
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.
|
||||
}
|
||||
|
||||
if (Regex.IsMatch(ss, @"^[\d\.]")) // starts with a number or '.' decimal pt
|
||||
{
|
||||
settings.Add("byWordPrefix", @"[^0-9a-zA-Z.vbpi:\\-]");
|
||||
}
|
||||
else if (Regex.IsMatch(ss, @"^[a-zA-Z]")) // starts with a letter
|
||||
{
|
||||
settings.Add("byWordPrefix", @"[^a-zA-Z]");
|
||||
}
|
||||
if (Regex.IsMatch(ss, @"^[\d\.]")) // ends with a number or decimal
|
||||
{
|
||||
settings.Add("byWordSuffix", @"[^0-9a-zA-Z.vbpi:\\-]");
|
||||
}
|
||||
else if (Regex.IsMatch(ss, @"[a-zA-Z]$")) // ends with a letter
|
||||
{
|
||||
settings.Add("byWordSuffix", @"[^a-zA-Z]");
|
||||
}
|
||||
return settings;
|
||||
//default
|
||||
return string.Empty;
|
||||
|
mschill marked this conversation as resolved
Outdated
mschill
commented
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 void ClearResults() // B2021-103 if no results when RNO only, clear results list. (moved from btnSearch_Click)
|
||||
{
|
||||
|
||||
Please remove the code you had commented out.