This commit is contained in:
2018-10-09 15:05:26 +00:00
parent 7f03a019d7
commit 2f5d2a8d26
6 changed files with 46 additions and 29 deletions

View File

@@ -2,6 +2,8 @@ using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace AyaNova.Util
{
@@ -12,7 +14,8 @@ namespace AyaNova.Util
internal static class ServerBootConfig
{
//TEST AUTOID
//AUTOID's
//Get the highest id number issued previously and start the auto-id at that level
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