WIP: copy process
This commit is contained in:
@@ -9,6 +9,7 @@ namespace WebAPI
|
|||||||
public DbSet<User> Users { get; set; }
|
public DbSet<User> Users { get; set; }
|
||||||
public DbSet<Layer> Layers { get; set; }
|
public DbSet<Layer> Layers { get; set; }
|
||||||
public DbSet<Record> Records { get; set; }
|
public DbSet<Record> Records { get; set; }
|
||||||
|
public DbSet<ProcessSource> ProcessSources { get; set; }
|
||||||
|
|
||||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
|
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
|
||||||
{
|
{
|
||||||
@@ -16,6 +17,11 @@ namespace WebAPI
|
|||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
modelBuilder.Entity<ProcessSource>().HasKey(x => new
|
||||||
|
{
|
||||||
|
x.LayerId,
|
||||||
|
x.SourceId
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly Microsoft.Extensions.Logging.LoggerFactory _myLoggerFactory =
|
public static readonly Microsoft.Extensions.Logging.LoggerFactory _myLoggerFactory =
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using WebAPI.dataParsers;
|
using WebAPI.dataParsers;
|
||||||
|
using WebAPI.dataProcessors;
|
||||||
using WebAPI.Exports;
|
using WebAPI.Exports;
|
||||||
using WebAPI.Models;
|
using WebAPI.Models;
|
||||||
|
|
||||||
@@ -211,7 +212,8 @@ namespace WebAPI.Controllers
|
|||||||
return BadRequest();
|
return BadRequest();
|
||||||
} else
|
} 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)
|
if (sourceLayer == null)
|
||||||
{
|
{
|
||||||
logsController.AddEntry(new LogEntry
|
logsController.AddEntry(new LogEntry
|
||||||
@@ -245,9 +247,12 @@ namespace WebAPI.Controllers
|
|||||||
return BadRequest();
|
return BadRequest();
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
Layer processedLayer;
|
||||||
switch (processType)
|
switch (processType)
|
||||||
{
|
{
|
||||||
case "Copy":
|
case "Copy":
|
||||||
|
CopyProcessor processor = new CopyProcessor(db);
|
||||||
|
processedLayer = processor.process(sourceLayer);
|
||||||
break;
|
break;
|
||||||
case "Deaggregate":
|
case "Deaggregate":
|
||||||
break;
|
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
|
Layer layer = new Layer
|
||||||
{
|
{
|
||||||
Source = "GoogleSheet",
|
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.Name = $"L{layer.Number}-I-{name}-{year}/{month}-{DateTime.Now.ToString("yyyyMMddHHmm")}";
|
||||||
layer.Type = LayerType.import;
|
layer.Type = LayerType.import;
|
||||||
|
|||||||
302
WebAPI/Migrations/20230917110252_Layer.parent.Designer.cs
generated
Normal file
302
WebAPI/Migrations/20230917110252_Layer.parent.Designer.cs
generated
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using WebAPI;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace WebAPI.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20230917110252_Layer.parent")]
|
||||||
|
partial class Layerparent
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.10")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.Layer", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<Guid>("CreatedById")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<Guid>("ModifiedById")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Number")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<Guid?>("parentId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CreatedById");
|
||||||
|
|
||||||
|
b.HasIndex("ModifiedById");
|
||||||
|
|
||||||
|
b.HasIndex("parentId");
|
||||||
|
|
||||||
|
b.ToTable("Layers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.Record", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<string>("Code")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<Guid>("CreatedById")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<string>("Desc1")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Desc2")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Desc3")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Desc4")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Desc5")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<Guid>("LayerId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<Guid>("ModifiedById")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<float?>("Value1")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value10")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value11")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value12")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value13")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value14")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value15")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value16")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value17")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value18")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value19")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value2")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value20")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value21")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value22")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value23")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value24")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value25")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value26")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value27")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value28")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value29")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value3")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value30")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value31")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value4")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value5")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value6")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value7")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value8")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value9")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CreatedById");
|
||||||
|
|
||||||
|
b.HasIndex("LayerId");
|
||||||
|
|
||||||
|
b.HasIndex("ModifiedById");
|
||||||
|
|
||||||
|
b.ToTable("Records");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("nvarchar(50)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.Layer", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebAPI.Models.User", "CreatedBy")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CreatedById")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebAPI.Models.User", "ModifiedBy")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ModifiedById")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebAPI.Models.Layer", "parent")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("parentId");
|
||||||
|
|
||||||
|
b.Navigation("CreatedBy");
|
||||||
|
|
||||||
|
b.Navigation("ModifiedBy");
|
||||||
|
|
||||||
|
b.Navigation("parent");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.Record", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebAPI.Models.User", "CreatedBy")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CreatedById")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebAPI.Models.Layer", null)
|
||||||
|
.WithMany("Records")
|
||||||
|
.HasForeignKey("LayerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebAPI.Models.User", "ModifiedBy")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ModifiedById")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("CreatedBy");
|
||||||
|
|
||||||
|
b.Navigation("ModifiedBy");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.Layer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Records");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
49
WebAPI/Migrations/20230917110252_Layer.parent.cs
Normal file
49
WebAPI/Migrations/20230917110252_Layer.parent.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace WebAPI.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Layerparent : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "parentId",
|
||||||
|
table: "Layers",
|
||||||
|
type: "uniqueidentifier",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Layers_parentId",
|
||||||
|
table: "Layers",
|
||||||
|
column: "parentId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Layers_Layers_parentId",
|
||||||
|
table: "Layers",
|
||||||
|
column: "parentId",
|
||||||
|
principalTable: "Layers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Layers_Layers_parentId",
|
||||||
|
table: "Layers");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Layers_parentId",
|
||||||
|
table: "Layers");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "parentId",
|
||||||
|
table: "Layers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
330
WebAPI/Migrations/20230918090621_ProcessSource.Designer.cs
generated
Normal file
330
WebAPI/Migrations/20230918090621_ProcessSource.Designer.cs
generated
Normal file
@@ -0,0 +1,330 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using WebAPI;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace WebAPI.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20230918090621_ProcessSource")]
|
||||||
|
partial class ProcessSource
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.10")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.Layer", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<Guid>("CreatedById")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<Guid>("ModifiedById")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Number")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<Guid?>("parentId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CreatedById");
|
||||||
|
|
||||||
|
b.HasIndex("ModifiedById");
|
||||||
|
|
||||||
|
b.HasIndex("parentId");
|
||||||
|
|
||||||
|
b.ToTable("Layers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.ProcessSource", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("LayerId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.HasKey("LayerId", "SourceId");
|
||||||
|
|
||||||
|
b.HasIndex("SourceId");
|
||||||
|
|
||||||
|
b.ToTable("ProcessSources");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.Record", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<string>("Code")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<Guid>("CreatedById")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<string>("Desc1")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Desc2")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Desc3")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Desc4")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Desc5")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDeleted")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<Guid>("LayerId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<Guid>("ModifiedById")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<float?>("Value1")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value10")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value11")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value12")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value13")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value14")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value15")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value16")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value17")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value18")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value19")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value2")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value20")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value21")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value22")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value23")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value24")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value25")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value26")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value27")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value28")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value29")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value3")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value30")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value31")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value4")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value5")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value6")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value7")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value8")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<float?>("Value9")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CreatedById");
|
||||||
|
|
||||||
|
b.HasIndex("LayerId");
|
||||||
|
|
||||||
|
b.HasIndex("ModifiedById");
|
||||||
|
|
||||||
|
b.ToTable("Records");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("nvarchar(50)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.Layer", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebAPI.Models.User", "CreatedBy")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CreatedById")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebAPI.Models.User", "ModifiedBy")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ModifiedById")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebAPI.Models.Layer", "parent")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("parentId");
|
||||||
|
|
||||||
|
b.Navigation("CreatedBy");
|
||||||
|
|
||||||
|
b.Navigation("ModifiedBy");
|
||||||
|
|
||||||
|
b.Navigation("parent");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.ProcessSource", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebAPI.Models.Layer", "Source")
|
||||||
|
.WithMany("Sources")
|
||||||
|
.HasForeignKey("SourceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Source");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.Record", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebAPI.Models.User", "CreatedBy")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CreatedById")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebAPI.Models.Layer", null)
|
||||||
|
.WithMany("Records")
|
||||||
|
.HasForeignKey("LayerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebAPI.Models.User", "ModifiedBy")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ModifiedById")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("CreatedBy");
|
||||||
|
|
||||||
|
b.Navigation("ModifiedBy");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.Layer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Records");
|
||||||
|
|
||||||
|
b.Navigation("Sources");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
WebAPI/Migrations/20230918090621_ProcessSource.cs
Normal file
45
WebAPI/Migrations/20230918090621_ProcessSource.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace WebAPI.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class ProcessSource : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ProcessSources",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
LayerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||||
|
SourceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ProcessSources", x => new { x.LayerId, x.SourceId });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ProcessSources_Layers_SourceId",
|
||||||
|
column: x => x.SourceId,
|
||||||
|
principalTable: "Layers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ProcessSources_SourceId",
|
||||||
|
table: "ProcessSources",
|
||||||
|
column: "SourceId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ProcessSources");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,15 +57,35 @@ namespace WebAPI.Migrations
|
|||||||
b.Property<int>("Type")
|
b.Property<int>("Type")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<Guid?>("parentId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("CreatedById");
|
b.HasIndex("CreatedById");
|
||||||
|
|
||||||
b.HasIndex("ModifiedById");
|
b.HasIndex("ModifiedById");
|
||||||
|
|
||||||
|
b.HasIndex("parentId");
|
||||||
|
|
||||||
b.ToTable("Layers");
|
b.ToTable("Layers");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.ProcessSource", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("LayerId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.HasKey("LayerId", "SourceId");
|
||||||
|
|
||||||
|
b.HasIndex("SourceId");
|
||||||
|
|
||||||
|
b.ToTable("ProcessSources");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("WebAPI.Models.Record", b =>
|
modelBuilder.Entity("WebAPI.Models.Record", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
@@ -248,9 +268,26 @@ namespace WebAPI.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("WebAPI.Models.Layer", "parent")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("parentId");
|
||||||
|
|
||||||
b.Navigation("CreatedBy");
|
b.Navigation("CreatedBy");
|
||||||
|
|
||||||
b.Navigation("ModifiedBy");
|
b.Navigation("ModifiedBy");
|
||||||
|
|
||||||
|
b.Navigation("parent");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("WebAPI.Models.ProcessSource", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("WebAPI.Models.Layer", "Source")
|
||||||
|
.WithMany("Sources")
|
||||||
|
.HasForeignKey("SourceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Source");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("WebAPI.Models.Record", b =>
|
modelBuilder.Entity("WebAPI.Models.Record", b =>
|
||||||
@@ -281,6 +318,8 @@ namespace WebAPI.Migrations
|
|||||||
modelBuilder.Entity("WebAPI.Models.Layer", b =>
|
modelBuilder.Entity("WebAPI.Models.Layer", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Records");
|
b.Navigation("Records");
|
||||||
|
|
||||||
|
b.Navigation("Sources");
|
||||||
});
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,14 +30,15 @@ namespace WebAPI.Models
|
|||||||
#endregion
|
#endregion
|
||||||
#region Relations
|
#region Relations
|
||||||
public ICollection<Record>? Records { get; set; }
|
public ICollection<Record>? Records { get; set; }
|
||||||
|
public ICollection<ProcessSource>? Sources { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public Guid CreatedById { get; set; }
|
public Guid CreatedById { get; set; }
|
||||||
public User? CreatedBy { get; set; }
|
public User? CreatedBy { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public Guid ModifiedById { get; set; }
|
public Guid ModifiedById { get; set; }
|
||||||
public User? ModifiedBy { get; set; }
|
public User? ModifiedBy { get; set; }
|
||||||
public Guid? parentId { get; set; }
|
public Guid? ParentId { get; set; }
|
||||||
public Layer? parent { get; set; }
|
public Layer? Parent { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
WebAPI/Models/ProcessSource.cs
Normal file
15
WebAPI/Models/ProcessSource.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace WebAPI.Models
|
||||||
|
{
|
||||||
|
public class ProcessSource
|
||||||
|
{
|
||||||
|
#region Relations
|
||||||
|
[Required]
|
||||||
|
public Guid LayerId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public Guid SourceId { get; set; }
|
||||||
|
public Layer? Source { get; set; }
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,61 +2,26 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using WebAPI.Models;
|
using WebAPI.Models;
|
||||||
|
|
||||||
namespace WebAPI.dataParsers
|
namespace WebAPI.dataProcessors
|
||||||
{
|
{
|
||||||
public class morskaK5Parser
|
public class CopyProcessor
|
||||||
{
|
{
|
||||||
private SpreadsheetsResource.ValuesResource googleSheetValues;
|
|
||||||
private AppDbContext db;
|
private AppDbContext db;
|
||||||
|
|
||||||
public morskaK5Parser(
|
public CopyProcessor(
|
||||||
SpreadsheetsResource.ValuesResource _googleSheetValues,
|
|
||||||
AppDbContext _db)
|
AppDbContext _db)
|
||||||
{
|
{
|
||||||
googleSheetValues = _googleSheetValues;
|
|
||||||
db = _db;
|
db = _db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Layer parse()
|
public Layer process(Layer sourceLayer)
|
||||||
{
|
{
|
||||||
Layer layer = new Layer();
|
Layer dataSource = this.db.Layers
|
||||||
layer.Source = "GoogleSheet";
|
.Where(x => x.ParentId == sourceLayer.Id)
|
||||||
|
.OrderByDescending(x => x.CreatedAt)
|
||||||
string sheetId = "1ZzndU8HjYqz5VKCcrVHBOFW8fqpYfwquclznX9q39Yk";
|
.First();
|
||||||
|
|
||||||
var range = "Sierpien_2023!B3:AR5";
|
return null;
|
||||||
|
|
||||||
var request = googleSheetValues.Get(sheetId, range);
|
|
||||||
var response = request.Execute();
|
|
||||||
var data = response.Values;
|
|
||||||
|
|
||||||
layer.Source = "GoogleSheet";
|
|
||||||
layer.Number = db.Layers.Count() + 1;
|
|
||||||
layer.Name = $"L{layer.Number}-I-{data[0][1]}-{data[0][2]}/{data[0][3]}-{DateTime.Now.ToString("yyyyMMddHHmm")}";
|
|
||||||
layer.Type = LayerType.import;
|
|
||||||
|
|
||||||
List<Record> records = new List<Record>();
|
|
||||||
|
|
||||||
for (int i = 1; i < data[1].Count; i++)
|
|
||||||
{
|
|
||||||
float value;
|
|
||||||
|
|
||||||
if (
|
|
||||||
data[1][i].ToString()?.Length > 0 &&
|
|
||||||
float.TryParse(data[2][i].ToString(), CultureInfo.GetCultureInfo("pl-PL"), out value))
|
|
||||||
{
|
|
||||||
Record record = new Record();
|
|
||||||
record.Id = Guid.NewGuid();
|
|
||||||
record.Code = data[1][i].ToString();
|
|
||||||
record.Value1 = value;
|
|
||||||
record.CreatedAt = DateTime.UtcNow;
|
|
||||||
record.ModifiedAt = DateTime.UtcNow;
|
|
||||||
records.Add(record);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
layer.Records = records;
|
|
||||||
return layer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ using WebAPI.Models;
|
|||||||
|
|
||||||
namespace WebAPI.dataProcessors
|
namespace WebAPI.dataProcessors
|
||||||
{
|
{
|
||||||
public class copyProcessor
|
public class deaggregationProcessor
|
||||||
{
|
{
|
||||||
private AppDbContext db;
|
private AppDbContext db;
|
||||||
|
|
||||||
public copyProcessor(
|
public deaggregationProcessor(
|
||||||
AppDbContext _db)
|
AppDbContext _db)
|
||||||
{
|
{
|
||||||
db = _db;
|
db = _db;
|
||||||
|
|||||||
Reference in New Issue
Block a user