This commit is contained in:
2020-03-25 16:02:15 +00:00
parent fb7fd98c91
commit 127d113f8f
2 changed files with 25 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Linq; using System.Linq;
using AyaNova.Biz; using AyaNova.Biz;
using AyaNova.Util;
namespace AyaNova.PickList namespace AyaNova.PickList
{ {
@@ -130,7 +131,13 @@ namespace AyaNova.PickList
//so this will handle it as a like query against all tags as a composite string of text just like //so this will handle it as a like query against all tags as a composite string of text just like
//all the other templated fields //all the other templated fields
if (HasAutoCompleteQuery && !HasTagSpecificQuery) if (HasAutoCompleteQuery && !HasTagSpecificQuery)
sWhere = $"(array_to_string({valueColumnName},',') like '%{autoCompleteQuery}%')"; {
if (ServerGlobalBizSettings.SearchCaseSensitiveOnly)
sWhere = $"(array_to_string({valueColumnName},',') like '%{autoCompleteQuery}%')";
else
sWhere = $"(lower(array_to_string({valueColumnName},',')) like lower('%{autoCompleteQuery}%'))";
}
} }
else if (o.ColumnDataType == UiFieldDataType.Text || o.ColumnDataType == UiFieldDataType.EmailAddress || o.ColumnDataType == UiFieldDataType.HTTP) else if (o.ColumnDataType == UiFieldDataType.Text || o.ColumnDataType == UiFieldDataType.EmailAddress || o.ColumnDataType == UiFieldDataType.HTTP)
@@ -140,7 +147,11 @@ namespace AyaNova.PickList
lSelect.Add(valueColumnName); lSelect.Add(valueColumnName);
lOrderBy.Add(valueColumnName); lOrderBy.Add(valueColumnName);
if (HasAutoCompleteQuery) if (HasAutoCompleteQuery)
sWhere = $"({valueColumnName} like '%{autoCompleteQuery}%')"; if (ServerGlobalBizSettings.SearchCaseSensitiveOnly)
sWhere = $"({valueColumnName} like '%{autoCompleteQuery}%')";
else
sWhere = $"(lower({valueColumnName}) like lower('%{autoCompleteQuery}%'))";
} }
else else
{ {
@@ -158,7 +169,10 @@ namespace AyaNova.PickList
//Where fragment is different for non text fields: it needs to be cast to text to like query on it //Where fragment is different for non text fields: it needs to be cast to text to like query on it
//(cast (awidget.serial as text) like '%some%') //(cast (awidget.serial as text) like '%some%')
if (HasAutoCompleteQuery) if (HasAutoCompleteQuery)
if (ServerGlobalBizSettings.SearchCaseSensitiveOnly)
sWhere = $"(cast ({valueColumnName} as text) like '%{autoCompleteQuery}%')"; sWhere = $"(cast ({valueColumnName} as text) like '%{autoCompleteQuery}%')";
else
sWhere = $"(lower(cast ({valueColumnName} as text)) like lower('%{autoCompleteQuery}%'))";
} }

View File

@@ -59,20 +59,23 @@ namespace AyaNova.Biz
// //
//put //put
internal async Task<bool> ReplaceAsync(GlobalBizSettings global) internal async Task<bool> ReplaceAsync(GlobalBizSettings inObj)
{ {
var o = await ct.GlobalBizSettings.FirstOrDefaultAsync(m => m.Id == 1); var dbObj = await ct.GlobalBizSettings.FirstOrDefaultAsync(m => m.Id == 1);
if (o == null) if (dbObj == null)
throw new System.Exception("GlobalBizSettingsBiz::ReplaceAsync -> Global settings object not found in database!!"); throw new System.Exception("GlobalBizSettingsBiz::ReplaceAsync -> Global settings object not found in database!!");
CopyObject.Copy(global, o); CopyObject.Copy(inObj, dbObj, "Id");
Validate(o);
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = inObj.ConcurrencyToken;
Validate(dbObj);
if (HasErrors) if (HasErrors)
return false; return false;
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Log modification and save context //Log modification and save context
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, 1, BizType, AyaEvent.Modified), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, 1, BizType, AyaEvent.Modified), ct);
//Update the static copy for the server //Update the static copy for the server
ServerGlobalBizSettings.Initialize(o); ServerGlobalBizSettings.Initialize(dbObj);
return true; return true;
} }