AutoImoport/AutoProcess fix

This commit is contained in:
Michał Zieliński
2025-06-08 11:48:31 +02:00
parent 733c219b6f
commit 23a19ba0fe
2 changed files with 31 additions and 17 deletions

View File

@@ -301,12 +301,20 @@ public class LayersController : Controller
var type = importWorker.Records!.FirstOrDefault(x => x.Code == "ImportType")?.Desc1 ?? "Standard";
var source = importWorker.Records!.FirstOrDefault(x => x.Code == "Source")?.Desc1 ?? "GoogleSheet";
var plugin = importWorker.Records!.FirstOrDefault(x => x.Code == "Plugin")?.Desc1;
if (plugin == null)
{
_logger.LogError("AutoImport: Plugin not found for layer {LayerName} ({LayerId}), skipping",
importWorker.Name, importWorker.Id);
continue;
}
_logger.LogInformation("AutoImport: Processing layer {LayerName} with type {ImportType} and source {Source}",
importWorker.Name, type, source);
if (source == "DataInbox" && type == "Import-D3")
{
var d3Importer = _pluginManager.GetImporter("MorskaD3");
var d3Importer = _pluginManager.GetImporter(plugin);
if (d3Importer == null)
{
throw new Exception("MorskaD3 importer not found");
@@ -321,7 +329,7 @@ public class LayersController : Controller
switch (type)
{
case "D1":
var d1importer = _pluginManager.GetImporter("MorskaD1");
var d1importer = _pluginManager.GetImporter(plugin);
if (d1importer == null)
{
throw new Exception("MorskaD1 importer not found");
@@ -334,7 +342,7 @@ public class LayersController : Controller
break;
case "FK2":
var fk2importer = _pluginManager.GetImporter("MorskaFK2");
var fk2importer = _pluginManager.GetImporter(plugin);
if (fk2importer == null)
{
throw new Exception("MorskaFK2 importer not found");
@@ -364,7 +372,7 @@ public class LayersController : Controller
if (startDateParsed.Date <= DateTime.UtcNow.Date && endDateParsed.Date >= DateTime.UtcNow.Date)
{
var importer = _pluginManager.GetImporter("MorskaImporter");
var importer = _pluginManager.GetImporter(plugin);
if (importer == null)
{
throw new Exception("MorskaImporter not found");
@@ -377,7 +385,7 @@ public class LayersController : Controller
}
else if (IsImportedLayerUpToDate(importWorker) == false)
{
var importer = _pluginManager.GetImporter("MorskaImporter");
var importer = _pluginManager.GetImporter(plugin);
if (importer == null)
{
throw new Exception("MorskaImporter not found");
@@ -501,6 +509,12 @@ public class LayersController : Controller
throw new Exception("Year record not found");
}
var plugin = processWorker.Records?.SingleOrDefault(x => x.Code == "Plugin")?.Desc1;
if (plugin == null)
{
throw new Exception("Plugin record not found");
}
var processType = processWorker.Records?.SingleOrDefault(x => x.Code == "ProcessType")?.Desc1;
switch (processType)
{
@@ -508,7 +522,7 @@ public class LayersController : Controller
throw new Exception("ProcessType record not found");
case "T3-SourceYearSummary":
{
var processor = _pluginManager.GetProcessor("T3.SourceYearSummary");
var processor = _pluginManager.GetProcessor(plugin);
if (processor == null)
{
throw new Exception("T3.SourceYearSummary processor not found");
@@ -518,7 +532,7 @@ public class LayersController : Controller
}
case "T3-MultiSourceYearSummary":
{
var processor = _pluginManager.GetProcessor("T3.MultiSourceYearSummary");
var processor = _pluginManager.GetProcessor(plugin);
if (processor == null)
{
throw new Exception("T3.MultiSourceYearSummary processor not found");
@@ -528,7 +542,7 @@ public class LayersController : Controller
}
case "T3-MultiSourceCopySelectedCodesYearSummary":
{
var processor = _pluginManager.GetProcessor("T3.MultiSourceCopySelectedCodesYearSummary");
var processor = _pluginManager.GetProcessor(plugin);
if (processor == null)
{
throw new Exception("T3.MultiSourceCopySelectedCodesYearSummary processor not found");
@@ -538,7 +552,7 @@ public class LayersController : Controller
}
case "T1-R1":
{
var processor = _pluginManager.GetProcessor("T1.R1");
var processor = _pluginManager.GetProcessor(plugin);
if (processor == null)
{
throw new Exception("T1.R1 processor not found");
@@ -548,7 +562,7 @@ public class LayersController : Controller
}
case "T4-R2":
{
var processor = _pluginManager.GetProcessor("T4.R2");
var processor = _pluginManager.GetProcessor(plugin);
if (processor == null)
{
throw new Exception("T4.R2 processor not found");
@@ -558,7 +572,7 @@ public class LayersController : Controller
}
case "T1-R3":
{
var processor = _pluginManager.GetProcessor("T1.R3");
var processor = _pluginManager.GetProcessor(plugin);
if (processor == null)
{
throw new Exception("T1.R3 processor not found");
@@ -578,7 +592,7 @@ public class LayersController : Controller
{
case "T3-SingleSource":
{
var t3SingleSource = _pluginManager.GetProcessor("T3.SingleSource");
var t3SingleSource = _pluginManager.GetProcessor(plugin);
if (t3SingleSource == null)
{
throw new Exception("T3.SingleSource processor not found");
@@ -588,7 +602,7 @@ public class LayersController : Controller
}
case "T4-SingleSource":
{
var t4SingleSource = _pluginManager.GetProcessor("T4.SingleSource");
var t4SingleSource = _pluginManager.GetProcessor(plugin);
if (t4SingleSource == null)
{
throw new Exception("T4.SingleSource processor not found");
@@ -598,7 +612,7 @@ public class LayersController : Controller
}
case "T5-LastValues":
{
var t5LastValues = _pluginManager.GetProcessor("T5.LastValues");
var t5LastValues = _pluginManager.GetProcessor(plugin);
if (t5LastValues == null)
{
throw new Exception("T5.LastValues processor not found");
@@ -608,7 +622,7 @@ public class LayersController : Controller
}
case "T3-MultiSourceSummary":
{
var t3MultiSourceSummary = _pluginManager.GetProcessor("T3.MultiSourceSummary");
var t3MultiSourceSummary = _pluginManager.GetProcessor(plugin);
if (t3MultiSourceSummary == null)
{
throw new Exception("T3.MultiSourceSummary processor not found");
@@ -618,7 +632,7 @@ public class LayersController : Controller
}
case "T3-MultiSourceCopySelectedCodes":
{
var t3MultiSourceCopySelectedCode = _pluginManager.GetProcessor("T3.MultiSourceCopySelectedCodes");
var t3MultiSourceCopySelectedCode = _pluginManager.GetProcessor(plugin);
if (t3MultiSourceCopySelectedCode == null)
{
throw new Exception("T3.MultiSourceCopySelectedCodes processor not found");

View File

@@ -1,3 +1,3 @@
###
GET http://localhost:5400/api/Layers/CheckProcessors
GET http://localhost:5400/api/Layers/AutoProcess/10763478CB738D4ecb2h76g803478CB738D4e
Timeout: 500000