//added a duplicate counter to deal with calculations where there is more 1 duplicate.
This commit is contained in:
parent
c2e4f9d861
commit
178ba1ea5b
@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Transactions;
|
using System.Transactions;
|
||||||
using FarmmapsApi;
|
using FarmmapsApi;
|
||||||
@ -92,7 +93,7 @@ namespace FarmmapsKPI
|
|||||||
int nrun = 1;
|
int nrun = 1;
|
||||||
for (int run = 1; run <= nrun; run++) {
|
for (int run = 1; run <= nrun; run++) {
|
||||||
for (int i = 0; i < fieldsInputs.Count; i++)
|
for (int i = 0; i < fieldsInputs.Count; i++)
|
||||||
//for (int i = 6; i < 7; i++) // for testing
|
//for (int i = 11; i < 13; i++) // for testing
|
||||||
{
|
{
|
||||||
watch.Restart();
|
watch.Restart();
|
||||||
input = fieldsInputs[i];
|
input = fieldsInputs[i];
|
||||||
@ -426,15 +427,17 @@ namespace FarmmapsKPI
|
|||||||
//Remove duplicate KPI items
|
//Remove duplicate KPI items
|
||||||
List<Item> KPIItemsClean = new List<Item>();
|
List<Item> KPIItemsClean = new List<Item>();
|
||||||
Item itemi;
|
Item itemi;
|
||||||
string id, idNext;
|
string id, idNext;
|
||||||
double value, valueNext;
|
double value, valueNext;
|
||||||
|
int DuplicateCounter;
|
||||||
value = 0;
|
value = 0;
|
||||||
id = "";
|
id = "";
|
||||||
|
DuplicateCounter = 1;
|
||||||
for (int i = 0; i < KPIItems.Count; i++)
|
for (int i = 0; i < KPIItems.Count; i++)
|
||||||
{
|
{
|
||||||
itemi = KPIItems[i];
|
itemi = KPIItems[i];
|
||||||
idNext = JsonConvert.DeserializeObject<KPIOutput>(itemi.Data.ToString()).id;
|
idNext = JsonConvert.DeserializeObject<KPIOutput>(itemi.Data.ToString()).id;
|
||||||
valueNext = Convert.ToDouble(JsonConvert.DeserializeObject<KPIOutput>(itemi.Data.ToString()).value); //hoe doe ik dit voor een getal?
|
valueNext = Convert.ToDouble(JsonConvert.DeserializeObject<KPIOutput>(itemi.Data.ToString()).value);
|
||||||
if (idNext != null)
|
if (idNext != null)
|
||||||
{
|
{
|
||||||
if (id != idNext)
|
if (id != idNext)
|
||||||
@ -446,8 +449,9 @@ namespace FarmmapsKPI
|
|||||||
if (valueNext >= value)
|
if (valueNext >= value)
|
||||||
{
|
{
|
||||||
//Remove the previous element from this list with same id but wrong value (valueNext > value) or duplicate value (valueNext == value). Presumes list is always sorted by kpiid, e.g. we may havce "
|
//Remove the previous element from this list with same id but wrong value (valueNext > value) or duplicate value (valueNext == value). Presumes list is always sorted by kpiid, e.g. we may havce "
|
||||||
KPIItemsClean.RemoveAt(i - 1);
|
KPIItemsClean.RemoveAt(i - DuplicateCounter); //added a duplicate counter to deal with calculations where there is more 1 duplicate.
|
||||||
KPIItemsClean.Add(itemi);
|
KPIItemsClean.Add(itemi);
|
||||||
|
DuplicateCounter = DuplicateCounter + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user