Split import into sources

This commit is contained in:
Michał Zieliński
2024-11-14 20:57:51 +01:00
parent 17bbd1ad9a
commit 6228408bec

View File

@@ -185,7 +185,7 @@ public class LayersController : Controller
[HttpGet] [HttpGet]
[Route("AutoImportWithQueue/{apiKey}")] [Route("AutoImportWithQueue/{apiKey}")]
[AllowAnonymous] [AllowAnonymous]
public async Task<IActionResult> AutoImportWithQueue(string apiKey) public IActionResult AutoImportWithQueue(string apiKey)
{ {
if (Request.Host.Value != _configuration["apiLocalUrl"] || apiKey != _configuration["apiKey"]) if (Request.Host.Value != _configuration["apiLocalUrl"] || apiKey != _configuration["apiKey"])
{ {
@@ -243,7 +243,7 @@ public class LayersController : Controller
[HttpGet] [HttpGet]
[Route("ProcessQueue/{apiKey}")] [Route("ProcessQueue/{apiKey}")]
[AllowAnonymous] [AllowAnonymous]
public async Task<IActionResult> ProcessQueue(string apiKey) public IActionResult ProcessQueue(string apiKey)
{ {
/* /*
var allJobs = await _queue.GetJobs(); var allJobs = await _queue.GetJobs();
@@ -260,9 +260,9 @@ public class LayersController : Controller
} }
[HttpGet] [HttpGet]
[Route("AutoImport/{apiKey}")] [Route("AutoImport/{apiKey}/{nameFilter}")]
[AllowAnonymous] [AllowAnonymous]
public IActionResult AutoImport(string apiKey) public IActionResult AutoImport(string apiKey, string nameFilter)
{ {
if (Request.Host.Value != _configuration["apiLocalUrl"] || apiKey != _configuration["apiKey"]) if (Request.Host.Value != _configuration["apiLocalUrl"] || apiKey != _configuration["apiKey"])
{ {
@@ -277,11 +277,19 @@ public class LayersController : Controller
var importWorkerLayers = _db.Layers var importWorkerLayers = _db.Layers
.Include(x => x.Records) .Include(x => x.Records)
.Where(x => .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 == "Type" && y.Desc1 == "ImportWorker") &&
x.Records!.Any(y => y.Code == "IsEnabled" && y.Desc1 == "True") x.Records!.Any(y => y.Code == "IsEnabled" && y.Desc1 == "True")
) )
.OrderBy(x => x.CreatedAt) .OrderByDescending(x => x.CreatedAt)
.ToList(); .ToList();
_logsController.AddEntry(new LogEntry
{
Title = $"Starting import: {nameFilter}, Admin layers count ({importWorkerLayers.Count})",
Type = LogEntryType.Info,
LogType = LogType.Import,
CreatedAt = DateTime.UtcNow
});
try try
{ {
if (importWorkerLayers.Count == 0) if (importWorkerLayers.Count == 0)
@@ -302,7 +310,6 @@ public class LayersController : Controller
{ {
var type = importWorker.Records!.FirstOrDefault(x => x.Code == "ImportType")?.Desc1 ?? var type = importWorker.Records!.FirstOrDefault(x => x.Code == "ImportType")?.Desc1 ??
"Standard"; "Standard";
var name = importWorker.Name;
switch (type) switch (type)
{ {
case "D1": case "D1":