Config all processors for using two digits month number.
This commit is contained in:
@@ -5,20 +5,10 @@ using WebAPI.Models;
|
||||
|
||||
namespace WebAPI.dataProcessors;
|
||||
|
||||
public class T3SourceYearSummaryProcessor
|
||||
public class T3SourceYearSummaryProcessor(
|
||||
AppDbContext db,
|
||||
LayersController controller)
|
||||
{
|
||||
private readonly AppDbContext _db;
|
||||
private readonly LayersController _controller;
|
||||
|
||||
public T3SourceYearSummaryProcessor(
|
||||
AppDbContext db,
|
||||
LayersController controller
|
||||
)
|
||||
{
|
||||
_db = db;
|
||||
_controller = controller;
|
||||
}
|
||||
|
||||
public void Process(Layer processWorker)
|
||||
{
|
||||
var year = processWorker.Records?.SingleOrDefault(x => x.Code == "Year")?.Desc1;
|
||||
@@ -27,7 +17,7 @@ public class T3SourceYearSummaryProcessor
|
||||
{
|
||||
throw new Exception("Source record not found");
|
||||
}
|
||||
var processedLayer = _db.Layers
|
||||
var processedLayer = db.Layers
|
||||
.Where(x => x.ParentId == processWorker.Id
|
||||
&& !x.IsDeleted)
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
@@ -42,7 +32,7 @@ public class T3SourceYearSummaryProcessor
|
||||
Id = Guid.NewGuid(),
|
||||
Type = LayerType.Processed,
|
||||
ParentId = processWorker.Id,
|
||||
Number = _db.Layers.Count() + 1
|
||||
Number = db.Layers.Count() + 1
|
||||
};
|
||||
processedLayer.Name = $"L{processedLayer.Number}-P-{year}/13-{source}-T3";
|
||||
processedLayer.CreatedById = Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D");
|
||||
@@ -59,11 +49,11 @@ public class T3SourceYearSummaryProcessor
|
||||
var dataSources = new List<Layer>();
|
||||
for (var i=1; i<13; i++)
|
||||
{
|
||||
var i1 = i;
|
||||
var dataSource = _db.Layers.Where(x =>
|
||||
var j = i;
|
||||
var dataSource = db.Layers.Where(x =>
|
||||
x.Type == LayerType.Processed
|
||||
&& !x.IsDeleted
|
||||
&& x.Name!=null && x.Name.Contains($"{year}/{i1}-{source}-T3"))
|
||||
&& x.Name!=null && x.Name.Contains($"{year}/{j:D2}-{source}-T3"))
|
||||
.Include(x => x.Records)
|
||||
.FirstOrDefault();
|
||||
if (dataSource != null)
|
||||
@@ -99,12 +89,12 @@ public class T3SourceYearSummaryProcessor
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
_db.Layers.Add(processedLayer);
|
||||
db.Layers.Add(processedLayer);
|
||||
} else
|
||||
{
|
||||
_db.Layers.Update(processedLayer);
|
||||
db.Layers.Update(processedLayer);
|
||||
}
|
||||
_controller.SaveRecords(processedLayer.Id, newRecords, Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D"));
|
||||
_db.SaveChanges();
|
||||
controller.SaveRecords(processedLayer.Id, newRecords, Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D"));
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user