public async Task <string> Invoke() { var file = $"{WorkspaceId}/{LayerId}.mbtiles"; if (await _tileStorage.Exist(file)) { return(await _tileStorage.GetMd5($"{WorkspaceId}/{LayerId}.mbtiles")); } throw new EntityNotFoundException(); }
public async Task <ActionResult> Invoke() { var layer = _mapData.HasLayer(WorkspaceId, LayerId) ? _mapData.GetLayer(WorkspaceId, LayerId) : throw new EntityNotFoundException(); return(new JsonResult(new LayerDto { Id = layer.Id, Name = layer.Name, Description = layer.Source.Description, MbTileMd5 = await _tileStorage.GetMd5($"{WorkspaceId}/{LayerId}.mbtiles"), CustomStyleMd5 = await _styleStorage.GetMd5($"{WorkspaceId}/{LayerId}.json"), Links = _resourceLinksGenerator.GenerateResourceLinks(WorkspaceId, LayerId) }, new JsonSerializerSettings { Formatting = Formatting.Indented, ContractResolver = new CamelCasePropertyNamesContractResolver() })); }
public async Task UpdateLayer(string workspaceId, string layerId) { _logger.LogDebug($"Syncing layer {workspaceId}/{layerId}"); var serviceClosed = false; var tileBlobPath = $"{workspaceId}/{layerId}.mbtiles"; if (_tileCache.GetFileMd5(workspaceId, layerId) != await _tileStorage.GetMd5(tileBlobPath)) { CloseService(layerId); serviceClosed = true; await _tileStorage.UpdateLocalFile(tileBlobPath, _tileCache.GetFilePath(workspaceId, layerId)); } var styleBlobPath = $"{workspaceId}/{layerId}.json"; if (_styleCache.GetFileMd5(workspaceId, layerId) != await _styleStorage.GetMd5(styleBlobPath)) { CloseService(layerId); serviceClosed = true; if (await _styleStorage.Exist(styleBlobPath)) { await _styleStorage.UpdateLocalFile(styleBlobPath, _styleCache.GetFilePath(workspaceId, layerId)); } else { _styleCache.DeleteIfExist(workspaceId, layerId); } } if (serviceClosed) { OpenService(workspaceId, layerId); _logger.LogDebug($"Layer {workspaceId}/{layerId} synced with latest data"); } }