From 9383ab7f6ff71f6718de3c384355f34be290ae10 Mon Sep 17 00:00:00 2001 From: Carla Lopes Date: Fri, 17 Jul 2026 14:53:19 -0300 Subject: [PATCH 1/3] [WVS-437] added new version with geolocation fields --- Auditing/VotingEventEncoding.cs | 11 ++++++++++- Auditing/VotingEventRecord.cs | 10 ++++++++++ Counter/Csv/CsvReaderBase.cs | 2 ++ Counter/Csv/VotingEventsCsvReader.cs | 21 +++++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Auditing/VotingEventEncoding.cs b/Auditing/VotingEventEncoding.cs index 9090d87..e58112f 100644 --- a/Auditing/VotingEventEncoding.cs +++ b/Auditing/VotingEventEncoding.cs @@ -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))); @@ -77,6 +77,15 @@ .. getFields(ve, 3), ve.VoterAddressId?.ToString(), ], + 5 => [ + .. getFields(ve, 4), + ve.GeolocationOriginCode, + ve.GeolocationTimestamp?.ToString("u"), + ve.GeolocationLatitude?.ToString(), + ve.GeolocationLongitude?.ToString(), + ve.GeolocationAccuracy?.ToString(), + ], + _ => throw new NotImplementedException() }; } diff --git a/Auditing/VotingEventRecord.cs b/Auditing/VotingEventRecord.cs index 007f0fb..e698898 100644 --- a/Auditing/VotingEventRecord.cs +++ b/Auditing/VotingEventRecord.cs @@ -85,5 +85,15 @@ public class VotingEventRecord { public Guid? CampaignNotificationId { get; set; } public Guid? VoterAddressId { get; set; } + + public string? GeolocationOriginCode { get; set; } + + public DateTime? GeolocationTimestamp { get; set; } + + public double? GeolocationLatitude { get; set; } + + public double? GeolocationLongitude { get; set; } + + public double? GeolocationAccuracy { get; set; } } } diff --git a/Counter/Csv/CsvReaderBase.cs b/Counter/Csv/CsvReaderBase.cs index 1e8b01d..da2e46d 100644 --- a/Counter/Csv/CsvReaderBase.cs +++ b/Counter/Csv/CsvReaderBase.cs @@ -45,6 +45,8 @@ public IEnumerable GetRecords() { protected int? ParseNullableInt(string s) => IsNull(s) ? null : int.Parse(s); + protected double? ParseNullableDouble(string s) => IsNull(s) ? null : double.Parse(s, CultureInfo.InvariantCulture); + protected bool? ParseNullableBool(string s) => IsNull(s) ? null : s switch { "0" => false, "1" => true, diff --git a/Counter/Csv/VotingEventsCsvReader.cs b/Counter/Csv/VotingEventsCsvReader.cs index 3e86659..a61c2d1 100644 --- a/Counter/Csv/VotingEventsCsvReader.cs +++ b/Counter/Csv/VotingEventsCsvReader.cs @@ -114,6 +114,22 @@ public class VotingEventCsvRecord { // V4 [Optional] public string VoterAddressId { get; set; } + + // V5 + [Optional] + public string GeolocationOriginCode { get; set; } + + [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 { @@ -173,5 +189,10 @@ public static VotingEventsCsvReader Open(FileInfo file) { PasswordId = ParseNullableGuid(r.PasswordId), CampaignNotificationId = ParseNullableGuid(r.CampaignNotificationId), VoterAddressId = ParseNullableGuid(r.VoterAddressId), + GeolocationOriginCode = ParseString(r.GeolocationOriginCode), + GeolocationTimestamp = ParseNullableDate(r.GeolocationTimestamp), + GeolocationLatitude = ParseNullableDouble(r.GeolocationLatitude), + GeolocationLongitude = ParseNullableDouble(r.GeolocationLongitude), + GeolocationAccuracy = ParseNullableDouble(r.GeolocationAccuracy) }; } From 45060a50e0e8f08788ca80b3e2c633b8e0e6a460 Mon Sep 17 00:00:00 2001 From: Carla Lopes Date: Mon, 20 Jul 2026 11:00:22 -0300 Subject: [PATCH 2/3] [WVS-437] removed unnecessary enum --- Auditing/VotingEventEncoding.cs | 1 - Auditing/VotingEventRecord.cs | 2 -- Counter/Csv/CsvReaderBase.cs | 2 +- Counter/Csv/VotingEventsCsvReader.cs | 4 ---- 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Auditing/VotingEventEncoding.cs b/Auditing/VotingEventEncoding.cs index e58112f..ea45fbd 100644 --- a/Auditing/VotingEventEncoding.cs +++ b/Auditing/VotingEventEncoding.cs @@ -79,7 +79,6 @@ .. getFields(ve, 3), 5 => [ .. getFields(ve, 4), - ve.GeolocationOriginCode, ve.GeolocationTimestamp?.ToString("u"), ve.GeolocationLatitude?.ToString(), ve.GeolocationLongitude?.ToString(), diff --git a/Auditing/VotingEventRecord.cs b/Auditing/VotingEventRecord.cs index e698898..3a53c1e 100644 --- a/Auditing/VotingEventRecord.cs +++ b/Auditing/VotingEventRecord.cs @@ -86,8 +86,6 @@ public class VotingEventRecord { public Guid? VoterAddressId { get; set; } - public string? GeolocationOriginCode { get; set; } - public DateTime? GeolocationTimestamp { get; set; } public double? GeolocationLatitude { get; set; } diff --git a/Counter/Csv/CsvReaderBase.cs b/Counter/Csv/CsvReaderBase.cs index da2e46d..2ee1797 100644 --- a/Counter/Csv/CsvReaderBase.cs +++ b/Counter/Csv/CsvReaderBase.cs @@ -45,7 +45,7 @@ public IEnumerable GetRecords() { protected int? ParseNullableInt(string s) => IsNull(s) ? null : int.Parse(s); - protected double? ParseNullableDouble(string s) => IsNull(s) ? null : double.Parse(s, CultureInfo.InvariantCulture); + protected double? ParseNullableDouble(string s) => IsNull(s) ? null : double.Parse(s); protected bool? ParseNullableBool(string s) => IsNull(s) ? null : s switch { "0" => false, diff --git a/Counter/Csv/VotingEventsCsvReader.cs b/Counter/Csv/VotingEventsCsvReader.cs index a61c2d1..4c9692d 100644 --- a/Counter/Csv/VotingEventsCsvReader.cs +++ b/Counter/Csv/VotingEventsCsvReader.cs @@ -116,9 +116,6 @@ public class VotingEventCsvRecord { public string VoterAddressId { get; set; } // V5 - [Optional] - public string GeolocationOriginCode { get; set; } - [Optional] public string GeolocationTimestamp { get; set; } @@ -189,7 +186,6 @@ public static VotingEventsCsvReader Open(FileInfo file) { PasswordId = ParseNullableGuid(r.PasswordId), CampaignNotificationId = ParseNullableGuid(r.CampaignNotificationId), VoterAddressId = ParseNullableGuid(r.VoterAddressId), - GeolocationOriginCode = ParseString(r.GeolocationOriginCode), GeolocationTimestamp = ParseNullableDate(r.GeolocationTimestamp), GeolocationLatitude = ParseNullableDouble(r.GeolocationLatitude), GeolocationLongitude = ParseNullableDouble(r.GeolocationLongitude), From b741986dc897c0e46d58695d9f5b81af0b281f16 Mon Sep 17 00:00:00 2001 From: Lais Portela Date: Tue, 21 Jul 2026 11:20:26 -0300 Subject: [PATCH 3/3] Add new version with kba --- Auditing/VotingEventEncoding.cs | 8 +++++++- Auditing/VotingEventRecord.cs | 3 +++ Counter/Csv/VotingEventsCsvReader.cs | 12 +++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Auditing/VotingEventEncoding.cs b/Auditing/VotingEventEncoding.cs index ea45fbd..e362891 100644 --- a/Auditing/VotingEventEncoding.cs +++ b/Auditing/VotingEventEncoding.cs @@ -7,7 +7,7 @@ namespace Webvoto.VotingSystem.Auditing; public static class VotingEventEncoding { - public static readonly int LatestVersion = 5; // itentionally not a const! + public static readonly int LatestVersion = 6; // itentionally not a const! public static byte[] Encode(VotingEventRecord ve, int version, byte[] lastEventSignature = null) => Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(getFields(ve, version, lastEventSignature))); @@ -85,6 +85,12 @@ .. getFields(ve, 4), ve.GeolocationAccuracy?.ToString(), ], + 6 => [ + .. getFields(ve, 5), + ve.KbaCheckFailureCode, + ve.CausedKbaLocked.ToString(), + ], + _ => throw new NotImplementedException() }; } diff --git a/Auditing/VotingEventRecord.cs b/Auditing/VotingEventRecord.cs index 3a53c1e..5afc9b6 100644 --- a/Auditing/VotingEventRecord.cs +++ b/Auditing/VotingEventRecord.cs @@ -93,5 +93,8 @@ public class VotingEventRecord { public double? GeolocationLongitude { get; set; } public double? GeolocationAccuracy { get; set; } + + public string KbaCheckFailureCode { get; set; } + public bool? CausedKbaLocked { get; set; } } } diff --git a/Counter/Csv/VotingEventsCsvReader.cs b/Counter/Csv/VotingEventsCsvReader.cs index 4c9692d..8100247 100644 --- a/Counter/Csv/VotingEventsCsvReader.cs +++ b/Counter/Csv/VotingEventsCsvReader.cs @@ -127,6 +127,14 @@ public class VotingEventCsvRecord { [Optional] public string GeolocationAccuracy { get; set; } + + // V6 + + [Optional] + public string KbaCheckFailureCode { get; set; } + + [Optional] + public string CausedKbaLocked { get; set; } } public class VotingEventsCsvReader : CsvReaderBase { @@ -189,6 +197,8 @@ public static VotingEventsCsvReader Open(FileInfo file) { GeolocationTimestamp = ParseNullableDate(r.GeolocationTimestamp), GeolocationLatitude = ParseNullableDouble(r.GeolocationLatitude), GeolocationLongitude = ParseNullableDouble(r.GeolocationLongitude), - GeolocationAccuracy = ParseNullableDouble(r.GeolocationAccuracy) + GeolocationAccuracy = ParseNullableDouble(r.GeolocationAccuracy), + KbaCheckFailureCode = ParseString(r.KbaCheckFailureCode), + CausedKbaLocked = ParseNullableBool(r.CausedKbaLocked), }; }