cleanup of old autoid serial stuff
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
namespace AyaNova.Util
|
||||
{
|
||||
public class AutoId
|
||||
{
|
||||
private readonly object valueLock = new object();
|
||||
private uint currentValue; //postgre bigint
|
||||
|
||||
public AutoId(uint initialValue)
|
||||
{
|
||||
currentValue = initialValue;
|
||||
}
|
||||
|
||||
public uint GetNext()
|
||||
{
|
||||
lock (valueLock)
|
||||
{
|
||||
currentValue += 1;
|
||||
if (currentValue == 0)
|
||||
currentValue += 1;
|
||||
return currentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,10 +60,6 @@ namespace AyaNova.Util
|
||||
ApiServerState.ServerState wasServerState = apiServerState.GetState();
|
||||
string wasReason = apiServerState.Reason;
|
||||
|
||||
//START SERIAL NUMBER GENERATORS
|
||||
if (ServerBootConfig.WIDGET_SERIAL == null)
|
||||
ServerBootConfig.WIDGET_SERIAL = new AutoId(0);
|
||||
|
||||
try
|
||||
{
|
||||
await LogStatusAsync(JobId, LogJob, log, $"SEEDER: Seeding data level is {slevel.ToString()}, time zone offset is {timeZoneOffset.ToString()}");
|
||||
|
||||
@@ -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...
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user