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

@@ -28,10 +28,14 @@ Once that is done then can steam ahead on the biz objects but until I have the c
IMMEDIATE ITEMS: IMMEDIATE ITEMS:
================ ================
- fixup removal of db context from search processing, then...
- Re-test search with new processing code, do a huge test locally repeatedly for a bit - Re-test search with new processing code, do a huge test locally repeatedly for a bit
- If ok then move on to do the devops test again with a fresh build and huge db - If ok then move on to do the devops test again with a fresh build and huge db
- Whole point is to eliminate the exceptions and have it work properly.
- Also maybe find better way using lock() code to generate unique ID numbers for the unit tests
- Put up copy to devops, build huge dataset, run all tests, pound it with 1000 runs, shake it out - Put up copy to devops, build huge dataset, run all tests, pound it with 1000 runs, shake it out
- Starting 1000 test runs at 2018-10-9-4:12pm - Starting 1000 test runs at 2018-10-9-4:12pm

View File

@@ -233,7 +233,7 @@ namespace AyaNova.Api.Controllers
EventLogProcessor.LogEventToDatabase(new Event(UserId, attachToObject.ObjectId, attachToObject.ObjectType, AyaEvent.AttachmentCreate, v.DisplayFileName), ct); EventLogProcessor.LogEventToDatabase(new Event(UserId, attachToObject.ObjectId, attachToObject.ObjectType, AyaEvent.AttachmentCreate, v.DisplayFileName), ct);
//SEARCH INDEXING //SEARCH INDEXING
Search.ProcessNewObjectKeywords(ct, UserLocaleIdFromContext.Id(HttpContext.Items), v.Id, AyaType.FileAttachment, v.DisplayFileName, v.DisplayFileName, v.Notes, v.StoredFileName); Search.ProcessNewObjectKeywords( UserLocaleIdFromContext.Id(HttpContext.Items), v.Id, AyaType.FileAttachment, v.DisplayFileName, v.DisplayFileName, v.Notes, v.StoredFileName);
} }
} }
@@ -303,7 +303,7 @@ namespace AyaNova.Api.Controllers
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.AttachToObjectId, dbObj.AttachToObjectType, AyaEvent.AttachmentDelete, dbObj.DisplayFileName), ct); EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.AttachToObjectId, dbObj.AttachToObjectType, AyaEvent.AttachmentDelete, dbObj.DisplayFileName), ct);
//Delete search index //Delete search index
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, AyaType.FileAttachment); Search.ProcessDeletedObjectKeywords(dbObj.Id, AyaType.FileAttachment);
return NoContent(); return NoContent();
} }

View File

@@ -104,6 +104,10 @@ namespace AyaNova
var logRuleFilterOutMicrosoftEfCoreCommandExceptions = new LoggingRule("Microsoft.EntityFrameworkCore.Database.Command", NLog.LogLevel.Trace, NLog.LogLevel.Error, nullTarget); var logRuleFilterOutMicrosoftEfCoreCommandExceptions = new LoggingRule("Microsoft.EntityFrameworkCore.Database.Command", NLog.LogLevel.Trace, NLog.LogLevel.Error, nullTarget);
logRuleFilterOutMicrosoftEfCoreCommandExceptions.Final = true; logRuleFilterOutMicrosoftEfCoreCommandExceptions.Final = true;
var logRuleFilterOutMicrosoftEfCoreDbUpdateExceptions = new LoggingRule("Microsoft.EntityFrameworkCore.DbUpdateException", NLog.LogLevel.Trace, NLog.LogLevel.Error, nullTarget);
logRuleFilterOutMicrosoftEfCoreDbUpdateExceptions.Final = true;
//Log all other regular items at selected level //Log all other regular items at selected level
var logRuleAyaNovaItems = new LoggingRule("*", NLogLevel, fileTarget); var logRuleAyaNovaItems = new LoggingRule("*", NLogLevel, fileTarget);
@@ -121,6 +125,7 @@ namespace AyaNova
logConfig.LoggingRules.Add(logRuleFilterOutMicrosoft); logConfig.LoggingRules.Add(logRuleFilterOutMicrosoft);
logConfig.LoggingRules.Add(logRuleFilterOutMicrosoftEfCoreConcurrencyExceptions); logConfig.LoggingRules.Add(logRuleFilterOutMicrosoftEfCoreConcurrencyExceptions);
logConfig.LoggingRules.Add(logRuleFilterOutMicrosoftEfCoreCommandExceptions); logConfig.LoggingRules.Add(logRuleFilterOutMicrosoftEfCoreCommandExceptions);
logConfig.LoggingRules.Add(logRuleFilterOutMicrosoftEfCoreDbUpdateExceptions);
} }
logConfig.LoggingRules.Add(logRuleAyaNovaItems); logConfig.LoggingRules.Add(logRuleAyaNovaItems);

View File

