diff --git a/FarmmapsKPI/KPIApplication.cs b/FarmmapsKPI/KPIApplication.cs index 0d6e514..0416615 100644 --- a/FarmmapsKPI/KPIApplication.cs +++ b/FarmmapsKPI/KPIApplication.cs @@ -87,8 +87,8 @@ namespace FarmmapsKPI TimeSpan tsRemaining; TimeSpan tsTotalEstimated; - for (int i = 0; i < fieldsInputs.Count; i++) - //for (int i = 3; i < 4; i++) + //for (int i = 0; i < fieldsInputs.Count; i++) + for (int i = 3; i < 4; i++) { watch.Restart(); input = fieldsInputs[i]; @@ -476,6 +476,48 @@ namespace FarmmapsKPI sw.WriteLine(string.Join(",", dataList)); } } + + else if (kpio.id == "C1") //TtD + { + //Make a new dataList = new line to be written + dataList = new List { }; + //Fill the datalist with this kpi + dataList.Add(kpio.parentName); + dataList.Add(cropfieldItem.Code); + dataList.Add(kpio.data.area); + dataList.Add(kpio.data.cropTypeCode); + dataList.Add(kpio.data.cropTypeName); + dataList.Add(kpio.id); + dataList.Add(kpio.quantity); // in KPI output quantity is what we call KPIvariable in headerlist of csv file + dataList.Add(kpio.value); + dataList.Add(kpio.unit); + dataList.Add(kpio.targetValue); + dataList.Add(kpio.thresholdValue); + //Write the datalist to a line to the streamwrieter sw for the output csv file + sw.WriteLine(string.Join(",", dataList)); + KPIelementsOfBalance kPIelementsOfBalance = kpio.data.values; + + foreach (string elementName in kpio.C1elements) + { + // get C1element from the element called values + dataList = new List { }; + string elementValue = (string)kPIelementsOfBalance.GetType().GetProperty(elementName).GetValue(kPIelementsOfBalance, null); + dataList.Add(kpio.parentName); + dataList.Add(cropfieldItem.Code); + dataList.Add(kpio.data.area); + dataList.Add(kpio.data.cropTypeCode); + dataList.Add(kpio.data.cropTypeName); + dataList.Add(kpio.id); + dataList.Add(elementName); // specific output variable name for C1 element + dataList.Add(elementValue); // specific output value name for C1 element + dataList.Add(kpio.unit); + dataList.Add(""); + dataList.Add(""); + //Write the datalist to a line to the streamwrieter sw for the output csv file + sw.WriteLine(string.Join(",", dataList)); + } + } + else if (kpio.id == "E1") { //for E1, environmentMeasureData is an array of elements with 1 per pesticide. Inside each element there are multiple mbp_KPIvariables to be written diff --git a/FarmmapsKPI/Models/KPIoutput.cs b/FarmmapsKPI/Models/KPIoutput.cs index 5073eda..b7dd992 100644 --- a/FarmmapsKPI/Models/KPIoutput.cs +++ b/FarmmapsKPI/Models/KPIoutput.cs @@ -19,10 +19,13 @@ namespace FarmmapsKPI.Models public List B1elements; public List B2elements; + public List C1elements; //TtD public KPIOutput() { this.B1elements = new List() { "disposal", "nFixationNKgHa", "nDepositionNKgHa","nFertilizerNKgHa","sowPlantingNKgHa" }; //TODO Tamara: rename disposal to nHarvestedNKgHa this.B2elements = new List() { "disposal", "pFertillizerNKgHa", "sowPlantingNKgHa" }; //TODO Tamara: rename from pFertilizerNKgHa to pFertilizerPKgHa; rename disposal to pHarvestedPKgHa + this.C1elements = new List() { "fertilizerEom", "greenManureEom", "cropLeftoversEom" }; //TtD + } } public class KPIOutputData @@ -47,7 +50,7 @@ namespace FarmmapsKPI.Models } public class KPIelementsOfBalance { - public string disposal { get; set; } + public string disposal { get; set; } //TODO Tamara: rename this one public string nFixationNKgHa { get; set; } public string nDepositionNKgHa { get; set; } public string nFertilizerNKgHa { get; set; } @@ -55,5 +58,10 @@ namespace FarmmapsKPI.Models public string pFertillizerNKgHa { get; set; } //TODO Tamara: delete this one after renaming public string pFertilizerPKgHa { get; set; } public string sowPlantingPKgHa { get; set; } + public string fertilizerEom { get; set; } //TtD + public string greenManureEom { get; set; } //TtD + public string cropLeftoversEom { get; set; } //TtD + + } } \ No newline at end of file diff --git a/FarmmapsKPI/TODO.txt b/FarmmapsKPI/TODO.txt index 9419da2..dfbbb93 100644 --- a/FarmmapsKPI/TODO.txt +++ b/FarmmapsKPI/TODO.txt @@ -49,11 +49,11 @@ dataOperations: "status": "3": "code": "860619", //PO20231004: so what does this code mean? Can we see the code list somewhere? NOT YET TESTED KPIelementsOfBalance: Tamara - a. define elements for C1 organic matter supply - b. for nitrogen B1 rename disposal to nHarvestedNKgHa - c. for phosporous B2 rename disposal to pHarvestedPKgHa - d. for phosporous B2 rename from pFertilizerNKgHa to pFertilizerPKgHa - e. idem sowPlantingNKgHa + a. define elements for C1 organic matter supply DONE + b. for nitrogen B1 rename disposal to nHarvestedNKgHa PARTLY + c. for phosporous B2 rename disposal to pHarvestedPKgHa PARTLY + d. for phosporous B2 rename from pFertilizerNKgHa to pFertilizerPKgHa PARTLY + e. idem sowPlantingNKgHa PARTLY f. add straw for N & P in output g. add 2 examples in KPIinput.json: straw yes/no removed. Bijv. nStrawLeftInField EN nStrawRemoved h. update KPIdefinitions.csv