From 6228408bec71e75a87bf319b94b04f26e6ab373b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Thu, 14 Nov 2024 20:57:51 +0100 Subject: [PATCH] Split import into sources --- WebAPI/Controllers/LayersController.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/WebAPI/Controllers/LayersController.cs b/WebAPI/Controllers/LayersController.cs index e2bbd16..5a36685 100644 --- a/WebAPI/Controllers/LayersController.cs +++ b/WebAPI/Controllers/LayersController.cs @@ -185,7 +185,7 @@ public class LayersController : Controller [HttpGet] [Route("AutoImportWithQueue/{apiKey}")] [AllowAnonymous] - public async Task AutoImportWithQueue(string apiKey) + public IActionResult AutoImportWithQueue(string apiKey) { if (Request.Host.Value != _configuration["apiLocalUrl"] || apiKey != _configuration["apiKey"]) { @@ -243,7 +243,7 @@ public class LayersController : Controller [HttpGet] [Route("ProcessQueue/{apiKey}")] [AllowAnonymous] - public async Task ProcessQueue(string apiKey) + public IActionResult ProcessQueue(string apiKey) { /* var allJobs = await _queue.GetJobs(); @@ -260,9 +260,9 @@ public class LayersController : Controller } [HttpGet] - [Route("AutoImport/{apiKey}")] + [Route("AutoImport/{apiKey}/{nameFilter}")] [AllowAnonymous] - public IActionResult AutoImport(string apiKey) + public IActionResult AutoImport(string apiKey, string nameFilter) { if (Request.Host.Value != _configuration["apiLocalUrl"] || apiKey != _configuration["apiKey"]) { @@ -277,11 +277,19 @@ public class LayersController : Controller var importWorkerLayers = _db.Layers .Include(x => x.Records) .Where(x => + x.Name != null && x.Name.Contains(nameFilter) && x.Records!.Any(y => y.Code == "Type" && y.Desc1 == "ImportWorker") && x.Records!.Any(y => y.Code == "IsEnabled" && y.Desc1 == "True") ) - .OrderBy(x => x.CreatedAt) + .OrderByDescending(x => x.CreatedAt) .ToList(); + _logsController.AddEntry(new LogEntry + { + Title = $"Starting import: {nameFilter}, Admin layers count ({importWorkerLayers.Count})", + Type = LogEntryType.Info, + LogType = LogType.Import, + CreatedAt = DateTime.UtcNow + }); try { if (importWorkerLayers.Count == 0) @@ -302,7 +310,6 @@ public class LayersController : Controller { var type = importWorker.Records!.FirstOrDefault(x => x.Code == "ImportType")?.Desc1 ?? "Standard"; - var name = importWorker.Name; switch (type) { case "D1":