KPI items ophalen voor een cropfield werkt nu. wel dus een bestaand cropfield ingeven bij de settings in de BIN. Alle KPIs worden opgehaald na een minuut wachten.

This commit is contained in:
2023-04-07 14:33:49 +02:00
parent 3d7bf186e7
commit 55f00da9d0
3 changed files with 7 additions and 13 deletions

View File

@@ -277,7 +277,7 @@ namespace FarmmapsApi.Services
return bofekItem;
}
public async Task<Item> RunKPITask(Item cropfieldItem) // dit is dus nieuw om de KPI task te runnen
public async Task<List<Item>> GetKpiItemsForCropField(Item cropfieldItem) // dit is dus nieuw om de KPI task te runnen
{
var taskmapRequest = new TaskRequest { TaskType = KPI_TASK }; //hier KPI request van maken
taskmapRequest.attributes["processAggregateKpi"] = "false"; // zo de properties meegeven?, moet dit niet bij de KPIinput?
@@ -298,20 +298,14 @@ namespace FarmmapsApi.Services
_logger.LogError($"Something went wrong with task execution: {itemTask.Message}");
return null;
}
await Task.Delay(60000); //wacht hier een minuut tot de KPIs berekend zijn
//hier nog definieren waar in de hierarchie een KPI item is?
//the kpi data is a child of the cropfield --> is dit wel zo?
var itemName = "kpi";
var KPIItem = await FindChildItemAsync(cropfieldItem.Code,
CROPFIELD_ITEMTYPE, itemName); //hier moet ik dus verwijzen naar waar het KPIItem zit? ik gok dat het een cropfield item type is.-> of onderdeel van een croppingscheme? net toegevoegd.
if (KPIItem == null)
{
_logger.LogError("could not find the KPI data as a child item under the cropfield");
return null;
}
//the kpi data is a child of the cropfield --> is dit wel zo? is kpi ook de itemName?
return KPIItem;
return await _farmmapsApiService.GetItemChildrenAsync(cropfieldItem.Code, KPI_ITEM);
}
public async Task<Item> RunAhnTask(Item cropfieldItem) {