don't write duplicate KPIOutput items to output csv

This commit is contained in:
Pepijn van Oort 2023-10-16 13:55:12 +02:00
parent 8771e47b28
commit 1a9d5af5f6
2 changed files with 3 additions and 3 deletions

View File

@ -83,7 +83,7 @@ namespace FarmmapsKPI
private async Task Process(List<UserRoot> roots, KPIInput input, StreamWriter sw)
{
KPIOutput kpio;
KPIOutput kpioPrevious = null;
KPIOutput kpioPrevious = new KPIOutput(); //creates a new empty
string downloadFolder = input.DownloadFolder;
if (string.IsNullOrEmpty(downloadFolder)) {
@ -271,7 +271,7 @@ namespace FarmmapsKPI
dataList = new List<string> { };
kpio = JsonConvert.DeserializeObject<KPIOutput>(item.Data.ToString());
//Seems sometimes duplicate KPI items are returned. So check that here and only write if this kpio is different from previous
if (kpio != kpioPrevious)
if (kpio.id != kpioPrevious.id)
{
dataList.Add(kpio.parentName);
dataList.Add(kpio.data.area);

View File

@ -90,7 +90,7 @@
"name": "Kunstmest strooien",
"operationCode": "7",
"product": "7360",
"quantity": "400",
"quantity": "200",
"status": "3",
"to": "2022-05-23T12:34:00",
"unit": "kg/ha",