From adda80c05b1c6f6fe0249de9e3b6ced05182254e Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 10 Sep 2021 17:35:26 +0000 Subject: [PATCH] --- .../GlobalBizSettingsController.cs | 2 +- .../DataListSqlFilterCriteriaBuilder.cs | 47 +++++++------------ server/AyaNova/PickList/PickListSqlBuilder.cs | 6 +-- server/AyaNova/biz/Search.cs | 4 +- server/AyaNova/biz/TagBiz.cs | 2 +- server/AyaNova/models/GlobalBizSettings.cs | 4 +- server/AyaNova/resource/de.json | 2 +- server/AyaNova/resource/en.json | 2 +- server/AyaNova/resource/es.json | 2 +- server/AyaNova/resource/fr.json | 2 +- server/AyaNova/util/AySchema.cs | 2 +- 11 files changed, 32 insertions(+), 43 deletions(-) diff --git a/server/AyaNova/Controllers/GlobalBizSettingsController.cs b/server/AyaNova/Controllers/GlobalBizSettingsController.cs index 8702a128..65ad930c 100644 --- a/server/AyaNova/Controllers/GlobalBizSettingsController.cs +++ b/server/AyaNova/Controllers/GlobalBizSettingsController.cs @@ -112,7 +112,7 @@ namespace AyaNova.Api.Controllers var ret = new { //Actual global settings: - SearchCaseSensitiveOnly = AyaNova.Util.ServerGlobalBizSettings.Cache.SearchCaseSensitiveOnly, + FilterCaseSensitive = AyaNova.Util.ServerGlobalBizSettings.Cache.FilterCaseSensitive, UseInventory = AyaNova.Util.ServerGlobalBizSettings.Cache.UseInventory, DefaultTaxPartSaleId = AyaNova.Util.ServerGlobalBizSettings.Cache.TaxPartSaleId, DefaultTaxPartPurchaseId = AyaNova.Util.ServerGlobalBizSettings.Cache.TaxPartPurchaseId, diff --git a/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs b/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs index 31f58377..039e7191 100644 --- a/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs +++ b/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs @@ -5,6 +5,7 @@ using System.Text; using System.Linq; using AyaNova.Models; using AyaNova.Biz; +using AyaNova.Util; namespace AyaNova.DataList { @@ -238,45 +239,33 @@ namespace AyaNova.DataList sb.Append(sValue); sb.Append("'"); break; - - - /* NOTE: CASE - I decided to NOT do case insensitive for now for datalists like I did for picklists because it's a bit of a different situation - I would need to make big changes to the select builder and this criteria builder so it's TTM at the moment because it's all tested and working - however also the use is a bit different in that it's much more necessary to be hyper accurate here since this drives reporting and potentially a lot - of important business data. Matching two different clients inadvertantly because of a case issue would be a bit of a kerfuffle potentially so I'd rather err on the side of accuracy - and also I'm not certain how the case code will work with other languages so it's a bit more risky here, if a picklist doesn't work I get a support call but if a report is missing data then maybe - the user doesn't realize it and has bad reports. - - code from picklist in case I decide to do it later - if (ServerGlobalBizSettings.SearchCaseSensitiveOnly) - sWhere = $"({valueColumnName} like '%{autoCompleteQuery}%')"; - else - sWhere = $"(lower({valueColumnName}) like lower('%{autoCompleteQuery}%'))"; - */ - - //Following 7 operators added 14-June-2006 + case DataListFilterComparisonOperator.NotContains: - sb.Append("Not Like '%"); - sb.Append(sValue); - sb.Append("%'"); + if (ServerGlobalBizSettings.Cache.FilterCaseSensitive) + sb.Append($"NOT LIKE '%{sValue}%'"); + else + sb.Append($"NOT LIKE lower('%{sValue}%')"); break; case DataListFilterComparisonOperator.Contains: - sb.Append("Like '%"); - sb.Append(sValue); - sb.Append("%'"); + if (ServerGlobalBizSettings.Cache.FilterCaseSensitive) + sb.Append($"LIKE '%{sValue}%'"); + else + sb.Append($"LIKE lower('%{sValue}%')"); break; case DataListFilterComparisonOperator.StartsWith: - sb.Append("Like '"); - sb.Append(sValue); - sb.Append("%'"); + if (ServerGlobalBizSettings.Cache.FilterCaseSensitive) + sb.Append($"LIKE '{sValue}%'"); + else + sb.Append($"LIKE lower('{sValue}%')"); break; case DataListFilterComparisonOperator.EndsWith: - sb.Append("Like '%"); - sb.Append(sValue); - sb.Append("'"); + if (ServerGlobalBizSettings.Cache.FilterCaseSensitive) + sb.Append($"LIKE '%{sValue}'"); + else + sb.Append($"LIKE lower('%{sValue}')"); break; default: diff --git a/server/AyaNova/PickList/PickListSqlBuilder.cs b/server/AyaNova/PickList/PickListSqlBuilder.cs index c75dc1b7..a0f5053f 100644 --- a/server/AyaNova/PickList/PickListSqlBuilder.cs +++ b/server/AyaNova/PickList/PickListSqlBuilder.cs @@ -149,7 +149,7 @@ namespace AyaNova.PickList //all the other templated fields if (HasAutoCompleteQuery && !HasTagSpecificQuery) { - if (ServerGlobalBizSettings.Cache.SearchCaseSensitiveOnly) + if (ServerGlobalBizSettings.Cache.FilterCaseSensitive) sWhere = $"(array_to_string({valueColumnName},',') like '%{autoCompleteQuery}%')"; else sWhere = $"(lower(array_to_string({valueColumnName},',')) like lower('%{autoCompleteQuery}%'))"; @@ -164,7 +164,7 @@ namespace AyaNova.PickList lSelect.Add(valueColumnName); lOrderBy.Add(valueColumnName); if (HasAutoCompleteQuery) - if (ServerGlobalBizSettings.Cache.SearchCaseSensitiveOnly) + if (ServerGlobalBizSettings.Cache.FilterCaseSensitive) sWhere = $"({valueColumnName} like '%{autoCompleteQuery}%')"; else sWhere = $"(lower({valueColumnName}) like lower('%{autoCompleteQuery}%'))"; @@ -186,7 +186,7 @@ namespace AyaNova.PickList //Where fragment is different for non text fields: it needs to be cast to text to like query on it //(cast (aworkorder.serial as text) like '%some%') if (HasAutoCompleteQuery) - if (ServerGlobalBizSettings.Cache.SearchCaseSensitiveOnly) + if (ServerGlobalBizSettings.Cache.FilterCaseSensitive) sWhere = $"(cast ({valueColumnName} as text) like '%{autoCompleteQuery}%')"; else sWhere = $"(lower(cast ({valueColumnName} as text)) like lower('%{autoCompleteQuery}%'))"; diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index a95bbaae..f5d9404e 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -784,7 +784,7 @@ namespace AyaNova.Biz { #region Include token //All latin text is converted to lower case - c = char.ToLower(c); + c = char.ToLower(c,System.Globalization.CultureInfo.CurrentCulture); //Do we already have a word? if (sbWord.Length > 0) @@ -851,7 +851,7 @@ namespace AyaNova.Biz { #region Latin Include token //All latin text is converted to lower case - c = char.ToLower(c); + c = char.ToLower(c,System.Globalization.CultureInfo.CurrentCulture); //Do we already have a word? if (sbWord.Length > 0) diff --git a/server/AyaNova/biz/TagBiz.cs b/server/AyaNova/biz/TagBiz.cs index fe74cf42..906366d4 100644 --- a/server/AyaNova/biz/TagBiz.cs +++ b/server/AyaNova/biz/TagBiz.cs @@ -56,7 +56,7 @@ namespace AyaNova.Biz if (string.IsNullOrWhiteSpace(inObj)) return null; //Must be lowercase per rules //This may be naive when we get international cust omers but for now supporting utf-8 and it appears it's safe to do this with unicode - inObj = inObj.ToLowerInvariant(); + inObj = inObj.ToLower(System.Globalization.CultureInfo.CurrentCulture); //No spaces in tags, replace with dashes inObj = inObj.Replace(" ", "-"); //Remove multiple dash sequences diff --git a/server/AyaNova/models/GlobalBizSettings.cs b/server/AyaNova/models/GlobalBizSettings.cs index a90610ab..2e9bb08c 100644 --- a/server/AyaNova/models/GlobalBizSettings.cs +++ b/server/AyaNova/models/GlobalBizSettings.cs @@ -22,7 +22,7 @@ namespace AyaNova.Models //Picklist and other searches override the normal case insensitive value //this is precautionarily added for non latinate languages where it could be an issue - public bool SearchCaseSensitiveOnly { get; set; } + public bool FilterCaseSensitive { get; set; } public bool UseInventory { get; set; } //TAX CODE DEFAULTS @@ -92,7 +92,7 @@ namespace AyaNova.Models public GlobalBizSettings() { Id = 1;//always 1 - SearchCaseSensitiveOnly = false; + FilterCaseSensitive = false; UseInventory = true; } } diff --git a/server/AyaNova/resource/de.json b/server/AyaNova/resource/de.json index e085d69c..8aca884c 100644 --- a/server/AyaNova/resource/de.json +++ b/server/AyaNova/resource/de.json @@ -321,7 +321,7 @@ "GlobalUnitNameDisplayFormatsDescription": "Bestimmt das Format, in dem Einheiten in den Dropdown-Auswahlfeldern auf Servicearbeitsaufträgen, Angeboten und Wartung/Inspektion-Aufträgen angezeigt werden.", "GlobalUseInventory": "Bestand verwenden", "GlobalUseInventoryDescription": "Wenn FALSCH festgelegt ist, wird der Zugriff auf die Teileeingabe und die Auswahl von auf Arbeitsaufträgen verwendeten Teilen eingeschränkt. Wenn WAHR festgelegt ist, kann auf alle Bestandsfunktionen zugegriffen werden.", - "GlobalSearchCaseSensitiveOnly": "Suche zwischen Groß- und Kleinschreibung unterscheiden", + "GlobalFilterCaseSensitive": "Bei Filtervorgängen muss die Groß-/Kleinschreibung beachtet werden", "GlobalUseNotification": "Benachrichtigung verwenden", "GlobalUseNotificationDescription": "Wird WAHR festgelegt, wird das Benachrichtigungssystem eingeschaltet. Wird FALSCH festgelegt, wird die gesamte Benachrichtigungsverarbeitung ausgeschaltet.", "GlobalUseRegions": "Regionen verwenden", diff --git a/server/AyaNova/resource/en.json b/server/AyaNova/resource/en.json index 2ae585a8..5fba5b4e 100644 --- a/server/AyaNova/resource/en.json +++ b/server/AyaNova/resource/en.json @@ -321,7 +321,7 @@ "GlobalUnitNameDisplayFormatsDescription": "Determines the format of how Units display within drop down selection boxes within workorders, quotes, and pm's.", "GlobalUseInventory": "Use Inventory", "GlobalUseInventoryDescription": "FALSE restricts access to part entry and selection of parts used within workorders. TRUE allows access to all inventory functions.", - "GlobalSearchCaseSensitiveOnly": "Search is case sensitive", + "GlobalFilterCaseSensitive": "Filtering is case sensitive", "GlobalUseNotification": "Use Notification", "GlobalUseNotificationDescription": "If set to TRUE turns on notification system\r\nIf set to FALSE turns off all notification processing.", "GlobalUseRegions": "Use Regions", diff --git a/server/AyaNova/resource/es.json b/server/AyaNova/resource/es.json index 1bde2a97..3b0a438c 100644 --- a/server/AyaNova/resource/es.json +++ b/server/AyaNova/resource/es.json @@ -321,7 +321,7 @@ "GlobalUnitNameDisplayFormatsDescription": "Determina el formato en el que se muestran las unidades en los cuadros de selección desplegables de los pedidos de servicio, presupuestos y mantenimientos preventivos", "GlobalUseInventory": "Usar inventario", "GlobalUseInventoryDescription": "Si se ajusta a falso, el acceso queda limitado a la entrada de piezas y a la selección de las utilizadas en los pedidos de servicio. Si se ajusta a verdadero, se permite el acceso a todas las funciones del inventario.", - "GlobalSearchCaseSensitiveOnly": "Búsqueda sensible a mayúsculas y minúsculas", + "GlobalFilterCaseSensitive": "El filtrado distingue entre mayúsculas y minúsculas", "GlobalUseNotification": "Usar notificaciones", "GlobalUseNotificationDescription": "Si se ajusta a verdadero, se activa el sistema de notificaciones. Si se ajusta a falso, todo el procesamiento de las notificaciones se desactiva.", "GlobalUseRegions": "Usar regiones", diff --git a/server/AyaNova/resource/fr.json b/server/AyaNova/resource/fr.json index 78dadd2a..97ea830e 100644 --- a/server/AyaNova/resource/fr.json +++ b/server/AyaNova/resource/fr.json @@ -321,7 +321,7 @@ "GlobalUnitNameDisplayFormatsDescription": "Détermine le format d'affichage des unités dans les champs déroulants pour les bons de travail de service, les devis et les entretiens préventifs.", "GlobalUseInventory": "Utiliser le stock", "GlobalUseInventoryDescription": "FAUX limite l’accès à la saisie de pièces et à la sélection des pièces utilisées dans les bons de travail de service. VRAI autorise l’accès à toutes les fonctions liées aux stocks.", - "GlobalSearchCaseSensitiveOnly": "Recherche sensible à la casse", + "GlobalFilterCaseSensitive": "Le filtrage est sensible à la casse", "GlobalUseNotification": "Utiliser notification", "GlobalUseNotificationDescription": "Si VRAI, active le système de notification. Si FAUX, désactive toutes les procédures de notification.", "GlobalUseRegions": "Utiliser les régions", diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 3ddfc433..7b283858 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -251,7 +251,7 @@ namespace AyaNova.Util //create global biz settings table await ExecQueryAsync("CREATE TABLE aglobalbizsettings (id INTEGER NOT NULL PRIMARY KEY, " - + "searchcasesensitiveonly BOOL DEFAULT FALSE, " + + "filtercasesensitive BOOL DEFAULT FALSE, " + "useinventory BOOL DEFAULT TRUE, " + "allowscheduleconflicts BOOL DEFAULT TRUE, " + "workordercompletebyage INTERVAL NOT NULL DEFAULT '00:00:00', "