diff --git a/FarmmapsKPI/KPIApplication.cs b/FarmmapsKPI/KPIApplication.cs index c772e19..af93856 100644 --- a/FarmmapsKPI/KPIApplication.cs +++ b/FarmmapsKPI/KPIApplication.cs @@ -127,13 +127,13 @@ namespace FarmmapsKPI var cropRecPath = Path.Combine(downloadFolder, $"croprecordings_{crprecItem}.json"); _logger.LogInformation($"Found {cropRec.Count} crop recordings"); - var count = 0; + var count1 = 0; await Task.Delay(500); foreach (var item in cropRec) { - Console.WriteLine($"Crop recording #{count}: {item.Name}"); + Console.WriteLine($"Crop recording #{count1}: {item.Name}"); File.AppendAllText(cropRecPath, item.Data +Environment.NewLine); - count++; + count1++; } _logger.LogInformation($"Downloaded file {cropRecPath}"); } @@ -142,15 +142,33 @@ namespace FarmmapsKPI //todo set croprecordings from file } - // Get KPI data + // Get KPI data for saving it in a file - _logger.LogInformation("Calculate KPI map for field"); - var KPIItem = await _generalService.GetKpiItemsForCropField(cropfieldItem);// hier dus verwijzen naar de KPI task - if ((object)null == null) + + _logger.LogInformation($"Trying to get the cropfielditem: {cropfieldItem}"); + var KPIItem = await _generalService.GetKpiItemsForCropField(cropfieldItem); + + + var KPIItemPath = Path.Combine(downloadFolder, $"KPIItems_{KPIItem}.json"); + _logger.LogInformation($"Found {KPIItem.Count} KPI items"); + var count = 0; + await Task.Delay(50); + foreach (var item in KPIItem) { - _logger.LogError("Something went wrong while obtaining the KPI map"); - return; + Console.WriteLine($"KPI item #{count}: {item.Name}"); + File.AppendAllText(KPIItemPath, item.Data + Environment.NewLine); + count++; } + _logger.LogInformation($"Downloaded file {KPIItemPath}"); + + //////////// + //_logger.LogInformation("Calculate KPI map for field"); + //var KPIItem = await _generalService.GetKpiItemsForCropField(cropfieldItem);// hier dus verwijzen naar de KPI task + //if ((object)null == null) + //{ + // _logger.LogError("Something went wrong while obtaining the KPI map"); + // return; + // } //_logger.LogInformation("Downloading KPI map"); //await _farmmapsApiService.DownloadItemAsync(KPIItem.Code,