Update LayersController.cs
This commit is contained in:
@@ -279,7 +279,7 @@ namespace WebAPI.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProcessLayer(processWorker, true);
|
ProcessLayer(processWorker);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -308,65 +308,7 @@ namespace WebAPI.Controllers
|
|||||||
return BadRequest(e.ToString());
|
return BadRequest(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal void ProcessLayer(Layer processWorker)
|
||||||
[HttpGet]
|
|
||||||
[Route("ProcessLayer/{id}")]
|
|
||||||
public IActionResult ProcessLayer(Guid id)
|
|
||||||
{
|
|
||||||
if (googleSheetValues is null)
|
|
||||||
{
|
|
||||||
throw new Exception("Google Sheets API not initialized");
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Layer layer = db.Layers
|
|
||||||
.Include(x => x.Records)
|
|
||||||
.Where(x => x.Id == id && !x.IsDeleted).First();
|
|
||||||
if (layer == null)
|
|
||||||
{
|
|
||||||
logsController.AddEntry(new LogEntry
|
|
||||||
{
|
|
||||||
Title = "Process error",
|
|
||||||
Type = LogEntryType.error,
|
|
||||||
LogType = LogType.process,
|
|
||||||
Message = "Layer not found",
|
|
||||||
CreatedAt = DateTime.UtcNow
|
|
||||||
});
|
|
||||||
return BadRequest("Layer not found");
|
|
||||||
}
|
|
||||||
Layer processWorker = db.Layers
|
|
||||||
.Include(x => x.Records)
|
|
||||||
.Where(x => x.Id == layer.ParentId && !x.IsDeleted).First();
|
|
||||||
|
|
||||||
if (processWorker == null)
|
|
||||||
{
|
|
||||||
logsController.AddEntry(new LogEntry
|
|
||||||
{
|
|
||||||
Title = "Process error",
|
|
||||||
Type = LogEntryType.error,
|
|
||||||
LogType = LogType.process,
|
|
||||||
Message = "ProcessWorker not found",
|
|
||||||
CreatedAt = DateTime.UtcNow
|
|
||||||
});
|
|
||||||
return BadRequest("ProcessWorker not found");
|
|
||||||
}
|
|
||||||
ProcessLayer(processWorker, true);
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
logsController.AddEntry(new LogEntry
|
|
||||||
{
|
|
||||||
Title = "Process error",
|
|
||||||
Type = LogEntryType.error,
|
|
||||||
LogType = LogType.process,
|
|
||||||
Message = e.ToString(),
|
|
||||||
CreatedAt = DateTime.UtcNow
|
|
||||||
});
|
|
||||||
return BadRequest(e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
internal void ProcessLayer(Layer processWorker, bool alwaysProcess = false)
|
|
||||||
{
|
{
|
||||||
if (googleSheetValues == null)
|
if (googleSheetValues == null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user