Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Auditing/VotingEventEncoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Webvoto.VotingSystem.Auditing;

public static class VotingEventEncoding {

public static readonly int LatestVersion = 4; // itentionally not a const!
public static readonly int LatestVersion = 5; // itentionally not a const!

public static byte[] Encode(VotingEventRecord ve, int version, byte[] lastEventSignature = null)
=> Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(getFields(ve, version, lastEventSignature)));
Expand Down Expand Up @@ -77,6 +77,14 @@ .. getFields(ve, 3),
ve.VoterAddressId?.ToString(),
],

5 => [
.. getFields(ve, 4),
ve.GeolocationTimestamp?.ToString("u"),
ve.GeolocationLatitude?.ToString(),
ve.GeolocationLongitude?.ToString(),
ve.GeolocationAccuracy?.ToString(),
],

_ => throw new NotImplementedException()
};
}
8 changes: 8 additions & 0 deletions Auditing/VotingEventRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,13 @@ public class VotingEventRecord {
public Guid? CampaignNotificationId { get; set; }

public Guid? VoterAddressId { get; set; }

public DateTime? GeolocationTimestamp { get; set; }

public double? GeolocationLatitude { get; set; }

public double? GeolocationLongitude { get; set; }

public double? GeolocationAccuracy { get; set; }
}
}
2 changes: 2 additions & 0 deletions Counter/Csv/CsvReaderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public IEnumerable<TOutputRecord> GetRecords() {

protected int? ParseNullableInt(string s) => IsNull(s) ? null : int.Parse(s);

protected double? ParseNullableDouble(string s) => IsNull(s) ? null : double.Parse(s);

protected bool? ParseNullableBool(string s) => IsNull(s) ? null : s switch {
"0" => false,
"1" => true,
Expand Down
17 changes: 17 additions & 0 deletions Counter/Csv/VotingEventsCsvReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ public class VotingEventCsvRecord {
// V4
[Optional]
public string VoterAddressId { get; set; }

// V5
[Optional]
public string GeolocationTimestamp { get; set; }

[Optional]
public string GeolocationLatitude { get; set; }

[Optional]
public string GeolocationLongitude { get; set; }

[Optional]
public string GeolocationAccuracy { get; set; }
}

public class VotingEventsCsvReader : CsvReaderBase<VotingEventCsvRecord, SignedVotingEventRecord> {
Expand Down Expand Up @@ -173,5 +186,9 @@ public static VotingEventsCsvReader Open(FileInfo file) {
PasswordId = ParseNullableGuid(r.PasswordId),
CampaignNotificationId = ParseNullableGuid(r.CampaignNotificationId),
VoterAddressId = ParseNullableGuid(r.VoterAddressId),
GeolocationTimestamp = ParseNullableDate(r.GeolocationTimestamp),
GeolocationLatitude = ParseNullableDouble(r.GeolocationLatitude),
GeolocationLongitude = ParseNullableDouble(r.GeolocationLongitude),
GeolocationAccuracy = ParseNullableDouble(r.GeolocationAccuracy)
};
}