diff --git a/Backend/BackendLoop.cs b/Backend/BackendLoop.cs index f97b875b..0a7ce62b 100644 --- a/Backend/BackendLoop.cs +++ b/Backend/BackendLoop.cs @@ -51,6 +51,14 @@ namespace Swarmops.Backend SystemSettings.BackendHostname = Dns.GetHostName(); + + // Other one-time initializations + + FinancialTransactions.FixAllUnsequenced(); + + + // Begin main loop + UnixSignal[] killSignals = null; if (!Debugger.IsAttached) diff --git a/Logic/Financial/FinancialTransactionRows.cs b/Logic/Financial/FinancialTransactionRows.cs index 9c0443ba..b852e03e 100644 --- a/Logic/Financial/FinancialTransactionRows.cs +++ b/Logic/Financial/FinancialTransactionRows.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using Swarmops.Basic.Types.Financial; using Swarmops.Common.Enums; +using Swarmops.Database; namespace Swarmops.Logic.Financial { diff --git a/Logic/Financial/FinancialTransactions.cs b/Logic/Financial/FinancialTransactions.cs index 28724923..5ef7f35f 100644 --- a/Logic/Financial/FinancialTransactions.cs +++ b/Logic/Financial/FinancialTransactions.cs @@ -70,5 +70,18 @@ namespace Swarmops.Logic.Financial throw new NotImplementedException ("Unimplemented dependency type:" + foreignObject.GetType()); } + + // This needs only be run once. It populates the OrganizationSequenceId field. + + public static void FixAllUnsequenced() + { + SwarmDb db = SwarmDb.GetDatabaseForReading(); + FinancialTransactions txs = FromArray(db.GetAllFinancialTransactionsWithoutSequenceNumber()); + + foreach (FinancialTransaction tx in txs) + { + tx.SetOrganizationSequenceId(); + } + } } } \ No newline at end of file