probeersel om een runKPItask te maken

master
abel 2023-03-31 11:02:06 +02:00
parent c79e0d062c
commit 7dda21dd77
5 changed files with 45 additions and 10 deletions

View File

@ -27,5 +27,6 @@ namespace FarmmapsApiSamples
public const string SHADOW_TASK = "vnd.farmmaps.task.shadow";
public const string AHN_TASK = "vnd.farmmaps.task.ahn";
public const string WATBAL_TASK = "vnd.farmmaps.task.watbal";
public const string KPI_TASK = "vnd.farmmaps.task.kpi"; // dus nieuwe taak om de KPIs te berekenen
}
}

View File

@ -277,6 +277,41 @@ namespace FarmmapsApi.Services
return bofekItem;
}
public async Task<Item> RunKPITask(Item cropfieldItem) // dit is dus nieuw om de KPI task te runnen
{
var taskmapRequest = new TaskRequest { TaskType = KPI_TASK };
string itemTaskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, taskmapRequest);
await PollTask(TimeSpan.FromSeconds(5), async (tokenSource) => {
var itemTaskStatus = await _farmmapsApiService.GetTaskStatusAsync(cropfieldItem.Code, itemTaskCode);
_logger.LogInformation($"Waiting on retreiving KPI data; status: {itemTaskStatus.State}");
if (itemTaskStatus.IsFinished)
tokenSource.Cancel();
});
var itemTask = await _farmmapsApiService.GetTaskStatusAsync(cropfieldItem.Code, itemTaskCode);
if (itemTask.State == ItemTaskState.Error)
{
_logger.LogError($"Something went wrong with task execution: {itemTask.Message}");
return null;
}
//hier nog definieren waar in de hierarchie een KPI item is?
////the BOFEK data is a child of the cropfield
//var itemName = "bofek";
//var bofekItem = await FindChildItemAsync(cropfieldItem.Code,
// SHAPE_PROCESSED_ITEMTYPE, itemName);
//if (bofekItem == null)
//{
// _logger.LogError("Could not find the BOFEK data as a child item under the cropfield");
// return null;
//}
return bofekItem;
}
public async Task<Item> RunAhnTask(Item cropfieldItem) {
var taskmapRequest = new TaskRequest { TaskType = AHN_TASK };

View File

@ -146,8 +146,7 @@ namespace FarmmapsKPI
//_logger.LogInformation("Calculate KPI map for field");
//var KPIItem = await _generalService.RunKPITask(cropfieldItem);
var KPIItem = null;
if (KPIItem == null)
if ((object)null == null)
{
_logger.LogError("Something went wrong while obtaining the KPI map");
return;

View File

@ -1,10 +1,10 @@
[
{
"UseCreatedCropfield": false,
"UseCreatedCropfield": true,
"outputFileName": "TestData",
"fieldName": "TestField",
"DownloadFolder": "Downloads", //"C:\\workdir\\groenmonitor\\", // "Downloads", -> if you just put "Downloads" the program will download to somewhere in ..\FarmMapsApiClient_WURtest\FarmmapsDataDownload\bin\Debug\netcoreapp3.1\Downloads\
"GetCropRecordings": true,
"GetCropRecordings": false,
"CrprecItem": "...", //item code of de crop recording parrent - can be found by opening the crop recording page of a field.
"GetShadowData": false,
"GetSatelliteData": false,

View File

@ -14,12 +14,12 @@ namespace FarmmapsKPI.Models
public JObject GeometryJson { get; set; }
public string InputLayerName { get; set; }
public string fieldName { get; set; }
public bool GetSatelliteData { get; set; }
public bool GetVanDerSatData { get; set; }
public string SatelliteBand { get; set; }
public bool StoreSatelliteStatisticsSingleImage { get; set; }
public bool StoreSatelliteStatisticsCropYear { get; set; }
public bool StoreVanDerSatStatistics { get; set; }
//public bool GetSatelliteData { get; set; }
// public bool GetVanDerSatData { get; set; }
// public string SatelliteBand { get; set; }
// public bool StoreSatelliteStatisticsSingleImage { get; set; }
// public bool StoreSatelliteStatisticsCropYear { get; set; }
//public bool StoreVanDerSatStatistics { get; set; }
public bool GetShadowData { get; set; }
public bool GetCropRecordings { get; set; }
public string CrprecItem { get; set; }