fixed upload shape zip.

This commit is contained in:
Mark van der Wal 2020-10-06 15:50:05 +02:00
parent a065a28e01
commit d9fa663de9
3 changed files with 10 additions and 37 deletions

View File

@ -64,34 +64,9 @@ namespace FarmmapsApi.Services
if (result.Progress.Status == UploadStatus.Failed)
return null;
var zipName = Path.GetFileName(filePath);
Item shapeItem = null;
await PollTask(TimeSpan.FromSeconds(3), async source =>
{
_logger.LogInformation($"Searching for {itemName} item");
var uploadedFilesChildren = await _farmmapsApiService.GetItemChildrenAsync(root.Code);
var zipItems = uploadedFilesChildren.Where(i => i.Name.Contains(zipName));
foreach (var zipItem in zipItems)
{
List<Item> items = await _farmmapsApiService.GetItemChildrenAsync(zipItem.Code,
SHAPE_PROCESSED_ITEMTYPE);
items = items.Where(i => i.Created >= startUpload).OrderByDescending(i => i.Created).ToList();
if (items.Any())
{
shapeItem = items.First(i => i.Name.Contains(itemName));
if (shapeItem != null)
{
source.Cancel();
break;
}
}
}
});
return shapeItem;
return await FindChildItemAsync(root.Code, SHAPE_PROCESSED_ITEMTYPE, itemName,
i => i.Created >= startUpload &&
i.Name.ToLower().Contains(itemName.ToLower()));;
}
public async Task<Item> ShapeToGeotiff(Item shapeItem)
@ -172,13 +147,9 @@ namespace FarmmapsApi.Services
{
_logger.LogInformation($"Trying to get {containsName} data");
var uploadedFilesChildren = await _farmmapsApiService.GetItemChildrenAsync(parentCode, itemType);
if (uploadedFilesChildren.Count > 0)
{
Func<Item, bool> func = filter ?? (i => i.Name.ToLower().Contains(containsName.ToLower()));
dataItem = uploadedFilesChildren.FirstOrDefault(func);
source.Cancel();
}
else if (tries == maxTries)
Func<Item, bool> func = filter ?? (i => i.Name.ToLower().Contains(containsName.ToLower()));
dataItem = uploadedFilesChildren.FirstOrDefault(func);
if (dataItem != null || tries == maxTries)
{
source.Cancel();
}

View File

@ -75,8 +75,7 @@ namespace FarmmapsNbs
_logger.LogError("Could not find a needed root item");
return;
}
var cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDriveRoot.Code,
$"VRA NBS cropfield {input.OutputFileName}", plantingDate.Year, input.GeometryJson.ToString(Formatting.None));

View File

@ -12,6 +12,9 @@
<None Update="Data\**\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PotenInput.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>