This commit is contained in:
2018-10-11 17:14:15 +00:00
parent 7e366f7718
commit 2bd5831a38
9 changed files with 46 additions and 35 deletions

View File

@@ -375,20 +375,21 @@ namespace AyaNova.Biz
#region ProcessKeywords into Database
public static void ProcessNewObjectKeywords(AyContext ct, long localeId, long objectID, AyaType objectType, string name, params string[] text)
public static void ProcessNewObjectKeywords(long localeId, long objectID, AyaType objectType, string name, params string[] text)
{
ProcessKeywords(ct, localeId, objectID, objectType, true, name, text);
ProcessKeywords(localeId, objectID, objectType, true, name, text);
}
public static void ProcessUpdatedObjectKeywords(AyContext ct, long localeId, long objectID, AyaType objectType, string name, params string[] text)
public static void ProcessUpdatedObjectKeywords(long localeId, long objectID, AyaType objectType, string name, params string[] text)
{
ProcessKeywords(ct, localeId, objectID, objectType, false, name, text);
ProcessKeywords(localeId, objectID, objectType, false, name, text);
}
public static void ProcessDeletedObjectKeywords(AyContext ct, long objectID, AyaType objectType)
public static void ProcessDeletedObjectKeywords(long objectID, AyaType objectType)
{
//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
AyContext ct = ServiceProviderProvider.DBContext;
ct.Database.ExecuteSqlCommand($"delete from asearchkey where objectid={objectID} and objecttype={(int)objectType}");
}
@@ -397,9 +398,10 @@ namespace AyaNova.Biz
/// Process the keywords into the dictionary
/// NOTE: NAME parameter is in ADDITION to the NAME also being on of the strings passed in text parameter
/// </summary>
private static void ProcessKeywords(AyContext ct, long localeId, long objectID, AyaType objectType, bool newRecord, string name, params string[] text)
private static void ProcessKeywords(long localeId, long objectID, AyaType objectType, bool newRecord, string name, params string[] text)
{
AyContext ct = ServiceProviderProvider.DBContext;
#if (DEBUG)
if (objectType == AyaType.TagMap || objectType == AyaType.JobOperations || objectType == AyaType.Locale)
{
@@ -411,7 +413,7 @@ namespace AyaNova.Biz
//IF NOT NEW, DELETE ALL EXISTING ENTRIES FOR OBJECT TYPE AND ID
if (!newRecord)
{
ProcessDeletedObjectKeywords(ct, objectID, objectType);
ProcessDeletedObjectKeywords(objectID, objectType);
}
//BREAK STRING ARRAY INTO KEYWORD LIST

View File

@@ -48,8 +48,8 @@ namespace AyaNova.Biz
{
//This is simple so nothing more here, but often will be copying to a different output object or some other ops
return await ct.Tag.SingleOrDefaultAsync(m => m.Id == fetchId);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE
@@ -76,10 +76,10 @@ namespace AyaNova.Biz
//Handle child and associated items:
//EVENT LOG
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
//SEARCH INDEXING
Search.ProcessNewObjectKeywords(ct, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name);
Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name);
return outObj;
}
@@ -101,7 +101,7 @@ namespace AyaNova.Biz
return inObj;
}
@@ -185,9 +185,9 @@ namespace AyaNova.Biz
//Log modification
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Name);
Search.ProcessUpdatedObjectKeywords( UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Name);
return true;
@@ -210,9 +210,9 @@ namespace AyaNova.Biz
//Log modification
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Name);
Search.ProcessUpdatedObjectKeywords( UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Name);
return true;
@@ -240,7 +240,7 @@ namespace AyaNova.Biz
ct.SaveChanges();
//Delete search index
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, BizType);
Search.ProcessDeletedObjectKeywords(dbObj.Id, BizType);
return true;
}
@@ -258,7 +258,7 @@ namespace AyaNova.Biz
ct.Database.ExecuteSqlCommand($"delete from ataggroupmap where tagid = {dbObj.Id}");
//Log
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.TagMassUntag), ct);
return true;
}

View File

@@ -69,7 +69,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
//SEARCH INDEXING
Search.ProcessNewObjectKeywords(ct, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name);
Search.ProcessNewObjectKeywords( UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name);
return outObj;
}
@@ -204,7 +204,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Name);
Search.ProcessUpdatedObjectKeywords( UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Name);
return true;
}
@@ -228,7 +228,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Name);
Search.ProcessUpdatedObjectKeywords( UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Name);
return true;
}
@@ -253,7 +253,7 @@ namespace AyaNova.Biz
ct.SaveChanges();
//Delete search index
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, BizType);
Search.ProcessDeletedObjectKeywords(dbObj.Id, BizType);
return true;
}

View File

@@ -75,7 +75,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
//SEARCH INDEXING
Search.ProcessNewObjectKeywords(ct, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.EmployeeNumber, outObj.Notes, outObj.Name);
Search.ProcessNewObjectKeywords( UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.EmployeeNumber, outObj.Notes, outObj.Name);
return outObj;
@@ -112,7 +112,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext);
//SEARCH INDEXING
Search.ProcessNewObjectKeywords(TempContext, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.EmployeeNumber, outObj.Notes, outObj.Name);
Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.EmployeeNumber, outObj.Notes, outObj.Name);
return outObj;
@@ -253,7 +253,7 @@ namespace AyaNova.Biz
//Log modification
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.EmployeeNumber, dbObj.Notes, dbObj.Name);
Search.ProcessUpdatedObjectKeywords( UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.EmployeeNumber, dbObj.Notes, dbObj.Name);
return true;
}
@@ -287,7 +287,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.EmployeeNumber, dbObj.Notes, dbObj.Name);
Search.ProcessUpdatedObjectKeywords( UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.EmployeeNumber, dbObj.Notes, dbObj.Name);
return true;
}
@@ -315,7 +315,7 @@ namespace AyaNova.Biz
ct.SaveChanges();
//Delete search index
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, BizType);
Search.ProcessDeletedObjectKeywords(dbObj.Id, BizType);
//TAGS
TagMapBiz.DeleteAllForObject(new AyaTypeId(BizType, dbObj.Id), ct);

View File

@@ -78,7 +78,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
//SEARCH INDEXING
Search.ProcessNewObjectKeywords(ct, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Notes, outObj.Name, outObj.Serial.ToString());
Search.ProcessNewObjectKeywords( UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Notes, outObj.Name, outObj.Serial.ToString());
return outObj;
@@ -109,7 +109,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext);
//SEARCH INDEXING
Search.ProcessNewObjectKeywords(TempContext, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Notes, outObj.Name, outObj.Serial.ToString());
Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Notes, outObj.Name, outObj.Serial.ToString());
return outObj;
@@ -225,7 +225,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Notes, dbObj.Name, dbObj.Serial.ToString());
Search.ProcessUpdatedObjectKeywords( UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Notes, dbObj.Name, dbObj.Serial.ToString());
return true;
}
@@ -248,7 +248,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Notes, dbObj.Name, dbObj.Serial.ToString());
Search.ProcessUpdatedObjectKeywords( UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Notes, dbObj.Name, dbObj.Serial.ToString());
return true;
}
@@ -275,7 +275,7 @@ namespace AyaNova.Biz
ct.SaveChanges();
//Delete search index
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, BizType);
Search.ProcessDeletedObjectKeywords(dbObj.Id, BizType);
//TAGS
TagMapBiz.DeleteAllForObject(new AyaTypeId(BizType, dbObj.Id), ct);