WIP: list scrolling
This commit is contained in:
@@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WebAPI.dataParsers;
|
||||
using WebAPI.dataProcessors;
|
||||
using WebAPI.dataProcessors;
|
||||
using WebAPI.Exports;
|
||||
using WebAPI.Models;
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace WebAPI.Controllers
|
||||
{
|
||||
if (codes != null && codes.Length > 0)
|
||||
{
|
||||
|
||||
return Ok(db.Layers.Where(x => !x.IsDeleted)
|
||||
.Where(x => codes.Select(Int32.Parse).ToList().Contains(x.Number))
|
||||
.OrderByDescending(x => x.Number)
|
||||
@@ -173,8 +174,8 @@ namespace WebAPI.Controllers
|
||||
return BadRequest(e.ToString());
|
||||
}
|
||||
return Ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("AutoProcess/{apiKey}")]
|
||||
[AllowAnonymous]
|
||||
@@ -199,73 +200,73 @@ namespace WebAPI.Controllers
|
||||
foreach (Layer processWorker in processWorkerLayers)
|
||||
{
|
||||
string? sourceName = processWorker?.Records?.Single(x => x.Code == "Source")?.Desc1;
|
||||
if (sourceName == null)
|
||||
{
|
||||
logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "Process error",
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.import,
|
||||
Message = processWorker?.Name + " Source record not found",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return BadRequest();
|
||||
} else
|
||||
if (sourceName == null)
|
||||
{
|
||||
Layer sourceLayer = db.Layers.Include(x => x.Records)
|
||||
.Single(x => x.Name == sourceName);
|
||||
if (sourceLayer == null)
|
||||
{
|
||||
logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "Process error",
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.import,
|
||||
Message = processWorker?.Name + " Source layer not found " + sourceLayer,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return BadRequest();
|
||||
} else
|
||||
{
|
||||
string startDate = sourceLayer.Records!.Where(x => x.Code == "StartDate").First().Desc1!;
|
||||
logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "Process error",
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.import,
|
||||
Message = processWorker?.Name + " Source record not found",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return BadRequest();
|
||||
} else
|
||||
{
|
||||
Layer sourceLayer = db.Layers.Include(x => x.Records)
|
||||
.Single(x => x.Name == sourceName);
|
||||
if (sourceLayer == null)
|
||||
{
|
||||
logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "Process error",
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.import,
|
||||
Message = processWorker?.Name + " Source layer not found " + sourceLayer,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return BadRequest();
|
||||
} else
|
||||
{
|
||||
string startDate = sourceLayer.Records!.Where(x => x.Code == "StartDate").First().Desc1!;
|
||||
string endDate = sourceLayer.Records!.Where(x => x.Code == "EndDate").First().Desc1!;
|
||||
var startDateParsed = DateTime.ParseExact(startDate, "yyyy.MM.dd", null);
|
||||
var endDateParsed = DateTime.ParseExact(endDate, "yyyy.MM.dd", null);
|
||||
if (startDateParsed.Date <= DateTime.UtcNow.Date && endDateParsed.Date >= DateTime.UtcNow.Date)
|
||||
{
|
||||
string? processType = processWorker?.Records?.Single(x => x.Code == "ProcessType")?.Desc1;
|
||||
if (processType == null)
|
||||
{
|
||||
logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "Process error",
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.import,
|
||||
Message = processWorker?.Name + " ProcessType record not found",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return BadRequest();
|
||||
} else
|
||||
{
|
||||
Layer? processedLayer = null;
|
||||
switch (processType)
|
||||
{
|
||||
case "Copy":
|
||||
CopyProcessor cp = new CopyProcessor(db, googleSheetValues);
|
||||
processedLayer = cp.process(sourceLayer, processWorker?.Id);
|
||||
break;
|
||||
case "Deaggregation":
|
||||
DeaggregationProcessor dp = new DeaggregationProcessor(db, googleSheetValues);
|
||||
processedLayer = dp.process(sourceLayer, processWorker?.Id);
|
||||
break;
|
||||
}
|
||||
if (processedLayer != null)
|
||||
{
|
||||
AddLayer(processedLayer, Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var startDateParsed = DateTime.ParseExact(startDate, "yyyy.MM.dd", null);
|
||||
var endDateParsed = DateTime.ParseExact(endDate, "yyyy.MM.dd", null);
|
||||
if (startDateParsed.Date <= DateTime.UtcNow.Date && endDateParsed.Date >= DateTime.UtcNow.Date)
|
||||
{
|
||||
string? processType = processWorker?.Records?.Single(x => x.Code == "ProcessType")?.Desc1;
|
||||
if (processType == null)
|
||||
{
|
||||
logsController.AddEntry(new LogEntry
|
||||
{
|
||||
Title = "Process error",
|
||||
Type = LogEntryType.error,
|
||||
LogType = LogType.import,
|
||||
Message = processWorker?.Name + " ProcessType record not found",
|
||||
CreatedAt = DateTime.UtcNow
|
||||
});
|
||||
return BadRequest();
|
||||
} else
|
||||
{
|
||||
Layer? processedLayer = null;
|
||||
switch (processType)
|
||||
{
|
||||
case "Copy":
|
||||
CopyProcessor cp = new CopyProcessor(db, googleSheetValues);
|
||||
processedLayer = cp.process(sourceLayer, processWorker?.Id);
|
||||
break;
|
||||
case "Deaggregation":
|
||||
DeaggregationProcessor dp = new DeaggregationProcessor(db, googleSheetValues);
|
||||
processedLayer = dp.process(sourceLayer, processWorker?.Id);
|
||||
break;
|
||||
}
|
||||
if (processedLayer != null)
|
||||
{
|
||||
AddLayer(processedLayer, Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Ok();
|
||||
@@ -282,9 +283,9 @@ namespace WebAPI.Controllers
|
||||
});
|
||||
return BadRequest(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[Route("checkDates")]
|
||||
public IActionResult checkDates()
|
||||
@@ -420,7 +421,7 @@ namespace WebAPI.Controllers
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SaveSources(ICollection<ProcessSource> sources)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user