This commit is contained in:
@@ -28,8 +28,7 @@ Once that is done then can steam ahead on the biz objects but until I have the c
|
|||||||
IMMEDIATE ITEMS:
|
IMMEDIATE ITEMS:
|
||||||
================
|
================
|
||||||
|
|
||||||
- Auto visible id number assigning code
|
- Auto visible id number assigning code
|
||||||
- Give widgets a visible ID number scheme and add to tests
|
|
||||||
- Ensure search code process keywords includes the Visible ID value andadd test for that in Search indexing tests
|
- Ensure search code process keywords includes the Visible ID value andadd test for that in Search indexing tests
|
||||||
- Remove validation index from awidget table that was only for testing uniqueness of serial field
|
- Remove validation index from awidget table that was only for testing uniqueness of serial field
|
||||||
|
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ namespace AyaNova
|
|||||||
// ******************** TESTING WIPE DB *****************************
|
// ******************** TESTING WIPE DB *****************************
|
||||||
//
|
//
|
||||||
//Set this to true to wipe the db and reinstall a trial license and re-seed the data
|
//Set this to true to wipe the db and reinstall a trial license and re-seed the data
|
||||||
var TESTING_REFRESH_DB = false;
|
var TESTING_REFRESH_DB = true;
|
||||||
|
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
//TESTING
|
//TESTING
|
||||||
@@ -372,8 +372,6 @@ namespace AyaNova
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (ServerBootConfig.AYANOVA_PERMANENTLY_ERASE_DATABASE)
|
if (ServerBootConfig.AYANOVA_PERMANENTLY_ERASE_DATABASE)
|
||||||
{
|
{
|
||||||
_log.LogWarning("BOOT: AYANOVA_PERMANENTLY_ERASE_DATABASE is true, dropping and recreating database");
|
_log.LogWarning("BOOT: AYANOVA_PERMANENTLY_ERASE_DATABASE is true, dropping and recreating database");
|
||||||
@@ -389,8 +387,6 @@ namespace AyaNova
|
|||||||
_log.LogDebug("BOOT: db integrity check");
|
_log.LogDebug("BOOT: db integrity check");
|
||||||
DbUtil.CheckFingerPrint(AySchema.EXPECTED_COLUMN_COUNT, AySchema.EXPECTED_INDEX_COUNT, _log);
|
DbUtil.CheckFingerPrint(AySchema.EXPECTED_COLUMN_COUNT, AySchema.EXPECTED_INDEX_COUNT, _log);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Initialize license
|
//Initialize license
|
||||||
AyaNova.Core.License.Initialize(apiServerState, dbContext, _log);
|
AyaNova.Core.License.Initialize(apiServerState, dbContext, _log);
|
||||||
|
|
||||||
@@ -405,25 +401,14 @@ namespace AyaNova
|
|||||||
if (TESTING_REFRESH_DB)
|
if (TESTING_REFRESH_DB)
|
||||||
{
|
{
|
||||||
AyaNova.Core.License.Fetch(apiServerState, dbContext, _log);
|
AyaNova.Core.License.Fetch(apiServerState, dbContext, _log);
|
||||||
Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.HugeForLoadTest);
|
Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.SmallOneManShopTrialDataSet);
|
||||||
}
|
}
|
||||||
//TESTING
|
//TESTING
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//TEST AUTOID
|
//Set autoId values
|
||||||
//Note that seeder may init this already in which case this code doesn't even need to run
|
ServerBootConfig.SetMostRecentAutoIdValuesFromDatabase(dbContext);
|
||||||
if (ServerBootConfig.WIDGET_SERIAL == null)
|
|
||||||
{
|
|
||||||
//query for most recently used serial number
|
|
||||||
//(note, can't query for highest serial as it can and likely will reset or be changed manually from time to time
|
|
||||||
// so the algorithm is to keep the most recent sequence going on startup of the server)
|
|
||||||
var MostRecentWidget = dbContext.Widget.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
|
|
||||||
uint MaxWidgetId = 0;
|
|
||||||
if (MostRecentWidget != null)
|
|
||||||
MaxWidgetId = MostRecentWidget.Serial;
|
|
||||||
ServerBootConfig.WIDGET_SERIAL = new AutoId(MaxWidgetId);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Open up the server for visitors
|
//Open up the server for visitors
|
||||||
apiServerState.SetOpen();
|
apiServerState.SetOpen();
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ namespace AyaNova.Biz
|
|||||||
IsValid = false;
|
IsValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (objectPatch.Operations.Any(m => m.path == "/serial"))
|
||||||
|
{
|
||||||
|
biz.AddError(ValidationErrorType.NotChangeable, "Serial");
|
||||||
|
IsValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (objectPatch.Operations.Any(m => m.op == "add"))
|
if (objectPatch.Operations.Any(m => m.op == "add"))
|
||||||
{
|
{
|
||||||
biz.AddError(ValidationErrorType.InvalidOperation, "add");
|
biz.AddError(ValidationErrorType.InvalidOperation, "add");
|
||||||
|
|||||||
@@ -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);
|
Search.ProcessNewObjectKeywords(ct, 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);
|
Search.ProcessNewObjectKeywords(TempContext, 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);
|
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Notes, dbObj.Name, dbObj.Serial.ToString());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -234,6 +234,7 @@ namespace AyaNova.Biz
|
|||||||
internal bool Patch(Widget dbObj, JsonPatchDocument<Widget> objectPatch, uint concurrencyToken)
|
internal bool Patch(Widget dbObj, JsonPatchDocument<Widget> objectPatch, uint concurrencyToken)
|
||||||
{
|
{
|
||||||
//Validate Patch is allowed
|
//Validate Patch is allowed
|
||||||
|
//Note: Id, OwnerId and Serial are all checked for and disallowed in the validate code by default
|
||||||
if (!ValidateJsonPatch<Widget>.Validate(this, objectPatch)) return false;
|
if (!ValidateJsonPatch<Widget>.Validate(this, objectPatch)) return false;
|
||||||
|
|
||||||
//Do the patching
|
//Do the patching
|
||||||
@@ -247,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);
|
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Notes, dbObj.Name, dbObj.Serial.ToString());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace AyaNova.Util
|
|||||||
private const int DESIRED_SCHEMA_LEVEL = 9;
|
private const int DESIRED_SCHEMA_LEVEL = 9;
|
||||||
|
|
||||||
internal const long EXPECTED_COLUMN_COUNT = 100;
|
internal const long EXPECTED_COLUMN_COUNT = 100;
|
||||||
internal const long EXPECTED_INDEX_COUNT = 23;
|
internal const long EXPECTED_INDEX_COUNT = 22;
|
||||||
|
|
||||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!!
|
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!!
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ namespace AyaNova.Util
|
|||||||
"startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, roles int4, notes text)");
|
"startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, roles int4, notes text)");
|
||||||
|
|
||||||
//TEST TEST TEST ONLY FOR DEVELOPMENT TESTING TO ENSURE UNIQUENESS
|
//TEST TEST TEST ONLY FOR DEVELOPMENT TESTING TO ENSURE UNIQUENESS
|
||||||
exec("CREATE UNIQUE INDEX awidget_serial_idx ON awidget (serial);");
|
//exec("CREATE UNIQUE INDEX awidget_serial_idx ON awidget (serial);");
|
||||||
|
|
||||||
|
|
||||||
//Compound index for name fetching
|
//Compound index for name fetching
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace AyaNova.Util
|
namespace AyaNova.Util
|
||||||
{
|
{
|
||||||
@@ -12,7 +14,8 @@ namespace AyaNova.Util
|
|||||||
internal static class ServerBootConfig
|
internal static class ServerBootConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
//TEST AUTOID
|
//AUTOID's
|
||||||
|
|
||||||
//Get the highest id number issued previously and start the auto-id at that level
|
//Get the highest id number issued previously and start the auto-id at that level
|
||||||
internal static AutoId WIDGET_SERIAL { get; set; }
|
internal static AutoId WIDGET_SERIAL { get; set; }
|
||||||
|
|
||||||
@@ -202,6 +205,29 @@ namespace AyaNova.Util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Get the auto-id most recent values at boot time
|
||||||
|
internal static void SetMostRecentAutoIdValuesFromDatabase(AyaNova.Models.AyContext ct)
|
||||||
|
{
|
||||||
|
//WIDGET SERIALS
|
||||||
|
if (WIDGET_SERIAL == null)
|
||||||
|
{
|
||||||
|
//query for most recently used serial number
|
||||||
|
//(note, can't query for highest serial as it can and likely will reset or be changed manually from time to time
|
||||||
|
// so the algorithm is to keep the most recent sequence going on startup of the server)
|
||||||
|
var MostRecentWidget = ct.Widget.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
|
||||||
|
uint MaxWidgetId = 0;
|
||||||
|
if (MostRecentWidget != null)
|
||||||
|
MaxWidgetId = MostRecentWidget.Serial;
|
||||||
|
WIDGET_SERIAL = new AutoId(MaxWidgetId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//OTHER SERIALS HERE IN FUTURE...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user