WIP: copy process

This commit is contained in:
Michał Zieliński
2023-09-18 11:29:25 +02:00
parent 5cb362b5e0
commit 716ed532f1
11 changed files with 809 additions and 61 deletions

View File

@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using WebAPI.dataParsers;
using WebAPI.dataProcessors;
using WebAPI.Exports;
using WebAPI.Models;
@@ -211,7 +212,8 @@ namespace WebAPI.Controllers
return BadRequest();
} else
{
Layer sourceLayer = db.Layers.Single(x => x.Name == sourceName);
Layer sourceLayer = db.Layers.Include(x => x.Records)
.Single(x => x.Name == sourceName);
if (sourceLayer == null)
{
logsController.AddEntry(new LogEntry
@@ -245,9 +247,12 @@ namespace WebAPI.Controllers
return BadRequest();
} else
{
Layer processedLayer;
switch (processType)
{
case "Copy":
CopyProcessor processor = new CopyProcessor(db);
processedLayer = processor.process(sourceLayer);
break;
case "Deaggregate":
break;
@@ -256,16 +261,6 @@ namespace WebAPI.Controllers
}
}
}
//Layer sourceLayer = db.Layers.Single(x => x.Name == layer.Records.Single(y => y.Code == "Source").Desc1);
// string startDate = layer.Records!.Where(x => x.Code == "StartDate").First().Desc1!;
/// string endDate = layer.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)
// {
// processImportWorker(layer);
// }
}
}
@@ -355,7 +350,8 @@ namespace WebAPI.Controllers
Layer layer = new Layer
{
Source = "GoogleSheet",
Number = db.Layers.Count() + 1
Number = db.Layers.Count() + 1,
ParentId = importWorker.Id
};
layer.Name = $"L{layer.Number}-I-{name}-{year}/{month}-{DateTime.Now.ToString("yyyyMMddHHmm")}";
layer.Type = LayerType.import;