From 54758f768b2cae44600d375d8eb5616be2f30b63 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 15 Jan 2017 21:16:51 +0100 Subject: [PATCH] Inserted tracepoints to find exception location --- Logic/Swarm/Positions.cs | 16 ++++++++++++++++ .../v5/Ledgers/Json-OutstandingAccounts.aspx.cs | 2 +- Site/Pages/v5/Public/Initialize.aspx.cs | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Logic/Swarm/Positions.cs b/Logic/Swarm/Positions.cs index 413a0744..f60b8526 100644 --- a/Logic/Swarm/Positions.cs +++ b/Logic/Swarm/Positions.cs @@ -105,6 +105,8 @@ namespace Swarmops.Logic.Swarm { // first, verify there aren't actually any sysadmin positions. Defensive coding for the win. + SwarmDb.GetDatabaseForWriting().CreateExceptionLogEntry(DateTime.UtcNow, "Initialization", new Exception("Tracepoint 2")); + if (Positions.ForSystem().Count > 0) { throw new InvalidOperationException ("Can't initialize sysadmin positions - already there"); @@ -112,25 +114,39 @@ namespace Swarmops.Logic.Swarm // Ok, so there are zero system-level positions. Create the Sysadmin positions. + SwarmDb.GetDatabaseForWriting().CreateExceptionLogEntry(DateTime.UtcNow, "Initialization", new Exception("Tracepoint 3")); + Position sysadminPrincipal = Position.Create (PositionLevel.SystemWide, null /* createdByPerson*/, null /*createdByPosition*/, PositionType.System_SysadminMain, PositionTitle.Default, false /*volunteerable*/, false /*overridable*/, null /*reportsTo*/, null /*dotReportsTo*/, 1 /*minCount*/, 1 /*maxCount*/); + SwarmDb.GetDatabaseForWriting().CreateExceptionLogEntry(DateTime.UtcNow, "Initialization", new Exception("Tracepoint 4")); + Position.Create(PositionLevel.SystemWide, null /* createdByPerson*/, null /*createdByPosition*/, PositionType.System_SysadminReadWrite, PositionTitle.Default, false, false, sysadminPrincipal, null /*dotReportsTo*/, 0 /*minCount*/, 0 /*maxCount*/); + SwarmDb.GetDatabaseForWriting().CreateExceptionLogEntry(DateTime.UtcNow, "Initialization", new Exception("Tracepoint 5")); + Position.Create(PositionLevel.SystemWide, null /* createdByPerson*/, null /*createdByPosition*/, PositionType.System_SysadminAssistantReadOnly, PositionTitle.Default, false, false, sysadminPrincipal, null /*dotReportsTo*/, 0 /*minCount*/, 0 /*maxCount*/); + SwarmDb.GetDatabaseForWriting().CreateExceptionLogEntry(DateTime.UtcNow, "Initialization", new Exception("Tracepoint 6")); + // If there's exactly one person in the system, we're undergoing Setup, so assign to Sysadmin Principal position. // Otherwise let grandfathering code handle it. People allPeople = People.GetAll(); // calling People.GetAll() would be a killer on well-built-out systems, but this code only runs once, and in Setup + SwarmDb.GetDatabaseForWriting().CreateExceptionLogEntry(DateTime.UtcNow, "Initialization", new Exception("Tracepoint 7")); + + if (allPeople.Count == 1) { sysadminPrincipal.Assign (allPeople[0], null, null, "Assigned initial sysadmin", null); } + + SwarmDb.GetDatabaseForWriting().CreateExceptionLogEntry(DateTime.UtcNow, "Initialization", new Exception("Tracepoint 8")); + } public static void CreateOrganizationDefaultPositions (Organization organization, PositionTitle titleType = PositionTitle.Default) diff --git a/Site/Pages/v5/Ledgers/Json-OutstandingAccounts.aspx.cs b/Site/Pages/v5/Ledgers/Json-OutstandingAccounts.aspx.cs index beb9df34..6dd4eede 100644 --- a/Site/Pages/v5/Ledgers/Json-OutstandingAccounts.aspx.cs +++ b/Site/Pages/v5/Ledgers/Json-OutstandingAccounts.aspx.cs @@ -61,7 +61,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers if (renderPresentTime) { - ledgerExpectedCents = balanceAccount.GetDeltaCents (new DateTime (1800,1,1), DateTime.MaxValue); + ledgerExpectedCents = balanceAccount.GetDeltaCents (new DateTime (1800,1,1), new DateTime(2200,1,1)); // replaces DateTime.Min...MaxValue // get ALL transactions } else diff --git a/Site/Pages/v5/Public/Initialize.aspx.cs b/Site/Pages/v5/Public/Initialize.aspx.cs index c5b212ac..01d71743 100644 --- a/Site/Pages/v5/Public/Initialize.aspx.cs +++ b/Site/Pages/v5/Public/Initialize.aspx.cs @@ -751,7 +751,7 @@ namespace Swarmops.Frontend.Pages.v5.Public Person newPerson = Person.Create(name, mail, password, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, new DateTime(1972,1,21), PersonGender.Unknown); - newPerson.AddParticipation(Organization.Sandbox, DateTime.UtcNow.AddYears(100)); + newPerson.AddParticipation(Organization.Sandbox, DateTime.UtcNow.AddYears(25)); // Add membership in Sandbox // Initialize staffing to System and Sandbox with the new user