fix incomplete transactions not having a CompletedAt

This commit is contained in:
Florian Stinglmayr 2022-12-18 10:13:35 +01:00
parent efbbaa8abf
commit 9deafa6653
2 changed files with 25 additions and 19 deletions

View File

@ -1,4 +1,6 @@
namespace EDPlayerJournal.BGS;
using EDPlayerJournal.Entries;
namespace EDPlayerJournal.BGS;
public class IncompleteTransaction : Transaction {
public Transaction? UnderlyingTransaction { get; set; } = null;
@ -6,8 +8,9 @@ public class IncompleteTransaction : Transaction {
public IncompleteTransaction() { }
public IncompleteTransaction(Transaction? underlying, string reason) {
public IncompleteTransaction(Transaction? underlying, string reason, Entry entry) {
UnderlyingTransaction = underlying;
Reason = reason;
Entries.Add(entry);
}
}

View File

@ -123,7 +123,7 @@ internal class TransactionParserContext {
// Still unknown
grade = null;
} else {
transactions.AddIncomplete(new CombatZone(), "Failed to discern combat zone type");
transactions.AddIncomplete(new CombatZone(), "Failed to discern combat zone type", e);
return;
}
@ -209,8 +209,8 @@ internal class TransactionParserContext {
}
public class TransactionList : List<Transaction> {
public void AddIncomplete(Transaction underlying, string reason) {
Add(new IncompleteTransaction(underlying, reason));
public void AddIncomplete(Transaction underlying, string reason, Entry entry) {
Add(new IncompleteTransaction(underlying, reason, entry));
}
}
@ -394,7 +394,7 @@ internal class CommitCrimeParser : TransactionParserPart {
if (entry.Faction == null) {
transactions.AddIncomplete(
new FoulMurder(),
"On foot murder victim did not have a faction"
"On foot murder victim did not have a faction", e
);
return;
}
@ -405,7 +405,7 @@ internal class CommitCrimeParser : TransactionParserPart {
if (!context.NPCFaction.ContainsKey(victim)) {
transactions.AddIncomplete(
new FoulMurder(),
"Crime victim was not properly scanned."
"Crime victim was not properly scanned.", e
);
return;
}
@ -429,7 +429,8 @@ internal class MissionAcceptedParser : TransactionParserPart {
if (context.CurrentSystem == null || context.CurrentSystemAddress == null) {
transactions.AddIncomplete(new MissionCompleted(),
"Could not determine current location on mission acceptance."
"Could not determine current location on mission acceptance.",
e
);
return;
}
@ -438,7 +439,8 @@ internal class MissionAcceptedParser : TransactionParserPart {
context.MissionAccepted(entry);
} catch (Exception exception) {
transactions.AddIncomplete(new MissionCompleted(),
exception.Message
exception.Message,
e
);
}
}
@ -460,14 +462,14 @@ internal class MissionCompletedParser : TransactionParserPart {
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out accepted)) {
transactions.AddIncomplete(new MissionCompleted(),
String.Format("Mission acceptance for mission id {0} was not found",
entry.Mission.MissionID));
entry.Mission.MissionID), e);
return;
}
if (!context.AcceptedMissionLocation.TryGetValue(entry.Mission.MissionID, out accepted_location)) {
transactions.AddIncomplete(new MissionCompleted(),
String.Format("Location for acceptance for mission id {0} was not found",
entry.Mission.MissionID));
entry.Mission.MissionID), e);
return;
}
@ -515,7 +517,8 @@ internal class MissionCompletedParser : TransactionParserPart {
if (!context.SystemsByID.TryGetValue(system_address, out system)) {
transactions.AddIncomplete(new MissionCompleted(),
string.Format("Unknown system {0}, unable to assign that mission a target", system_address)
string.Format("Unknown system {0}, unable to assign that mission a target", system_address),
e
);
continue;
}
@ -571,21 +574,21 @@ internal class MissionFailedParser : TransactionParserPart {
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out accepted)) {
transactions.AddIncomplete(new MissionFailed(),
"Mission acceptance was not found"
"Mission acceptance was not found", e
);
return;
}
if (!context.AcceptedMissionLocation.TryGetValue(entry.Mission.MissionID, out accepted_location)) {
transactions.AddIncomplete(new MissionFailed(),
"Unable to figure out where failed mission was accepted"
"Unable to figure out where failed mission was accepted", e
);
return;
}
if (!context.SystemsByID.TryGetValue(accepted_location.SystemAddress, out accepted_system)) {
transactions.AddIncomplete(new MissionFailed(),
"Unable to figure out in which system failed mission was accepted"
"Unable to figure out in which system failed mission was accepted", e
);
return;
}
@ -659,7 +662,7 @@ internal class RedeemVoucherParser : TransactionParserPart {
if (context.CurrentSystem == null) {
transactions.AddIncomplete(new Vouchers(),
"Could not find out where the vouchers were redeemed"
"Could not find out where the vouchers were redeemed", e
);
return;
}
@ -667,7 +670,7 @@ internal class RedeemVoucherParser : TransactionParserPart {
List<Faction>? current_factions = context.GetFactions(context.CurrentSystem);
if (current_factions == null) {
transactions.AddIncomplete(new Vouchers(),
"Current system factions are unknown, so vouchers were ineffective");
"Current system factions are unknown, so vouchers were ineffective", e);
}
foreach (string faction in entry.Factions) {
@ -688,8 +691,8 @@ internal class RedeemVoucherParser : TransactionParserPart {
relevantBond = true;
} else {
transactions.AddIncomplete(new Vouchers(),
string.Format("Vouchers for {0} had no effect in {1} since said " +
"faction is not present here", faction, context.CurrentSystem)
string.Format("Vouchers for \"{0}\" had no effect in \"{1}\" since said " +
"faction is not present there", faction, context.CurrentSystem), e
);
}
}