@@ -105,7 +105,7 @@ namespace AyaNova
services.AddEntityFrameworkNpgsql().AddDbContext<AyContext>( services.AddEntityFrameworkNpgsql().AddDbContext<AyContext>(
options => options.UseNpgsql(_connectionString options => options.UseNpgsql(_connectionString
//,opt => opt.EnableRetryOnFailure() //,opt => opt.EnableRetryOnFailure()//REMOVED THIS BECAUSE IT WAS INTEFERING WITH TRANSACTIONS BUT THEN DIDN'T USE THE TRANSACTION BUT IT SEEMS FASTER WITHOUT IT AS WELL SO...??
)//http://www.npgsql.org/efcore/misc.html?q=execution%20strategy#execution-strategy )//http://www.npgsql.org/efcore/misc.html?q=execution%20strategy#execution-strategy
.ConfigureWarnings(warnings => //https://livebook.manning.com/#!/book/entity-framework-core-in-action/chapter-12/v-10/85 .ConfigureWarnings(warnings => //https://livebook.manning.com/#!/book/entity-framework-core-in-action/chapter-12/v-10/85
warnings.Throw( //Throw an exception on client eval, not necessarily an error but a smell warnings.Throw( //Throw an exception on client eval, not necessarily an error but a smell

View File

@@ -375,20 +375,21 @@ namespace AyaNova.Biz
#region ProcessKeywords into Database #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 //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 //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}"); 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 /// 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 /// NOTE: NAME parameter is in ADDITION to the NAME also being on of the strings passed in text parameter
/// </summary> /// </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 (DEBUG)
if (objectType == AyaType.TagMap || objectType == AyaType.JobOperations || objectType == AyaType.Locale) 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 NOT NEW, DELETE ALL EXISTING ENTRIES FOR OBJECT TYPE AND ID
if (!newRecord) if (!newRecord)
{ {
ProcessDeletedObjectKeywords(ct, objectID, objectType); ProcessDeletedObjectKeywords(objectID, objectType);
} }
//BREAK STRING ARRAY INTO KEYWORD LIST //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 //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); return await ct.Tag.SingleOrDefaultAsync(m => m.Id == fetchId);
} }
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE //CREATE
@@ -76,10 +76,10 @@ namespace AyaNova.Biz
//Handle child and associated items: //Handle child and associated items:
//EVENT LOG //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 INDEXING
Search.ProcessNewObjectKeywords(ct, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name); Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name);
return outObj; return outObj;
} }
@@ -101,7 +101,7 @@ namespace AyaNova.Biz
return inObj; return inObj;
} }
@@ -185,9 +185,9 @@ namespace AyaNova.Biz
//Log modification //Log modification
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct); EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords //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; return true;
@@ -210,9 +210,9 @@ namespace AyaNova.Biz
//Log modification //Log modification
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct); EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords //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; return true;
@@ -240,7 +240,7 @@ namespace AyaNova.Biz
ct.SaveChanges(); ct.SaveChanges();
//Delete search index //Delete search index
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, BizType); Search.ProcessDeletedObjectKeywords(dbObj.Id, BizType);
return true; return true;
} }
@@ -258,7 +258,7 @@ namespace AyaNova.Biz
ct.Database.ExecuteSqlCommand($"delete from ataggroupmap where tagid = {dbObj.Id}"); ct.Database.ExecuteSqlCommand($"delete from ataggroupmap where tagid = {dbObj.Id}");
//Log //Log
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.TagMassUntag), ct); EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.TagMassUntag), ct);
return true; return true;
} }

View File

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

View File

@@ -75,7 +75,7 @@ namespace AyaNova.Biz
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 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; return outObj;
@@ -112,7 +112,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext); EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext);
//SEARCH INDEXING //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; return outObj;
@@ -253,7 +253,7 @@ namespace AyaNova.Biz
//Log modification //Log modification
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct); EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords //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; return true;
} }
@@ -287,7 +287,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct); EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords //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; return true;
} }
@@ -315,7 +315,7 @@ namespace AyaNova.Biz
ct.SaveChanges(); ct.SaveChanges();
//Delete search index //Delete search index
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, BizType); Search.ProcessDeletedObjectKeywords(dbObj.Id, BizType);
//TAGS //TAGS
TagMapBiz.DeleteAllForObject(new AyaTypeId(BizType, dbObj.Id), ct); 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); EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
//SEARCH INDEXING //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; return outObj;
@@ -109,7 +109,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext); EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext);
//SEARCH INDEXING //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; return outObj;
@@ -225,7 +225,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct); EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords //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; return true;
} }
@@ -248,7 +248,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct); EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords //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; return true;
} }
@@ -275,7 +275,7 @@ namespace AyaNova.Biz
ct.SaveChanges(); ct.SaveChanges();
//Delete search index //Delete search index
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, BizType); Search.ProcessDeletedObjectKeywords(dbObj.Id, BizType);
//TAGS //TAGS
TagMapBiz.DeleteAllForObject(new AyaTypeId(BizType, dbObj.Id), ct); TagMapBiz.DeleteAllForObject(new AyaTypeId(BizType, dbObj.Id), ct);