Added code to set sequence numbers for legacy txs

This commit is contained in:
Falkvinge
2017-04-25 16:20:28 +02:00
parent 1a6afb38bc
commit 43719acb42
3 changed files with 22 additions and 0 deletions
+8
View File
@@ -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)
@@ -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
{
+13
View File
@@ -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();
}
}
}
}