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]
[Route("AutoImportWithQueue/{apiKey}")]
[AllowAnonymous]
public async Task<IActionResult> 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<IActionResult> 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":