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.Linq;
using AyaNova.Biz;
using AyaNova.Util;
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
//all the other templated fields
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)
@@ -140,7 +147,11 @@ namespace AyaNova.PickList
lSelect.Add(valueColumnName);
lOrderBy.Add(valueColumnName);
if (HasAutoCompleteQuery)
sWhere = $"({valueColumnName} like '%{autoCompleteQuery}%')";
if (ServerGlobalBizSettings.SearchCaseSensitiveOnly)
sWhere = $"({valueColumnName} like '%{autoCompleteQuery}%')";
else
sWhere = $"(lower({valueColumnName}) like lower('%{autoCompleteQuery}%'))";
}
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
//(cast (awidget.serial as text) like '%some%')
if (HasAutoCompleteQuery)
if (ServerGlobalBizSettings.SearchCaseSensitiveOnly)
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
internal async Task<bool> ReplaceAsync(GlobalBizSettings global)
internal async Task<bool> ReplaceAsync(GlobalBizSettings inObj)
{
var o = await ct.GlobalBizSettings.FirstOrDefaultAsync(m => m.Id == 1);
if (o == null)
var dbObj = await ct.GlobalBizSettings.FirstOrDefaultAsync(m => m.Id == 1);
if (dbObj == null)
throw new System.Exception("GlobalBizSettingsBiz::ReplaceAsync -> Global settings object not found in database!!");
CopyObject.Copy(global, o);
Validate(o);
CopyObject.Copy(inObj, dbObj, "Id");
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = inObj.ConcurrencyToken;
Validate(dbObj);
if (HasErrors)
return false;
await ct.SaveChangesAsync();
//Log modification and save context
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, 1, BizType, AyaEvent.Modified), ct);
//Update the static copy for the server
ServerGlobalBizSettings.Initialize(o);
ServerGlobalBizSettings.Initialize(dbObj);
return true;
}