cleanup of old autoid serial stuff

This commit is contained in:
2020-05-14 16:13:40 +00:00
parent 40d9056eac
commit 9eac437ada
10 changed files with 58 additions and 112 deletions

View File

@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace AyaNova.Util
{
@@ -13,14 +12,6 @@ namespace AyaNova.Util
internal static class ServerBootConfig
{
//AUTOID's
//Get the most recent id number issued previously and start the auto-id at that level
internal static AutoId WIDGET_SERIAL { get; set; }
internal static AutoId WORKORDER_SERIAL { get; set; }
internal static AutoId QUOTE_SERIAL { get; set; }
internal static AutoId PM_SERIAL { get; set; }
//Diagnostic static values used during development, may not be related to config at all, this is just a convenient class to put them in
#if (DEBUG)
internal static List<string> TranslationKeysRequested { get; set; }
@@ -219,50 +210,6 @@ namespace AyaNova.Util
}
//Get the auto-id most recent values at boot time
internal static void SetMostRecentAutoIdValuesFromDatabase(AyaNova.Models.AyContext ct)
{
//TODO: CHANGE TO A DEDICATED SPOT IN GLOBAL RATHER THAN INFERRING AS IT IS NOT RIGHT PRACTICALLY for reasons
//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 serializedObject = ct.Widget.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
// WIDGET_SERIAL = new AutoId(serializedObject == null ? 0 : serializedObject.Serial);
// var MostRecentWidget = ct.Widget.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
// uint MaxWidgetId = 0;
// if (MostRecentWidget != null)
// MaxWidgetId = MostRecentWidget.Serial;
// WIDGET_SERIAL = new AutoId(MaxWidgetId);
}
//Workorder
if (WORKORDER_SERIAL == null)
{
var serializedObject = ct.WorkOrder.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
WORKORDER_SERIAL = new AutoId(serializedObject == null ? 0 : serializedObject.Serial);
}
//quote
if (QUOTE_SERIAL == null)
{
var serializedObject = ct.Quote.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
QUOTE_SERIAL = new AutoId(serializedObject == null ? 0 : serializedObject.Serial);
}
//PM
if (PM_SERIAL == null)
{
var serializedObject = ct.PM.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
PM_SERIAL = new AutoId(serializedObject == null ? 0 : serializedObject.Serial);
}
//OTHER SERIALS HERE IN FUTURE...
}