Inserted tracepoints to find exception location

This commit is contained in:
Rick Falkvinge
2017-01-15 21:16:51 +01:00
parent 2f0481e310
commit 54758f768b
3 changed files with 18 additions and 2 deletions
+16
View File
@@ -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)
@@ -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
+1 -1
View File
@@ -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