KPI items opslaan werkt. alle KPI items worden nu naar een JSON file in de dowload folder geschreven

This commit is contained in:
Abel Hoeven, van 2023-04-25 12:00:08 +02:00
parent 55f00da9d0
commit 7149086ce2

View File

@ -127,13 +127,13 @@ namespace FarmmapsKPI
var cropRecPath = Path.Combine(downloadFolder, $"croprecordings_{crprecItem}.json"); var cropRecPath = Path.Combine(downloadFolder, $"croprecordings_{crprecItem}.json");
_logger.LogInformation($"Found {cropRec.Count} crop recordings"); _logger.LogInformation($"Found {cropRec.Count} crop recordings");
var count = 0; var count1 = 0;
await Task.Delay(500); await Task.Delay(500);
foreach (var item in cropRec) 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); File.AppendAllText(cropRecPath, item.Data +Environment.NewLine);
count++; count1++;
} }
_logger.LogInformation($"Downloaded file {cropRecPath}"); _logger.LogInformation($"Downloaded file {cropRecPath}");
} }
@ -142,15 +142,33 @@ namespace FarmmapsKPI
//todo set croprecordings from file //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 _logger.LogInformation($"Trying to get the cropfielditem: {cropfieldItem}");
if ((object)null == null) 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"); Console.WriteLine($"KPI item #{count}: {item.Name}");
return; 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"); //_logger.LogInformation("Downloading KPI map");
//await _farmmapsApiService.DownloadItemAsync(KPIItem.Code, //await _farmmapsApiService.DownloadItemAsync(KPIItem.Code,