rename all variants of naming that hold an AyaType value to "aType" (parameter) / "AType" (not parameter) everywhere front and back; "ayType", "objectType", "oType" all are used in various areas
This commit is contained in:
@@ -152,11 +152,11 @@ namespace AyaNova.Biz
|
||||
|
||||
//Of type?
|
||||
if (searchParameters.TypeOnly != AyaType.NoType)
|
||||
q = q.Where(z => z.ObjectType == searchParameters.TypeOnly);
|
||||
q = q.Where(z => z.AType == searchParameters.TypeOnly);
|
||||
|
||||
|
||||
//Find the records that have the search terms in searchkey
|
||||
var SearchMatches = q.GroupBy(z => new { z.ObjectType, z.ObjectId }).Select(z => new { ObjectId = z.Key.ObjectId, ObjectType = z.Key.ObjectType, ObjectCount = z.LongCount() });
|
||||
var SearchMatches = q.GroupBy(z => new { z.AType, z.ObjectId }).Select(z => new { ObjectId = z.Key.ObjectId, AType = z.Key.AType, ObjectCount = z.LongCount() });
|
||||
|
||||
|
||||
//PUT THE RESULTS INTO MATCHING OBJECTS LIST
|
||||
@@ -164,7 +164,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
//keep any object that matches *all* the search terms
|
||||
if (SearchMatch.ObjectCount == TotalSearchTermsToMatch)
|
||||
MatchingObjects.Add(new AyaTypeId(SearchMatch.ObjectType, SearchMatch.ObjectId));
|
||||
MatchingObjects.Add(new AyaTypeId(SearchMatch.AType, SearchMatch.ObjectId));
|
||||
}
|
||||
|
||||
|
||||
@@ -173,19 +173,19 @@ namespace AyaNova.Biz
|
||||
List<AyaTypeId> CanReadMatchingObjects = new List<AyaTypeId>();
|
||||
foreach (AyaTypeId t in MatchingObjects)
|
||||
{
|
||||
if (t.ObjectType == AyaType.FileAttachment)
|
||||
if (t.AType == AyaType.FileAttachment)
|
||||
{
|
||||
//have to look up the actual underlying object type and id here
|
||||
//check if it's readable for user
|
||||
//then add the PARENT object type and id to the CanREadMatchingObjects list
|
||||
//this means user will not see it return as an attachment, just as the object
|
||||
FileAttachment f = await ct.FileAttachment.AsNoTracking().FirstOrDefaultAsync(z => z.Id == t.ObjectId);
|
||||
if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, f.AttachToObjectType))
|
||||
if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, f.AttachToAType))
|
||||
{
|
||||
CanReadMatchingObjects.Add(new AyaTypeId(f.AttachToObjectType, f.AttachToObjectId));
|
||||
CanReadMatchingObjects.Add(new AyaTypeId(f.AttachToAType, f.AttachToObjectId));
|
||||
}
|
||||
}
|
||||
else if (t.ObjectType == AyaType.Memo)
|
||||
else if (t.AType == AyaType.Memo)
|
||||
{
|
||||
//Users are only permitted to search their own memo's
|
||||
if (await ct.Memo.AsNoTracking().AnyAsync(z => z.Id == t.ObjectId && z.ToId == currentUserId))
|
||||
@@ -193,7 +193,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, t.ObjectType))
|
||||
if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, t.AType))
|
||||
{
|
||||
CanReadMatchingObjects.Add(t);
|
||||
}
|
||||
@@ -217,7 +217,7 @@ namespace AyaNova.Biz
|
||||
|
||||
//Sort and group the matching objects list in return order
|
||||
//zCzustomer.OrderBy(z => z.LastName).ThenBy(z => z.FirstName)
|
||||
var OrderedMatchingObjects = MatchingObjects.OrderBy(z => z.ObjectType).ThenByDescending(z => z.ObjectId);
|
||||
var OrderedMatchingObjects = MatchingObjects.OrderBy(z => z.AType).ThenByDescending(z => z.ObjectId);
|
||||
|
||||
|
||||
|
||||
@@ -233,11 +233,11 @@ namespace AyaNova.Biz
|
||||
foreach (AyaTypeId i in OrderedMatchingObjects)
|
||||
{
|
||||
SearchResult SR = new SearchResult();
|
||||
SR.Name = BizObjectNameFetcherDirect.Name(i.ObjectType,
|
||||
SR.Name = BizObjectNameFetcherDirect.Name(i.AType,
|
||||
i.ObjectId,
|
||||
command);
|
||||
SR.Id = i.ObjectId;
|
||||
SR.Type = i.ObjectType;
|
||||
SR.Type = i.AType;
|
||||
ReturnObject.SearchResults.Add(SR);
|
||||
}
|
||||
}
|
||||
@@ -581,16 +581,16 @@ namespace AyaNova.Biz
|
||||
{
|
||||
public long TranslationId { get; set; }
|
||||
public long ObjectId { get; set; }
|
||||
public AyaType ObjectType { get; set; }
|
||||
public AyaType AType { get; set; }
|
||||
public List<string> Words { get; set; }
|
||||
|
||||
|
||||
public SearchIndexProcessObjectParameters(long translationId, long objectID, AyaType objectType)
|
||||
public SearchIndexProcessObjectParameters(long translationId, long objectID, AyaType aType)
|
||||
{
|
||||
Words = new List<string>();
|
||||
TranslationId = translationId;
|
||||
ObjectId = objectID;
|
||||
ObjectType = objectType;
|
||||
AType = aType;
|
||||
}
|
||||
|
||||
//format used for getsummmary by biz objects
|
||||
@@ -599,7 +599,7 @@ namespace AyaNova.Biz
|
||||
Words = new List<string>();
|
||||
TranslationId = 0;
|
||||
ObjectId = 0;
|
||||
ObjectType = 0;
|
||||
AType = 0;
|
||||
}
|
||||
|
||||
public SearchIndexProcessObjectParameters AddText(string s)
|
||||
@@ -663,11 +663,11 @@ namespace AyaNova.Biz
|
||||
await ProcessKeywordsAsync(searchIndexObjectParameters, false);
|
||||
}
|
||||
|
||||
public static async Task ProcessDeletedObjectKeywordsAsync(long objectID, AyaType objectType, AyContext ct)
|
||||
public static async Task ProcessDeletedObjectKeywordsAsync(long objectID, AyaType aType, AyContext ct)
|
||||
{
|
||||
//Be careful in future, if you put ToString at the end of each object in the string interpolation
|
||||
//npgsql driver will assume it's a string and put quotes around it triggering an error that a string can't be compared to an int
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from asearchkey where objectid={objectID} and objecttype={(int)objectType}");
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from asearchkey where objectid={objectID} and aType={(int)aType}");
|
||||
//nothing to save here, it's a direct command already executed
|
||||
}
|
||||
|
||||
@@ -678,15 +678,15 @@ namespace AyaNova.Biz
|
||||
private static async Task ProcessKeywordsAsync(SearchIndexProcessObjectParameters p, bool newRecord)
|
||||
{
|
||||
// #if (DEBUG)
|
||||
// if (!p.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
// throw new System.NotSupportedException($"Search::ProcessKeywords - Invalid type presented {p.ObjectType}");
|
||||
// if (!p.AType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
// throw new System.NotSupportedException($"Search::ProcessKeywords - Invalid type presented {p.AType}");
|
||||
// #endif
|
||||
List<string> KeyWordList = await BreakAsync(p.TranslationId, p.Words);
|
||||
|
||||
if (KeyWordList.Count == 0) return;
|
||||
//call stored procedure to do the work right at the server (fastest method by far)
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"call aydosearchindex({KeyWordList},{p.ObjectId},{p.ObjectType},{!newRecord})");
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"call aydosearchindex({KeyWordList},{p.ObjectId},{p.AType},{!newRecord})");
|
||||
return;
|
||||
}//eoc
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user