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) if (result.Progress.Status == UploadStatus.Failed)
return null; return null;
var zipName = Path.GetFileName(filePath); return await FindChildItemAsync(root.Code, SHAPE_PROCESSED_ITEMTYPE, itemName,
Item shapeItem = null; i => i.Created >= startUpload &&
await PollTask(TimeSpan.FromSeconds(3), async source => i.Name.ToLower().Contains(itemName.ToLower()));;
{
_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;
} }
public async Task<Item> ShapeToGeotiff(Item shapeItem) public async Task<Item> ShapeToGeotiff(Item shapeItem)
@ -172,13 +147,9 @@ namespace FarmmapsApi.Services
{ {
_logger.LogInformation($"Trying to get {containsName} data"); _logger.LogInformation($"Trying to get {containsName} data");
var uploadedFilesChildren = await _farmmapsApiService.GetItemChildrenAsync(parentCode, itemType); 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);
Func<Item, bool> func = filter ?? (i => i.Name.ToLower().Contains(containsName.ToLower())); if (dataItem != null || tries == maxTries)
dataItem = uploadedFilesChildren.FirstOrDefault(func);
source.Cancel();
}
else if (tries == maxTries)
{ {
source.Cancel(); source.Cancel();
} }

View File

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

View File

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